Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65afe42d2c | ||
|
|
9da206e280 | ||
|
|
c2ae3df1db | ||
|
|
dc9fe10779 | ||
|
|
08a583526e | ||
|
|
125fa885f6 | ||
|
|
4a1eefcf87 | ||
|
|
68c0a0b333 | ||
|
|
fdc73126f7 | ||
|
|
1e0c0ebb2d | ||
|
|
5bffa2c51c | ||
|
|
34fa4f85db | ||
|
|
ef0e412d36 | ||
|
|
7df02934f3 | ||
|
|
d64b259b77 | ||
|
|
8850d5c8ff | ||
|
|
15c7106430 | ||
|
|
56dfc985d2 | ||
|
|
dfa778942c | ||
|
|
bd71833f18 | ||
|
|
c6f25bf33f | ||
|
|
fc22d7e6c8 | ||
|
|
22f604cd7e | ||
|
|
a85b9e8100 | ||
|
|
8d380f4278 | ||
|
|
1486d58813 | ||
|
|
9d3de047a0 | ||
|
|
c75e5bd6a7 | ||
|
|
30a3a4fb89 | ||
|
|
9fe9cd3a8a | ||
|
|
12926980e2 | ||
|
|
31787b5e5b | ||
|
|
d56921b611 | ||
|
|
15a5e6f710 | ||
|
|
422f2b699b | ||
|
|
eda8abf55c | ||
|
|
2b955894d3 | ||
|
|
539c4e696a | ||
|
|
aa35ace816 | ||
|
|
8ea7686b2c | ||
|
|
7dbd620886 | ||
|
|
6a1b0e044a | ||
|
|
afe3584b70 | ||
|
|
d8096e7f2e | ||
|
|
121c735073 | ||
|
|
52698423d0 | ||
|
|
bbff706890 | ||
|
|
2a079be7c2 | ||
|
|
a8e767250a | ||
|
|
5593dfb8e5 | ||
|
|
afd072c313 | ||
|
|
d26cac9622 | ||
|
|
2c341ab7ad | ||
|
|
54eaccca0d | ||
|
|
0d5661f8a6 | ||
|
|
7a19cb8d04 | ||
|
|
9fddf7b176 | ||
|
|
f687dff702 | ||
|
|
249280312e | ||
|
|
a200975cda | ||
|
|
0163bc8c24 | ||
|
|
a5a789c440 | ||
|
|
87aed8f3f2 | ||
|
|
cadab9e6bb | ||
|
|
13b5545999 | ||
|
|
f4a6c20695 | ||
|
|
ff583e40fb | ||
|
|
c8b0ca48de | ||
|
|
8d35d16575 | ||
|
|
e70f595f76 | ||
|
|
888441b81d | ||
|
|
71f4012537 | ||
|
|
ce6ca4dc0f | ||
|
|
becba6498e | ||
|
|
95bc340b06 | ||
|
|
1ab93c4021 | ||
|
|
b36052465f | ||
|
|
5695726d9a | ||
|
|
025a892daf | ||
|
|
74aa5f4598 | ||
|
|
db345577a2 | ||
|
|
80f41c8c24 | ||
|
|
169650f17c | ||
|
|
4361ebe636 | ||
|
|
9d52fd6212 | ||
|
|
abb2abe5c9 | ||
|
|
e9d1d257ea | ||
|
|
a721eb4d03 | ||
|
|
fe644127c1 | ||
|
|
71cc1ca4b5 | ||
|
|
5df0dacf92 | ||
|
|
448f452965 | ||
|
|
3d6c31c479 | ||
|
|
067c93a63a | ||
|
|
04a970ef08 | ||
|
|
3d32cb3adf | ||
|
|
1ef1a861ca | ||
|
|
deb11bf1a9 | ||
|
|
87ad6bd2b1 | ||
|
|
3054b758df | ||
|
|
5777f4a117 | ||
|
|
9615a5aba2 | ||
|
|
8fff947863 | ||
|
|
68f77cc809 | ||
|
|
4f801b4228 | ||
|
|
54dc05046f | ||
|
|
e05c585b37 | ||
|
|
a03a3a2a8d | ||
|
|
e251565837 | ||
|
|
455bb546f0 | ||
|
|
fa707e5391 | ||
|
|
6f2961a00b | ||
|
|
43ebe3c3e3 | ||
|
|
f8d10be031 | ||
|
|
3f01f0100c | ||
|
|
29d3787de8 | ||
|
|
59df758ceb | ||
|
|
80360bf27c | ||
|
|
3da7d7513e | ||
|
|
a654becac8 | ||
|
|
77a5b2212b | ||
|
|
7013ed8acf | ||
|
|
9d41854e22 | ||
|
|
edf9ccca8b | ||
|
|
d62165bf51 | ||
|
|
00bc4a9d6a | ||
|
|
7885babe1e | ||
|
|
9a53678838 | ||
|
|
91874ffc3b | ||
|
|
e71c34255b | ||
|
|
8e78a14c14 | ||
|
|
3b85200641 | ||
|
|
1dc0f72e54 | ||
|
|
13d27a6f4d | ||
|
|
3cec1751c9 | ||
|
|
80f9dce513 | ||
|
|
cf7c718493 | ||
|
|
0ba20299a3 | ||
|
|
54a979c641 | ||
|
|
e41d643488 | ||
|
|
5281f6e7dd | ||
|
|
7e2775114b | ||
|
|
cbbc127360 | ||
|
|
83a566d145 | ||
|
|
3d3c1a0430 | ||
|
|
08f6c0b1f1 | ||
|
|
4cc3ea0883 | ||
|
|
2876495b62 | ||
|
|
7d03831ba8 | ||
|
|
0514dd2ea5 | ||
|
|
f341fc132c | ||
|
|
27b4933262 | ||
|
|
fb368a9ebe | ||
|
|
8adb80b5eb | ||
|
|
4a60f0f903 | ||
|
|
a789e2ff7b | ||
|
|
1201c2979b | ||
|
|
0e15a98472 | ||
|
|
51d07c1c50 | ||
|
|
5f59a57a78 | ||
|
|
084fc5d327 | ||
|
|
2194c96883 | ||
|
|
bd421fcfab | ||
|
|
93e99bc1ef | ||
|
|
687e1f4f43 | ||
|
|
4ea5a76337 | ||
|
|
face56dce1 | ||
|
|
24aebfe92a | ||
|
|
9337ff8958 | ||
|
|
18e2ef01e7 | ||
|
|
516be47827 | ||
|
|
9e62c161b4 | ||
|
|
d4785f093e | ||
|
|
fad65e5b81 | ||
|
|
49d507dfad | ||
|
|
75031f66b5 | ||
|
|
ad48770606 | ||
|
|
f7bd440a96 | ||
|
|
b2586cf13b | ||
|
|
7a5e57e1a8 | ||
|
|
0812204f11 | ||
|
|
066fef0513 | ||
|
|
8d7ed4c16c | ||
|
|
51b74fd618 | ||
|
|
6403c6480d | ||
|
|
9dcd95b2c3 | ||
|
|
4c7919fe82 | ||
|
|
df09b9a5ee | ||
|
|
a5f5185f1d | ||
|
|
bd6c2e1dcc | ||
|
|
9352ea54f8 | ||
|
|
e1325311c7 | ||
|
|
a0bb191e9f | ||
|
|
44ae5c8c1b | ||
|
|
35ced30047 | ||
|
|
f498d59303 | ||
|
|
62b321b7e9 | ||
|
|
279e0f01ea | ||
|
|
ea59ab372e | ||
|
|
70b4e74b52 | ||
|
|
a8de222bc2 | ||
|
|
70a10132d0 | ||
|
|
25a2cb2eb9 | ||
|
|
43a36be834 | ||
|
|
a33f2d7fae | ||
|
|
a349c001fe | ||
|
|
0fbe2dc432 | ||
|
|
0323300acd | ||
|
|
189936ecd2 | ||
|
|
9a581c534f | ||
|
|
99e2297d67 | ||
|
|
3fc2a3e395 | ||
|
|
5c1c7940a3 | ||
|
|
15348f659a | ||
|
|
8dfacde007 | ||
|
|
859a79d7da | ||
|
|
e27d107ebc | ||
|
|
0ddf718be1 | ||
|
|
6738b2a16b | ||
|
|
c75f497c79 | ||
|
|
84bb022a31 | ||
|
|
b48edbde04 | ||
|
|
ab0406ba77 | ||
|
|
600c843747 | ||
|
|
d2bd9679da | ||
|
|
518aafe617 | ||
|
|
0166d1a3b1 | ||
|
|
0da5b65858 | ||
|
|
e8da5554dc | ||
|
|
8a67061d32 | ||
|
|
29ec3efa9c | ||
|
|
4a360bac44 | ||
|
|
1c4b27e56c | ||
|
|
673239108c | ||
|
|
56b926be40 | ||
|
|
963630db7e | ||
|
|
54dcb32232 | ||
|
|
9e4718abc3 | ||
|
|
5e5e32769f | ||
|
|
c0f88bbf62 | ||
|
|
ec2f118d80 | ||
|
|
2a8c7334a9 | ||
|
|
ad4092b8f6 | ||
|
|
92cec1f798 | ||
|
|
56c80fb5c3 | ||
|
|
6e011f9297 | ||
|
|
d11e9d3b77 | ||
|
|
0f631eb1d9 | ||
|
|
9fbfcb3851 | ||
|
|
a982d8c0f0 | ||
|
|
27f7c3e72b | ||
|
|
819d7f3d39 | ||
|
|
25404d6c92 | ||
|
|
b340c7246b | ||
|
|
2669967b49 | ||
|
|
e945db8cb6 | ||
|
|
9a09e53572 | ||
|
|
0c040db6f0 | ||
|
|
46c7cab3a4 | ||
|
|
922afc12a5 | ||
|
|
4817bf7e2b | ||
|
|
2a118acf77 | ||
|
|
0b93cd0e09 | ||
|
|
b1af6ad721 | ||
|
|
c6d8a83ac9 | ||
|
|
72a070da3e | ||
|
|
dbe0f7049e | ||
|
|
91b81ebb24 | ||
|
|
897e9545c2 | ||
|
|
947e5c3e07 | ||
|
|
ececd96718 | ||
|
|
e9ace2dd6b | ||
|
|
c72f8f766d | ||
|
|
1b89327d84 | ||
|
|
8a8c1a33a6 | ||
|
|
761249d39f | ||
|
|
e03da34f55 | ||
|
|
03ec04cc8d | ||
|
|
f387899dab | ||
|
|
ce49daa300 | ||
|
|
249a720cee | ||
|
|
fa59cbcc01 | ||
|
|
803c24f4d3 | ||
|
|
5e19a5af33 | ||
|
|
8911f1eb94 | ||
|
|
6f0bd98be2 | ||
|
|
e325a03c0a | ||
|
|
b9317df859 | ||
|
|
11bb1349e9 | ||
|
|
6289e9317d | ||
|
|
2d9d67bcb2 | ||
|
|
62fd868130 | ||
|
|
b2b8c48fd0 | ||
|
|
9f9d05d3c6 | ||
|
|
6e01a0affd | ||
|
|
d6d6307550 | ||
|
|
1afdf0fb81 | ||
|
|
fd529ce967 | ||
|
|
c5ba1864d1 | ||
|
|
831b8ad5ad | ||
|
|
58256b5b64 | ||
|
|
d209e9b768 | ||
|
|
61b1f0d8a4 | ||
|
|
2748624dde | ||
|
|
d5b19b8869 | ||
|
|
650f89e1ce | ||
|
|
00172ee675 | ||
|
|
45aab8f9f2 | ||
|
|
1e455b0391 | ||
|
|
59cb67da6e | ||
|
|
6b96e1a8e2 | ||
|
|
5ef94d94e6 | ||
|
|
a59c384884 | ||
|
|
7638d678bb | ||
|
|
f3c30130d2 | ||
|
|
bb583065f3 | ||
|
|
f5bb30559d | ||
|
|
87afb84a4d | ||
|
|
07078b21f1 | ||
|
|
63d3dcb31b | ||
|
|
478e663506 | ||
|
|
6bb8ae1dfc | ||
|
|
2cea70e643 | ||
|
|
54de77a110 | ||
|
|
e38cb88640 | ||
|
|
8deeda641a | ||
|
|
f75420a642 | ||
|
|
efd435e908 | ||
|
|
875ffb7f2d | ||
|
|
385ca98125 | ||
|
|
c4630039c4 | ||
|
|
cf6df691d2 | ||
|
|
76dfbe030e | ||
|
|
c7a168d3b3 | ||
|
|
b79bf429f7 | ||
|
|
6e1c482e2d | ||
|
|
b506060e48 | ||
|
|
8294f6af4f |
No files matched your search
@@ -1,26 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a bug report so we can fix it
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug, provide any errors**
|
||||
A clear and concise description of what the bug is. Can you https://hastebin.com the error?
|
||||
|
||||
**How can we reproduce it?**
|
||||
Steps to reproduce the behavior:
|
||||
1. Login on 1.12'
|
||||
2. Click on '....'
|
||||
3. The '....' is displayed wrong
|
||||
|
||||
**Expected behaviour**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**ViaVersion Dump:**
|
||||
- Type /viaversion dump, and put the link here.
|
||||
|
||||
**Additional server info**
|
||||
Do you use a proxy (eg. BungeeCord)? What software do you use and what plugins?
|
||||
@@ -0,0 +1,96 @@
|
||||
name: Bug Report
|
||||
description: Report a bug or console error
|
||||
labels: [unconfirmed]
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: "**Before reporting a bug, please see if using master/dev builds from https://ci.viaversion.com/ fixes your issue.**"
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
label: "'/viaversion dump' Output"
|
||||
description: |
|
||||
Run `/viaversion dump` in the console or in the chat, then copy and paste the given link here.
|
||||
placeholder: |
|
||||
https://dump.viaversion.com/...
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Console Error
|
||||
description: |
|
||||
If you encounter warnings/errors in your console, **paste them with https://paste.gg/ and put the paste link here**.
|
||||
If the error is small/less than 10 lines, you may put it directly into this field.
|
||||
value: |
|
||||
```
|
||||
Put the paste.gg link or text here.
|
||||
```
|
||||
placeholder: Please do not remove the grave accents; simply replace the line of text in the middle.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Bug Description
|
||||
description: |
|
||||
Describe the unexpected behavior.
|
||||
If you want to attach screenshots, use the comment field at the bottom of the page.
|
||||
placeholder: |
|
||||
Example: "Placing signs on 1.13.2 causes text to disappear."
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
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.
|
||||
placeholder: |
|
||||
Example:
|
||||
1. Login with a 1.13.2 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."
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Additional Server Info
|
||||
description: |
|
||||
Do you use a proxy (eg. BungeeCord)? What software do you use and what plugins?
|
||||
placeholder: |
|
||||
Example: "I also use BungeeCord with the following plugins: x, y, z"
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Checklist
|
||||
description: Make sure you have followed each of the steps outlined here.
|
||||
options:
|
||||
- label: Via plugins are only running on **EITHER** the backend servers (e.g. Paper) **OR** the proxy (e.g. BungeeCord), **not on both**.
|
||||
required: true
|
||||
- label: I have included a ViaVersion dump.
|
||||
required: true
|
||||
- label: If applicable, I have included a paste (**not a screenshot**) of the error.
|
||||
required: true
|
||||
- label: I have tried a build from https://ci.viaversion.com/ and the issue still persists.
|
||||
required: true
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
## Comments And Screenshots
|
||||
If needed, add **screenshots to help explain your problem** in the comment field below.
|
||||
@@ -0,0 +1,8 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Dev builds
|
||||
url: https://ci.viaversion.com/
|
||||
about: Before reporting a bug, please check if using master/dev builds from our ci fixes your issue.
|
||||
- name: ViaVersion Discord
|
||||
url: https://discord.gg/viaversion
|
||||
about: For smaller issues or questions, you can also join our Discord server.
|
||||
@@ -0,0 +1,37 @@
|
||||
name: Feature Request
|
||||
description: Suggest a feature to be added
|
||||
|
||||
body:
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Problem Description
|
||||
description: |
|
||||
Describe the issue you are facing or why you need the feature to be added.
|
||||
placeholder: |
|
||||
I am always frustrated with...
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Solution Description
|
||||
description: |
|
||||
Describe the solution you would like to see.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Alternatives
|
||||
description: |
|
||||
Describe alternatives you have considered.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Additional Info
|
||||
description: |
|
||||
Does the feature apply to any specific version or environment?
|
||||
validations:
|
||||
required: false
|
||||
@@ -0,0 +1,25 @@
|
||||
# This workflow will build a Java project with Gradle
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
||||
|
||||
name: Java CI with Gradle
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: 11
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: artifact
|
||||
path: build/libs
|
||||
+81
-105
@@ -1,108 +1,35 @@
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
||||
### Maven template
|
||||
target/
|
||||
*/target
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
### NetBeans template
|
||||
nbproject/private/
|
||||
build/
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
nbactions.xml
|
||||
.nb-gradle/
|
||||
### Eclipse template
|
||||
### Java files ###
|
||||
*.class
|
||||
|
||||
.metadata
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
.recommenders
|
||||
# Package Files
|
||||
#*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# Eclipse Core
|
||||
.project
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# PyDev specific (Python IDE for Eclipse)
|
||||
*.pydevproject
|
||||
|
||||
# CDT-specific (C/C++ Development Tooling)
|
||||
.cproject
|
||||
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
|
||||
# Java annotation processor (APT)
|
||||
.factorypath
|
||||
|
||||
# PDT-specific (PHP Development Tools)
|
||||
.buildpath
|
||||
|
||||
# sbteclipse plugin
|
||||
.target
|
||||
|
||||
# Tern plugin
|
||||
.tern-project
|
||||
|
||||
# TeXlipse plugin
|
||||
.texlipse
|
||||
|
||||
# STS (Spring Tool Suite)
|
||||
.springBeans
|
||||
|
||||
# Code Recommenders
|
||||
.recommenders/
|
||||
### JetBrains template
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff:
|
||||
.idea/workspace.xml
|
||||
.idea/tasks.xml
|
||||
.idea/dictionaries
|
||||
.idea/vcs.xml
|
||||
.idea/
|
||||
### Intellij ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
|
||||
# Ignore project files
|
||||
*.iml
|
||||
.idea/jsLibraryMappings.xml
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
.idea/dataSources.ids
|
||||
.idea/dataSources.xml
|
||||
.idea/dataSources.local.xml
|
||||
.idea/sqlDataSources.xml
|
||||
.idea/dynamic.xml
|
||||
.idea/uiDesigner.xml
|
||||
# Ignore IDEA directory
|
||||
.idea/*
|
||||
!.idea/copyright/*
|
||||
!.idea/scopes/*
|
||||
|
||||
# Gradle:
|
||||
.idea/gradle.xml
|
||||
.idea/libraries
|
||||
# Include the project's dictionary
|
||||
!.idea/dictionaries/
|
||||
!.idea/dictionaries/*
|
||||
|
||||
# Mongo Explorer plugin:
|
||||
.idea/mongoSettings.xml
|
||||
|
||||
## File-based project format:
|
||||
# File-based project format:
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
### Plugin-specific files: ###
|
||||
# IntelliJ
|
||||
/out/
|
||||
|
||||
@@ -116,18 +43,67 @@ atlassian-ide-plugin.xml
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
### Java template
|
||||
*.class
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
### Eclipse ###
|
||||
*.pydevproject
|
||||
.metadata
|
||||
.gradle
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
|
||||
# Eclipse Core
|
||||
.project
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# CDT-specific
|
||||
.cproject
|
||||
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
|
||||
# PDT-specific
|
||||
.buildpath
|
||||
|
||||
# sbteclipse plugin
|
||||
.target
|
||||
|
||||
# TeXlipse plugin
|
||||
.texlipse
|
||||
|
||||
|
||||
|
||||
### Maven ###
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
|
||||
|
||||
|
||||
### NetBeans ###
|
||||
nbproject/private/
|
||||
build/
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
nbactions.xml
|
||||
nb-configuration.xml
|
||||
.nb-gradle/
|
||||
Generated
+10
@@ -0,0 +1,10 @@
|
||||
<component name="CopyrightManager">
|
||||
<settings>
|
||||
<module2copyright>
|
||||
<element module="ViaBackwards" copyright="viabackwards-gpl" />
|
||||
</module2copyright>
|
||||
<LanguageOptions name="__TEMPLATE__">
|
||||
<option name="addBlankAfter" value="false" />
|
||||
</LanguageOptions>
|
||||
</settings>
|
||||
</component>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards Copyright (C) 2016-2022 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/>." />
|
||||
<option name="myName" value="viabackwards-gpl" />
|
||||
</copyright>
|
||||
</component>
|
||||
Generated
+3
@@ -0,0 +1,3 @@
|
||||
<component name="DependencyValidationManager">
|
||||
<scope name="ViaBackwards" pattern="com.viaversion.viabackwards..*" />
|
||||
</component>
|
||||
@@ -1,21 +1,674 @@
|
||||
MIT License
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (c) 2016-2020
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
Preamble
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -1,7 +1,17 @@
|
||||
# ViaBackwards
|
||||
|
||||
Allows older Minecraft versions on a newer Minecraft server
|
||||
[](https://github.com/ViaVersion/ViaBackwards/releases)
|
||||
[](https://github.com/ViaVersion/ViaBackwards/actions)
|
||||
[](https://viaversion.com/discord)
|
||||
|
||||
**Allows older Minecraft client versions to connect to newer server versions**
|
||||
|
||||
Supported Versions
|
||||
-
|
||||
**Green** = ViaVersion\
|
||||
**Purple** = ViaBackwards addition
|
||||
|
||||

|
||||
|
||||
Releases / Dev Builds
|
||||
-
|
||||
@@ -12,10 +22,32 @@ You can find the latest dev builds here:\
|
||||
|
||||
**Spigot page:** https://www.spigotmc.org/resources/viabackwards.27448/
|
||||
|
||||
---
|
||||
**CurseForge page:** https://www.curseforge.com/minecraft/mc-mods/viabackwards
|
||||
|
||||
**Maven:** https://repo.viaversion.com/
|
||||
Known issues
|
||||
-
|
||||
* Custom 1.17+ min_y and height world values are not and will (most likely) never be supported => Clients older than 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))
|
||||
|
||||
Other Links
|
||||
-
|
||||
**Maven:** https://repo.viaversion.com
|
||||
|
||||
**Issue tracker:** https://github.com/ViaVersion/ViaBackwards/issues
|
||||
|
||||
**List of contributors:** https://github.com/ViaVersion/ViaBackwards/graphs/contributors
|
||||
**List of contributors:** https://github.com/ViaVersion/ViaBackwards/graphs/contributors
|
||||
|
||||
License
|
||||
-
|
||||
This project is licensed under the [GNU General Public License](LICENSE).
|
||||
|
||||
Special Thanks
|
||||
-
|
||||

|
||||
|
||||
[YourKit](https://www.yourkit.com/) supports open source projects with innovative and intelligent tools
|
||||
for monitoring and profiling Java and .NET applications.
|
||||
YourKit is the creator of [YourKit Java Profiler](https://www.yourkit.com/java/profiler/),
|
||||
[YourKit .NET Profiler](https://www.yourkit.com/.net/profiler/),
|
||||
and [YourKit YouMonitor](https://www.yourkit.com/youmonitor/).
|
||||
-151
@@ -1,151 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2016 Matsv
|
||||
~
|
||||
~ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
~
|
||||
~ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
~
|
||||
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-all</artifactId>
|
||||
<name>ViaBackwards</name>
|
||||
|
||||
<build>
|
||||
<finalName>${project.name}-${project.version}</finalName>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
|
||||
<plugins>
|
||||
<!-- Write git commit hash into build properties -->
|
||||
<plugin>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>scriptus</artifactId>
|
||||
<version>0.3.2</version>
|
||||
<configuration>
|
||||
<format>git-ViaBackwards-${project.parent.version}:%s</format>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>initialize</phase>
|
||||
<goals>
|
||||
<goal>describe</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<!--suppress MavenModelInspection -->
|
||||
<Implementation-Version>${describe}</Implementation-Version>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<showWarnings>false</showWarnings>
|
||||
<showDeprecation>false</showDeprecation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>false</minimizeJar>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.google.gson</pattern>
|
||||
<shadedPattern>us.myles.viaversion.libs.gson</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.md_5.bungee</pattern>
|
||||
<shadedPattern>us.myles.viaversion.libs.bungeecordchat</shadedPattern>
|
||||
<includes>
|
||||
<include>net.md_5.bungee.api.chat.**</include>
|
||||
<include>net.md_5.bungee.api.ChatColor</include>
|
||||
<include>net.md_5.bungee.api.ChatMessageType</include>
|
||||
<include>net.md_5.bungee.chat.**</include>
|
||||
</includes>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<artifactId>viabackwards-core</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<artifactId>viabackwards-bukkit</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<artifactId>viabackwards-bungee</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<artifactId>viabackwards-fabric</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<artifactId>viabackwards-sponge</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<artifactId>viabackwards-velocity</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,12 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// version must be manually kept in sync with the one in root project settings.gradle.kts
|
||||
implementation("gradle.plugin.com.github.johnrengelman", "shadow", "7.1.2")
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import org.gradle.api.JavaVersion
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.get
|
||||
import org.gradle.kotlin.dsl.named
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
fun Project.publishShadowJar() {
|
||||
configurePublication {
|
||||
artifact(tasks["shadowJar"])
|
||||
artifact(tasks["sourcesJar"])
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.publishJavaComponents() {
|
||||
configurePublication {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
|
||||
private fun Project.configurePublication(configurer: MavenPublication.() -> Unit) {
|
||||
extensions.configure<PublishingExtension> {
|
||||
publications.named<MavenPublication>("mavenJava") {
|
||||
apply(configurer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.latestCommitHash(): String {
|
||||
val byteOut = ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine = listOf("git", "rev-parse", "--short", "HEAD")
|
||||
standardOutput = byteOut
|
||||
}
|
||||
return byteOut.toString(Charsets.UTF_8.name()).trim()
|
||||
}
|
||||
|
||||
fun JavaPluginExtension.javaTarget(version: Int) {
|
||||
sourceCompatibility = JavaVersion.toVersion(version)
|
||||
targetCompatibility = JavaVersion.toVersion(version)
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
tasks {
|
||||
// Variable replacements
|
||||
processResources {
|
||||
filesMatching(listOf("plugin.yml", "META-INF/sponge_plugins.json", "fabric.mod.json", "bungee.yml")) {
|
||||
expand("version" to project.version, "description" to project.description, "url" to "https://github.com/ViaVersion/ViaBackwards")
|
||||
}
|
||||
}
|
||||
javadoc {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
(options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet")
|
||||
}
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.compilerArgs.addAll(listOf("-nowarn", "-Xlint:-unchecked", "-Xlint:-deprecation"))
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
javaTarget(8)
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications.create<MavenPublication>("mavenJava") {
|
||||
groupId = rootProject.group as String
|
||||
artifactId = project.name
|
||||
version = rootProject.version as String
|
||||
}
|
||||
repositories.maven {
|
||||
name = "Via"
|
||||
url = uri("https://repo.viaversion.com/")
|
||||
credentials(PasswordCredentials::class)
|
||||
authentication {
|
||||
create<BasicAuthentication>("basic")
|
||||
}
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,10 @@
|
||||
plugins {
|
||||
id("vb.shadow-conventions")
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
archiveFileName.set("ViaBackwards-${project.name.substringAfter("viabackwards-").capitalize()}-${project.version}.jar")
|
||||
destinationDirectory.set(rootProject.layout.buildDirectory.dir("libs"))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import org.gradle.kotlin.dsl.named
|
||||
|
||||
plugins {
|
||||
id("vb.base-conventions")
|
||||
id("com.github.johnrengelman.shadow")
|
||||
}
|
||||
|
||||
tasks {
|
||||
named<Jar>("jar") {
|
||||
archiveClassifier.set("unshaded")
|
||||
from(project.rootProject.file("LICENSE"))
|
||||
}
|
||||
val shadowJar = named<ShadowJar>("shadowJar") {
|
||||
archiveClassifier.set("")
|
||||
configureRelocations()
|
||||
}
|
||||
named("build") {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
}
|
||||
|
||||
publishShadowJar()
|
||||
|
||||
fun ShadowJar.configureRelocations() {
|
||||
relocate("com.google.gson", "com.viaversion.viaversion.libs.gson")
|
||||
relocate("it.unimi.dsi.fastutil", "com.viaversion.viaversion.libs.fastutil")
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
plugins {
|
||||
id("vb.base-conventions")
|
||||
}
|
||||
|
||||
publishJavaComponents()
|
||||
@@ -0,0 +1,31 @@
|
||||
plugins {
|
||||
base
|
||||
id("vb.build-logic")
|
||||
}
|
||||
|
||||
allprojects {
|
||||
group = "com.viaversion"
|
||||
version = "4.3.0"
|
||||
description = "Allow older clients to join newer server versions."
|
||||
}
|
||||
|
||||
val platforms = setOf(
|
||||
projects.viabackwardsBukkit,
|
||||
projects.viabackwardsBungee,
|
||||
projects.viabackwardsFabric,
|
||||
projects.viabackwardsSponge,
|
||||
projects.viabackwardsVelocity
|
||||
).map { it.dependencyProject }
|
||||
|
||||
// Would otherwise contain api/depdency modules if at some point needed
|
||||
val special = setOf(
|
||||
projects.viabackwards
|
||||
).map { it.dependencyProject }
|
||||
|
||||
subprojects {
|
||||
when (this) {
|
||||
in platforms -> plugins.apply("vb.platform-conventions")
|
||||
in special -> plugins.apply("vb.base-conventions")
|
||||
else -> plugins.apply("vb.standard-conventions")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
dependencies {
|
||||
implementation(projects.viabackwardsCommon)
|
||||
compileOnly(libs.paper) {
|
||||
exclude("com.google.code.gson", "gson")
|
||||
exclude("javax.persistence", "persistence-api")
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2016 Matsv
|
||||
~
|
||||
~ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
~
|
||||
~ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
~
|
||||
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-bukkit</artifactId>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<artifactId>viabackwards-core</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>.</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>src/main/resources/</directory>
|
||||
<includes>
|
||||
<include>*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.viabackwards.listener.FireDamageListener;
|
||||
import com.viaversion.viabackwards.listener.FireExtinguishListener;
|
||||
import com.viaversion.viabackwards.listener.LecternInteractListener;
|
||||
import com.viaversion.viaversion.ViaVersionPlugin;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.bukkit.platform.BukkitViaLoader;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
if (!ViaVersionPlugin.getInstance().isLateBind()) {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (ViaVersionPlugin.getInstance().isLateBind()) {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
init(getDataFolder());
|
||||
Via.getPlatform().runSync(this::onServerLoaded);
|
||||
}
|
||||
|
||||
private void onServerLoaded() {
|
||||
BukkitViaLoader loader = (BukkitViaLoader) Via.getManager().getLoader();
|
||||
int protocolVersion = Via.getAPI().getServerVersion().highestSupportedVersion();
|
||||
if (protocolVersion >= ProtocolVersion.v1_16.getVersion()) {
|
||||
loader.storeListener(new FireExtinguishListener(this)).register();
|
||||
}
|
||||
if (protocolVersion >= ProtocolVersion.v1_14.getVersion()) {
|
||||
loader.storeListener(new LecternInteractListener(this)).register();
|
||||
}
|
||||
if (protocolVersion >= ProtocolVersion.v1_12.getVersion()) {
|
||||
loader.storeListener(new FireDamageListener(this)).register();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
getPluginLoader().disablePlugin(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.SoundCategory;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
public class FireDamageListener extends ViaBukkitListener {
|
||||
|
||||
public FireDamageListener(BukkitPlugin plugin) {
|
||||
super(plugin, Protocol1_11_1To1_12.class);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFireDamage(EntityDamageEvent event) {
|
||||
if (event.getEntityType() != EntityType.PLAYER) return;
|
||||
|
||||
EntityDamageEvent.DamageCause cause = event.getCause();
|
||||
if (cause != EntityDamageEvent.DamageCause.FIRE
|
||||
&& cause != EntityDamageEvent.DamageCause.FIRE_TICK
|
||||
&& cause != EntityDamageEvent.DamageCause.LAVA
|
||||
&& cause != EntityDamageEvent.DamageCause.DROWNING) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
if (isOnPipe(player)) {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_HURT, SoundCategory.PLAYERS, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_15_2to1_16.Protocol1_15_2To1_16;
|
||||
import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class FireExtinguishListener extends ViaBukkitListener {
|
||||
|
||||
public FireExtinguishListener(BukkitPlugin plugin) {
|
||||
super(plugin, Protocol1_15_2To1_16.class);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFireExtinguish(PlayerInteractEvent event) {
|
||||
if (event.getAction() != Action.LEFT_CLICK_BLOCK) return;
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
if (block == null) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (!isOnPipe(player)) return;
|
||||
|
||||
Block relative = block.getRelative(event.getBlockFace());
|
||||
if (relative.getType() == Material.FIRE) {
|
||||
event.setCancelled(true);
|
||||
relative.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
-7
@@ -1,7 +1,25 @@
|
||||
package nl.matsv.viabackwards.listener;
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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 nl.matsv.viabackwards.BukkitPlugin;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||
import com.viaversion.viabackwards.BukkitPlugin;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||
import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Lectern;
|
||||
@@ -11,7 +29,6 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener;
|
||||
|
||||
public class LecternInteractListener extends ViaBukkitListener {
|
||||
|
||||
@@ -21,12 +38,12 @@ public class LecternInteractListener extends ViaBukkitListener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onLecternInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (!isOnPipe(player)) return;
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
if (block == null || block.getType() != Material.LECTERN) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (!isOnPipe(player)) return;
|
||||
|
||||
Lectern lectern = (Lectern) block.getState();
|
||||
ItemStack book = lectern.getInventory().getItem(0);
|
||||
if (book == null) return;
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards;
|
||||
|
||||
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||
import nl.matsv.viabackwards.listener.LecternInteractListener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
import us.myles.ViaVersion.bukkit.platform.BukkitViaLoader;
|
||||
|
||||
public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
init(getDataFolder());
|
||||
Via.getPlatform().runSync(this::onServerLoaded);
|
||||
}
|
||||
|
||||
private void onServerLoaded() {
|
||||
if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_14.getId()) {
|
||||
BukkitViaLoader loader = (BukkitViaLoader) Via.getManager().getLoader();
|
||||
loader.storeListener(new LecternInteractListener(this)).register();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
getPluginLoader().disablePlugin(this);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
name: ViaBackwards
|
||||
version: ${project.version}
|
||||
version: ${version}
|
||||
description: Allow older Minecraft versions to connect to a newer server version.
|
||||
main: nl.matsv.viabackwards.BukkitPlugin
|
||||
main: com.viaversion.viabackwards.BukkitPlugin
|
||||
api-version: 1.13
|
||||
|
||||
authors: [Matsv, KennyTV, Gerrygames, creeper123123321, ForceUpdate1]
|
||||
website: ${project.url}
|
||||
authors: [Matsv, kennytv, Gerrygames, creeper123123321, ForceUpdate1]
|
||||
website: ${url}
|
||||
|
||||
load: STARTUP
|
||||
depend: [ViaVersion]
|
||||
@@ -0,0 +1,4 @@
|
||||
dependencies {
|
||||
implementation(projects.viabackwardsCommon)
|
||||
compileOnly(libs.bungee)
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2016 Matsv
|
||||
~
|
||||
~ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
~
|
||||
~ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
~
|
||||
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-bungee</artifactId>
|
||||
|
||||
<repositories>
|
||||
<!-- Bungee repo -->
|
||||
<repository>
|
||||
<id>bungeecord-repo</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<!-- BungeeCord API -->
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.15-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Core Module -->
|
||||
<dependency>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<artifactId>viabackwards-core</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>.</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>src/main/resources/</directory>
|
||||
<includes>
|
||||
<include>*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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 net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
public class BungeePlugin extends Plugin implements ViaBackwardsPlatform {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
Via.getManager().addEnableListener(() -> this.init(getDataFolder()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards;
|
||||
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
|
||||
public class BungeePlugin extends Plugin implements ViaBackwardsPlatform {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
Via.getManager().addEnableListener(() -> this.init(getDataFolder()));
|
||||
}
|
||||
|
||||
// Why is this not a thing in Bungee? O_o
|
||||
@Override
|
||||
public void disable() {
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
name: ViaBackwards
|
||||
main: nl.matsv.viabackwards.BungeePlugin
|
||||
author: "Matsv, KennyTV, Gerrygames, creeper123123321, ForceUpdate1"
|
||||
version: ${project.version}
|
||||
main: com.viaversion.viabackwards.BungeePlugin
|
||||
author: "Matsv, kennytv, Gerrygames, creeper123123321, ForceUpdate1"
|
||||
version: ${version}
|
||||
depends: [ViaVersion]
|
||||
@@ -0,0 +1,19 @@
|
||||
plugins {
|
||||
id("net.kyori.blossom")
|
||||
}
|
||||
|
||||
blossom {
|
||||
replaceToken("\$VERSION", project.version)
|
||||
replaceToken("\$IMPL_VERSION", "git-ViaBackwards-${project.version}:${rootProject.latestCommitHash()}")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(libs.viaver)
|
||||
compileOnlyApi(libs.netty)
|
||||
compileOnlyApi(libs.guava)
|
||||
compileOnlyApi(libs.checkerQual)
|
||||
}
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.google.common.base.Preconditions;
|
||||
import com.viaversion.viabackwards.api.ViaBackwardsConfig;
|
||||
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
|
||||
|
||||
public class ViaBackwards {
|
||||
|
||||
private static ViaBackwardsPlatform platform;
|
||||
private static ViaBackwardsConfig config;
|
||||
|
||||
public static void init(ViaBackwardsPlatform platform, ViaBackwardsConfig config) {
|
||||
Preconditions.checkArgument(platform != null, "ViaBackwards is already initialized");
|
||||
|
||||
ViaBackwards.platform = platform;
|
||||
ViaBackwards.config = config;
|
||||
}
|
||||
|
||||
public static ViaBackwardsPlatform getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
public static ViaBackwardsConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.viaversion.util.Config;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ViaBackwardsConfig extends Config implements com.viaversion.viabackwards.api.ViaBackwardsConfig {
|
||||
|
||||
private boolean addCustomEnchantsToLore;
|
||||
private boolean addTeamColorToPrefix;
|
||||
private boolean fix1_13FacePlayer;
|
||||
private boolean alwaysShowOriginalMobName;
|
||||
private boolean fix1_13FormattedInventoryTitles;
|
||||
private boolean handlePingsAsInvAcknowledgements;
|
||||
private Map<String, String> chatTypeFormats;
|
||||
|
||||
public ViaBackwardsConfig(File configFile) {
|
||||
super(configFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
super.reloadConfig();
|
||||
loadFields();
|
||||
}
|
||||
|
||||
private void loadFields() {
|
||||
addCustomEnchantsToLore = getBoolean("add-custom-enchants-into-lore", true);
|
||||
addTeamColorToPrefix = getBoolean("add-teamcolor-to-prefix", true);
|
||||
fix1_13FacePlayer = getBoolean("fix-1_13-face-player", false);
|
||||
fix1_13FormattedInventoryTitles = getBoolean("fix-formatted-inventory-titles", true);
|
||||
alwaysShowOriginalMobName = getBoolean("always-show-original-mob-name", true);
|
||||
handlePingsAsInvAcknowledgements = getBoolean("handle-pings-as-inv-acknowledgements", false);
|
||||
chatTypeFormats = get("chat-types", Map.class, new HashMap<String, String>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addCustomEnchantsToLore() {
|
||||
return addCustomEnchantsToLore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addTeamColorTo1_13Prefix() {
|
||||
return addTeamColorToPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFix1_13FacePlayer() {
|
||||
return fix1_13FacePlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fix1_13FormattedInventoryTitle() {
|
||||
return fix1_13FormattedInventoryTitles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean alwaysShowOriginalMobName() {
|
||||
return alwaysShowOriginalMobName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePingsAsInvAcknowledgements() {
|
||||
return handlePingsAsInvAcknowledgements || Boolean.getBoolean("com.viaversion.handlePingsAsInvAcknowledgements");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String chatTypeFormat(final String translationKey) {
|
||||
return chatTypeFormats.get(translationKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getDefaultConfigURL() {
|
||||
return getClass().getClassLoader().getResource("assets/viabackwards/config.yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleConfig(Map<String, Object> map) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUnsupportedOptions() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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;
|
||||
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappings;
|
||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
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 org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class BackwardsProtocol<C1 extends ClientboundPacketType, C2 extends ClientboundPacketType, S1 extends ServerboundPacketType, S2 extends ServerboundPacketType>
|
||||
extends AbstractProtocol<C1, C2, S1, S2> {
|
||||
|
||||
protected BackwardsProtocol() {
|
||||
}
|
||||
|
||||
protected BackwardsProtocol(@Nullable Class<C1> oldClientboundPacketEnum, @Nullable Class<C2> clientboundPacketEnum,
|
||||
@Nullable Class<S1> oldServerboundPacketEnum, @Nullable Class<S2> serverboundPacketEnum) {
|
||||
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
|
||||
public boolean hasMappingDataToLoad() {
|
||||
// Manually load them later, since they depend on VV's mappings
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BackwardsMappings getMappingData() { // Change return type to BackwardsMappings
|
||||
return null;
|
||||
}
|
||||
|
||||
public @Nullable TranslatableRewriter getTranslatableRewriter() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface ViaBackwardsConfig {
|
||||
|
||||
/**
|
||||
* Mimics name and level of a custom enchant through the item's lore.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean addCustomEnchantsToLore();
|
||||
|
||||
/**
|
||||
* Writes the color of the scoreboard team after the prefix.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean addTeamColorTo1_13Prefix();
|
||||
|
||||
/**
|
||||
* Converts the new 1.13 face player packets to look packets.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean isFix1_13FacePlayer();
|
||||
|
||||
boolean fix1_13FormattedInventoryTitle();
|
||||
|
||||
/**
|
||||
* Always shows the original mob's name instead of only when hovering over them with the cursor.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean alwaysShowOriginalMobName();
|
||||
|
||||
boolean handlePingsAsInvAcknowledgements();
|
||||
|
||||
@Nullable String chatTypeFormat(String translationKey);
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.ViaBackwardsConfig;
|
||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_1to1_12_2.Protocol1_12_1To1_12_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12to1_12_1.Protocol1_12To1_12_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_1to1_13_2.Protocol1_13_1To1_13_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_14_1to1_14_2.Protocol1_14_1To1_14_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_14_2to1_14_3.Protocol1_14_2To1_14_3;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_14_3to1_14_4.Protocol1_14_3To1_14_4;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_14to1_14_1.Protocol1_14To1_14_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_15_1to1_15_2.Protocol1_15_1To1_15_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_15to1_15_1.Protocol1_15To1_15_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_1To1_16_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16_2to1_16_3.Protocol1_16_2To1_16_3;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16_3to1_16_4.Protocol1_16_3To1_16_4;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16_4to1_17.Protocol1_16_4To1_17;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16to1_16_1.Protocol1_16To1_16_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.Protocol1_17_1To1_18;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_17to1_17_1.Protocol1_17To1_17_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.Protocol1_18_2To1_19;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_18to1_18_2.Protocol1_18To1_18_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.ProtocolManager;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.update.Version;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public interface ViaBackwardsPlatform {
|
||||
|
||||
String MINIMUM_VV_VERSION = "4.3.0";
|
||||
String IMPL_VERSION = "$IMPL_VERSION";
|
||||
|
||||
/**
|
||||
* Initialize ViaBackwards.
|
||||
*/
|
||||
default void init(File dataFolder) {
|
||||
ViaBackwardsConfig config = new ViaBackwardsConfig(new File(dataFolder, "config.yml"));
|
||||
config.reloadConfig();
|
||||
|
||||
ViaBackwards.init(this, config);
|
||||
|
||||
if (isOutdated()) return;
|
||||
|
||||
Via.getManager().getSubPlatforms().add(IMPL_VERSION);
|
||||
|
||||
getLogger().info("Loading translations...");
|
||||
TranslatableRewriter.loadTranslatables();
|
||||
|
||||
ProtocolManager protocolManager = Via.getManager().getProtocolManager();
|
||||
protocolManager.registerProtocol(new Protocol1_9_4To1_10(), ProtocolVersion.v1_9_3, ProtocolVersion.v1_10);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_10To1_11(), ProtocolVersion.v1_10, ProtocolVersion.v1_11);
|
||||
protocolManager.registerProtocol(new Protocol1_11To1_11_1(), ProtocolVersion.v1_11, ProtocolVersion.v1_11_1);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_11_1To1_12(), ProtocolVersion.v1_11_1, ProtocolVersion.v1_12);
|
||||
protocolManager.registerProtocol(new Protocol1_12To1_12_1(), ProtocolVersion.v1_12, ProtocolVersion.v1_12_1);
|
||||
protocolManager.registerProtocol(new Protocol1_12_1To1_12_2(), ProtocolVersion.v1_12_1, ProtocolVersion.v1_12_2);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_12_2To1_13(), ProtocolVersion.v1_12_2, ProtocolVersion.v1_13);
|
||||
protocolManager.registerProtocol(new Protocol1_13To1_13_1(), ProtocolVersion.v1_13, ProtocolVersion.v1_13_1);
|
||||
protocolManager.registerProtocol(new Protocol1_13_1To1_13_2(), ProtocolVersion.v1_13_1, ProtocolVersion.v1_13_2);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_13_2To1_14(), ProtocolVersion.v1_13_2, ProtocolVersion.v1_14);
|
||||
protocolManager.registerProtocol(new Protocol1_14To1_14_1(), ProtocolVersion.v1_14, ProtocolVersion.v1_14_1);
|
||||
protocolManager.registerProtocol(new Protocol1_14_1To1_14_2(), ProtocolVersion.v1_14_1, ProtocolVersion.v1_14_2);
|
||||
protocolManager.registerProtocol(new Protocol1_14_2To1_14_3(), ProtocolVersion.v1_14_2, ProtocolVersion.v1_14_3);
|
||||
protocolManager.registerProtocol(new Protocol1_14_3To1_14_4(), ProtocolVersion.v1_14_3, ProtocolVersion.v1_14_4);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_14_4To1_15(), ProtocolVersion.v1_14_4, ProtocolVersion.v1_15);
|
||||
protocolManager.registerProtocol(new Protocol1_15To1_15_1(), ProtocolVersion.v1_15, ProtocolVersion.v1_15_1);
|
||||
protocolManager.registerProtocol(new Protocol1_15_1To1_15_2(), ProtocolVersion.v1_15_1, ProtocolVersion.v1_15_2);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_15_2To1_16(), ProtocolVersion.v1_15_2, ProtocolVersion.v1_16);
|
||||
protocolManager.registerProtocol(new Protocol1_16To1_16_1(), ProtocolVersion.v1_16, ProtocolVersion.v1_16_1);
|
||||
protocolManager.registerProtocol(new Protocol1_16_1To1_16_2(), ProtocolVersion.v1_16_1, ProtocolVersion.v1_16_2);
|
||||
protocolManager.registerProtocol(new Protocol1_16_2To1_16_3(), ProtocolVersion.v1_16_2, ProtocolVersion.v1_16_3);
|
||||
protocolManager.registerProtocol(new Protocol1_16_3To1_16_4(), ProtocolVersion.v1_16_3, ProtocolVersion.v1_16_4);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_16_4To1_17(), ProtocolVersion.v1_16_4, ProtocolVersion.v1_17);
|
||||
protocolManager.registerProtocol(new Protocol1_17To1_17_1(), ProtocolVersion.v1_17, ProtocolVersion.v1_17_1);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_17_1To1_18(), ProtocolVersion.v1_17_1, ProtocolVersion.v1_18);
|
||||
protocolManager.registerProtocol(new Protocol1_18To1_18_2(), ProtocolVersion.v1_18, ProtocolVersion.v1_18_2);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_18_2To1_19(), ProtocolVersion.v1_18_2, ProtocolVersion.v1_19);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logger provided by the platform.
|
||||
*
|
||||
* @return logger instance
|
||||
*/
|
||||
Logger getLogger();
|
||||
|
||||
default boolean isOutdated() {
|
||||
String vvVersion = Via.getPlatform().getPluginVersion();
|
||||
if (vvVersion != null && new Version(vvVersion).compareTo(new Version(MINIMUM_VV_VERSION + "--")) < 0) {
|
||||
getLogger().severe("================================");
|
||||
getLogger().severe("YOUR VIAVERSION IS OUTDATED");
|
||||
getLogger().severe("PLEASE USE VIAVERSION " + MINIMUM_VV_VERSION + " OR NEWER");
|
||||
getLogger().severe("LINK: https://ci.viaversion.com/");
|
||||
getLogger().severe("VIABACKWARDS WILL NOW DISABLE");
|
||||
getLogger().severe("================================");
|
||||
|
||||
disable();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the plugin.
|
||||
*/
|
||||
void disable();
|
||||
|
||||
/**
|
||||
* Returns ViaBackwards's data folder.
|
||||
*
|
||||
* @return data folder
|
||||
*/
|
||||
File getDataFolder();
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.data;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.data.MappingDataBase;
|
||||
import com.viaversion.viaversion.api.data.Mappings;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class BackwardsMappings extends MappingDataBase {
|
||||
|
||||
private final Class<? extends Protocol> vvProtocolClass;
|
||||
private Int2ObjectMap<MappedItem> backwardsItemMappings;
|
||||
private Map<String, String> backwardsSoundMappings;
|
||||
private Map<String, String> entityNames;
|
||||
|
||||
public BackwardsMappings(String oldVersion, String newVersion, @Nullable Class<? extends Protocol> vvProtocolClass) {
|
||||
this(oldVersion, newVersion, vvProtocolClass, false);
|
||||
}
|
||||
|
||||
public BackwardsMappings(String oldVersion, String newVersion, @Nullable Class<? extends Protocol> vvProtocolClass, boolean hasDiffFile) {
|
||||
super(oldVersion, newVersion, hasDiffFile);
|
||||
Preconditions.checkArgument(vvProtocolClass == null || !vvProtocolClass.isAssignableFrom(BackwardsProtocol.class));
|
||||
this.vvProtocolClass = vvProtocolClass;
|
||||
// Just re-use ViaVersion's item id map
|
||||
loadItems = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadExtras(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings) {
|
||||
if (diffMappings != null) {
|
||||
JsonObject diffItems = diffMappings.getAsJsonObject("items");
|
||||
if (diffItems != null) {
|
||||
backwardsItemMappings = VBMappingDataLoader.loadItemMappings(oldMappings.getAsJsonObject("items"),
|
||||
newMappings.getAsJsonObject("items"), diffItems, shouldWarnOnMissing("items"));
|
||||
}
|
||||
|
||||
JsonObject diffSounds = diffMappings.getAsJsonObject("sounds");
|
||||
if (diffSounds != null) {
|
||||
backwardsSoundMappings = VBMappingDataLoader.objectToNamespacedMap(diffSounds);
|
||||
}
|
||||
|
||||
JsonObject diffEntityNames = diffMappings.getAsJsonObject("entitynames");
|
||||
if (diffEntityNames != null) {
|
||||
entityNames = VBMappingDataLoader.objectToMap(diffEntityNames);
|
||||
}
|
||||
}
|
||||
|
||||
// Just re-use ViaVersion's item id map
|
||||
if (vvProtocolClass != null) {
|
||||
itemMappings = Via.getManager().getProtocolManager().getProtocol(vvProtocolClass).getMappingData().getItemMappings().inverse();
|
||||
}
|
||||
|
||||
loadVBExtras(oldMappings, newMappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable Mappings loadFromArray(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
|
||||
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
|
||||
|
||||
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
|
||||
return VBMappings.vbBuilder().unmapped(oldMappings.getAsJsonArray(key)).mapped(newMappings.getAsJsonArray(key))
|
||||
.diffMappings(diff).warnOnMissing(shouldWarnOnMissing(key)).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
|
||||
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
|
||||
|
||||
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
|
||||
return VBMappings.vbBuilder().unmapped(oldMappings.getAsJsonObject(key)).mapped(newMappings.getAsJsonObject(key))
|
||||
.diffMappings(diff).warnOnMissing(shouldWarnOnMissing(key)).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject loadDiffFile() {
|
||||
return VBMappingDataLoader.loadFromDataDir("mapping-" + newVersion + "to" + oldVersion + ".json");
|
||||
}
|
||||
|
||||
/**
|
||||
* To be overridden.
|
||||
*/
|
||||
protected void loadVBExtras(JsonObject oldMappings, JsonObject newMappings) {
|
||||
}
|
||||
|
||||
protected boolean shouldWarnOnMissing(String key) {
|
||||
return !key.equals("blocks") && !key.equals("statistics") && !key.equals("entities");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Logger getLogger() {
|
||||
return ViaBackwards.getPlatform().getLogger();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #getMappedItem(int) for custom backwards mappings
|
||||
*/
|
||||
@Override
|
||||
public int getNewItemId(int id) {
|
||||
// Don't warn on missing here
|
||||
return this.itemMappings.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewBlockId(int id) {
|
||||
// Don't warn on missing here
|
||||
return this.blockMappings.getNewId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOldItemId(final int id) {
|
||||
// Warn on missing
|
||||
return checkValidity(id, this.itemMappings.inverse().get(id), "item");
|
||||
}
|
||||
|
||||
public @Nullable MappedItem getMappedItem(int id) {
|
||||
return backwardsItemMappings != null ? backwardsItemMappings.get(id) : null;
|
||||
}
|
||||
|
||||
public @Nullable String getMappedNamedSound(String id) {
|
||||
if (backwardsSoundMappings == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (id.indexOf(':') == -1) {
|
||||
id = "minecraft:" + id;
|
||||
}
|
||||
|
||||
return backwardsSoundMappings.get(id);
|
||||
}
|
||||
|
||||
public @Nullable String mappedEntityName(String entityName) {
|
||||
if (entityNames == null) {
|
||||
ViaBackwards.getPlatform().getLogger().severe("No entity mappings found when requesting them for " + entityName);
|
||||
new Exception().printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return entityNames.get(entityName);
|
||||
}
|
||||
|
||||
public @Nullable Int2ObjectMap<MappedItem> getBackwardsItemMappings() {
|
||||
return backwardsItemMappings;
|
||||
}
|
||||
|
||||
public @Nullable Map<String, String> getBackwardsSoundMappings() {
|
||||
return backwardsSoundMappings;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.data;
|
||||
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
|
||||
public class MappedItem {
|
||||
|
||||
private final int id;
|
||||
private final String jsonName;
|
||||
|
||||
public MappedItem(int id, String name) {
|
||||
this.id = id;
|
||||
this.jsonName = ChatRewriter.legacyTextToJsonString("§f" + name);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getJsonName() {
|
||||
return jsonName;
|
||||
}
|
||||
}
|
||||
+23
-8
@@ -1,9 +1,25 @@
|
||||
package nl.matsv.viabackwards.api.data;
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.data;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import nl.matsv.viabackwards.utils.Block;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viabackwards.utils.Block;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class MappedLegacyBlockItem {
|
||||
|
||||
@@ -16,7 +32,7 @@ public class MappedLegacyBlockItem {
|
||||
public MappedLegacyBlockItem(int id, short data, @Nullable String name, boolean block) {
|
||||
this.id = id;
|
||||
this.data = data;
|
||||
this.name = name != null ? ChatColor.RESET + name : null;
|
||||
this.name = name != null ? "§f" + name : null;
|
||||
this.block = block ? new Block(id, data) : null;
|
||||
}
|
||||
|
||||
@@ -44,8 +60,7 @@ public class MappedLegacyBlockItem {
|
||||
return blockEntityHandler != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BlockEntityHandler getBlockEntityHandler() {
|
||||
public @Nullable BlockEntityHandler getBlockEntityHandler() {
|
||||
return blockEntityHandler;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.data;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonIOException;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.gson.JsonPrimitive;
|
||||
import com.viaversion.viaversion.libs.gson.JsonSyntaxException;
|
||||
import com.viaversion.viaversion.util.GsonUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class VBMappingDataLoader {
|
||||
|
||||
public static JsonObject loadFromDataDir(String name) {
|
||||
File file = new File(ViaBackwards.getPlatform().getDataFolder(), name);
|
||||
if (!file.exists()) return loadData(name);
|
||||
|
||||
// Load the file from the platform's directory if present
|
||||
try (FileReader reader = new FileReader(file)) {
|
||||
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
|
||||
} catch (JsonSyntaxException e) {
|
||||
ViaBackwards.getPlatform().getLogger().warning(name + " is badly formatted!");
|
||||
e.printStackTrace();
|
||||
ViaBackwards.getPlatform().getLogger().warning("Falling back to resource's file!");
|
||||
return loadData(name);
|
||||
} catch (IOException | JsonIOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JsonObject loadData(String name) {
|
||||
InputStream stream = VBMappingDataLoader.class.getClassLoader().getResourceAsStream("assets/viabackwards/data/" + name);
|
||||
try (InputStreamReader reader = new InputStreamReader(stream)) {
|
||||
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers, boolean warnOnMissing) {
|
||||
Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(newIdentifiers);
|
||||
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
|
||||
String key = entry.getValue().getAsString();
|
||||
int mappedId = newIdentifierMap.getInt(key);
|
||||
if (mappedId == -1) {
|
||||
if (diffIdentifiers != null) {
|
||||
// Search in diff mappings
|
||||
JsonPrimitive diffValueJson = diffIdentifiers.getAsJsonPrimitive(key);
|
||||
String diffValue = diffValueJson != null ? diffValueJson.getAsString() : null;
|
||||
|
||||
int dataIndex;
|
||||
if (diffValue == null && (dataIndex = key.indexOf('[')) != -1
|
||||
&& (diffValueJson = diffIdentifiers.getAsJsonPrimitive(key.substring(0, dataIndex))) != null) {
|
||||
// Check for wildcard mappings
|
||||
diffValue = diffValueJson.getAsString();
|
||||
|
||||
// Keep original properties if value ends with [
|
||||
if (diffValue.endsWith("[")) {
|
||||
diffValue += key.substring(dataIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (diffValue != null) {
|
||||
mappedId = newIdentifierMap.getInt(diffValue);
|
||||
}
|
||||
}
|
||||
|
||||
if (mappedId == -1) {
|
||||
// Nothing found :(
|
||||
if (warnOnMissing && !Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
output[Integer.parseInt(entry.getKey())] = mappedId;
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, String> objectToNamespacedMap(JsonObject object) {
|
||||
Map<String, String> mappings = new HashMap<>(object.size());
|
||||
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (key.indexOf(':') == -1) {
|
||||
key = "minecraft:" + key;
|
||||
}
|
||||
String value = entry.getValue().getAsString();
|
||||
if (value.indexOf(':') == -1) {
|
||||
value = "minecraft:" + value;
|
||||
}
|
||||
mappings.put(key, value);
|
||||
}
|
||||
return mappings;
|
||||
}
|
||||
|
||||
public static Map<String, String> objectToMap(JsonObject object) {
|
||||
Map<String, String> mappings = new HashMap<>(object.size());
|
||||
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
mappings.put(entry.getKey(), entry.getValue().getAsString());
|
||||
}
|
||||
return mappings;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<MappedItem> loadItemMappings(JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) {
|
||||
Int2ObjectMap<MappedItem> itemMapping = new Int2ObjectOpenHashMap<>(diffMapping.size(), 0.99F);
|
||||
Object2IntMap<String> newIdenfierMap = MappingDataLoader.indexedObjectToMap(newMapping);
|
||||
Object2IntMap<String> oldIdenfierMap = MappingDataLoader.indexedObjectToMap(oldMapping);
|
||||
for (Map.Entry<String, JsonElement> entry : diffMapping.entrySet()) {
|
||||
JsonObject object = entry.getValue().getAsJsonObject();
|
||||
String mappedIdName = object.getAsJsonPrimitive("id").getAsString();
|
||||
int mappedId = newIdenfierMap.getInt(mappedIdName);
|
||||
if (mappedId == -1) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No key for " + mappedIdName + " :( ");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
int oldId = oldIdenfierMap.getInt(entry.getKey());
|
||||
if (oldId == -1) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No old entry for " + mappedIdName + " :( ");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = object.getAsJsonPrimitive("name").getAsString();
|
||||
itemMapping.put(oldId, new MappedItem(mappedId, name));
|
||||
}
|
||||
|
||||
// Look for missing keys
|
||||
if (warnOnMissing && !Via.getConfig().isSuppressConversionWarnings()) {
|
||||
for (Object2IntMap.Entry<String> entry : oldIdenfierMap.object2IntEntrySet()) {
|
||||
if (!newIdenfierMap.containsKey(entry.getKey()) && !itemMapping.containsKey(entry.getIntValue())) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No item mapping for " + entry.getKey() + " :( ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return itemMapping;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.data;
|
||||
|
||||
import com.viaversion.viaversion.api.data.IntArrayMappings;
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||
import com.viaversion.viaversion.api.data.Mappings;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class VBMappings extends IntArrayMappings {
|
||||
|
||||
private VBMappings(final int[] oldToNew, final int mappedIds) {
|
||||
super(oldToNew, mappedIds);
|
||||
}
|
||||
|
||||
public static Mappings.Builder<VBMappings> vbBuilder() {
|
||||
return new Builder(VBMappings::new);
|
||||
}
|
||||
|
||||
public static final class Builder extends Mappings.Builder<VBMappings> {
|
||||
|
||||
private Builder(final MappingsSupplier<VBMappings> supplier) {
|
||||
super(supplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VBMappings build() {
|
||||
final int size = this.size != -1 ? this.size : size(unmapped);
|
||||
final int mappedSize = this.mappedSize != -1 ? this.mappedSize : size(mapped);
|
||||
final int[] mappings = new int[size];
|
||||
Arrays.fill(mappings, -1);
|
||||
// Do conversion if one is an array and the other an object, otherwise directly map
|
||||
if (unmapped.isJsonArray()) {
|
||||
if (mapped.isJsonObject()) {
|
||||
VBMappingDataLoader.mapIdentifiers(mappings, toJsonObject(unmapped.getAsJsonArray()), mapped.getAsJsonObject(), diffMappings, warnOnMissing);
|
||||
} else {
|
||||
// Use the normal loader
|
||||
MappingDataLoader.mapIdentifiers(mappings, unmapped.getAsJsonArray(), mapped.getAsJsonArray(), diffMappings, warnOnMissing);
|
||||
}
|
||||
} else if (mapped.isJsonArray()) {
|
||||
VBMappingDataLoader.mapIdentifiers(mappings, unmapped.getAsJsonObject(), toJsonObject(mapped.getAsJsonArray()), diffMappings, warnOnMissing);
|
||||
} else {
|
||||
VBMappingDataLoader.mapIdentifiers(mappings, unmapped.getAsJsonObject(), mapped.getAsJsonObject(), diffMappings, warnOnMissing);
|
||||
}
|
||||
return supplier.supply(mappings, mappedSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.entities.storage;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class EntityData {
|
||||
private final BackwardsProtocol<?, ?, ?, ?> protocol;
|
||||
private final int id;
|
||||
private final int replacementId;
|
||||
private final String key;
|
||||
private NameVisibility nameVisibility = NameVisibility.NONE;
|
||||
private MetaCreator defaultMeta;
|
||||
|
||||
public EntityData(BackwardsProtocol<?, ?, ?, ?> protocol, EntityType type, int replacementId) {
|
||||
this(protocol, type.name(), type.getId(), replacementId);
|
||||
}
|
||||
|
||||
public EntityData(BackwardsProtocol<?, ?, ?, ?> protocol, String key, int id, int replacementId) {
|
||||
this.protocol = protocol;
|
||||
this.id = id;
|
||||
this.replacementId = replacementId;
|
||||
this.key = key.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
public EntityData jsonName() {
|
||||
this.nameVisibility = NameVisibility.JSON;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityData plainName() {
|
||||
this.nameVisibility = NameVisibility.PLAIN;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityData spawnMetadata(MetaCreator handler) {
|
||||
this.defaultMeta = handler;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasBaseMeta() {
|
||||
return this.defaultMeta != null;
|
||||
}
|
||||
|
||||
public int typeId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return custom mobname, can be either a String or a JsonElement
|
||||
*/
|
||||
public @Nullable Object mobName() {
|
||||
if (nameVisibility == NameVisibility.NONE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String name = protocol.getMappingData().mappedEntityName(key);
|
||||
if (name == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Entity name for " + key + " not found in protocol " + protocol.getClass().getSimpleName());
|
||||
name = key;
|
||||
}
|
||||
return nameVisibility == NameVisibility.JSON ? ChatRewriter.legacyTextToJson(name) : name;
|
||||
}
|
||||
|
||||
public int replacementId() {
|
||||
return replacementId;
|
||||
}
|
||||
|
||||
public @Nullable MetaCreator defaultMeta() {
|
||||
return defaultMeta;
|
||||
}
|
||||
|
||||
public boolean isObjectType() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int objectData() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EntityData{" +
|
||||
"id=" + id +
|
||||
", mobName='" + key + '\'' +
|
||||
", replacementId=" + replacementId +
|
||||
", defaultMeta=" + defaultMeta +
|
||||
'}';
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface MetaCreator {
|
||||
|
||||
void createMeta(WrappedMetadata storage);
|
||||
}
|
||||
|
||||
private enum NameVisibility {
|
||||
PLAIN,
|
||||
JSON,
|
||||
NONE
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.entities.storage;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
|
||||
public class EntityObjectData extends EntityData {
|
||||
private final int objectData;
|
||||
|
||||
public EntityObjectData(BackwardsProtocol<?, ?, ?, ?> protocol, String key, int id, int replacementId, int objectData) {
|
||||
super(protocol, key, id, replacementId);
|
||||
this.objectData = objectData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isObjectType() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int objectData() {
|
||||
return objectData;
|
||||
}
|
||||
}
|
||||
+39
-16
@@ -1,23 +1,41 @@
|
||||
package nl.matsv.viabackwards.api.entities.storage;
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.entities.storage;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriterBase;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.rewriters.EntityRewriterBase;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class EntityPositionHandler {
|
||||
|
||||
public static final double RELATIVE_MOVE_FACTOR = 32 * 128;
|
||||
private final EntityRewriterBase<?> entityRewriter;
|
||||
private final EntityRewriterBase entityRewriter;
|
||||
private final Class<? extends EntityPositionStorage> storageClass;
|
||||
private final Supplier<? extends EntityPositionStorage> storageSupplier;
|
||||
private boolean warnedForMissingEntity;
|
||||
|
||||
public EntityPositionHandler(EntityRewriterBase<?> entityRewriter,
|
||||
public EntityPositionHandler(EntityRewriterBase entityRewriter,
|
||||
Class<? extends EntityPositionStorage> storageClass, Supplier<? extends EntityPositionStorage> storageSupplier) {
|
||||
this.entityRewriter = entityRewriter;
|
||||
this.storageClass = storageClass;
|
||||
@@ -31,7 +49,7 @@ public class EntityPositionHandler {
|
||||
|
||||
public void cacheEntityPosition(PacketWrapper wrapper, double x, double y, double z, boolean create, boolean relative) throws Exception {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
EntityTracker.StoredEntity storedEntity = entityRewriter.getEntityTracker(wrapper.user()).getEntity(entityId);
|
||||
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! :>
|
||||
ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing at position: " + x + " - " + y + " - " + z + " in " + storageClass.getSimpleName());
|
||||
@@ -45,18 +63,23 @@ public class EntityPositionHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPositionStorage positionStorage = create ? storageSupplier.get() : storedEntity.get(storageClass);
|
||||
if (positionStorage == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing " + storageClass.getSimpleName());
|
||||
return;
|
||||
EntityPositionStorage positionStorage;
|
||||
if (create) {
|
||||
positionStorage = storageSupplier.get();
|
||||
storedEntity.put(positionStorage);
|
||||
} else {
|
||||
positionStorage = storedEntity.get(storageClass);
|
||||
if (positionStorage == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing " + storageClass.getSimpleName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
positionStorage.setCoordinates(x, y, z, relative);
|
||||
storedEntity.put(positionStorage);
|
||||
}
|
||||
|
||||
public EntityPositionStorage getStorage(UserConnection user, int entityId) {
|
||||
EntityTracker.StoredEntity storedEntity = user.get(EntityTracker.class).get(entityRewriter.getProtocol()).getEntity(entityId);
|
||||
StoredEntityData storedEntity = entityRewriter.tracker(user).entityData(entityId);
|
||||
EntityPositionStorage entityStorage;
|
||||
if (storedEntity == null || (entityStorage = storedEntity.get(EntityPositionStorage.class)) == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Untracked entity with id " + entityId + " in " + storageClass.getSimpleName());
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.entities.storage;
|
||||
|
||||
public abstract class EntityPositionStorage {
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setCoordinates(double x, double y, double z, boolean relative) {
|
||||
if (relative) {
|
||||
this.x += x;
|
||||
this.y += y;
|
||||
this.z += z;
|
||||
} else {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.entities.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
|
||||
public abstract class PlayerPositionStorage implements StorableObject {
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
|
||||
protected PlayerPositionStorage() {
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setX(final double x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public void setY(final double y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void setZ(final double z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public void setCoordinates(PacketWrapper wrapper, boolean relative) throws Exception {
|
||||
setCoordinates(wrapper.get(Type.DOUBLE, 0), wrapper.get(Type.DOUBLE, 1), wrapper.get(Type.DOUBLE, 2), relative);
|
||||
}
|
||||
|
||||
public void setCoordinates(double x, double y, double z, boolean relative) {
|
||||
if (relative) {
|
||||
this.x += x;
|
||||
this.y += y;
|
||||
this.z += z;
|
||||
} else {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.entities.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class WrappedMetadata {
|
||||
private final List<Metadata> metadataList;
|
||||
|
||||
public WrappedMetadata(List<Metadata> metadataList) {
|
||||
this.metadataList = metadataList;
|
||||
}
|
||||
|
||||
public boolean has(Metadata data) {
|
||||
return this.metadataList.contains(data);
|
||||
}
|
||||
|
||||
public void remove(Metadata data) {
|
||||
this.metadataList.remove(data);
|
||||
}
|
||||
|
||||
public void remove(int index) {
|
||||
metadataList.removeIf(meta -> meta.id() == index);
|
||||
}
|
||||
|
||||
public void add(Metadata data) {
|
||||
this.metadataList.add(data);
|
||||
}
|
||||
|
||||
public @Nullable Metadata get(int index) {
|
||||
for (Metadata meta : this.metadataList) {
|
||||
if (index == meta.id()) {
|
||||
return meta;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Metadata> metadataList() {
|
||||
return metadataList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MetaStorage{" + "metaDataList=" + metadataList + '}';
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.exceptions;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class RemovedValueException extends IOException {
|
||||
|
||||
/**
|
||||
* May be cached since it is never actually printed, only checked.
|
||||
*/
|
||||
public static final RemovedValueException EX = new RemovedValueException() {
|
||||
@Override
|
||||
public Throwable fillInStackTrace() {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
}
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ShortTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Rewriter to handle the addition of new enchantments.
|
||||
*/
|
||||
public class EnchantmentRewriter {
|
||||
|
||||
private final Map<String, String> enchantmentMappings = new HashMap<>();
|
||||
private final ItemRewriter itemRewriter;
|
||||
private final boolean jsonFormat;
|
||||
|
||||
public EnchantmentRewriter(ItemRewriter itemRewriter, boolean jsonFormat) {
|
||||
this.itemRewriter = itemRewriter;
|
||||
this.jsonFormat = jsonFormat;
|
||||
}
|
||||
|
||||
public EnchantmentRewriter(ItemRewriter itemRewriter) {
|
||||
this(itemRewriter, true);
|
||||
}
|
||||
|
||||
public void registerEnchantment(String key, String replacementLore) {
|
||||
enchantmentMappings.put(key, replacementLore);
|
||||
}
|
||||
|
||||
public void handleToClient(Item item) {
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) return;
|
||||
|
||||
if (tag.get("Enchantments") instanceof ListTag) {
|
||||
rewriteEnchantmentsToClient(tag, false);
|
||||
}
|
||||
if (tag.get("StoredEnchantments") instanceof ListTag) {
|
||||
rewriteEnchantmentsToClient(tag, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleToServer(Item item) {
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) return;
|
||||
|
||||
if (tag.contains(itemRewriter.getNbtTagName() + "|Enchantments")) {
|
||||
rewriteEnchantmentsToServer(tag, false);
|
||||
}
|
||||
if (tag.contains(itemRewriter.getNbtTagName() + "|StoredEnchantments")) {
|
||||
rewriteEnchantmentsToServer(tag, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) {
|
||||
String key = storedEnchant ? "StoredEnchantments" : "Enchantments";
|
||||
ListTag enchantments = tag.get(key);
|
||||
List<Tag> loreToAdd = new ArrayList<>();
|
||||
boolean changed = false;
|
||||
|
||||
Iterator<Tag> iterator = enchantments.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
CompoundTag enchantmentEntry = (CompoundTag) iterator.next();
|
||||
Tag idTag = enchantmentEntry.get("id");
|
||||
if (!(idTag instanceof StringTag)) continue;
|
||||
|
||||
String enchantmentId = ((StringTag) idTag).getValue();
|
||||
String remappedName = enchantmentMappings.get(enchantmentId);
|
||||
if (remappedName != null) {
|
||||
if (!changed) {
|
||||
// Backup original before doing modifications
|
||||
itemRewriter.saveListTag(tag, enchantments, key);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
iterator.remove();
|
||||
|
||||
int level = ((NumberTag) enchantmentEntry.get("lvl")).asInt();
|
||||
String loreValue = remappedName + " " + getRomanNumber(level);
|
||||
if (jsonFormat) {
|
||||
loreValue = ChatRewriter.legacyTextToJsonString(loreValue);
|
||||
}
|
||||
|
||||
loreToAdd.add(new StringTag(loreValue));
|
||||
}
|
||||
}
|
||||
|
||||
if (!loreToAdd.isEmpty()) {
|
||||
// Add dummy enchant for the glow effect if there are no actual enchantments left
|
||||
if (!storedEnchant && enchantments.size() == 0) {
|
||||
CompoundTag dummyEnchantment = new CompoundTag();
|
||||
dummyEnchantment.put("id", new StringTag());
|
||||
dummyEnchantment.put("lvl", new ShortTag((short) 0));
|
||||
enchantments.add(dummyEnchantment);
|
||||
}
|
||||
|
||||
CompoundTag display = tag.get("display");
|
||||
if (display == null) {
|
||||
tag.put("display", display = new CompoundTag());
|
||||
}
|
||||
|
||||
ListTag loreTag = display.get("Lore");
|
||||
if (loreTag == null) {
|
||||
display.put("Lore", loreTag = new ListTag(StringTag.class));
|
||||
} else {
|
||||
// Save original lore
|
||||
itemRewriter.saveListTag(display, loreTag, "Lore");
|
||||
}
|
||||
|
||||
loreToAdd.addAll(loreTag.getValue());
|
||||
loreTag.setValue(loreToAdd);
|
||||
}
|
||||
}
|
||||
|
||||
public void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnchant) {
|
||||
// Just restore the original tag ig present (lore is always restored in the item rewriter)
|
||||
String key = storedEnchant ? "StoredEnchantments" : "Enchantments";
|
||||
itemRewriter.restoreListTag(tag, key);
|
||||
}
|
||||
|
||||
public static String getRomanNumber(int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return "I";
|
||||
case 2:
|
||||
return "II";
|
||||
case 3:
|
||||
return "III";
|
||||
case 4:
|
||||
return "IV";
|
||||
case 5:
|
||||
return "V";
|
||||
case 6:
|
||||
return "VI";
|
||||
case 7:
|
||||
return "VII";
|
||||
case 8:
|
||||
return "VIII";
|
||||
case 9:
|
||||
return "IX";
|
||||
case 10:
|
||||
return "X";
|
||||
default:
|
||||
return Integer.toString(number);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
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.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||
|
||||
public abstract class EntityRewriter<T extends BackwardsProtocol> extends EntityRewriterBase<T> {
|
||||
|
||||
protected EntityRewriter(T protocol) {
|
||||
this(protocol, Types1_14.META_TYPES.optionalComponentType, Types1_14.META_TYPES.booleanType);
|
||||
}
|
||||
|
||||
protected EntityRewriter(T protocol, MetaType displayType, MetaType displayVisibilityType) {
|
||||
super(protocol, displayType, 2, displayVisibilityType, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTrackerWithData(ClientboundPacketType packetType, EntityType fallingBlockType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - Entity UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
map(Type.DOUBLE); // 3 - X
|
||||
map(Type.DOUBLE); // 4 - Y
|
||||
map(Type.DOUBLE); // 5 - Z
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Type.BYTE); // 7 - Yaw
|
||||
map(Type.INT); // 8 - Data
|
||||
handler(getSpawnTrackerWithDataHandler(fallingBlockType));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public PacketHandler getSpawnTrackerWithDataHandler(EntityType fallingBlockType) {
|
||||
return wrapper -> {
|
||||
// Check against the UNMAPPED entity type
|
||||
EntityType entityType = setOldEntityId(wrapper);
|
||||
if (entityType == fallingBlockType) {
|
||||
int blockState = wrapper.get(Type.INT, 0);
|
||||
wrapper.set(Type.INT, 0, protocol.getMappingData().getNewBlockStateId(blockState));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public PacketHandler getSpawnTrackerWithDataHandler1_19(EntityType fallingBlockType) {
|
||||
return wrapper -> {
|
||||
// Check against the UNMAPPED entity type
|
||||
EntityType entityType = setOldEntityId(wrapper);
|
||||
if (entityType == fallingBlockType) {
|
||||
int blockState = wrapper.get(Type.VAR_INT, 2);
|
||||
wrapper.set(Type.VAR_INT, 2, protocol.getMappingData().getNewBlockStateId(blockState));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void registerSpawnTracker(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Entity UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
handler(wrapper -> setOldEntityId(wrapper));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the mapped entity id and returns the unmapped entity type.
|
||||
*
|
||||
* @param wrapper packet wrapper
|
||||
* @return unmapped (!) entity type
|
||||
*/
|
||||
protected EntityType setOldEntityId(PacketWrapper wrapper) throws Exception {
|
||||
int typeId = wrapper.get(Type.VAR_INT, 1);
|
||||
EntityType entityType = typeFromId(typeId);
|
||||
tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), entityType);
|
||||
|
||||
int mappedTypeId = newEntityId(entityType.getId());
|
||||
if (typeId != mappedTypeId) {
|
||||
wrapper.set(Type.VAR_INT, 1, mappedTypeId);
|
||||
}
|
||||
|
||||
return entityType;
|
||||
}
|
||||
}
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.google.common.base.Preconditions;
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityData;
|
||||
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.Int2IntMapMappings;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.rewriter.meta.MetaHandlerEvent;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Entity rewriter base class.
|
||||
*
|
||||
* @see com.viaversion.viabackwards.api.rewriters.EntityRewriter
|
||||
* @see LegacyEntityRewriter
|
||||
*/
|
||||
public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends EntityRewriter<T> {
|
||||
private final Int2ObjectMap<EntityData> entityDataMappings = new Int2ObjectOpenHashMap<>();
|
||||
private final MetaType displayNameMetaType;
|
||||
private final MetaType displayVisibilityMetaType;
|
||||
private final int displayNameIndex;
|
||||
private final int displayVisibilityIndex;
|
||||
|
||||
EntityRewriterBase(T protocol, MetaType displayNameMetaType, int displayNameIndex,
|
||||
MetaType displayVisibilityMetaType, int displayVisibilityIndex) {
|
||||
super(protocol, false);
|
||||
this.displayNameMetaType = displayNameMetaType;
|
||||
this.displayNameIndex = displayNameIndex;
|
||||
this.displayVisibilityMetaType = displayVisibilityMetaType;
|
||||
this.displayVisibilityIndex = displayVisibilityIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMetadata(int entityId, List<Metadata> metadataList, UserConnection connection) {
|
||||
super.handleMetadata(entityId, metadataList, connection);
|
||||
|
||||
EntityType type = tracker(connection).entityType(entityId);
|
||||
if (type == null) {
|
||||
return; // Don't handle untracked entities - basically always the fault of a plugin sending virtual entities through concurrency-unsafe handling
|
||||
}
|
||||
|
||||
EntityData entityData = entityDataForType(type);
|
||||
|
||||
// Set the mapped entity name if there is no custom name set already
|
||||
Metadata meta = getMeta(displayNameIndex, metadataList);
|
||||
if (meta != null && entityData != null && entityData.mobName() != null
|
||||
&& (meta.getValue() == null || meta.getValue().toString().isEmpty())
|
||||
&& meta.metaType().typeId() == displayNameMetaType.typeId()) {
|
||||
meta.setValue(entityData.mobName());
|
||||
if (ViaBackwards.getConfig().alwaysShowOriginalMobName()) {
|
||||
removeMeta(displayVisibilityIndex, metadataList);
|
||||
metadataList.add(new Metadata(displayVisibilityIndex, displayVisibilityMetaType, true));
|
||||
}
|
||||
}
|
||||
|
||||
// Add any other extra meta for mapped entities
|
||||
//TODO only do this once for a first meta packet?
|
||||
if (entityData != null && entityData.hasBaseMeta()) {
|
||||
entityData.defaultMeta().createMeta(new WrappedMetadata(metadataList));
|
||||
}
|
||||
}
|
||||
|
||||
protected @Nullable Metadata getMeta(int metaIndex, List<Metadata> metadataList) {
|
||||
for (Metadata metadata : metadataList) {
|
||||
if (metadata.id() == metaIndex) {
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void removeMeta(int metaIndex, List<Metadata> metadataList) {
|
||||
metadataList.removeIf(meta -> meta.id() == metaIndex);
|
||||
}
|
||||
|
||||
protected boolean hasData(EntityType type) {
|
||||
return entityDataMappings.containsKey(type.getId());
|
||||
}
|
||||
|
||||
protected @Nullable EntityData entityDataForType(EntityType type) {
|
||||
return entityDataMappings.get(type.getId());
|
||||
}
|
||||
|
||||
protected @Nullable StoredEntityData storedEntityData(MetaHandlerEvent event) {
|
||||
return tracker(event.user()).entityData(event.entityId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps an entity type to another with extra data.
|
||||
* Note that both types should be of the same version.
|
||||
*
|
||||
* @param type entity type
|
||||
* @param mappedType mapped entity type
|
||||
* @return created entity data
|
||||
* @see #mapEntityType(EntityType, EntityType) for id only rewriting
|
||||
*/
|
||||
protected EntityData mapEntityTypeWithData(EntityType type, EntityType mappedType) {
|
||||
Preconditions.checkArgument(type.getClass() == mappedType.getClass());
|
||||
|
||||
// Already rewrite the id here
|
||||
int mappedReplacementId = newEntityId(mappedType.getId());
|
||||
EntityData data = new EntityData(protocol, type, mappedReplacementId);
|
||||
mapEntityType(type.getId(), mappedReplacementId);
|
||||
entityDataMappings.put(type.getId(), data);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps entity ids based on the enum constant's names.
|
||||
*
|
||||
* @param oldTypes entity types of the higher version
|
||||
* @param newTypeClass entity types enum class of the lower version
|
||||
* @param <E> new enum type
|
||||
*/
|
||||
@Override
|
||||
public <E extends Enum<E> & EntityType> void mapTypes(EntityType[] oldTypes, Class<E> newTypeClass) {
|
||||
if (typeMappings == null) {
|
||||
typeMappings = Int2IntMapMappings.of();
|
||||
}
|
||||
for (EntityType oldType : oldTypes) {
|
||||
try {
|
||||
E newType = Enum.valueOf(newTypeClass, oldType.name());
|
||||
typeMappings.setNewId(oldType.getId(), newType.getId());
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
// Don't warn
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerMetaTypeHandler(@Nullable MetaType itemType, @Nullable MetaType blockType, @Nullable MetaType particleType, @Nullable MetaType optChatType) {
|
||||
filter().handler((event, meta) -> {
|
||||
MetaType type = meta.metaType();
|
||||
if (itemType != null && type == itemType) {
|
||||
protocol.getItemRewriter().handleItemToClient(meta.value());
|
||||
} else if (blockType != null && type == blockType) {
|
||||
int data = meta.value();
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
} else if (particleType != null && type == particleType) {
|
||||
rewriteParticle(meta.value());
|
||||
} else if (optChatType != null && type == optChatType) {
|
||||
JsonElement text = meta.value();
|
||||
if (text != null) {
|
||||
protocol.getTranslatableRewriter().processText(text);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ONLY TRACKS, DOESN'T REWRITE IDS
|
||||
protected PacketHandler getTrackerHandler(Type<? extends Number> intType, int typeIndex) {
|
||||
return wrapper -> {
|
||||
Number id = wrapper.get(intType, typeIndex);
|
||||
tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), typeFromId(id.intValue()));
|
||||
};
|
||||
}
|
||||
|
||||
protected PacketHandler getTrackerHandler() {
|
||||
return getTrackerHandler(Type.VAR_INT, 1);
|
||||
}
|
||||
|
||||
protected PacketHandler getTrackerHandler(EntityType entityType, Type<? extends Number> intType) {
|
||||
return wrapper -> tracker(wrapper.user()).addEntity((int) wrapper.get(intType, 0), entityType);
|
||||
}
|
||||
|
||||
protected PacketHandler getDimensionHandler(int index) {
|
||||
return wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, index);
|
||||
clientWorld.setEnvironment(dimensionId);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.MappedItem;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewriterBase<T> {
|
||||
|
||||
protected ItemRewriter(T protocol) {
|
||||
super(protocol, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Item handleItemToClient(@Nullable Item item) {
|
||||
if (item == null) return null;
|
||||
|
||||
CompoundTag display = item.tag() != null ? item.tag().get("display") : null;
|
||||
if (protocol.getTranslatableRewriter() != null && display != null) {
|
||||
// Handle name and lore components
|
||||
StringTag name = display.get("Name");
|
||||
if (name != null) {
|
||||
String newValue = protocol.getTranslatableRewriter().processText(name.getValue()).toString();
|
||||
if (!newValue.equals(name.getValue())) {
|
||||
saveStringTag(display, name, "Name");
|
||||
}
|
||||
|
||||
name.setValue(newValue);
|
||||
}
|
||||
|
||||
ListTag lore = display.get("Lore");
|
||||
if (lore != null) {
|
||||
boolean changed = false;
|
||||
for (Tag loreEntryTag : lore) {
|
||||
if (!(loreEntryTag instanceof StringTag)) continue;
|
||||
|
||||
StringTag loreEntry = (StringTag) loreEntryTag;
|
||||
String newValue = protocol.getTranslatableRewriter().processText(loreEntry.getValue()).toString();
|
||||
if (!changed && !newValue.equals(loreEntry.getValue())) {
|
||||
// Backup original lore before doing any modifications
|
||||
changed = true;
|
||||
saveListTag(display, lore, "Lore");
|
||||
}
|
||||
|
||||
loreEntry.setValue(newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MappedItem data = protocol.getMappingData().getMappedItem(item.identifier());
|
||||
if (data == null) {
|
||||
// Just rewrite the id
|
||||
return super.handleItemToClient(item);
|
||||
}
|
||||
|
||||
if (item.tag() == null) {
|
||||
item.setTag(new CompoundTag());
|
||||
}
|
||||
|
||||
// Save original id, set remapped id
|
||||
item.tag().put(nbtTagName + "|id", new IntTag(item.identifier()));
|
||||
item.setIdentifier(data.getId());
|
||||
|
||||
// Set custom name - only done if there is no original one
|
||||
if (display == null) {
|
||||
item.tag().put("display", display = new CompoundTag());
|
||||
}
|
||||
if (!display.contains("Name")) {
|
||||
display.put("Name", new StringTag(data.getJsonName()));
|
||||
display.put(nbtTagName + "|customName", new ByteTag());
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Item handleItemToServer(@Nullable Item item) {
|
||||
if (item == null) return null;
|
||||
|
||||
super.handleItemToServer(item);
|
||||
if (item.tag() != null) {
|
||||
IntTag originalId = item.tag().remove(nbtTagName + "|id");
|
||||
if (originalId != null) {
|
||||
item.setIdentifier(originalId.asInt());
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAdvancements(ClientboundPacketType packetType, Type<Item> type) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
final int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Identifier
|
||||
|
||||
// Parent
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
}
|
||||
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
final JsonElement title = wrapper.passthrough(Type.COMPONENT);
|
||||
final JsonElement description = wrapper.passthrough(Type.COMPONENT);
|
||||
final TranslatableRewriter translatableRewriter = protocol.getTranslatableRewriter();
|
||||
if (translatableRewriter != null) {
|
||||
translatableRewriter.processText(title);
|
||||
translatableRewriter.processText(description);
|
||||
}
|
||||
|
||||
handleItemToClient(wrapper.passthrough(type)); // Icon
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0) {
|
||||
wrapper.passthrough(Type.STRING); // Background texture
|
||||
}
|
||||
wrapper.passthrough(Type.FLOAT); // X
|
||||
wrapper.passthrough(Type.FLOAT); // Y
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
|
||||
|
||||
final int arrayLength = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int array = 0; array < arrayLength; array++) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class ItemRewriterBase<T extends BackwardsProtocol> extends ItemRewriter<T> {
|
||||
|
||||
protected final String nbtTagName;
|
||||
protected final boolean jsonNameFormat;
|
||||
|
||||
protected ItemRewriterBase(T protocol, boolean jsonNameFormat) {
|
||||
super(protocol);
|
||||
this.jsonNameFormat = jsonNameFormat;
|
||||
nbtTagName = "VB|" + protocol.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public @Nullable Item handleItemToServer(@Nullable Item item) {
|
||||
if (item == null) return null;
|
||||
super.handleItemToServer(item);
|
||||
|
||||
restoreDisplayTag(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
protected boolean hasBackupTag(CompoundTag displayTag, String tagName) {
|
||||
return displayTag.contains(nbtTagName + "|o" + tagName);
|
||||
}
|
||||
|
||||
protected void saveStringTag(CompoundTag displayTag, StringTag original, String name) {
|
||||
// Multiple places might try to backup data
|
||||
String backupName = nbtTagName + "|o" + name;
|
||||
if (!displayTag.contains(backupName)) {
|
||||
displayTag.put(backupName, new StringTag(original.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
protected void saveListTag(CompoundTag displayTag, ListTag original, String name) {
|
||||
// Multiple places might try to backup data
|
||||
String backupName = nbtTagName + "|o" + name;
|
||||
if (!displayTag.contains(backupName)) {
|
||||
// Clone all tag entries
|
||||
ListTag listTag = new ListTag();
|
||||
for (Tag tag : original.getValue()) {
|
||||
listTag.add(tag.clone());
|
||||
}
|
||||
|
||||
displayTag.put(backupName, listTag);
|
||||
}
|
||||
}
|
||||
|
||||
protected void restoreDisplayTag(Item item) {
|
||||
if (item.tag() == null) return;
|
||||
|
||||
CompoundTag display = item.tag().get("display");
|
||||
if (display != null) {
|
||||
// Remove custom name / restore original name
|
||||
if (display.remove(nbtTagName + "|customName") != null) {
|
||||
display.remove("Name");
|
||||
} else {
|
||||
restoreStringTag(display, "Name");
|
||||
}
|
||||
|
||||
// Restore lore
|
||||
restoreListTag(display, "Lore");
|
||||
}
|
||||
}
|
||||
|
||||
protected void restoreStringTag(CompoundTag tag, String tagName) {
|
||||
StringTag original = tag.remove(nbtTagName + "|o" + tagName);
|
||||
if (original != null) {
|
||||
tag.put(tagName, new StringTag(original.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
protected void restoreListTag(CompoundTag tag, String tagName) {
|
||||
ListTag original = tag.remove(nbtTagName + "|o" + tagName);
|
||||
if (original != null) {
|
||||
tag.put(tagName, new ListTag(original.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
public String getNbtTagName() {
|
||||
return nbtTagName;
|
||||
}
|
||||
}
|
||||
+65
-62
@@ -1,36 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* 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.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* 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 nl.matsv.viabackwards.api.rewriters;
|
||||
package com.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.data.MappedLegacyBlockItem;
|
||||
import nl.matsv.viabackwards.api.data.VBMappingDataLoader;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.BlockColors;
|
||||
import nl.matsv.viabackwards.utils.Block;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.rewriters.IdRewriteFunction;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
import us.myles.viaversion.libs.gson.JsonPrimitive;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.MappedLegacyBlockItem;
|
||||
import com.viaversion.viabackwards.api.data.VBMappingDataLoader;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.BlockColors;
|
||||
import com.viaversion.viabackwards.utils.Block;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
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.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -78,34 +86,22 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
||||
}
|
||||
}
|
||||
|
||||
protected LegacyBlockItemRewriter(T protocol, @Nullable IdRewriteFunction oldRewriter, @Nullable IdRewriteFunction newRewriter) {
|
||||
super(protocol, oldRewriter, newRewriter, false);
|
||||
protected LegacyBlockItemRewriter(T protocol) {
|
||||
super(protocol, false);
|
||||
replacementData = LEGACY_MAPPINGS.get(protocol.getClass().getSimpleName().split("To")[1].replace("_", "."));
|
||||
}
|
||||
|
||||
protected LegacyBlockItemRewriter(T protocol) {
|
||||
this(protocol, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Item handleItemToClient(Item item) {
|
||||
public @Nullable Item handleItemToClient(@Nullable Item item) {
|
||||
if (item == null) return null;
|
||||
|
||||
MappedLegacyBlockItem data = replacementData.get(item.getIdentifier());
|
||||
MappedLegacyBlockItem data = replacementData.get(item.identifier());
|
||||
if (data == null) {
|
||||
// Just rewrite the id
|
||||
return super.handleItemToClient(item);
|
||||
}
|
||||
|
||||
if (item.getTag() == null) {
|
||||
item.setTag(new CompoundTag(""));
|
||||
}
|
||||
|
||||
// Backup data for toServer
|
||||
short originalData = item.getData();
|
||||
item.getTag().put(createViaNBT(item));
|
||||
|
||||
short originalData = item.data();
|
||||
item.setIdentifier(data.getId());
|
||||
// Keep original data if mapped data is set to -1
|
||||
if (data.getData() != -1) {
|
||||
@@ -114,19 +110,25 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
||||
|
||||
// Set display name
|
||||
if (data.getName() != null) {
|
||||
CompoundTag tag = item.getTag().get("display");
|
||||
if (tag == null) {
|
||||
item.getTag().put(tag = new CompoundTag("display"));
|
||||
if (item.tag() == null) {
|
||||
item.setTag(new CompoundTag());
|
||||
}
|
||||
StringTag nameTag = tag.get("Name");
|
||||
|
||||
CompoundTag display = item.tag().get("display");
|
||||
if (display == null) {
|
||||
item.tag().put("display", display = new CompoundTag());
|
||||
}
|
||||
|
||||
StringTag nameTag = display.get("Name");
|
||||
if (nameTag == null) {
|
||||
tag.put(nameTag = new StringTag("Name", data.getName()));
|
||||
display.put("Name", nameTag = new StringTag(data.getName()));
|
||||
display.put(nbtTagName + "|customName", new ByteTag());
|
||||
}
|
||||
|
||||
// Handle colors
|
||||
String value = nameTag.getValue();
|
||||
if (value.contains("%vb_color%")) {
|
||||
tag.put(new StringTag("Name", value.replace("%vb_color%", BlockColors.get(originalData))));
|
||||
display.put("Name", new StringTag(value.replace("%vb_color%", BlockColors.get(originalData))));
|
||||
}
|
||||
}
|
||||
return item;
|
||||
@@ -142,8 +144,7 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
||||
return (b.getId() << 4 | (b.getData() & 15));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Block handleBlock(int blockId, int data) {
|
||||
public @Nullable Block handleBlock(int blockId, int data) {
|
||||
MappedLegacyBlockItem settings = replacementData.get(blockId);
|
||||
if (settings == null || !settings.isBlock()) return null;
|
||||
|
||||
@@ -167,12 +168,14 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
||||
}
|
||||
|
||||
Pos pos = new Pos(
|
||||
(int) xTag.getValue() & 0xF,
|
||||
(int) yTag.getValue(),
|
||||
(int) zTag.getValue() & 0xF);
|
||||
((NumberTag) xTag).asInt() & 0xF,
|
||||
((NumberTag) yTag).asInt(),
|
||||
((NumberTag) zTag).asInt() & 0xF);
|
||||
tags.put(pos, tag);
|
||||
|
||||
// Handle given Block Entities
|
||||
if (pos.getY() < 0 || pos.getY() > 255) continue; // 1.17
|
||||
|
||||
ChunkSection section = chunk.getSections()[pos.getY() >> 4];
|
||||
if (section == null) continue;
|
||||
|
||||
@@ -229,10 +232,10 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
||||
// Already handled above
|
||||
if (tags.containsKey(pos)) continue;
|
||||
|
||||
CompoundTag tag = new CompoundTag("");
|
||||
tag.put(new IntTag("x", x + (chunk.getX() << 4)));
|
||||
tag.put(new IntTag("y", y + (i << 4)));
|
||||
tag.put(new IntTag("z", z + (chunk.getZ() << 4)));
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.put("x", new IntTag(x + (chunk.getX() << 4)));
|
||||
tag.put("y", new IntTag(y + (i << 4)));
|
||||
tag.put("z", new IntTag(z + (chunk.getZ() << 4)));
|
||||
|
||||
settings.getBlockEntityHandler().handleOrNewCompoundTag(block, tag);
|
||||
chunk.getBlockEntities().add(tag);
|
||||
@@ -243,10 +246,10 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
||||
}
|
||||
|
||||
protected CompoundTag getNamedTag(String text) {
|
||||
CompoundTag tag = new CompoundTag("");
|
||||
tag.put(new CompoundTag("display"));
|
||||
text = ChatColor.RESET + text;
|
||||
((CompoundTag) tag.get("display")).put(new StringTag("Name", jsonNameFormat ? ChatRewriter.legacyTextToJson(text) : text));
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.put("display", new CompoundTag());
|
||||
text = "§r" + text;
|
||||
((CompoundTag) tag.get("display")).put("Name", new StringTag(jsonNameFormat ? ChatRewriter.legacyTextToJsonString(text) : text));
|
||||
return tag;
|
||||
}
|
||||
|
||||
+58
-26
@@ -1,8 +1,37 @@
|
||||
package nl.matsv.viabackwards.api.rewriters;
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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 us.myles.viaversion.libs.opennbt.tag.builtin.*;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ShortTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class LegacyEnchantmentRewriter {
|
||||
|
||||
@@ -21,52 +50,55 @@ public class LegacyEnchantmentRewriter {
|
||||
public void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) {
|
||||
String key = storedEnchant ? "StoredEnchantments" : "ench";
|
||||
ListTag enchantments = tag.get(key);
|
||||
ListTag remappedEnchantments = new ListTag(nbtTagName + "|" + key, CompoundTag.class);
|
||||
ListTag remappedEnchantments = new ListTag(CompoundTag.class);
|
||||
List<Tag> lore = new ArrayList<>();
|
||||
for (Tag enchantmentEntry : enchantments.clone()) {
|
||||
Short newId = (Short) ((CompoundTag) enchantmentEntry).get("id").getValue();
|
||||
Tag idTag = ((CompoundTag) enchantmentEntry).get("id");
|
||||
if (idTag == null) continue;
|
||||
|
||||
short newId = ((NumberTag) idTag).asShort();
|
||||
String enchantmentName = enchantmentMappings.get(newId);
|
||||
if (enchantmentName != null) {
|
||||
enchantments.remove(enchantmentEntry);
|
||||
Number level = (Number) ((CompoundTag) enchantmentEntry).get("lvl").getValue();
|
||||
short level = ((NumberTag) ((CompoundTag) enchantmentEntry).get("lvl")).asShort();
|
||||
if (hideLevelForEnchants != null && hideLevelForEnchants.contains(newId)) {
|
||||
lore.add(new StringTag("", enchantmentName));
|
||||
lore.add(new StringTag(enchantmentName));
|
||||
} else {
|
||||
lore.add(new StringTag("", enchantmentName + " " + EnchantmentRewriter.getRomanNumber(level.shortValue())));
|
||||
lore.add(new StringTag(enchantmentName + " " + EnchantmentRewriter.getRomanNumber(level)));
|
||||
}
|
||||
remappedEnchantments.add(enchantmentEntry);
|
||||
}
|
||||
}
|
||||
if (!lore.isEmpty()) {
|
||||
if (!storedEnchant && enchantments.size() == 0) {
|
||||
CompoundTag dummyEnchantment = new CompoundTag("");
|
||||
dummyEnchantment.put(new ShortTag("id", (short) 0));
|
||||
dummyEnchantment.put(new ShortTag("lvl", (short) 0));
|
||||
CompoundTag dummyEnchantment = new CompoundTag();
|
||||
dummyEnchantment.put("id", new ShortTag((short) 0));
|
||||
dummyEnchantment.put("lvl", new ShortTag((short) 0));
|
||||
enchantments.add(dummyEnchantment);
|
||||
|
||||
tag.put(new ByteTag(nbtTagName + "|dummyEnchant"));
|
||||
tag.put(nbtTagName + "|dummyEnchant", new ByteTag());
|
||||
|
||||
IntTag hideFlags = tag.get("HideFlags");
|
||||
if (hideFlags == null) {
|
||||
hideFlags = new IntTag("HideFlags");
|
||||
hideFlags = new IntTag();
|
||||
} else {
|
||||
tag.put(new IntTag(nbtTagName + "|oldHideFlags", hideFlags.getValue()));
|
||||
tag.put(nbtTagName + "|oldHideFlags", new IntTag(hideFlags.asByte()));
|
||||
}
|
||||
|
||||
int flags = hideFlags.getValue() | 1;
|
||||
int flags = hideFlags.asByte() | 1;
|
||||
hideFlags.setValue(flags);
|
||||
tag.put(hideFlags);
|
||||
tag.put("HideFlags", hideFlags);
|
||||
}
|
||||
|
||||
tag.put(remappedEnchantments);
|
||||
tag.put(nbtTagName + "|" + key, remappedEnchantments);
|
||||
|
||||
CompoundTag display = tag.get("display");
|
||||
if (display == null) {
|
||||
tag.put(display = new CompoundTag("display"));
|
||||
tag.put("display", display = new CompoundTag());
|
||||
}
|
||||
ListTag loreTag = display.get("Lore");
|
||||
if (loreTag == null) {
|
||||
display.put(loreTag = new ListTag("Lore", StringTag.class));
|
||||
display.put("Lore", loreTag = new ListTag(StringTag.class));
|
||||
}
|
||||
|
||||
lore.addAll(loreTag.getValue());
|
||||
@@ -76,16 +108,16 @@ public class LegacyEnchantmentRewriter {
|
||||
|
||||
public void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnchant) {
|
||||
String key = storedEnchant ? "StoredEnchantments" : "ench";
|
||||
ListTag remappedEnchantments = tag.get(nbtTagName + "|" + key);
|
||||
ListTag remappedEnchantments = tag.remove(nbtTagName + "|" + key);
|
||||
ListTag enchantments = tag.get(key);
|
||||
if (enchantments == null) {
|
||||
enchantments = new ListTag(key, CompoundTag.class);
|
||||
enchantments = new ListTag(CompoundTag.class);
|
||||
}
|
||||
|
||||
if (!storedEnchant && tag.remove(nbtTagName + "|dummyEnchant") != null) {
|
||||
for (Tag enchantment : enchantments.clone()) {
|
||||
Short id = (Short) ((CompoundTag) enchantment).get("id").getValue();
|
||||
Short level = (Short) ((CompoundTag) enchantment).get("lvl").getValue();
|
||||
short id = ((NumberTag) ((CompoundTag) enchantment).get("id")).asShort();
|
||||
short level = ((NumberTag) ((CompoundTag) enchantment).get("lvl")).asShort();
|
||||
if (id == 0 && level == 0) {
|
||||
enchantments.remove(enchantment);
|
||||
}
|
||||
@@ -93,7 +125,7 @@ public class LegacyEnchantmentRewriter {
|
||||
|
||||
IntTag hideFlags = tag.remove(nbtTagName + "|oldHideFlags");
|
||||
if (hideFlags != null) {
|
||||
tag.put(new IntTag("HideFlags", hideFlags.getValue()));
|
||||
tag.put("HideFlags", new IntTag(hideFlags.asByte()));
|
||||
} else {
|
||||
tag.remove("HideFlags");
|
||||
}
|
||||
@@ -114,8 +146,8 @@ public class LegacyEnchantmentRewriter {
|
||||
tag.remove("display");
|
||||
}
|
||||
}
|
||||
tag.put(enchantments);
|
||||
tag.remove(remappedEnchantments.getName());
|
||||
|
||||
tag.put(key, enchantments);
|
||||
}
|
||||
|
||||
public void setHideLevelForEnchants(int... enchants) {
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityData;
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityObjectData;
|
||||
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.ObjectType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
||||
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.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public abstract class LegacyEntityRewriter<T extends BackwardsProtocol> extends EntityRewriterBase<T> {
|
||||
private final Map<ObjectType, EntityData> objectTypes = new HashMap<>();
|
||||
|
||||
protected LegacyEntityRewriter(T protocol) {
|
||||
this(protocol, MetaType1_9.String, MetaType1_9.Boolean);
|
||||
}
|
||||
|
||||
protected LegacyEntityRewriter(T protocol, MetaType displayType, MetaType displayVisibilityType) {
|
||||
super(protocol, displayType, 2, displayVisibilityType, 3);
|
||||
}
|
||||
|
||||
protected EntityObjectData mapObjectType(ObjectType oldObjectType, ObjectType replacement, int data) {
|
||||
EntityObjectData entData = new EntityObjectData(protocol, oldObjectType.getType().name(), oldObjectType.getId(), replacement.getId(), data);
|
||||
objectTypes.put(oldObjectType, entData);
|
||||
return entData;
|
||||
}
|
||||
|
||||
protected @Nullable EntityData getObjectData(ObjectType type) {
|
||||
return objectTypes.get(type);
|
||||
}
|
||||
|
||||
protected void registerRespawn(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
clientWorld.setEnvironment(wrapper.get(Type.INT, 0));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void registerJoinGame(ClientboundPacketType packetType, EntityType playerType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||
clientChunks.setEnvironment(wrapper.get(Type.INT, 1));
|
||||
addTrackedEntity(wrapper, wrapper.get(Type.INT, 0), playerType);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMetadataRewriter(ClientboundPacketType packetType, Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
if (oldMetaType != null) {
|
||||
map(oldMetaType, newMetaType);
|
||||
} else {
|
||||
map(newMetaType);
|
||||
}
|
||||
handler(wrapper -> {
|
||||
List<Metadata> metadata = wrapper.get(newMetaType, 0);
|
||||
handleMetadata(wrapper.get(Type.VAR_INT, 0), metadata, wrapper.user());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMetadataRewriter(ClientboundPacketType packetType, Type<List<Metadata>> metaType) {
|
||||
registerMetadataRewriter(packetType, null, metaType);
|
||||
}
|
||||
|
||||
protected PacketHandler getMobSpawnRewriter(Type<List<Metadata>> metaType) {
|
||||
return wrapper -> {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
EntityType type = tracker(wrapper.user()).entityType(entityId);
|
||||
|
||||
List<Metadata> metadata = wrapper.get(metaType, 0);
|
||||
handleMetadata(entityId, metadata, wrapper.user());
|
||||
|
||||
EntityData entityData = entityDataForType(type);
|
||||
if (entityData != null) {
|
||||
wrapper.set(Type.VAR_INT, 1, entityData.replacementId());
|
||||
if (entityData.hasBaseMeta()) {
|
||||
entityData.defaultMeta().createMeta(new WrappedMetadata(metadata));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected PacketHandler getObjectTrackerHandler() {
|
||||
return wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), getObjectTypeFromId(wrapper.get(Type.BYTE, 0)));
|
||||
}
|
||||
|
||||
protected PacketHandler getTrackerAndMetaHandler(Type<List<Metadata>> metaType, EntityType entityType) {
|
||||
return wrapper -> {
|
||||
addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), entityType);
|
||||
List<Metadata> metadata = wrapper.get(metaType, 0);
|
||||
handleMetadata(wrapper.get(Type.VAR_INT, 0), metadata, wrapper.user());
|
||||
};
|
||||
}
|
||||
|
||||
protected PacketHandler getObjectRewriter(Function<Byte, ObjectType> objectGetter) {
|
||||
return wrapper -> {
|
||||
ObjectType type = objectGetter.apply(wrapper.get(Type.BYTE, 0));
|
||||
if (type == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Could not find Entity Type" + wrapper.get(Type.BYTE, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
EntityData data = getObjectData(type);
|
||||
if (data != null) {
|
||||
wrapper.set(Type.BYTE, 0, (byte) data.replacementId());
|
||||
if (data.objectData() != -1) {
|
||||
wrapper.set(Type.INT, 0, data.objectData());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected EntityType getObjectTypeFromId(int typeId) {
|
||||
return typeFromId(typeId);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected void addTrackedEntity(PacketWrapper wrapper, int entityId, EntityType type) throws Exception {
|
||||
tracker(wrapper.user()).addEntity(entityId, type);
|
||||
}
|
||||
}
|
||||
+19
-9
@@ -1,20 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* 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.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* 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 nl.matsv.viabackwards.api.rewriters;
|
||||
package com.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public abstract class LegacySoundRewriter<T extends BackwardsProtocol> extends Rewriter<T> {
|
||||
@Deprecated
|
||||
public abstract class LegacySoundRewriter<T extends BackwardsProtocol> extends RewriterBase<T> {
|
||||
protected final Int2ObjectMap<SoundData> soundRewrites = new Int2ObjectOpenHashMap<>(64);
|
||||
|
||||
protected LegacySoundRewriter(T protocol) {
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.rewriter.IdRewriteFunction;
|
||||
|
||||
public final class MapColorRewriter {
|
||||
|
||||
/**
|
||||
* Returns a packethandler to rewrite map data color ids. Reading starts from the icon count.
|
||||
*
|
||||
* @param rewriter id rewriter returning mapped colors, or -1 if unmapped
|
||||
* @return packethandler to rewrite map data color ids
|
||||
*/
|
||||
public static PacketHandler getRewriteHandler(IdRewriteFunction rewriter) {
|
||||
return wrapper -> {
|
||||
int iconCount = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < iconCount; i++) {
|
||||
wrapper.passthrough(Type.VAR_INT); // Type
|
||||
wrapper.passthrough(Type.BYTE); // X
|
||||
wrapper.passthrough(Type.BYTE); // Z
|
||||
wrapper.passthrough(Type.BYTE); // Direction
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.COMPONENT); // Display Name
|
||||
}
|
||||
}
|
||||
|
||||
short columns = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
if (columns < 1) return;
|
||||
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Rows
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // X
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Z
|
||||
byte[] data = wrapper.passthrough(Type.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;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
|
||||
public class SoundRewriter extends com.viaversion.viaversion.rewriter.SoundRewriter {
|
||||
|
||||
private final BackwardsProtocol protocol;
|
||||
|
||||
public SoundRewriter(BackwardsProtocol protocol) {
|
||||
super(protocol);
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public void registerNamedSound(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // Sound identifier
|
||||
handler(getNamedSoundHandler());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerStopSound(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(getStopSoundHandler());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public PacketHandler getNamedSoundHandler() {
|
||||
return wrapper -> {
|
||||
String soundId = wrapper.get(Type.STRING, 0);
|
||||
String mappedId = protocol.getMappingData().getMappedNamedSound(soundId);
|
||||
if (mappedId == null) return;
|
||||
if (!mappedId.isEmpty()) {
|
||||
wrapper.set(Type.STRING, 0, mappedId);
|
||||
} else {
|
||||
wrapper.cancel();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public PacketHandler getStopSoundHandler() {
|
||||
return wrapper -> {
|
||||
byte flags = wrapper.passthrough(Type.BYTE);
|
||||
if ((flags & 0x02) == 0) return; // No sound specified
|
||||
|
||||
if ((flags & 0x01) != 0) {
|
||||
wrapper.passthrough(Type.VAR_INT); // Source
|
||||
}
|
||||
|
||||
String soundId = wrapper.read(Type.STRING);
|
||||
String mappedId = protocol.getMappingData().getMappedNamedSound(soundId);
|
||||
if (mappedId == null) {
|
||||
// No mapping found
|
||||
wrapper.write(Type.STRING, soundId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mappedId.isEmpty()) {
|
||||
wrapper.write(Type.STRING, mappedId);
|
||||
} else {
|
||||
// Cancel if set to empty
|
||||
wrapper.cancel();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.VBMappingDataLoader;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
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;
|
||||
|
||||
public class TranslatableRewriter extends ComponentRewriter {
|
||||
|
||||
private static final Map<String, Map<String, String>> TRANSLATABLES = new HashMap<>();
|
||||
protected final Map<String, String> newTranslatables;
|
||||
|
||||
public static void loadTranslatables() {
|
||||
JsonObject jsonObject = VBMappingDataLoader.loadData("translation-mappings.json");
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
|
||||
Map<String, String> versionMappings = new HashMap<>();
|
||||
TRANSLATABLES.put(entry.getKey(), versionMappings);
|
||||
for (Map.Entry<String, JsonElement> translationEntry : entry.getValue().getAsJsonObject().entrySet()) {
|
||||
versionMappings.put(translationEntry.getKey(), translationEntry.getValue().getAsString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TranslatableRewriter(BackwardsProtocol protocol) {
|
||||
this(protocol, protocol.getClass().getSimpleName().split("To")[1].replace("_", "."));
|
||||
}
|
||||
|
||||
public TranslatableRewriter(BackwardsProtocol protocol, String sectionIdentifier) {
|
||||
super(protocol);
|
||||
final Map<String, String> newTranslatables = TRANSLATABLES.get(sectionIdentifier);
|
||||
if (newTranslatables == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Error loading " + sectionIdentifier + " translatables!");
|
||||
this.newTranslatables = new HashMap<>();
|
||||
} else {
|
||||
this.newTranslatables = newTranslatables;
|
||||
}
|
||||
}
|
||||
|
||||
public void registerPing() {
|
||||
protocol.registerClientbound(State.LOGIN, 0x00, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerDisconnect(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerChatMessage(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerLegacyOpenWindow(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // Id
|
||||
map(Type.STRING); // Window Type
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerOpenWindow(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Id
|
||||
map(Type.VAR_INT); // Window Type
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerTabList(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
processText(wrapper.passthrough(Type.COMPONENT));
|
||||
processText(wrapper.passthrough(Type.COMPONENT));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerCombatKill(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.INT);
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject root, String translate) {
|
||||
String newTranslate = newTranslatables.get(translate);
|
||||
if (newTranslate != null) {
|
||||
root.addProperty("translate", newTranslate);
|
||||
}
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_10to1_11;
|
||||
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||
|
||||
public class PotionSplashHandler {
|
||||
|
||||
private static final Int2IntMap DATA = new Int2IntOpenHashMap(14, 0.99F);
|
||||
|
||||
static {
|
||||
DATA.defaultReturnValue(-1);
|
||||
DATA.put(2039713, 5); // night vision
|
||||
DATA.put(8356754, 7); // invisibility
|
||||
DATA.put(2293580, 9); // jump boost
|
||||
DATA.put(14981690, 12); // fire resistance
|
||||
DATA.put(8171462, 14); // swiftness
|
||||
DATA.put(5926017, 17); // slowness
|
||||
DATA.put(3035801, 19); // water breathing
|
||||
DATA.put(16262179, 21); // instant health
|
||||
DATA.put(4393481, 23); // instant damage
|
||||
DATA.put(5149489, 25); // poison
|
||||
DATA.put(13458603, 28); // regeneration
|
||||
DATA.put(9643043, 31); // strength
|
||||
DATA.put(4738376, 34); // weakness
|
||||
DATA.put(3381504, 36); // luck
|
||||
}
|
||||
|
||||
public static int getOldData(int data) {
|
||||
return DATA.get(data);
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_10to1_11;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappings;
|
||||
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets.BlockItemPackets1_11;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets.EntityPackets1_11;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets.PlayerPackets1_11;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_10To1_11 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
||||
|
||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.11", "1.10", null, true);
|
||||
private final EntityPackets1_11 entityPackets = new EntityPackets1_11(this); // Required for the item rewriter
|
||||
private BlockItemPackets1_11 blockItemPackets;
|
||||
|
||||
public Protocol1_10To1_11() {
|
||||
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
(blockItemPackets = new BlockItemPackets1_11(this)).register();
|
||||
entityPackets.register();
|
||||
new PlayerPackets1_11().register(this);
|
||||
|
||||
SoundRewriter soundRewriter = new SoundRewriter(this);
|
||||
soundRewriter.registerNamedSound(ClientboundPackets1_9_3.NAMED_SOUND);
|
||||
soundRewriter.registerSound(ClientboundPackets1_9_3.SOUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_11Types.EntityType.PLAYER, true));
|
||||
|
||||
if (!user.has(WindowTracker.class)) {
|
||||
user.put(new WindowTracker());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappings getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPackets1_11 getEntityRewriter() {
|
||||
return entityPackets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItemPackets1_11 getItemRewriter() {
|
||||
return blockItemPackets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMappingDataToLoad() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+75
-72
@@ -1,43 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* 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.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* 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 nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets;
|
||||
package com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import nl.matsv.viabackwards.api.data.MappedLegacyBlockItem;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.api.rewriters.LegacyBlockItemRewriter;
|
||||
import nl.matsv.viabackwards.api.rewriters.LegacyEnchantmentRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage.ChestedHorseStorage;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_11Types;
|
||||
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_11to1_10.EntityIdRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viabackwards.api.data.MappedLegacyBlockItem;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEnchantmentRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.ChestedHorseStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
||||
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_11to1_10.EntityIdRewriter;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
@@ -52,16 +59,14 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.SET_SLOT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SET_SLOT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE); // 0 - Window ID
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot ID
|
||||
map(Type.ITEM); // 2 - Slot Value
|
||||
|
||||
handler(itemRewriter.itemToClientHandler(Type.ITEM));
|
||||
handler(itemToClientHandler(Type.ITEM));
|
||||
|
||||
// Handle Llama
|
||||
handler(new PacketHandler() {
|
||||
@@ -81,7 +86,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.WINDOW_ITEMS, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.WINDOW_ITEMS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
@@ -112,10 +117,10 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
}
|
||||
});
|
||||
|
||||
itemRewriter.registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
|
||||
// Plugin message Packet -> Trading
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Channel
|
||||
@@ -146,7 +151,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerIncoming(ServerboundPackets1_9_3.CLICK_WINDOW, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CLICK_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
@@ -156,7 +161,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
map(Type.VAR_INT); // 4 - Mode
|
||||
map(Type.ITEM); // 5 - Clicked Item
|
||||
|
||||
handler(itemRewriter.itemToServerHandler(Type.ITEM));
|
||||
handler(itemToServerHandler(Type.ITEM));
|
||||
|
||||
// Llama slot
|
||||
handler(new PacketHandler() {
|
||||
@@ -177,9 +182,9 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
}
|
||||
});
|
||||
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
|
||||
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.CHUNK_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@@ -207,7 +212,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.BLOCK_CHANGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Block Position
|
||||
@@ -223,7 +228,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Chunk X
|
||||
@@ -241,7 +246,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
@@ -265,12 +270,12 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.OPEN_WINDOW, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.OPEN_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.STRING); // 1 - Window Type
|
||||
map(Type.STRING); // 2 - Title
|
||||
map(Type.COMPONENT); // 2 - Title
|
||||
map(Type.UNSIGNED_BYTE); // 3 - Slots
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@@ -278,8 +283,9 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityId = -1;
|
||||
// Passthrough Entity ID
|
||||
if (wrapper.get(Type.STRING, 0).equals("EntityHorse"))
|
||||
if (wrapper.get(Type.STRING, 0).equals("EntityHorse")) {
|
||||
entityId = wrapper.passthrough(Type.INT);
|
||||
}
|
||||
|
||||
// Track Inventory
|
||||
String inventory = wrapper.get(Type.STRING, 0);
|
||||
@@ -288,14 +294,15 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
windowTracker.setEntityId(entityId);
|
||||
|
||||
// Change llama slotcount to the donkey one
|
||||
if (isLlama(wrapper.user()))
|
||||
if (isLlama(wrapper.user())) {
|
||||
wrapper.set(Type.UNSIGNED_BYTE, 1, (short) 17);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.CLOSE_WINDOW, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.CLOSE_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
// Inventory tracking
|
||||
@@ -311,7 +318,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
});
|
||||
|
||||
|
||||
protocol.registerIncoming(ServerboundPackets1_9_3.CLOSE_WINDOW, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CLOSE_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
// Inventory tracking
|
||||
@@ -326,13 +333,9 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
}
|
||||
});
|
||||
|
||||
protocol.getEntityPackets().registerMetaHandler().handle(e -> {
|
||||
Metadata data = e.getData();
|
||||
|
||||
if (data.getMetaType().getType().equals(Type.ITEM)) // Is Item
|
||||
data.setValue(handleItemToClient((Item) data.getValue()));
|
||||
|
||||
return data;
|
||||
protocol.getEntityRewriter().filter().handler((event, meta) -> {
|
||||
if (meta.metaType().type().equals(Type.ITEM)) // Is Item
|
||||
meta.setValue(handleItemToClient((Item) meta.getValue()));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -357,7 +360,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
if (item == null) return null;
|
||||
super.handleItemToClient(item);
|
||||
|
||||
CompoundTag tag = item.getTag();
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) return item;
|
||||
|
||||
// Rewrite spawn eggs (id checks are done in the method itself)
|
||||
@@ -373,11 +376,11 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item handleItemToServer(final Item item) {
|
||||
public Item handleItemToServer(Item item) {
|
||||
if (item == null) return null;
|
||||
super.handleItemToServer(item);
|
||||
|
||||
CompoundTag tag = item.getTag();
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) return item;
|
||||
|
||||
// Rewrite spawn eggs (id checks are done in the method itself)
|
||||
@@ -395,9 +398,9 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
private boolean isLlama(UserConnection user) {
|
||||
WindowTracker tracker = user.get(WindowTracker.class);
|
||||
if (tracker.getInventory() != null && tracker.getInventory().equals("EntityHorse")) {
|
||||
EntityTracker.ProtocolEntityTracker entTracker = user.get(EntityTracker.class).get(getProtocol());
|
||||
EntityTracker.StoredEntity storedEntity = entTracker.getEntity(tracker.getEntityId());
|
||||
return storedEntity != null && storedEntity.getType().is(Entity1_11Types.EntityType.LIAMA);
|
||||
EntityTracker entTracker = user.getEntityTracker(Protocol1_10To1_11.class);
|
||||
StoredEntityData entityData = entTracker.entityData(tracker.getEntityId());
|
||||
return entityData != null && entityData.type().is(Entity1_11Types.EntityType.LIAMA);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -405,10 +408,10 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
private Optional<ChestedHorseStorage> getChestedHorse(UserConnection user) {
|
||||
WindowTracker tracker = user.get(WindowTracker.class);
|
||||
if (tracker.getInventory() != null && tracker.getInventory().equals("EntityHorse")) {
|
||||
EntityTracker.ProtocolEntityTracker entTracker = user.get(EntityTracker.class).get(getProtocol());
|
||||
EntityTracker.StoredEntity storedEntity = entTracker.getEntity(tracker.getEntityId());
|
||||
if (storedEntity != null)
|
||||
return Optional.of(storedEntity.get(ChestedHorseStorage.class));
|
||||
EntityTracker entTracker = user.getEntityTracker(Protocol1_10To1_11.class);
|
||||
StoredEntityData entityData = entTracker.entityData(tracker.getEntityId());
|
||||
if (entityData != null)
|
||||
return Optional.of(entityData.get(ChestedHorseStorage.class));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
@@ -447,7 +450,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
int endNonExistingFormula = 2 + 3 * (storage.isChested() ? 5 : 0);
|
||||
|
||||
if (slotId >= startNonExistingFormula && slotId < endNonExistingFormula)
|
||||
return new Item(166, (byte) 1, (short) 0, getNamedTag(ChatColor.RED + "SLOT DISABLED"));
|
||||
return new DataItem(166, (byte) 1, (short) 0, getNamedTag("§4SLOT DISABLED"));
|
||||
if (slotId == 1)
|
||||
return null;
|
||||
return current;
|
||||
+412
@@ -0,0 +1,412 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_10to1_11.packets;
|
||||
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityData;
|
||||
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.PotionSplashHandler;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.ChestedHorseStorage;
|
||||
import com.viaversion.viabackwards.utils.Block;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class EntityPackets1_11 extends LegacyEntityRewriter<Protocol1_10To1_11> {
|
||||
|
||||
public EntityPackets1_11(Protocol1_10To1_11 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.EFFECT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
map(Type.POSITION);
|
||||
map(Type.INT);
|
||||
handler(wrapper -> {
|
||||
int type = wrapper.get(Type.INT, 0);
|
||||
if (type == 2002 || type == 2007) {
|
||||
// 2007 potion id doesn't exist in 1.10
|
||||
if (type == 2007) {
|
||||
wrapper.set(Type.INT, 0, 2002);
|
||||
}
|
||||
|
||||
int mappedData = PotionSplashHandler.getOldData(wrapper.get(Type.INT, 1));
|
||||
if (mappedData != -1) {
|
||||
wrapper.set(Type.INT, 1, mappedData);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.BYTE); // 2 - Type
|
||||
map(Type.DOUBLE); // 3 - x
|
||||
map(Type.DOUBLE); // 4 - y
|
||||
map(Type.DOUBLE); // 5 - z
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Type.BYTE); // 7 - Yaw
|
||||
map(Type.INT); // 8 - data
|
||||
|
||||
// Track Entity
|
||||
handler(getObjectTrackerHandler());
|
||||
handler(getObjectRewriter(id -> Entity1_11Types.ObjectType.findById(id).orElse(null)));
|
||||
|
||||
// Handle FallingBlock blocks
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Optional<Entity1_12Types.ObjectType> type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||
if (type.isPresent() && type.get() == Entity1_12Types.ObjectType.FALLING_BLOCK) {
|
||||
int objectData = wrapper.get(Type.INT, 0);
|
||||
int objType = objectData & 4095;
|
||||
int data = objectData >> 12 & 15;
|
||||
|
||||
Block block = protocol.getItemRewriter().handleBlock(objType, data);
|
||||
if (block == null)
|
||||
return;
|
||||
|
||||
wrapper.set(Type.INT, 0, block.getId() | block.getData() << 12);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, Entity1_11Types.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, Entity1_11Types.EntityType.WEATHER);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.VAR_INT, Type.UNSIGNED_BYTE); // 2 - Entity Type
|
||||
map(Type.DOUBLE); // 3 - X
|
||||
map(Type.DOUBLE); // 4 - Y
|
||||
map(Type.DOUBLE); // 5 - Z
|
||||
map(Type.BYTE); // 6 - Yaw
|
||||
map(Type.BYTE); // 7 - Pitch
|
||||
map(Type.BYTE); // 8 - Head Pitch
|
||||
map(Type.SHORT); // 9 - Velocity X
|
||||
map(Type.SHORT); // 10 - Velocity Y
|
||||
map(Type.SHORT); // 11 - Velocity Z
|
||||
map(Types1_9.METADATA_LIST); // 12 - Metadata
|
||||
|
||||
// Track entity
|
||||
handler(getTrackerHandler(Type.UNSIGNED_BYTE, 0));
|
||||
|
||||
// Rewrite entity type / metadata
|
||||
handler(wrapper -> {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
EntityType type = tracker(wrapper.user()).entityType(entityId);
|
||||
|
||||
List<Metadata> list = wrapper.get(Types1_9.METADATA_LIST, 0);
|
||||
handleMetadata(wrapper.get(Type.VAR_INT, 0), list, wrapper.user());
|
||||
|
||||
EntityData entityData = entityDataForType(type);
|
||||
if (entityData != null) {
|
||||
wrapper.set(Type.UNSIGNED_BYTE, 0, (short) entityData.replacementId());
|
||||
if (entityData.hasBaseMeta()) {
|
||||
entityData.defaultMeta().createMeta(new WrappedMetadata(list));
|
||||
}
|
||||
}
|
||||
|
||||
// Sub 1.11 clients will error if the list is empty
|
||||
if (list.isEmpty()) {
|
||||
list.add(new Metadata(0, MetaType1_9.Byte, (byte) 0));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_PAINTING, Entity1_11Types.EntityType.PAINTING);
|
||||
registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, Entity1_11Types.EntityType.PLAYER);
|
||||
registerRespawn(ClientboundPackets1_9_3.RESPAWN);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Player UUID
|
||||
map(Type.DOUBLE); // 2 - X
|
||||
map(Type.DOUBLE); // 3 - Y
|
||||
map(Type.DOUBLE); // 4 - Z
|
||||
map(Type.BYTE); // 5 - Yaw
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Types1_9.METADATA_LIST); // 7 - Metadata list
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_9.METADATA_LIST, Entity1_11Types.EntityType.PLAYER));
|
||||
handler(wrapper -> {
|
||||
// Sub 1.11 clients will cry if the list is empty
|
||||
List<Metadata> metadata = wrapper.get(Types1_9.METADATA_LIST, 0);
|
||||
if (metadata.isEmpty()) {
|
||||
metadata.add(new Metadata(0, MetaType1_9.Byte, (byte) 0));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerRemoveEntities(ClientboundPackets1_9_3.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_9.METADATA_LIST);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.ENTITY_STATUS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.BYTE); // 1 - Entity Status
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
byte b = wrapper.get(Type.BYTE, 0);
|
||||
|
||||
if (b == 35) {
|
||||
wrapper.clearPacket();
|
||||
wrapper.setId(0x1E); // Change Game State
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) 10); // Play Elder Guardian animation
|
||||
wrapper.write(Type.FLOAT, 0F);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
// Guardian
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.ELDER_GUARDIAN, Entity1_11Types.EntityType.GUARDIAN);
|
||||
// Skeletons
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.WITHER_SKELETON, Entity1_11Types.EntityType.SKELETON).spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(1)));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.STRAY, Entity1_11Types.EntityType.SKELETON).plainName().spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(2)));
|
||||
// Zombies
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.HUSK, Entity1_11Types.EntityType.ZOMBIE).plainName().spawnMetadata(storage -> handleZombieType(storage, 6));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.ZOMBIE_VILLAGER, Entity1_11Types.EntityType.ZOMBIE).spawnMetadata(storage -> handleZombieType(storage, 1));
|
||||
// Horses
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(0))); // Nob able to ride the horse without having the MetaType sent.
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.DONKEY, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.MULE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(2)));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.SKELETON_HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(4)));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.ZOMBIE_HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(3)));
|
||||
// New mobs
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.EVOCATION_FANGS, Entity1_11Types.EntityType.SHULKER);
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.EVOCATION_ILLAGER, Entity1_11Types.EntityType.VILLAGER).plainName();
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.VEX, Entity1_11Types.EntityType.BAT).plainName();
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.VINDICATION_ILLAGER, Entity1_11Types.EntityType.VILLAGER).plainName().spawnMetadata(storage -> storage.add(new Metadata(13, MetaType1_9.VarInt, 4))); // Base Profession
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.LIAMA, Entity1_11Types.EntityType.HORSE).plainName().spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.LIAMA_SPIT, Entity1_11Types.EntityType.SNOWBALL);
|
||||
|
||||
mapObjectType(Entity1_11Types.ObjectType.LIAMA_SPIT, Entity1_11Types.ObjectType.SNOWBALL, -1);
|
||||
// Replace with endertorchthingies
|
||||
mapObjectType(Entity1_11Types.ObjectType.EVOCATION_FANGS, Entity1_11Types.ObjectType.FALLING_BLOCK, 198 | 1 << 12);
|
||||
|
||||
// Handle ElderGuardian & target metadata
|
||||
filter().filterFamily(Entity1_11Types.EntityType.GUARDIAN).index(12).handler((event, meta) -> {
|
||||
boolean b = (boolean) meta.getValue();
|
||||
int bitmask = b ? 0x02 : 0;
|
||||
|
||||
if (event.entityType() == Entity1_11Types.EntityType.ELDER_GUARDIAN) {
|
||||
bitmask |= 0x04;
|
||||
}
|
||||
|
||||
meta.setTypeAndValue(MetaType1_9.Byte, (byte) bitmask);
|
||||
});
|
||||
|
||||
// Handle skeleton swing
|
||||
filter().filterFamily(Entity1_11Types.EntityType.ABSTRACT_SKELETON).index(12).toIndex(13);
|
||||
|
||||
/*
|
||||
ZOMBIE CHANGES
|
||||
*/
|
||||
filter().filterFamily(Entity1_11Types.EntityType.ZOMBIE).handler((event, meta) -> {
|
||||
switch (meta.id()) {
|
||||
case 13:
|
||||
event.cancel();
|
||||
return;
|
||||
case 14:
|
||||
event.setIndex(15);
|
||||
break;
|
||||
case 15:
|
||||
event.setIndex(14);
|
||||
break;
|
||||
// Profession
|
||||
case 16:
|
||||
event.setIndex(13);
|
||||
meta.setValue(1 + (int) meta.getValue());
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// Handle Evocation Illager
|
||||
filter().type(Entity1_11Types.EntityType.EVOCATION_ILLAGER).index(12).handler((event, meta) -> {
|
||||
event.setIndex(13);
|
||||
meta.setTypeAndValue(MetaType1_9.VarInt, ((Byte) meta.getValue()).intValue()); // Change the profession for the states
|
||||
});
|
||||
|
||||
// Handle Vex (Remove this field completely since the position is not updated correctly when idling for bats. Sad ):
|
||||
filter().type(Entity1_11Types.EntityType.VEX).index(12).handler((event, meta) -> {
|
||||
meta.setValue((byte) 0x00);
|
||||
});
|
||||
|
||||
// Handle VindicationIllager
|
||||
filter().type(Entity1_11Types.EntityType.VINDICATION_ILLAGER).index(12).handler((event, meta) -> {
|
||||
event.setIndex(13);
|
||||
meta.setTypeAndValue(MetaType1_9.VarInt, ((Number) meta.getValue()).intValue() == 1 ? 2 : 4);
|
||||
});
|
||||
|
||||
/*
|
||||
HORSES
|
||||
*/
|
||||
|
||||
// Handle horse flags
|
||||
filter().filterFamily(Entity1_11Types.EntityType.ABSTRACT_HORSE).index(13).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
byte b = (byte) meta.getValue();
|
||||
if (data.has(ChestedHorseStorage.class) && data.get(ChestedHorseStorage.class).isChested()) {
|
||||
b |= 0x08; // Chested
|
||||
meta.setValue(b);
|
||||
}
|
||||
});
|
||||
|
||||
// Create chested horse storage
|
||||
filter().filterFamily(Entity1_11Types.EntityType.CHESTED_HORSE).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
if (!data.has(ChestedHorseStorage.class)) {
|
||||
data.put(new ChestedHorseStorage());
|
||||
}
|
||||
});
|
||||
|
||||
// Handle horse armor
|
||||
filter().type(Entity1_11Types.EntityType.HORSE).index(16).toIndex(17);
|
||||
|
||||
// Handle chested horse
|
||||
filter().filterFamily(Entity1_11Types.EntityType.CHESTED_HORSE).index(15).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
ChestedHorseStorage storage = data.get(ChestedHorseStorage.class);
|
||||
boolean b = (boolean) meta.getValue();
|
||||
storage.setChested(b);
|
||||
event.cancel();
|
||||
});
|
||||
|
||||
// Get rid of Liama metadata
|
||||
filter().type(Entity1_11Types.EntityType.LIAMA).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
ChestedHorseStorage storage = data.get(ChestedHorseStorage.class);
|
||||
|
||||
int index = event.index();
|
||||
// Store them for later (:
|
||||
switch (index) {
|
||||
case 16:
|
||||
storage.setLiamaStrength((int) meta.getValue());
|
||||
event.cancel();
|
||||
break;
|
||||
case 17:
|
||||
storage.setLiamaCarpetColor((int) meta.getValue());
|
||||
event.cancel();
|
||||
break;
|
||||
case 18:
|
||||
storage.setLiamaVariant((int) meta.getValue());
|
||||
event.cancel();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// Handle Horse (Correct owner)
|
||||
filter().filterFamily(Entity1_11Types.EntityType.ABSTRACT_HORSE).index(14).toIndex(16);
|
||||
|
||||
// Handle villager - Change non-existing profession
|
||||
filter().type(Entity1_11Types.EntityType.VILLAGER).index(13).handler((event, meta) -> {
|
||||
if ((int) meta.getValue() == 5) {
|
||||
meta.setValue(0);
|
||||
}
|
||||
});
|
||||
|
||||
// handle new Shulker color meta
|
||||
filter().type(Entity1_11Types.EntityType.SHULKER).cancel(15);
|
||||
}
|
||||
|
||||
/*
|
||||
0 - Skeleton
|
||||
1 - Wither Skeleton
|
||||
2 - Stray
|
||||
*/
|
||||
|
||||
private Metadata getSkeletonTypeMeta(int type) {
|
||||
return new Metadata(12, MetaType1_9.VarInt, type);
|
||||
}
|
||||
|
||||
/*
|
||||
0 - Zombie
|
||||
1-5 - Villager with profession
|
||||
6 - Husk
|
||||
*/
|
||||
private Metadata getZombieTypeMeta(int type) {
|
||||
return new Metadata(13, MetaType1_9.VarInt, type);
|
||||
}
|
||||
|
||||
private void handleZombieType(WrappedMetadata storage, int type) {
|
||||
Metadata meta = storage.get(13);
|
||||
if (meta == null) {
|
||||
storage.add(getZombieTypeMeta(type));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Horse 0
|
||||
Donkey 1
|
||||
Mule 2
|
||||
Zombie horse 3
|
||||
Skeleton horse 4
|
||||
*/
|
||||
private Metadata getHorseMetaType(int type) {
|
||||
return new Metadata(14, MetaType1_9.VarInt, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return Entity1_11Types.getTypeFromId(typeId, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityType getObjectTypeFromId(int typeId) {
|
||||
return Entity1_11Types.getTypeFromId(typeId, true);
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_10to1_11.packets;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
|
||||
public class PlayerPackets1_11 {
|
||||
private static final ValueTransformer<Short, Float> TO_NEW_FLOAT = new ValueTransformer<Short, Float>(Type.FLOAT) {
|
||||
@Override
|
||||
public Float transform(PacketWrapper wrapper, Short inputValue) throws Exception {
|
||||
return inputValue / 15f;
|
||||
}
|
||||
};
|
||||
|
||||
public void register(Protocol1_10To1_11 protocol) {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.TITLE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Action
|
||||
|
||||
handler(wrapper -> {
|
||||
int action = wrapper.get(Type.VAR_INT, 0);
|
||||
|
||||
if (action == 2) { // Handle the new ActionBar
|
||||
JsonElement message = wrapper.read(Type.COMPONENT);
|
||||
|
||||
wrapper.clearPacket();
|
||||
wrapper.setId(ClientboundPackets1_9_3.CHAT_MESSAGE.ordinal());
|
||||
|
||||
// https://bugs.mojang.com/browse/MC-119145to
|
||||
String legacy = LegacyComponentSerializer.legacySection().serialize(GsonComponentSerializer.gson().deserialize(message.toString()));
|
||||
message = new JsonObject();
|
||||
message.getAsJsonObject().addProperty("text", legacy);
|
||||
|
||||
wrapper.write(Type.COMPONENT, message);
|
||||
wrapper.write(Type.BYTE, (byte) 2);
|
||||
} else if (action > 2) {
|
||||
wrapper.set(Type.VAR_INT, 0, action - 1); // Move everything one position down
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.COLLECT_ITEM, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Collected entity id
|
||||
map(Type.VAR_INT); // 1 - Collector entity id
|
||||
|
||||
handler(wrapper -> wrapper.read(Type.VAR_INT)); // Ignore item pickup count
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Location
|
||||
map(Type.VAR_INT); // 1 - Face
|
||||
map(Type.VAR_INT); // 2 - Hand
|
||||
|
||||
map(Type.UNSIGNED_BYTE, TO_NEW_FLOAT);
|
||||
map(Type.UNSIGNED_BYTE, TO_NEW_FLOAT);
|
||||
map(Type.UNSIGNED_BYTE, TO_NEW_FLOAT);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_10to1_11.storage;
|
||||
|
||||
public class ChestedHorseStorage {
|
||||
private boolean chested;
|
||||
private int liamaStrength;
|
||||
private int liamaCarpetColor = -1;
|
||||
private int liamaVariant;
|
||||
|
||||
public boolean isChested() {
|
||||
return chested;
|
||||
}
|
||||
|
||||
public void setChested(boolean chested) {
|
||||
this.chested = chested;
|
||||
}
|
||||
|
||||
public int getLiamaStrength() {
|
||||
return liamaStrength;
|
||||
}
|
||||
|
||||
public void setLiamaStrength(int liamaStrength) {
|
||||
this.liamaStrength = liamaStrength;
|
||||
}
|
||||
|
||||
public int getLiamaCarpetColor() {
|
||||
return liamaCarpetColor;
|
||||
}
|
||||
|
||||
public void setLiamaCarpetColor(int liamaCarpetColor) {
|
||||
this.liamaCarpetColor = liamaCarpetColor;
|
||||
}
|
||||
|
||||
public int getLiamaVariant() {
|
||||
return liamaVariant;
|
||||
}
|
||||
|
||||
public void setLiamaVariant(int liamaVariant) {
|
||||
this.liamaVariant = liamaVariant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChestedHorseStorage{" + "chested=" + chested + ", liamaStrength=" + liamaStrength + ", liamaCarpetColor=" + liamaCarpetColor + ", liamaVariant=" + liamaVariant + '}';
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_10to1_11.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class WindowTracker implements StorableObject {
|
||||
private String inventory;
|
||||
private int entityId = -1;
|
||||
|
||||
public String getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public void setInventory(String inventory) {
|
||||
this.inventory = inventory;
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
public void setEntityId(int entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WindowTracker{" + "inventory='" + inventory + '\'' + ", entityId=" + entityId + '}';
|
||||
}
|
||||
}
|
||||
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_11_1to1_12;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappings;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.ShoulderTracker;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.BlockItemPackets1_12;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.ChatPackets1_12;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.EntityPackets1_12;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.SoundPackets1_12;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
|
||||
public class Protocol1_11_1To1_12 extends BackwardsProtocol<ClientboundPackets1_12, ClientboundPackets1_9_3, ServerboundPackets1_12, ServerboundPackets1_9_3> {
|
||||
|
||||
private static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.12", "1.11", null, true) {
|
||||
@Override
|
||||
protected boolean shouldWarnOnMissing(final String key) {
|
||||
return super.shouldWarnOnMissing(key) && !key.equals("sounds");
|
||||
}
|
||||
};
|
||||
private final EntityPackets1_12 entityPackets = new EntityPackets1_12(this);
|
||||
private final BlockItemPackets1_12 blockItemPackets = new BlockItemPackets1_12(this);
|
||||
|
||||
public Protocol1_11_1To1_12() {
|
||||
super(ClientboundPackets1_12.class, ClientboundPackets1_9_3.class, ServerboundPackets1_12.class, ServerboundPackets1_9_3.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
blockItemPackets.register();
|
||||
entityPackets.register();
|
||||
new SoundPackets1_12(this).register();
|
||||
new ChatPackets1_12(this).register();
|
||||
|
||||
registerClientbound(ClientboundPackets1_12.TITLE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int action = wrapper.passthrough(Type.VAR_INT);
|
||||
if (action >= 0 && action <= 2) {
|
||||
JsonElement component = wrapper.read(Type.COMPONENT);
|
||||
wrapper.write(Type.COMPONENT, Protocol1_9To1_8.fixJson(component.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
cancelClientbound(ClientboundPackets1_12.ADVANCEMENTS);
|
||||
cancelClientbound(ClientboundPackets1_12.UNLOCK_RECIPES);
|
||||
cancelClientbound(ClientboundPackets1_12.SELECT_ADVANCEMENTS_TAB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_12Types.EntityType.PLAYER, true));
|
||||
|
||||
user.put(new ShoulderTracker(user));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappings getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPackets1_12 getEntityRewriter() {
|
||||
return entityPackets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItemPackets1_12 getItemRewriter() {
|
||||
return blockItemPackets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMappingDataToLoad() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+13
-5
@@ -1,14 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* 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.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* 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 nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data;
|
||||
package com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_11_1to1_12.data;
|
||||
|
||||
public class BlockColors {
|
||||
private static final String[] COLORS = new String[16];
|
||||
|
||||
static {
|
||||
COLORS[0] = "White";
|
||||
COLORS[1] = "Orange";
|
||||
COLORS[2] = "Magenta";
|
||||
COLORS[3] = "Light Blue";
|
||||
COLORS[4] = "Yellow";
|
||||
COLORS[5] = "Lime";
|
||||
COLORS[6] = "Pink";
|
||||
COLORS[7] = "Gray";
|
||||
COLORS[8] = "Light Gray";
|
||||
COLORS[9] = "Cyan";
|
||||
COLORS[10] = "Purple";
|
||||
COLORS[11] = "Blue";
|
||||
COLORS[12] = "Brown";
|
||||
COLORS[13] = "Green";
|
||||
COLORS[14] = "Red";
|
||||
COLORS[15] = "Black";
|
||||
}
|
||||
|
||||
public static String get(int key) {
|
||||
return key >= 0 && key < COLORS.length ? COLORS[key] : "Unknown color";
|
||||
}
|
||||
}
|
||||
+21
-4
@@ -1,10 +1,27 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data;
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_11_1to1_12.data;
|
||||
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||
|
||||
public class MapColorMapping {
|
||||
private static final Int2IntMap MAPPING = new Int2IntOpenHashMap(64, 1F);
|
||||
private static final Int2IntMap MAPPING = new Int2IntOpenHashMap(64, 0.99F);
|
||||
|
||||
static {
|
||||
MAPPING.defaultReturnValue(-1);
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_11_1to1_12.data;
|
||||
|
||||
public class ParrotStorage {
|
||||
private boolean tamed = true;
|
||||
private boolean sitting = true;
|
||||
|
||||
public boolean isTamed() {
|
||||
return tamed;
|
||||
}
|
||||
|
||||
public void setTamed(boolean tamed) {
|
||||
this.tamed = tamed;
|
||||
}
|
||||
|
||||
public boolean isSitting() {
|
||||
return sitting;
|
||||
}
|
||||
|
||||
public void setSitting(boolean sitting) {
|
||||
this.sitting = sitting;
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_11_1to1_12.data;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
|
||||
public class ShoulderTracker extends StoredObject {
|
||||
private int entityId;
|
||||
private String leftShoulder;
|
||||
private String rightShoulder;
|
||||
|
||||
public ShoulderTracker(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public void update() {
|
||||
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_12.CHAT_MESSAGE, null, getUser());
|
||||
|
||||
wrapper.write(Type.COMPONENT, Protocol1_9To1_8.fixJson(generateString()));
|
||||
wrapper.write(Type.BYTE, (byte) 2);
|
||||
|
||||
try {
|
||||
wrapper.scheduleSend(Protocol1_11_1To1_12.class);
|
||||
} catch (Exception e) {
|
||||
ViaBackwards.getPlatform().getLogger().severe("Failed to send the shoulder indication");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Does actionbar not support json colors? :(
|
||||
private String generateString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
// Empty spaces because the non-json formatting is weird
|
||||
builder.append(" ");
|
||||
if (leftShoulder == null) {
|
||||
builder.append("§4§lNothing");
|
||||
} else {
|
||||
builder.append("§2§l").append(getName(leftShoulder));
|
||||
}
|
||||
|
||||
builder.append("§8§l <- §7§lShoulders§8§l -> ");
|
||||
|
||||
if (rightShoulder == null) {
|
||||
builder.append("§4§lNothing");
|
||||
} else {
|
||||
builder.append("§2§l").append(getName(rightShoulder));
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private String getName(String current) {
|
||||
if (current.startsWith("minecraft:")) {
|
||||
current = current.substring(10);
|
||||
}
|
||||
|
||||
String[] array = current.split("_");
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
for (String s : array) {
|
||||
builder.append(s.substring(0, 1).toUpperCase())
|
||||
.append(s.substring(1))
|
||||
.append(" ");
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
public void setEntityId(int entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
public String getLeftShoulder() {
|
||||
return leftShoulder;
|
||||
}
|
||||
|
||||
public void setLeftShoulder(String leftShoulder) {
|
||||
this.leftShoulder = leftShoulder;
|
||||
}
|
||||
|
||||
public String getRightShoulder() {
|
||||
return rightShoulder;
|
||||
}
|
||||
|
||||
public void setRightShoulder(String rightShoulder) {
|
||||
this.rightShoulder = rightShoulder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ShoulderTracker{" + "entityId=" + entityId + ", leftShoulder='" + leftShoulder + '\'' + ", rightShoulder='" + rightShoulder + '\'' + '}';
|
||||
}
|
||||
}
|
||||
+139
-48
@@ -1,31 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* 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.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* 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 nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
package com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
|
||||
import nl.matsv.viabackwards.api.rewriters.LegacyBlockItemRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.MapColorMapping;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.MapColorMapping;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.LongArrayTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1To1_12> {
|
||||
|
||||
@@ -35,7 +50,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.MAP_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.MAP_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@@ -57,8 +72,8 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
if (columns <= 0) return;
|
||||
|
||||
short rows = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
wrapper.passthrough(Type.BYTE); //X
|
||||
wrapper.passthrough(Type.BYTE); //Z
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // X
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Z
|
||||
byte[] data = wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
short color = (short) (data[i] & 0xFF);
|
||||
@@ -73,14 +88,12 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
}
|
||||
});
|
||||
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_12.SET_SLOT, Type.ITEM);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_12.WINDOW_ITEMS, Type.ITEM_ARRAY);
|
||||
itemRewriter.registerEntityEquipment(ClientboundPackets1_12.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
registerSetSlot(ClientboundPackets1_12.SET_SLOT, Type.ITEM);
|
||||
registerWindowItems(ClientboundPackets1_12.WINDOW_ITEMS, Type.ITEM_ARRAY);
|
||||
registerEntityEquipment(ClientboundPackets1_12.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
|
||||
// Plugin message Packet -> Trading
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Channel
|
||||
@@ -110,7 +123,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerIncoming(ServerboundPackets1_9_3.CLICK_WINDOW, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CLICK_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
@@ -131,14 +144,14 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
wrapper.set(Type.ITEM, 0, null); // Set null item (probably will work)
|
||||
|
||||
// Apologize (may happen in some cases, maybe if inventory is full?)
|
||||
PacketWrapper confirm = wrapper.create(0x6);
|
||||
confirm.write(Type.BYTE, wrapper.get(Type.UNSIGNED_BYTE, 0).byteValue());
|
||||
PacketWrapper confirm = wrapper.create(ServerboundPackets1_12.WINDOW_CONFIRMATION);
|
||||
confirm.write(Type.UNSIGNED_BYTE, wrapper.get(Type.UNSIGNED_BYTE, 0));
|
||||
confirm.write(Type.SHORT, wrapper.get(Type.SHORT, 1));
|
||||
confirm.write(Type.BOOLEAN, false); // Success - not used
|
||||
|
||||
wrapper.sendToServer(Protocol1_11_1To1_12.class, true, true);
|
||||
wrapper.sendToServer(Protocol1_11_1To1_12.class);
|
||||
wrapper.cancel();
|
||||
confirm.sendToServer(Protocol1_11_1To1_12.class, true, true);
|
||||
confirm.sendToServer(Protocol1_11_1To1_12.class);
|
||||
return;
|
||||
|
||||
}
|
||||
@@ -149,9 +162,9 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
}
|
||||
});
|
||||
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
|
||||
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.CHUNK_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@@ -168,7 +181,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.BLOCK_CHANGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Block Position
|
||||
@@ -184,7 +197,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Chunk X
|
||||
@@ -202,7 +215,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
@@ -220,16 +233,12 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
}
|
||||
});
|
||||
|
||||
protocol.getEntityPackets().registerMetaHandler().handle(e -> {
|
||||
Metadata data = e.getData();
|
||||
|
||||
if (data.getMetaType().getType().equals(Type.ITEM)) // Is Item
|
||||
data.setValue(handleItemToClient((Item) data.getValue()));
|
||||
|
||||
return data;
|
||||
protocol.getEntityRewriter().filter().handler((event, meta) -> {
|
||||
if (meta.metaType().type().equals(Type.ITEM)) // Is Item
|
||||
meta.setValue(handleItemToClient((Item) meta.getValue()));
|
||||
});
|
||||
|
||||
protocol.registerIncoming(ServerboundPackets1_9_3.CLIENT_STATUS, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CLIENT_STATUS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Action ID
|
||||
@@ -246,4 +255,86 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Item handleItemToClient(Item item) {
|
||||
if (item == null) return null;
|
||||
super.handleItemToClient(item);
|
||||
|
||||
if (item.tag() != null) {
|
||||
CompoundTag backupTag = new CompoundTag();
|
||||
if (handleNbtToClient(item.tag(), backupTag)) {
|
||||
item.tag().put("Via|LongArrayTags", backupTag);
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
private boolean handleNbtToClient(CompoundTag compoundTag, CompoundTag backupTag) {
|
||||
// Long array tags were introduced in 1.12 - just remove them
|
||||
// Only save the removed tags instead of blindly copying the entire nbt again
|
||||
Iterator<Map.Entry<String, Tag>> iterator = compoundTag.iterator();
|
||||
boolean hasLongArrayTag = false;
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Tag> entry = iterator.next();
|
||||
if (entry.getValue() instanceof CompoundTag) {
|
||||
CompoundTag nestedBackupTag = new CompoundTag();
|
||||
backupTag.put(entry.getKey(), nestedBackupTag);
|
||||
hasLongArrayTag |= handleNbtToClient((CompoundTag) entry.getValue(), nestedBackupTag);
|
||||
} else if (entry.getValue() instanceof LongArrayTag) {
|
||||
backupTag.put(entry.getKey(), fromLongArrayTag((LongArrayTag) entry.getValue()));
|
||||
iterator.remove();
|
||||
hasLongArrayTag = true;
|
||||
}
|
||||
}
|
||||
return hasLongArrayTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Item handleItemToServer(Item item) {
|
||||
if (item == null) return null;
|
||||
super.handleItemToServer(item);
|
||||
|
||||
if (item.tag() != null) {
|
||||
Tag tag = item.tag().remove("Via|LongArrayTags");
|
||||
if (tag instanceof CompoundTag) {
|
||||
handleNbtToServer(item.tag(), (CompoundTag) tag);
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
private void handleNbtToServer(CompoundTag compoundTag, CompoundTag backupTag) {
|
||||
// Restore the removed long array tags
|
||||
for (Map.Entry<String, Tag> entry : backupTag) {
|
||||
if (entry.getValue() instanceof CompoundTag) {
|
||||
CompoundTag nestedTag = compoundTag.get(entry.getKey());
|
||||
handleNbtToServer(nestedTag, (CompoundTag) entry.getValue());
|
||||
} else {
|
||||
compoundTag.put(entry.getKey(), fromIntArrayTag((IntArrayTag) entry.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IntArrayTag fromLongArrayTag(LongArrayTag tag) {
|
||||
int[] intArray = new int[tag.length() * 2];
|
||||
long[] longArray = tag.getValue();
|
||||
int i = 0;
|
||||
for (long l : longArray) {
|
||||
intArray[i++] = (int) (l >> 32);
|
||||
intArray[i++] = (int) l;
|
||||
}
|
||||
return new IntArrayTag(intArray);
|
||||
}
|
||||
|
||||
private LongArrayTag fromIntArrayTag(IntArrayTag tag) {
|
||||
long[] longArray = new long[tag.length() / 2];
|
||||
int[] intArray = tag.getValue();
|
||||
for (int i = 0, j = 0; i < intArray.length; i += 2, j++) {
|
||||
longArray[j] = (long) intArray[i] << 32 | ((long) intArray[i + 1] & 0xFFFFFFFFL);
|
||||
}
|
||||
return new LongArrayTag(longArray);
|
||||
}
|
||||
}
|
||||
+23
-6
@@ -1,10 +1,27 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_11_1to1_12.packets;
|
||||
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.viaversion.libs.gson.JsonArray;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
import us.myles.viaversion.libs.gson.JsonPrimitive;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.libs.gson.JsonArray;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.gson.JsonPrimitive;
|
||||
|
||||
public class ChatItemRewriter {
|
||||
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_11_1to1_12.packets;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.AdvancementTranslations;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
|
||||
public class ChatPackets1_12 extends RewriterBase<Protocol1_11_1To1_12> {
|
||||
|
||||
private final ComponentRewriter componentRewriter = new ComponentRewriter() {
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject object, String translate) {
|
||||
String text = AdvancementTranslations.get(translate);
|
||||
if (text != null) {
|
||||
object.addProperty("translate", text);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public ChatPackets1_12(Protocol1_11_1To1_12 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.CHAT_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
JsonElement element = wrapper.passthrough(Type.COMPONENT);
|
||||
componentRewriter.processText(element);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+82
-74
@@ -1,32 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* 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.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* 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 nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
package com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
|
||||
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
||||
import nl.matsv.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.ParrotStorage;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.ShoulderTracker;
|
||||
import nl.matsv.viabackwards.utils.Block;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_12Types;
|
||||
import us.myles.ViaVersion.api.entities.EntityType;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_12;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_12;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.ParrotStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.ShoulderTracker;
|
||||
import com.viaversion.viabackwards.utils.Block;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_12;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_12;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -38,7 +46,7 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<Protocol1_11_1To1_12
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.SPAWN_ENTITY, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SPAWN_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@@ -65,7 +73,7 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<Protocol1_11_1To1_12
|
||||
int objType = objectData & 4095;
|
||||
int data = objectData >> 12 & 15;
|
||||
|
||||
Block block = getProtocol().getBlockItemPackets().handleBlock(objType, data);
|
||||
Block block = protocol.getItemRewriter().handleBlock(objType, data);
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
@@ -77,10 +85,10 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<Protocol1_11_1To1_12
|
||||
}
|
||||
});
|
||||
|
||||
registerExtraTracker(ClientboundPackets1_12.SPAWN_EXPERIENCE_ORB, Entity1_12Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_12.SPAWN_GLOBAL_ENTITY, Entity1_12Types.EntityType.WEATHER);
|
||||
registerTracker(ClientboundPackets1_12.SPAWN_EXPERIENCE_ORB, Entity1_12Types.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_12.SPAWN_GLOBAL_ENTITY, Entity1_12Types.EntityType.WEATHER);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.SPAWN_MOB, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@@ -105,9 +113,9 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<Protocol1_11_1To1_12
|
||||
}
|
||||
});
|
||||
|
||||
registerExtraTracker(ClientboundPackets1_12.SPAWN_PAINTING, Entity1_12Types.EntityType.PAINTING);
|
||||
registerTracker(ClientboundPackets1_12.SPAWN_PAINTING, Entity1_12Types.EntityType.PAINTING);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.SPAWN_PLAYER, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SPAWN_PLAYER, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@@ -123,7 +131,7 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<Protocol1_11_1To1_12
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.JOIN_GAME, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
@@ -146,23 +154,23 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<Protocol1_11_1To1_12
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||
PacketWrapper wrapper = new PacketWrapper(0x07, null, packetWrapper.user());
|
||||
PacketWrapper wrapper = PacketWrapper.create(0x07, null, packetWrapper.user());
|
||||
|
||||
wrapper.write(Type.VAR_INT, 1);
|
||||
wrapper.write(Type.STRING, "achievement.openInventory");
|
||||
wrapper.write(Type.VAR_INT, 1);
|
||||
|
||||
wrapper.send(Protocol1_11_1To1_12.class);
|
||||
wrapper.scheduleSend(Protocol1_11_1To1_12.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerRespawn(ClientboundPackets1_12.RESPAWN);
|
||||
registerEntityDestroy(ClientboundPackets1_12.DESTROY_ENTITIES);
|
||||
registerRemoveEntities(ClientboundPackets1_12.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_12.ENTITY_METADATA, Types1_12.METADATA_LIST);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.ENTITY_PROPERTIES, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.ENTITY_PROPERTIES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@@ -204,36 +212,37 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<Protocol1_11_1To1_12
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
mapEntity(Entity1_12Types.EntityType.PARROT, Entity1_12Types.EntityType.BAT).mobName("Parrot").spawnMetadata(storage -> storage.add(new Metadata(12, MetaType1_12.Byte, (byte) 0x00)));
|
||||
mapEntity(Entity1_12Types.EntityType.ILLUSION_ILLAGER, Entity1_12Types.EntityType.EVOCATION_ILLAGER).mobName("Illusioner");
|
||||
mapEntityTypeWithData(Entity1_12Types.EntityType.PARROT, Entity1_12Types.EntityType.BAT).plainName().spawnMetadata(storage -> storage.add(new Metadata(12, MetaType1_12.Byte, (byte) 0x00)));
|
||||
mapEntityTypeWithData(Entity1_12Types.EntityType.ILLUSION_ILLAGER, Entity1_12Types.EntityType.EVOCATION_ILLAGER).plainName();
|
||||
|
||||
// Handle Illager
|
||||
registerMetaHandler().filter(Entity1_12Types.EntityType.EVOCATION_ILLAGER, true, 12).removed();
|
||||
registerMetaHandler().filter(Entity1_12Types.EntityType.EVOCATION_ILLAGER, true, 13).handleIndexChange(12);
|
||||
filter().filterFamily(Entity1_12Types.EntityType.EVOCATION_ILLAGER).cancel(12);
|
||||
filter().filterFamily(Entity1_12Types.EntityType.EVOCATION_ILLAGER).index(13).toIndex(12);
|
||||
|
||||
registerMetaHandler().filter(Entity1_12Types.EntityType.ILLUSION_ILLAGER, 0).handle(e -> {
|
||||
byte mask = (byte) e.getData().getValue();
|
||||
filter().type(Entity1_12Types.EntityType.ILLUSION_ILLAGER).index(0).handler((event, meta) -> {
|
||||
byte mask = (byte) meta.getValue();
|
||||
|
||||
if ((mask & 0x20) == 0x20)
|
||||
if ((mask & 0x20) == 0x20) {
|
||||
mask &= ~0x20;
|
||||
}
|
||||
|
||||
e.getData().setValue(mask);
|
||||
return e.getData();
|
||||
meta.setValue(mask);
|
||||
});
|
||||
|
||||
// Create Parrot storage
|
||||
registerMetaHandler().filter(Entity1_12Types.EntityType.PARROT, true).handle(e -> {
|
||||
if (!e.getEntity().has(ParrotStorage.class))
|
||||
e.getEntity().put(new ParrotStorage());
|
||||
return e.getData();
|
||||
filter().filterFamily(Entity1_12Types.EntityType.PARROT).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
if (!data.has(ParrotStorage.class)) {
|
||||
data.put(new ParrotStorage());
|
||||
}
|
||||
});
|
||||
// Parrot remove animal metadata
|
||||
registerMetaHandler().filter(Entity1_12Types.EntityType.PARROT, 12).removed(); // Is baby
|
||||
registerMetaHandler().filter(Entity1_12Types.EntityType.PARROT, 13).handle(e -> {
|
||||
Metadata data = e.getData();
|
||||
ParrotStorage storage = e.getEntity().get(ParrotStorage.class);
|
||||
boolean isSitting = (((byte) data.getValue()) & 0x01) == 0x01;
|
||||
boolean isTamed = (((byte) data.getValue()) & 0x04) == 0x04;
|
||||
filter().type(Entity1_12Types.EntityType.PARROT).cancel(12); // Is baby
|
||||
filter().type(Entity1_12Types.EntityType.PARROT).index(13).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
ParrotStorage storage = data.get(ParrotStorage.class);
|
||||
boolean isSitting = (((byte) meta.getValue()) & 0x01) == 0x01;
|
||||
boolean isTamed = (((byte) meta.getValue()) & 0x04) == 0x04;
|
||||
|
||||
if (!storage.isTamed() && isTamed) {
|
||||
// TODO do something to let the user know it's done
|
||||
@@ -242,30 +251,29 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<Protocol1_11_1To1_12
|
||||
storage.setTamed(isTamed);
|
||||
|
||||
if (isSitting) {
|
||||
data.setId(12);
|
||||
data.setValue((byte) 0x01);
|
||||
event.setIndex(12);
|
||||
meta.setValue((byte) 0x01);
|
||||
storage.setSitting(true);
|
||||
} else if (storage.isSitting()) {
|
||||
data.setId(12);
|
||||
data.setValue((byte) 0x00);
|
||||
event.setIndex(12);
|
||||
meta.setValue((byte) 0x00);
|
||||
storage.setSitting(false);
|
||||
} else
|
||||
throw RemovedValueException.EX;
|
||||
|
||||
return data;
|
||||
} else {
|
||||
event.cancel();
|
||||
}
|
||||
}); // Flags (Is sitting etc, might be useful in the future
|
||||
registerMetaHandler().filter(Entity1_12Types.EntityType.PARROT, 14).removed(); // Owner
|
||||
registerMetaHandler().filter(Entity1_12Types.EntityType.PARROT, 15).removed(); // Variant
|
||||
filter().type(Entity1_12Types.EntityType.PARROT).cancel(14); // Owner
|
||||
filter().type(Entity1_12Types.EntityType.PARROT).cancel(15); // Variant
|
||||
|
||||
// Left shoulder entity data
|
||||
registerMetaHandler().filter(Entity1_12Types.EntityType.PLAYER, 15).handle(e -> {
|
||||
CompoundTag tag = (CompoundTag) e.getData().getValue();
|
||||
ShoulderTracker tracker = e.getUser().get(ShoulderTracker.class);
|
||||
filter().type(Entity1_12Types.EntityType.PLAYER).index(15).handler((event, meta) -> {
|
||||
CompoundTag tag = (CompoundTag) meta.getValue();
|
||||
ShoulderTracker tracker = event.user().get(ShoulderTracker.class);
|
||||
|
||||
if (tag.isEmpty() && tracker.getLeftShoulder() != null) {
|
||||
tracker.setLeftShoulder(null);
|
||||
tracker.update();
|
||||
} else if (tag.contains("id") && e.getEntity().getEntityId() == tracker.getEntityId()) {
|
||||
} else if (tag.contains("id") && event.entityId() == tracker.getEntityId()) {
|
||||
String id = (String) tag.get("id").getValue();
|
||||
if (tracker.getLeftShoulder() == null || !tracker.getLeftShoulder().equals(id)) {
|
||||
tracker.setLeftShoulder(id);
|
||||
@@ -273,18 +281,18 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<Protocol1_11_1To1_12
|
||||
}
|
||||
}
|
||||
|
||||
throw RemovedValueException.EX;
|
||||
event.cancel();
|
||||
});
|
||||
|
||||
// Right shoulder entity data
|
||||
registerMetaHandler().filter(Entity1_12Types.EntityType.PLAYER, 16).handle(e -> {
|
||||
CompoundTag tag = (CompoundTag) e.getData().getValue();
|
||||
ShoulderTracker tracker = e.getUser().get(ShoulderTracker.class);
|
||||
filter().type(Entity1_12Types.EntityType.PLAYER).index(16).handler((event, meta) -> {
|
||||
CompoundTag tag = (CompoundTag) event.meta().getValue();
|
||||
ShoulderTracker tracker = event.user().get(ShoulderTracker.class);
|
||||
|
||||
if (tag.isEmpty() && tracker.getRightShoulder() != null) {
|
||||
tracker.setRightShoulder(null);
|
||||
tracker.update();
|
||||
} else if (tag.contains("id") && e.getEntity().getEntityId() == tracker.getEntityId()) {
|
||||
} else if (tag.contains("id") && event.entityId() == tracker.getEntityId()) {
|
||||
String id = (String) tag.get("id").getValue();
|
||||
if (tracker.getRightShoulder() == null || !tracker.getRightShoulder().equals(id)) {
|
||||
tracker.setRightShoulder(id);
|
||||
@@ -292,12 +300,12 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<Protocol1_11_1To1_12
|
||||
}
|
||||
}
|
||||
|
||||
throw RemovedValueException.EX;
|
||||
event.cancel();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityType getTypeFromId(int typeId) {
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return Entity1_12Types.getTypeFromId(typeId, false);
|
||||
}
|
||||
|
||||
+25
-14
@@ -1,22 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* 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.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* 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 nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
package com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
|
||||
import nl.matsv.viabackwards.api.rewriters.LegacySoundRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacySoundRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
|
||||
public class SoundPackets1_12 extends LegacySoundRewriter<Protocol1_11_1To1_12> {
|
||||
|
||||
@@ -26,7 +34,7 @@ public class SoundPackets1_12 extends LegacySoundRewriter<Protocol1_11_1To1_12>
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.NAMED_SOUND, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.NAMED_SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Sound name
|
||||
@@ -39,7 +47,7 @@ public class SoundPackets1_12 extends LegacySoundRewriter<Protocol1_11_1To1_12>
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.SOUND, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Sound name
|
||||
@@ -73,6 +81,9 @@ public class SoundPackets1_12 extends LegacySoundRewriter<Protocol1_11_1To1_12>
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
//TODO use the diff file to also have named sound remaps
|
||||
// (there were *A LOT* of refactored names)
|
||||
|
||||
// Replacement sounds, suggestions are always welcome
|
||||
// Automatically generated from PAaaS
|
||||
added(26, 277, 1.4f); // block.end_portal.spawn -> entity.lightning.thunder
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_11to1_11_1;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets.EntityPackets1_11_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets.ItemPackets1_11_1;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_11To1_11_1 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
||||
|
||||
private final EntityPackets1_11_1 entityPackets = new EntityPackets1_11_1(this);
|
||||
private final ItemRewriter itemRewriter = new ItemPackets1_11_1(this);
|
||||
|
||||
public Protocol1_11To1_11_1() {
|
||||
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
entityPackets.register();
|
||||
itemRewriter.register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_11Types.EntityType.PLAYER));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPackets1_11_1 getEntityRewriter() {
|
||||
return entityPackets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRewriter getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
}
|
||||
+31
-23
@@ -1,23 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* 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.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* 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 nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.packets;
|
||||
package com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets;
|
||||
|
||||
import nl.matsv.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_11Types;
|
||||
import us.myles.ViaVersion.api.entities.EntityType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_9;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
|
||||
public class EntityPackets1_11_1 extends LegacyEntityRewriter<Protocol1_11To1_11_1> {
|
||||
|
||||
@@ -27,7 +35,7 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<Protocol1_11To1_11
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@@ -46,10 +54,10 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<Protocol1_11To1_11
|
||||
}
|
||||
});
|
||||
|
||||
registerExtraTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, Entity1_11Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, Entity1_11Types.EntityType.WEATHER);
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, Entity1_11Types.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, Entity1_11Types.EntityType.WEATHER);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.SPAWN_MOB, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@@ -74,11 +82,11 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<Protocol1_11To1_11
|
||||
}
|
||||
});
|
||||
|
||||
registerExtraTracker(ClientboundPackets1_9_3.SPAWN_PAINTING, Entity1_11Types.EntityType.PAINTING);
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_PAINTING, Entity1_11Types.EntityType.PAINTING);
|
||||
registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, Entity1_11Types.EntityType.PLAYER);
|
||||
registerRespawn(ClientboundPackets1_9_3.RESPAWN);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@@ -94,21 +102,21 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<Protocol1_11To1_11
|
||||
}
|
||||
});
|
||||
|
||||
registerEntityDestroy(ClientboundPackets1_9_3.DESTROY_ENTITIES);
|
||||
registerRemoveEntities(ClientboundPackets1_9_3.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_9.METADATA_LIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
// Handle non-existing firework metadata (index 7 entity id for boosting)
|
||||
registerMetaHandler().filter(Entity1_11Types.EntityType.FIREWORK, 7).removed();
|
||||
filter().type(Entity1_11Types.EntityType.FIREWORK).cancel(7);
|
||||
|
||||
// Handle non-existing pig metadata (index 14 - boost time)
|
||||
registerMetaHandler().filter(Entity1_11Types.EntityType.PIG, 14).removed();
|
||||
filter().type(Entity1_11Types.EntityType.PIG).cancel(14);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityType getTypeFromId(int typeId) {
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return Entity1_11Types.getTypeFromId(typeId, false);
|
||||
}
|
||||
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_11to1_11_1.packets;
|
||||
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEnchantmentRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
|
||||
public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<Protocol1_11To1_11_1> {
|
||||
|
||||
private LegacyEnchantmentRewriter enchantmentRewriter;
|
||||
|
||||
public ItemPackets1_11_1(Protocol1_11To1_11_1 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM);
|
||||
registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS, Type.ITEM_ARRAY);
|
||||
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
|
||||
// Plugin message Packet -> Trading
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Channel
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Input Item
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||
if (secondItem) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Second Item
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
wrapper.passthrough(Type.INT); // Number of tools uses
|
||||
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerClickWindow(ServerboundPackets1_9_3.CLICK_WINDOW, Type.ITEM);
|
||||
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
|
||||
|
||||
// Handle item metadata
|
||||
protocol.getEntityRewriter().filter().handler((event, meta) -> {
|
||||
if (meta.metaType().type().equals(Type.ITEM)) { // Is Item
|
||||
meta.setValue(handleItemToClient((Item) meta.getValue()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
enchantmentRewriter = new LegacyEnchantmentRewriter(nbtTagName);
|
||||
enchantmentRewriter.registerEnchantment(22, "§7Sweeping Edge");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item handleItemToClient(Item item) {
|
||||
if (item == null) return null;
|
||||
super.handleItemToClient(item);
|
||||
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) return item;
|
||||
|
||||
if (tag.get("ench") instanceof ListTag) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToClient(tag, false);
|
||||
}
|
||||
if (tag.get("StoredEnchantments") instanceof ListTag) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToClient(tag, true);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item handleItemToServer(Item item) {
|
||||
if (item == null) return null;
|
||||
super.handleItemToServer(item);
|
||||
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) return item;
|
||||
|
||||
if (tag.contains(nbtTagName + "|ench")) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToServer(tag, false);
|
||||
}
|
||||
if (tag.contains(nbtTagName + "|StoredEnchantments")) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToServer(tag, true);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_12_1to1_12_2;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class KeepAliveTracker implements StorableObject {
|
||||
private long keepAlive = Integer.MAX_VALUE;
|
||||
|
||||
public long getKeepAlive() {
|
||||
return keepAlive;
|
||||
}
|
||||
|
||||
public void setKeepAlive(long keepAlive) {
|
||||
this.keepAlive = keepAlive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "KeepAliveTracker{" + "keepAlive=" + keepAlive + '}';
|
||||
}
|
||||
}
|
||||
+24
-16
@@ -1,23 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* 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.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* 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 nl.matsv.viabackwards.protocol.protocol1_12_1to1_12_2;
|
||||
package com.viaversion.viabackwards.protocol.protocol1_12_1to1_12_2;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
|
||||
public class Protocol1_12_1To1_12_2 extends BackwardsProtocol<ClientboundPackets1_12_1, ClientboundPackets1_12_1, ServerboundPackets1_12_1, ServerboundPackets1_12_1> {
|
||||
|
||||
@@ -27,7 +35,7 @@ public class Protocol1_12_1To1_12_2 extends BackwardsProtocol<ClientboundPackets
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.KEEP_ALIVE, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_12_1.KEEP_ALIVE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@@ -41,7 +49,7 @@ public class Protocol1_12_1To1_12_2 extends BackwardsProtocol<ClientboundPackets
|
||||
}
|
||||
});
|
||||
|
||||
registerIncoming(ServerboundPackets1_12_1.KEEP_ALIVE, new PacketRemapper() {
|
||||
registerServerbound(ServerboundPackets1_12_1.KEEP_ALIVE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@@ -64,6 +72,6 @@ public class Protocol1_12_1To1_12_2 extends BackwardsProtocol<ClientboundPackets
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
userConnection.put(new KeepAliveTracker(userConnection));
|
||||
userConnection.put(new KeepAliveTracker());
|
||||
}
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_12_2to1_13;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.PaintingMapping;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets.EntityPackets1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets.PlayerPacket1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets.SoundPackets1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.PlayerPositionStorage1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.TabCompleteStorage;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
|
||||
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_13, ClientboundPackets1_12_1, ServerboundPackets1_13, ServerboundPackets1_12_1> {
|
||||
|
||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings();
|
||||
private final EntityRewriter entityRewriter = new EntityPackets1_13(this);
|
||||
private final BlockItemPackets1_13 blockItemPackets = new BlockItemPackets1_13(this);
|
||||
|
||||
public Protocol1_12_2To1_13() {
|
||||
super(ClientboundPackets1_13.class, ClientboundPackets1_12_1.class, ServerboundPackets1_13.class, ServerboundPackets1_12_1.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
executeAsyncAfterLoaded(Protocol1_13To1_12_2.class, () -> {
|
||||
MAPPINGS.load();
|
||||
PaintingMapping.init();
|
||||
Via.getManager().getProviders().register(BackwardsBlockEntityProvider.class, new BackwardsBlockEntityProvider());
|
||||
});
|
||||
|
||||
TranslatableRewriter translatableRewriter = new TranslatableRewriter(this) {
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject root, String translate) {
|
||||
String newTranslate = newTranslatables.get(translate);
|
||||
if (newTranslate != null || (newTranslate = getMappingData().getTranslateMappings().get(translate)) != null) {
|
||||
root.addProperty("translate", newTranslate);
|
||||
}
|
||||
}
|
||||
};
|
||||
translatableRewriter.registerPing();
|
||||
translatableRewriter.registerBossBar(ClientboundPackets1_13.BOSSBAR);
|
||||
translatableRewriter.registerChatMessage(ClientboundPackets1_13.CHAT_MESSAGE);
|
||||
translatableRewriter.registerLegacyOpenWindow(ClientboundPackets1_13.OPEN_WINDOW);
|
||||
translatableRewriter.registerDisconnect(ClientboundPackets1_13.DISCONNECT);
|
||||
translatableRewriter.registerCombatEvent(ClientboundPackets1_13.COMBAT_EVENT);
|
||||
translatableRewriter.registerTitle(ClientboundPackets1_13.TITLE);
|
||||
translatableRewriter.registerTabList(ClientboundPackets1_13.TAB_LIST);
|
||||
|
||||
blockItemPackets.register();
|
||||
entityRewriter.register();
|
||||
new PlayerPacket1_13(this).register();
|
||||
new SoundPackets1_13(this).register();
|
||||
|
||||
cancelClientbound(ClientboundPackets1_13.NBT_QUERY);
|
||||
cancelClientbound(ClientboundPackets1_13.CRAFT_RECIPE_RESPONSE);
|
||||
cancelClientbound(ClientboundPackets1_13.UNLOCK_RECIPES);
|
||||
cancelClientbound(ClientboundPackets1_13.ADVANCEMENTS);
|
||||
cancelClientbound(ClientboundPackets1_13.DECLARE_RECIPES);
|
||||
cancelClientbound(ClientboundPackets1_13.TAGS);
|
||||
|
||||
cancelServerbound(ServerboundPackets1_12_1.CRAFT_RECIPE_REQUEST);
|
||||
cancelServerbound(ServerboundPackets1_12_1.RECIPE_BOOK_DATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_13Types.EntityType.PLAYER));
|
||||
|
||||
user.put(new BackwardsBlockStorage());
|
||||
user.put(new TabCompleteStorage());
|
||||
|
||||
if (ViaBackwards.getConfig().isFix1_13FacePlayer() && !user.has(PlayerPositionStorage1_13.class)) {
|
||||
user.put(new PlayerPositionStorage1_13());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappings getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityRewriter getEntityRewriter() {
|
||||
return entityRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItemPackets1_13 getItemRewriter() {
|
||||
return blockItemPackets;
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_12_2to1_13.block_entity_handlers;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
|
||||
public class BannerHandler implements BackwardsBlockEntityHandler {
|
||||
private static final int WALL_BANNER_START = 7110; // 4 each
|
||||
private static final int WALL_BANNER_STOP = 7173;
|
||||
|
||||
private static final int BANNER_START = 6854; // 16 each
|
||||
private static final int BANNER_STOP = 7109;
|
||||
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
// Normal banners
|
||||
if (blockId >= BANNER_START && blockId <= BANNER_STOP) {
|
||||
int color = (blockId - BANNER_START) >> 4;
|
||||
tag.put("Base", new IntTag((15 - color)));
|
||||
}
|
||||
// Wall banners
|
||||
else if (blockId >= WALL_BANNER_START && blockId <= WALL_BANNER_STOP) {
|
||||
int color = (blockId - WALL_BANNER_START) >> 2;
|
||||
tag.put("Base", new IntTag((15 - color)));
|
||||
} else {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag);
|
||||
}
|
||||
|
||||
// Invert colors
|
||||
Tag patternsTag = tag.get("Patterns");
|
||||
if (patternsTag instanceof ListTag) {
|
||||
for (Tag pattern : (ListTag) patternsTag) {
|
||||
if (!(pattern instanceof CompoundTag)) continue;
|
||||
|
||||
IntTag c = ((CompoundTag) pattern).get("Color");
|
||||
c.setValue(15 - c.asInt()); // Invert color id
|
||||
}
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_12_2to1_13.block_entity_handlers;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
|
||||
public class BedHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
int offset = blockId - 748;
|
||||
int color = offset >> 4;
|
||||
|
||||
tag.put("color", new IntTag(color));
|
||||
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
+24
-16
@@ -1,27 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* 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.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* 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 nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import us.myles.ViaVersion.api.Pair;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
|
||||
public class FlowerPotHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||
|
||||
private static final Int2ObjectMap<Pair<String, Byte>> FLOWERS = new Int2ObjectOpenHashMap<>(22, 1F);
|
||||
private static final Int2ObjectMap<Pair<String, Byte>> FLOWERS = new Int2ObjectOpenHashMap<>(22, 0.99F);
|
||||
private static final Pair<String, Byte> AIR = new Pair<>("minecraft:air", (byte) 0);
|
||||
|
||||
static {
|
||||
@@ -67,8 +75,8 @@ public class FlowerPotHandler implements BackwardsBlockEntityProvider.BackwardsB
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
Pair<String, Byte> item = getOrDefault(blockId);
|
||||
|
||||
tag.put(new StringTag("Item", item.getKey()));
|
||||
tag.put(new IntTag("Data", item.getValue()));
|
||||
tag.put("Item", new StringTag(item.getKey()));
|
||||
tag.put("Data", new IntTag(item.getValue()));
|
||||
|
||||
return tag;
|
||||
}
|
||||
+39
-20
@@ -1,17 +1,34 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_12_2to1_13.block_entity_handlers;
|
||||
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.MappingDataLoader;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
@@ -40,7 +57,7 @@ public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBloc
|
||||
addEntries(entry.getKey(), entry.getValue());
|
||||
}
|
||||
} else {
|
||||
JsonObject mappings = MappingDataLoader.getMappingsCache().get("mapping-1.13.json").getAsJsonObject("blocks");
|
||||
JsonObject mappings = MappingDataLoader.getMappingsCache().get("mapping-1.13.json").getAsJsonObject("blockstates");
|
||||
for (Map.Entry<String, JsonElement> blockState : mappings.entrySet()) {
|
||||
String key = blockState.getValue().getAsString();
|
||||
if (!key.contains("piston")) continue;
|
||||
@@ -52,7 +69,7 @@ public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBloc
|
||||
|
||||
// There doesn't seem to be a nicer way around it :(
|
||||
private void addEntries(String data, int id) {
|
||||
id = BackwardsMappings.blockMappings.getNewId(id);
|
||||
id = Protocol1_12_2To1_13.MAPPINGS.getNewBlockStateId(id);
|
||||
pistonIds.put(data, id);
|
||||
|
||||
String substring = data.substring(10);
|
||||
@@ -68,6 +85,8 @@ public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBloc
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
CompoundTag blockState = tag.get("blockState");
|
||||
if (blockState == null) return tag;
|
||||
|
||||
String dataFromTag = getDataFromTag(blockState);
|
||||
if (dataFromTag == null) return tag;
|
||||
|
||||
@@ -77,8 +96,8 @@ public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBloc
|
||||
return tag;
|
||||
}
|
||||
|
||||
tag.put(new IntTag("blockId", id >> 4));
|
||||
tag.put(new IntTag("blockData", id & 15));
|
||||
tag.put("blockId", new IntTag(id >> 4));
|
||||
tag.put("blockData", new IntTag(id & 15));
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -91,9 +110,9 @@ public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBloc
|
||||
if (properties == null) return name.getValue();
|
||||
|
||||
StringJoiner joiner = new StringJoiner(",", name.getValue() + "[", "]");
|
||||
for (Tag property : properties) {
|
||||
if (!(property instanceof StringTag)) continue;
|
||||
joiner.add(property.getName() + "=" + ((StringTag) property).getValue());
|
||||
for (Map.Entry<String, Tag> entry : properties) {
|
||||
if (!(entry.getValue() instanceof StringTag)) continue;
|
||||
joiner.add(entry.getKey() + "=" + ((StringTag) entry.getValue()).getValue());
|
||||
}
|
||||
return joiner.toString();
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_12_2to1_13.block_entity_handlers;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
|
||||
public class SkullHandler implements BackwardsBlockEntityHandler {
|
||||
private static final int SKULL_START = 5447;
|
||||
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
int diff = blockId - SKULL_START;
|
||||
int pos = diff % 20;
|
||||
byte type = (byte) Math.floor(diff / 20f);
|
||||
|
||||
// Set type
|
||||
tag.put("SkullType", new ByteTag(type));
|
||||
|
||||
// Remove wall skulls
|
||||
if (pos < 4) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
// Add rotation for normal skulls
|
||||
tag.put("Rot", new ByteTag((byte) ((pos - 4) & 255)));
|
||||
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_12_2to1_13.block_entity_handlers;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.EntityNameRewrites;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
|
||||
public class SpawnerHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
Tag dataTag = tag.get("SpawnData");
|
||||
if (dataTag instanceof CompoundTag) {
|
||||
CompoundTag data = (CompoundTag) dataTag;
|
||||
Tag idTag = data.get("id");
|
||||
if (idTag instanceof StringTag) {
|
||||
StringTag s = (StringTag) idTag;
|
||||
s.setValue(EntityNameRewrites.rewrite(s.getValue()));
|
||||
}
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_12_2to1_13.data;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.data.VBMappings;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.data.IntArrayMappings;
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||
import com.viaversion.viaversion.api.data.Mappings;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.gson.JsonPrimitive;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.StatisticMappings;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BackwardsMappings extends com.viaversion.viabackwards.api.data.BackwardsMappings {
|
||||
private final Int2ObjectMap<String> statisticMappings = new Int2ObjectOpenHashMap<>();
|
||||
private final Map<String, String> translateMappings = new HashMap<>();
|
||||
|
||||
public BackwardsMappings() {
|
||||
super("1.13", "1.12", Protocol1_13To1_12_2.class, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadVBExtras(JsonObject oldMappings, JsonObject newMappings) {
|
||||
enchantmentMappings = VBMappings.vbBuilder().warnOnMissing(false)
|
||||
.unmapped(oldMappings.getAsJsonArray("enchantments")).mapped(newMappings.getAsJsonObject("legacy_enchantments")).build();
|
||||
for (Map.Entry<String, Integer> entry : StatisticMappings.CUSTOM_STATS.entrySet()) {
|
||||
statisticMappings.put(entry.getValue().intValue(), entry.getKey());
|
||||
}
|
||||
for (Map.Entry<String, String> entry : Protocol1_13To1_12_2.MAPPINGS.getTranslateMapping().entrySet()) {
|
||||
translateMappings.put(entry.getValue(), entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
// Has lots of compat layers, so we can't use the default Via method
|
||||
private static void mapIdentifiers(int[] output, JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) {
|
||||
Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(oldIdentifiers);
|
||||
for (Map.Entry<String, JsonElement> entry : newIdentifiers.entrySet()) {
|
||||
String key = entry.getValue().getAsString();
|
||||
int value = newIdentifierMap.getInt(key);
|
||||
short hardId = -1;
|
||||
if (value == -1) {
|
||||
JsonPrimitive replacement = mapping.getAsJsonPrimitive(key);
|
||||
int propertyIndex;
|
||||
if (replacement == null && (propertyIndex = key.indexOf('[')) != -1) {
|
||||
replacement = mapping.getAsJsonPrimitive(key.substring(0, propertyIndex));
|
||||
}
|
||||
if (replacement != null) {
|
||||
if (replacement.getAsString().startsWith("id:")) {
|
||||
String id = replacement.getAsString().replace("id:", "");
|
||||
hardId = Short.parseShort(id);
|
||||
value = newIdentifierMap.getInt(oldIdentifiers.getAsJsonPrimitive(id).getAsString());
|
||||
} else {
|
||||
value = newIdentifierMap.getInt(replacement.getAsString());
|
||||
}
|
||||
}
|
||||
if (value == -1) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
if (replacement != null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No key for " + entry.getValue() + "/" + replacement.getAsString() + " :( ");
|
||||
} else {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
output[Integer.parseInt(entry.getKey())] = hardId != -1 ? hardId : (short) value;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
|
||||
if (key.equals("blockstates")) {
|
||||
int[] oldToNew = new int[8582];
|
||||
Arrays.fill(oldToNew, -1);
|
||||
mapIdentifiers(oldToNew, oldMappings.getAsJsonObject("blockstates"), newMappings.getAsJsonObject("blocks"), diffMappings.getAsJsonObject("blockstates"));
|
||||
return IntArrayMappings.of(oldToNew, -1);
|
||||
} else {
|
||||
return super.loadFromObject(oldMappings, newMappings, diffMappings, key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewBlockStateId(int id) {
|
||||
int mappedId = super.getNewBlockStateId(id);
|
||||
|
||||
// https://github.com/ViaVersion/ViaBackwards/issues/290
|
||||
switch (mappedId) {
|
||||
case 1595:
|
||||
case 1596:
|
||||
case 1597:
|
||||
return 1584; // brown mushroom block
|
||||
case 1611:
|
||||
case 1612:
|
||||
case 1613:
|
||||
return 1600; // red mushroom block
|
||||
default:
|
||||
return mappedId;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int checkValidity(int id, int mappedId, String type) {
|
||||
// Don't warn for missing ids here
|
||||
return mappedId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldWarnOnMissing(String key) {
|
||||
return super.shouldWarnOnMissing(key) && !key.equals("items");
|
||||
}
|
||||
|
||||
public Int2ObjectMap<String> getStatisticMappings() {
|
||||
return statisticMappings;
|
||||
}
|
||||
|
||||
public Map<String, String> getTranslateMappings() {
|
||||
return translateMappings;
|
||||
}
|
||||
}
|
||||
+13
-5
@@ -1,14 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* 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.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* 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 nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_12_2to1_13.data;
|
||||
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.EntityTypeRewriter;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class EntityTypeMapping {
|
||||
private static final Int2IntMap TYPES = new Int2IntOpenHashMap();
|
||||
|
||||
static {
|
||||
TYPES.defaultReturnValue(-1);
|
||||
try {
|
||||
Field field = EntityTypeRewriter.class.getDeclaredField("ENTITY_TYPES");
|
||||
field.setAccessible(true);
|
||||
Int2IntMap entityTypes = (Int2IntMap) field.get(null);
|
||||
for (Int2IntMap.Entry entry : entityTypes.int2IntEntrySet()) {
|
||||
EntityTypeMapping.TYPES.put(entry.getIntValue(), entry.getIntKey());
|
||||
}
|
||||
} catch (NoSuchFieldException | IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int getOldId(int type1_13) {
|
||||
return TYPES.get(type1_13);
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_12_2to1_13.data;
|
||||
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.NamedSoundRewriter;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class NamedSoundMapping {
|
||||
private static final Map<String, String> SOUNDS = new HashMap<>();
|
||||
|
||||
static {
|
||||
try {
|
||||
Field field = NamedSoundRewriter.class.getDeclaredField("oldToNew");
|
||||
field.setAccessible(true);
|
||||
Map<String, String> sounds = (Map<String, String>) field.get(null);
|
||||
sounds.forEach((sound1_12, sound1_13) -> NamedSoundMapping.SOUNDS.put(sound1_13, sound1_12));
|
||||
} catch (NoSuchFieldException | IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getOldId(String sound1_13) {
|
||||
if (sound1_13.startsWith("minecraft:")) {
|
||||
sound1_13 = sound1_13.substring(10);
|
||||
}
|
||||
return SOUNDS.get(sound1_13);
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 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.protocol1_12_2to1_13.data;
|
||||
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public class PaintingMapping {
|
||||
private static final Int2ObjectMap<String> PAINTINGS = new Int2ObjectOpenHashMap<>(26, 0.99F);
|
||||
|
||||
public static void init() {
|
||||
add("Kebab");
|
||||
add("Aztec");
|
||||
add("Alban");
|
||||
add("Aztec2");
|
||||
add("Bomb");
|
||||
add("Plant");
|
||||
add("Wasteland");
|
||||
add("Pool");
|
||||
add("Courbet");
|
||||
add("Sea");
|
||||
add("Sunset");
|
||||
add("Creebet");
|
||||
add("Wanderer");
|
||||
add("Graham");
|
||||
add("Match");
|
||||
add("Bust");
|
||||
add("Stage");
|
||||
add("Void");
|
||||
add("SkullAndRoses");
|
||||
add("Wither");
|
||||
add("Fighters");
|
||||
add("Pointer");
|
||||
add("Pigscene");
|
||||
add("BurningSkull");
|
||||
add("Skeleton");
|
||||
add("DonkeyKong");
|
||||
}
|
||||
|
||||
private static void add(String motive) {
|
||||
PAINTINGS.put(PAINTINGS.size(), motive);
|
||||
}
|
||||
|
||||
public static String getStringId(int id) {
|
||||
return PAINTINGS.getOrDefault(id, "kebab");
|
||||
}
|
||||
}
|
||||
+31
-16
@@ -1,21 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* 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.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* 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 nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.Particle;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -35,13 +42,17 @@ public class ParticleMapping {
|
||||
}
|
||||
|
||||
private int[] rewrite(int newType) {
|
||||
int blockType = BlockItemPackets1_13.toOldId(newType);
|
||||
int blockType = Protocol1_12_2To1_13.MAPPINGS.getNewBlockStateId(newType);
|
||||
|
||||
int type = blockType >> 4;
|
||||
int meta = blockType & 15;
|
||||
|
||||
return new int[]{type + (meta << 12)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockHandler() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
particles = new ParticleData[]{
|
||||
@@ -107,8 +118,8 @@ public class ParticleMapping {
|
||||
}
|
||||
|
||||
private int[] rewrite(Protocol1_12_2To1_13 protocol, Item newItem) {
|
||||
Item item = protocol.getBlockItemPackets().handleItemToClient(newItem);
|
||||
return new int[]{item.getIdentifier(), item.getData()};
|
||||
Item item = protocol.getItemRewriter().handleItemToClient(newItem);
|
||||
return new int[]{item.identifier(), item.data()};
|
||||
}
|
||||
}), // (27->36) minecraft:item -> iconcrack
|
||||
rewrite(33), // (28->33) minecraft:item_slime -> slime
|
||||
@@ -148,11 +159,15 @@ public class ParticleMapping {
|
||||
return new ParticleData(replacementId, handler);
|
||||
}
|
||||
|
||||
interface ParticleHandler {
|
||||
public interface ParticleHandler {
|
||||
|
||||
int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception;
|
||||
|
||||
int[] rewrite(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData> data);
|
||||
|
||||
default boolean isBlockHandler() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static final class ParticleData {
|
||||
+216
-208
@@ -1,52 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* 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.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* 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 nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets;
|
||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.rewriters.EnchantmentRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.FlowerPotHandler;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
|
||||
import us.myles.ViaVersion.api.minecraft.Position;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.BlockIdData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.viaversion.libs.opennbt.conversion.ConverterRegistry;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.ShortTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.rewriters.EnchantmentRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.FlowerPotHandler;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.conversion.ConverterRegistry;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ShortTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.BlockIdData;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -55,29 +62,16 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.ItemRewriter<Protocol1_12_2To1_13> {
|
||||
public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewriters.ItemRewriter<Protocol1_12_2To1_13> {
|
||||
|
||||
private final Map<String, String> enchantmentMappings = new HashMap<>();
|
||||
private final String extraNbtTag;
|
||||
|
||||
public BlockItemPackets1_13(Protocol1_12_2To1_13 protocol) {
|
||||
super(protocol, null, id -> BackwardsMappings.itemMappings.getMappedItem(id));
|
||||
super(protocol);
|
||||
extraNbtTag = "VB|" + protocol.getClass().getSimpleName() + "|2";
|
||||
}
|
||||
|
||||
public static int toOldId(int oldId) {
|
||||
if (oldId < 0) {
|
||||
oldId = 0; // Some plugins use negative numbers to clear blocks, remap them to air.
|
||||
}
|
||||
int newId = BackwardsMappings.blockMappings.getNewId(oldId);
|
||||
if (newId != -1)
|
||||
return newId;
|
||||
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing block completely " + oldId);
|
||||
// Default stone
|
||||
return 1 << 4;
|
||||
}
|
||||
|
||||
public static boolean isDamageable(int id) {
|
||||
return id >= 256 && id <= 259 // iron shovel, pickaxe, axe, flint and steel
|
||||
|| id == 261 // bow
|
||||
@@ -94,29 +88,28 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.COOLDOWN, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.COOLDOWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int itemId = wrapper.read(Type.VAR_INT);
|
||||
int oldId = MappingData.oldToNewItems.inverse().get(itemId);
|
||||
if (oldId != -1) {
|
||||
Optional<String> eggEntityId = SpawnEggRewriter.getEntityId(oldId);
|
||||
if (eggEntityId.isPresent()) {
|
||||
itemId = 383 << 16;
|
||||
} else {
|
||||
itemId = (oldId >> 4) << 16 | oldId & 0xF;
|
||||
}
|
||||
}
|
||||
wrapper.write(Type.VAR_INT, itemId);
|
||||
handler(wrapper -> {
|
||||
int itemId = wrapper.read(Type.VAR_INT);
|
||||
int oldId = protocol.getMappingData().getItemMappings().get(itemId);
|
||||
if (oldId == -1) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (SpawnEggRewriter.getEntityId(oldId).isPresent()) {
|
||||
wrapper.write(Type.VAR_INT, 383 << 4);
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper.write(Type.VAR_INT, oldId >> 4);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.BLOCK_ACTION, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ACTION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // Location
|
||||
@@ -155,7 +148,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
@@ -183,7 +176,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.UNLOAD_CHUNK, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.UNLOAD_CHUNK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@@ -205,7 +198,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
});
|
||||
|
||||
// Block Change
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.BLOCK_CHANGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
@@ -220,7 +213,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
BackwardsBlockStorage storage = wrapper.user().get(BackwardsBlockStorage.class);
|
||||
storage.checkAndStore(position, blockState);
|
||||
|
||||
wrapper.write(Type.VAR_INT, toOldId(blockState));
|
||||
wrapper.write(Type.VAR_INT, protocol.getMappingData().getNewBlockStateId(blockState));
|
||||
|
||||
// Flower pot special treatment
|
||||
flowerPotSpecialTreatment(wrapper.user(), blockState, position);
|
||||
@@ -230,7 +223,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
});
|
||||
|
||||
// Multi Block Change
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Chunk X
|
||||
@@ -246,9 +239,9 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
int chunkZ = wrapper.get(Type.INT, 1);
|
||||
int block = record.getBlockId();
|
||||
Position position = new Position(
|
||||
(record.getHorizontal() >> 4 & 15) + (chunkX * 16),
|
||||
record.getSectionX() + (chunkX * 16),
|
||||
record.getY(),
|
||||
(record.getHorizontal() & 15) + (chunkZ * 16));
|
||||
record.getSectionZ() + (chunkZ * 16));
|
||||
|
||||
// Store if needed
|
||||
storage.checkAndStore(position, block);
|
||||
@@ -257,37 +250,35 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
flowerPotSpecialTreatment(wrapper.user(), block, position);
|
||||
|
||||
// Change to old id
|
||||
record.setBlockId(toOldId(block));
|
||||
record.setBlockId(protocol.getMappingData().getNewBlockStateId(block));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.WINDOW_ITEMS, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.WINDOW_ITEMS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
map(Type.FLAT_ITEM_ARRAY, Type.ITEM_ARRAY);
|
||||
|
||||
handler(itemRewriter.itemArrayHandler(Type.ITEM_ARRAY));
|
||||
handler(itemArrayHandler(Type.ITEM_ARRAY));
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.SET_SLOT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SET_SLOT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE);
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
map(Type.SHORT);
|
||||
map(Type.FLAT_ITEM, Type.ITEM);
|
||||
|
||||
handler(itemRewriter.itemToClientHandler(Type.ITEM));
|
||||
handler(itemToClientHandler(Type.ITEM));
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
@@ -309,12 +300,17 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
// Ignore if we don't handle it
|
||||
if (!provider.isHandled(id)) continue;
|
||||
|
||||
int sectionIndex = ((int) tag.get("y").getValue()) >> 4;
|
||||
int sectionIndex = ((NumberTag) tag.get("y")).asInt() >> 4;
|
||||
if (sectionIndex < 0 || sectionIndex > 15) {
|
||||
// 1.17 chunks
|
||||
continue;
|
||||
}
|
||||
|
||||
ChunkSection section = chunk.getSections()[sectionIndex];
|
||||
|
||||
int x = (int) tag.get("x").getValue();
|
||||
int y = (int) tag.get("y").getValue();
|
||||
int z = (int) tag.get("z").getValue();
|
||||
int x = ((NumberTag) tag.get("x")).asInt();
|
||||
int y = ((NumberTag) tag.get("y")).asInt();
|
||||
int z = ((NumberTag) tag.get("z")).asInt();
|
||||
Position position = new Position(x, (short) y, z);
|
||||
|
||||
int block = section.getFlatBlock(x & 0xF, y & 0xF, z & 0xF);
|
||||
@@ -357,7 +353,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
for (int p = 0; p < section.getPaletteSize(); p++) {
|
||||
int old = section.getPaletteEntry(p);
|
||||
if (old != 0) {
|
||||
int oldId = toOldId(old);
|
||||
int oldId = protocol.getMappingData().getNewBlockStateId(old);
|
||||
section.setPaletteEntry(p, oldId);
|
||||
}
|
||||
}
|
||||
@@ -401,7 +397,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.EFFECT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.EFFECT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // Effect Id
|
||||
@@ -413,9 +409,9 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
int data = wrapper.get(Type.INT, 1);
|
||||
if (id == 1010) { // Play record
|
||||
wrapper.set(Type.INT, 1, MappingData.oldToNewItems.inverse().get(data) >> 4);
|
||||
wrapper.set(Type.INT, 1, protocol.getMappingData().getItemMappings().get(data) >> 4);
|
||||
} else if (id == 2001) { // Block break + block break sound
|
||||
data = toOldId(data);
|
||||
data = protocol.getMappingData().getNewBlockStateId(data);
|
||||
int blockId = data >> 4;
|
||||
int blockData = data & 0xF;
|
||||
wrapper.set(Type.INT, 1, (blockId & 0xFFF) | (blockData << 12));
|
||||
@@ -425,7 +421,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.MAP_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.MAP_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@@ -441,7 +437,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
byte z = wrapper.read(Type.BYTE);
|
||||
byte direction = wrapper.read(Type.BYTE);
|
||||
if (wrapper.read(Type.BOOLEAN)) {
|
||||
wrapper.read(Type.STRING);
|
||||
wrapper.read(Type.COMPONENT);
|
||||
}
|
||||
if (type > 9) {
|
||||
wrapper.set(Type.VAR_INT, 1, wrapper.get(Type.VAR_INT, 1) - 1);
|
||||
@@ -456,18 +452,18 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.ENTITY_EQUIPMENT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.ENTITY_EQUIPMENT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.VAR_INT);
|
||||
map(Type.FLAT_ITEM, Type.ITEM);
|
||||
|
||||
handler(itemRewriter.itemToClientHandler(Type.ITEM));
|
||||
handler(itemToClientHandler(Type.ITEM));
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.WINDOW_PROPERTY, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.WINDOW_PROPERTY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // Window Id
|
||||
@@ -478,24 +474,24 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
// Enchantment table
|
||||
if (property >= 4 && property <= 6) {
|
||||
short oldId = wrapper.get(Type.SHORT, 1);
|
||||
wrapper.set(Type.SHORT, 1, (short) BackwardsMappings.enchantmentMappings.getNewId(oldId));
|
||||
wrapper.set(Type.SHORT, 1, (short) protocol.getMappingData().getEnchantmentMappings().getNewId(oldId));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
protocol.registerIncoming(ServerboundPackets1_12_1.CREATIVE_INVENTORY_ACTION, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_12_1.CREATIVE_INVENTORY_ACTION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.SHORT);
|
||||
map(Type.ITEM, Type.FLAT_ITEM);
|
||||
|
||||
handler(itemRewriter.itemToServerHandler(Type.FLAT_ITEM));
|
||||
handler(itemToServerHandler(Type.FLAT_ITEM));
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerIncoming(ServerboundPackets1_12_1.CLICK_WINDOW, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_12_1.CLICK_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
@@ -505,7 +501,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
map(Type.VAR_INT);
|
||||
map(Type.ITEM, Type.FLAT_ITEM);
|
||||
|
||||
handler(itemRewriter.itemToServerHandler(Type.FLAT_ITEM));
|
||||
handler(itemToServerHandler(Type.FLAT_ITEM));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -523,17 +519,17 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
if (item == null) return null;
|
||||
|
||||
// Custom mappings/super call moved down
|
||||
int originalId = item.getIdentifier();
|
||||
int originalId = item.identifier();
|
||||
|
||||
Integer rawId = null;
|
||||
boolean gotRawIdFromTag = false;
|
||||
|
||||
CompoundTag tag = item.getTag();
|
||||
CompoundTag tag = item.tag();
|
||||
|
||||
// Use tag to get original ID and data
|
||||
Tag originalIdTag;
|
||||
if (tag != null && (originalIdTag = tag.remove(extraNbtTag)) != null) {
|
||||
rawId = (Integer) originalIdTag.getValue();
|
||||
rawId = ((NumberTag) originalIdTag).asInt();
|
||||
gotRawIdFromTag = true;
|
||||
}
|
||||
|
||||
@@ -541,12 +537,9 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
// Look for custom mappings
|
||||
super.handleItemToClient(item);
|
||||
|
||||
// No custom mapping found, look at VV mappings
|
||||
if (item.getIdentifier() == originalId) {
|
||||
int oldId = MappingData.oldToNewItems.inverse().get(item.getIdentifier());
|
||||
if (oldId != -1) {
|
||||
rawId = itemIdToRaw(oldId, item, tag);
|
||||
} else if (item.getIdentifier() == 362) { // base/colorless shulker box
|
||||
// Handle one-way special case
|
||||
if (item.identifier() == -1) {
|
||||
if (originalId == 362) { // base/colorless shulker box
|
||||
rawId = 0xe50000; // purple shulker box
|
||||
} else {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
@@ -558,10 +551,10 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
} else { // Use the found custom mapping
|
||||
// Take the newly added tag
|
||||
if (tag == null) {
|
||||
tag = item.getTag();
|
||||
tag = item.tag();
|
||||
}
|
||||
|
||||
rawId = itemIdToRaw(item.getIdentifier(), item, tag);
|
||||
rawId = itemIdToRaw(item.identifier(), item, tag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -570,14 +563,14 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
|
||||
// NBT changes
|
||||
if (tag != null) {
|
||||
if (isDamageable(item.getIdentifier())) {
|
||||
if (isDamageable(item.identifier())) {
|
||||
Tag damageTag = tag.remove("Damage");
|
||||
if (!gotRawIdFromTag && damageTag instanceof IntTag) {
|
||||
item.setData((short) (int) damageTag.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getIdentifier() == 358) { // map
|
||||
if (item.identifier() == 358) { // map
|
||||
Tag mapTag = tag.remove("map");
|
||||
if (!gotRawIdFromTag && mapTag instanceof IntTag) {
|
||||
item.setData((short) (int) mapTag.getValue());
|
||||
@@ -591,9 +584,9 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
CompoundTag display = tag.get("display");
|
||||
if (display != null) {
|
||||
StringTag name = display.get("Name");
|
||||
if (name instanceof StringTag) {
|
||||
StringTag via = display.remove(extraNbtTag + "|Name");
|
||||
name.setValue(via != null ? via.getValue() : ChatRewriter.jsonTextToLegacy(name.getValue()));
|
||||
if (name != null) {
|
||||
display.put(extraNbtTag + "|Name", new StringTag(name.getValue()));
|
||||
name.setValue(ChatRewriter.jsonToLegacyText(name.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,12 +604,12 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
Optional<String> eggEntityId = SpawnEggRewriter.getEntityId(oldId);
|
||||
if (eggEntityId.isPresent()) {
|
||||
if (tag == null) {
|
||||
item.setTag(tag = new CompoundTag("tag"));
|
||||
item.setTag(tag = new CompoundTag());
|
||||
}
|
||||
if (!tag.contains("EntityTag")) {
|
||||
CompoundTag entityTag = new CompoundTag("EntityTag");
|
||||
entityTag.put(new StringTag("id", eggEntityId.get()));
|
||||
tag.put(entityTag);
|
||||
CompoundTag entityTag = new CompoundTag();
|
||||
entityTag.put("id", new StringTag(eggEntityId.get()));
|
||||
tag.put("EntityTag", entityTag);
|
||||
}
|
||||
return 0x17f0000; // 383 << 16;
|
||||
}
|
||||
@@ -625,48 +618,60 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
|
||||
private void rewriteCanPlaceToClient(CompoundTag tag, String tagName) {
|
||||
// The tag was manually created incorrectly so ignore rewriting it
|
||||
if (!(tag.get(tagName) instanceof ListTag)) return;
|
||||
ListTag blockTag = tag.get(tagName);
|
||||
if (blockTag == null) return;
|
||||
|
||||
ListTag newCanPlaceOn = new ListTag(tagName, StringTag.class);
|
||||
tag.put(ConverterRegistry.convertToTag(extraNbtTag + "|" + tagName, ConverterRegistry.convertToValue(blockTag)));
|
||||
ListTag newCanPlaceOn = new ListTag(StringTag.class);
|
||||
tag.put(extraNbtTag + "|" + tagName, ConverterRegistry.convertToTag(ConverterRegistry.convertToValue(blockTag)));
|
||||
for (Tag oldTag : blockTag) {
|
||||
Object value = oldTag.getValue();
|
||||
String[] newValues = value instanceof String ?
|
||||
BlockIdData.fallbackReverseMapping.get(((String) value).replace("minecraft:", "")) : null;
|
||||
if (newValues != null) {
|
||||
for (String newValue : newValues) {
|
||||
newCanPlaceOn.add(new StringTag("", newValue));
|
||||
newCanPlaceOn.add(new StringTag(newValue));
|
||||
}
|
||||
} else {
|
||||
newCanPlaceOn.add(oldTag);
|
||||
}
|
||||
}
|
||||
tag.put(newCanPlaceOn);
|
||||
tag.put(tagName, newCanPlaceOn);
|
||||
}
|
||||
|
||||
//TODO un-ugly all of this
|
||||
private void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnch) {
|
||||
String key = storedEnch ? "StoredEnchantments" : "Enchantments";
|
||||
ListTag enchantments = tag.get(key);
|
||||
if (enchantments == null) return;
|
||||
|
||||
ListTag noMapped = new ListTag(extraNbtTag + "|" + key, CompoundTag.class);
|
||||
ListTag newEnchantments = new ListTag(storedEnch ? key : "ench", CompoundTag.class);
|
||||
ListTag noMapped = new ListTag(CompoundTag.class);
|
||||
ListTag newEnchantments = new ListTag(CompoundTag.class);
|
||||
List<Tag> lore = new ArrayList<>();
|
||||
boolean hasValidEnchants = false;
|
||||
for (Tag enchantmentEntryTag : enchantments.clone()) {
|
||||
CompoundTag enchantmentEntry = (CompoundTag) enchantmentEntryTag;
|
||||
String newId = (String) enchantmentEntry.get("id").getValue();
|
||||
Number levelValue = (Number) enchantmentEntry.get("lvl").getValue();
|
||||
int intValue = levelValue.intValue();
|
||||
short level = intValue < Short.MAX_VALUE ? levelValue.shortValue() : Short.MAX_VALUE;
|
||||
Tag idTag = enchantmentEntry.get("id");
|
||||
if (!(idTag instanceof StringTag)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String newId = (String) idTag.getValue();
|
||||
NumberTag levelTag = enchantmentEntry.get("lvl");
|
||||
if (levelTag == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int levelValue = levelTag.asInt();
|
||||
short level = levelValue < Short.MAX_VALUE ? (short) levelValue : Short.MAX_VALUE;
|
||||
|
||||
String mappedEnchantmentId = enchantmentMappings.get(newId);
|
||||
if (mappedEnchantmentId != null) {
|
||||
lore.add(new StringTag("", mappedEnchantmentId + " " + EnchantmentRewriter.getRomanNumber(level)));
|
||||
lore.add(new StringTag(mappedEnchantmentId + " " + EnchantmentRewriter.getRomanNumber(level)));
|
||||
noMapped.add(enchantmentEntry);
|
||||
} else if (!newId.isEmpty()) {
|
||||
Short oldId = MappingData.oldEnchantmentsIds.inverse().get(newId);
|
||||
Short oldId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().inverse().get(newId);
|
||||
if (oldId == null) {
|
||||
if (!newId.startsWith("viaversion:legacy/")) {
|
||||
// Custom enchant (?)
|
||||
@@ -681,7 +686,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
name = "§7" + Character.toUpperCase(name.charAt(0)) + name.substring(1).toLowerCase(Locale.ENGLISH);
|
||||
|
||||
lore.add(new StringTag("", name + " " + EnchantmentRewriter.getRomanNumber(level)));
|
||||
lore.add(new StringTag(name + " " + EnchantmentRewriter.getRomanNumber(level)));
|
||||
}
|
||||
|
||||
if (Via.getManager().isDebug()) {
|
||||
@@ -697,9 +702,9 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
hasValidEnchants = true;
|
||||
}
|
||||
|
||||
CompoundTag newEntry = new CompoundTag("");
|
||||
newEntry.put(new ShortTag("id", oldId));
|
||||
newEntry.put(new ShortTag("lvl", level));
|
||||
CompoundTag newEntry = new CompoundTag();
|
||||
newEntry.put("id", new ShortTag(oldId));
|
||||
newEntry.put("lvl", new ShortTag(level));
|
||||
newEnchantments.add(newEntry);
|
||||
}
|
||||
}
|
||||
@@ -708,43 +713,43 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
if (!storedEnch && !hasValidEnchants) {
|
||||
IntTag hideFlags = tag.get("HideFlags");
|
||||
if (hideFlags == null) {
|
||||
hideFlags = new IntTag("HideFlags");
|
||||
tag.put(new ByteTag(extraNbtTag + "|DummyEnchant"));
|
||||
hideFlags = new IntTag();
|
||||
tag.put(extraNbtTag + "|DummyEnchant", new ByteTag());
|
||||
} else {
|
||||
tag.put(new IntTag(extraNbtTag + "|OldHideFlags", hideFlags.getValue()));
|
||||
tag.put(extraNbtTag + "|OldHideFlags", new IntTag(hideFlags.asByte()));
|
||||
}
|
||||
|
||||
if (newEnchantments.size() == 0) {
|
||||
CompoundTag enchEntry = new CompoundTag("");
|
||||
enchEntry.put(new ShortTag("id", (short) 0));
|
||||
enchEntry.put(new ShortTag("lvl", (short) 0));
|
||||
CompoundTag enchEntry = new CompoundTag();
|
||||
enchEntry.put("id", new ShortTag((short) 0));
|
||||
enchEntry.put("lvl", new ShortTag((short) 0));
|
||||
newEnchantments.add(enchEntry);
|
||||
}
|
||||
|
||||
int value = hideFlags.getValue() | 1;
|
||||
int value = hideFlags.asByte() | 1;
|
||||
hideFlags.setValue(value);
|
||||
tag.put(hideFlags);
|
||||
tag.put("HideFlags", hideFlags);
|
||||
}
|
||||
|
||||
if (noMapped.size() != 0) {
|
||||
tag.put(noMapped);
|
||||
tag.put(extraNbtTag + "|" + key, noMapped);
|
||||
|
||||
if (!lore.isEmpty()) {
|
||||
CompoundTag display = tag.get("display");
|
||||
if (display == null) {
|
||||
tag.put(display = new CompoundTag("display"));
|
||||
tag.put("display", display = new CompoundTag());
|
||||
}
|
||||
|
||||
ListTag loreTag = display.get("Lore");
|
||||
if (loreTag == null) {
|
||||
display.put(loreTag = new ListTag("Lore", StringTag.class));
|
||||
tag.put(new ByteTag(extraNbtTag + "|DummyLore"));
|
||||
display.put("Lore", loreTag = new ListTag(StringTag.class));
|
||||
tag.put(extraNbtTag + "|DummyLore", new ByteTag());
|
||||
} else if (loreTag.size() != 0) {
|
||||
ListTag oldLore = new ListTag(extraNbtTag + "|OldLore", StringTag.class);
|
||||
ListTag oldLore = new ListTag(StringTag.class);
|
||||
for (Tag value : loreTag) {
|
||||
oldLore.add(value.clone());
|
||||
}
|
||||
tag.put(oldLore);
|
||||
tag.put(extraNbtTag + "|OldLore", oldLore);
|
||||
|
||||
lore.addAll(loreTag.getValue());
|
||||
}
|
||||
@@ -754,27 +759,27 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
|
||||
tag.remove("Enchantments");
|
||||
tag.put(newEnchantments);
|
||||
tag.put(storedEnch ? key : "ench", newEnchantments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item handleItemToServer(Item item) {
|
||||
if (item == null) return null;
|
||||
CompoundTag tag = item.getTag();
|
||||
CompoundTag tag = item.tag();
|
||||
|
||||
// Save original id
|
||||
int originalId = (item.getIdentifier() << 16 | item.getData() & 0xFFFF);
|
||||
int originalId = (item.identifier() << 16 | item.data() & 0xFFFF);
|
||||
|
||||
int rawId = (item.getIdentifier() << 4 | item.getData() & 0xF);
|
||||
int rawId = (item.identifier() << 4 | item.data() & 0xF);
|
||||
|
||||
// NBT Additions
|
||||
if (isDamageable(item.getIdentifier())) {
|
||||
if (tag == null) item.setTag(tag = new CompoundTag("tag"));
|
||||
tag.put(new IntTag("Damage", item.getData()));
|
||||
if (isDamageable(item.identifier())) {
|
||||
if (tag == null) item.setTag(tag = new CompoundTag());
|
||||
tag.put("Damage", new IntTag(item.data()));
|
||||
}
|
||||
if (item.getIdentifier() == 358) { // map
|
||||
if (tag == null) item.setTag(tag = new CompoundTag("tag"));
|
||||
tag.put(new IntTag("map", item.getData()));
|
||||
if (item.identifier() == 358) { // map
|
||||
if (tag == null) item.setTag(tag = new CompoundTag());
|
||||
tag.put("map", new IntTag(item.data()));
|
||||
}
|
||||
|
||||
// NBT Changes
|
||||
@@ -787,9 +792,9 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
if (display instanceof CompoundTag) {
|
||||
CompoundTag displayTag = (CompoundTag) display;
|
||||
StringTag name = displayTag.get("Name");
|
||||
if (name instanceof StringTag) {
|
||||
displayTag.put(new StringTag(extraNbtTag + "|Name", name.getValue()));
|
||||
name.setValue(ChatRewriter.legacyTextToJson(name.getValue()));
|
||||
if (name != null) {
|
||||
StringTag via = displayTag.remove(extraNbtTag + "|Name");
|
||||
name.setValue(via != null ? via.getValue() : ChatRewriter.legacyTextToJsonString(name.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -801,7 +806,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
rewriteCanPlaceToServer(tag, "CanDestroy");
|
||||
|
||||
// Handle SpawnEggs
|
||||
if (item.getIdentifier() == 383) {
|
||||
if (item.identifier() == 383) {
|
||||
CompoundTag entityTag = tag.get("EntityTag");
|
||||
StringTag identifier;
|
||||
if (entityTag != null && (identifier = entityTag.get("id")) != null) {
|
||||
@@ -825,38 +830,39 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
|
||||
// Handle custom mappings
|
||||
int identifier = item.getIdentifier();
|
||||
int identifier = item.identifier();
|
||||
item.setIdentifier(rawId);
|
||||
super.handleItemToServer(item);
|
||||
|
||||
// Mapped with original data, we can return here
|
||||
if (item.getIdentifier() != rawId) return item;
|
||||
if (item.identifier() != rawId && item.identifier() != -1) return item;
|
||||
|
||||
// Set to legacy id again
|
||||
item.setIdentifier(identifier);
|
||||
|
||||
int newId = -1;
|
||||
if (!MappingData.oldToNewItems.containsKey(rawId)) {
|
||||
if (!isDamageable(item.getIdentifier()) && item.getIdentifier() != 358) { // Map
|
||||
if (tag == null) item.setTag(tag = new CompoundTag("tag"));
|
||||
tag.put(new IntTag(extraNbtTag, originalId)); // Data will be lost, saving original id
|
||||
if (!protocol.getMappingData().getItemMappings().inverse().containsKey(rawId)) {
|
||||
if (!isDamageable(item.identifier()) && item.identifier() != 358) { // Map
|
||||
if (tag == null) item.setTag(tag = new CompoundTag());
|
||||
tag.put(extraNbtTag, new IntTag(originalId)); // Data will be lost, saving original id
|
||||
}
|
||||
|
||||
if (item.getIdentifier() == 229) { // purple shulker box
|
||||
if (item.identifier() == 229) { // purple shulker box
|
||||
newId = 362; // directly set the new id -> base/colorless shulker box
|
||||
} else if (item.getIdentifier() == 31 && item.getData() == 0) { // Shrub was removed
|
||||
} else if (item.identifier() == 31 && item.data() == 0) { // Shrub was removed
|
||||
rawId = 32 << 4; // Dead Bush
|
||||
} else if (MappingData.oldToNewItems.containsKey(rawId & ~0xF)) {
|
||||
} else if (protocol.getMappingData().getItemMappings().inverse().containsKey(rawId & ~0xF)) {
|
||||
rawId &= ~0xF; // Remove data
|
||||
} else {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Failed to get 1.13 item for " + item.getIdentifier());
|
||||
ViaBackwards.getPlatform().getLogger().warning("Failed to get 1.13 item for " + item.identifier());
|
||||
}
|
||||
rawId = 16; // Stone
|
||||
}
|
||||
}
|
||||
|
||||
if (newId == -1) {
|
||||
newId = MappingData.oldToNewItems.get(rawId);
|
||||
newId = protocol.getMappingData().getItemMappings().inverse().get(rawId);
|
||||
}
|
||||
|
||||
item.setIdentifier(newId);
|
||||
@@ -865,15 +871,17 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
|
||||
private void rewriteCanPlaceToServer(CompoundTag tag, String tagName) {
|
||||
if (!(tag.get(tagName) instanceof ListTag)) return;
|
||||
ListTag blockTag = tag.remove(extraNbtTag + "|" + tagName);
|
||||
if (blockTag != null) {
|
||||
tag.put(ConverterRegistry.convertToTag(tagName, ConverterRegistry.convertToValue(blockTag)));
|
||||
tag.put(tagName, ConverterRegistry.convertToTag(ConverterRegistry.convertToValue(blockTag)));
|
||||
} else if ((blockTag = tag.get(tagName)) != null) {
|
||||
ListTag newCanPlaceOn = new ListTag(tagName, StringTag.class);
|
||||
ListTag newCanPlaceOn = new ListTag(StringTag.class);
|
||||
for (Tag oldTag : blockTag) {
|
||||
Object value = oldTag.getValue();
|
||||
String oldId = value.toString().replace("minecraft:", "");
|
||||
String numberConverted = BlockIdData.numberIdToString.get(Ints.tryParse(oldId));
|
||||
int key = Ints.tryParse(oldId);
|
||||
String numberConverted = BlockIdData.numberIdToString.get(key);
|
||||
if (numberConverted != null) {
|
||||
oldId = numberConverted;
|
||||
}
|
||||
@@ -882,13 +890,13 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
String[] newValues = BlockIdData.blockIdMapping.get(lowerCaseId);
|
||||
if (newValues != null) {
|
||||
for (String newValue : newValues) {
|
||||
newCanPlaceOn.add(new StringTag("", newValue));
|
||||
newCanPlaceOn.add(new StringTag(newValue));
|
||||
}
|
||||
} else {
|
||||
newCanPlaceOn.add(new StringTag("", lowerCaseId));
|
||||
newCanPlaceOn.add(new StringTag(lowerCaseId));
|
||||
}
|
||||
}
|
||||
tag.put(newCanPlaceOn);
|
||||
tag.put(tagName, newCanPlaceOn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -897,12 +905,12 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
ListTag enchantments = tag.get(storedEnch ? key : "ench");
|
||||
if (enchantments == null) return;
|
||||
|
||||
ListTag newEnchantments = new ListTag(key, CompoundTag.class);
|
||||
ListTag newEnchantments = new ListTag(CompoundTag.class);
|
||||
boolean dummyEnchant = false;
|
||||
if (!storedEnch) {
|
||||
IntTag hideFlags = tag.remove(extraNbtTag + "|OldHideFlags");
|
||||
if (hideFlags != null) {
|
||||
tag.put(new IntTag("HideFlags", hideFlags.getValue()));
|
||||
tag.put("HideFlags", new IntTag(hideFlags.asByte()));
|
||||
dummyEnchant = true;
|
||||
} else if (tag.remove(extraNbtTag + "|DummyEnchant") != null) {
|
||||
tag.remove("HideFlags");
|
||||
@@ -911,19 +919,19 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
|
||||
for (Tag enchEntry : enchantments) {
|
||||
CompoundTag enchantmentEntry = new CompoundTag("");
|
||||
short oldId = ((Number) ((CompoundTag) enchEntry).get("id").getValue()).shortValue();
|
||||
short level = ((Number) ((CompoundTag) enchEntry).get("lvl").getValue()).shortValue();
|
||||
CompoundTag enchantmentEntry = new CompoundTag();
|
||||
short oldId = ((NumberTag) ((CompoundTag) enchEntry).get("id")).asShort();
|
||||
short level = ((NumberTag) ((CompoundTag) enchEntry).get("lvl")).asShort();
|
||||
if (dummyEnchant && oldId == 0 && level == 0) {
|
||||
continue; //Skip dummy enchatment
|
||||
}
|
||||
String newId = MappingData.oldEnchantmentsIds.get(oldId);
|
||||
String newId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().get(oldId);
|
||||
if (newId == null) {
|
||||
newId = "viaversion:legacy/" + oldId;
|
||||
}
|
||||
enchantmentEntry.put(new StringTag("id", newId));
|
||||
enchantmentEntry.put("id", new StringTag(newId));
|
||||
|
||||
enchantmentEntry.put(new ShortTag("lvl", level));
|
||||
enchantmentEntry.put("lvl", new ShortTag(level));
|
||||
newEnchantments.add(enchantmentEntry);
|
||||
}
|
||||
|
||||
@@ -936,14 +944,14 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
|
||||
CompoundTag display = tag.get("display");
|
||||
if (display == null) {
|
||||
tag.put(display = new CompoundTag("display"));
|
||||
tag.put("display", display = new CompoundTag());
|
||||
}
|
||||
|
||||
ListTag oldLore = tag.remove(extraNbtTag + "|OldLore");
|
||||
if (oldLore != null) {
|
||||
ListTag lore = display.get("Lore");
|
||||
if (lore == null) {
|
||||
tag.put(lore = new ListTag("Lore"));
|
||||
tag.put("Lore", lore = new ListTag());
|
||||
}
|
||||
|
||||
lore.setValue(oldLore.getValue());
|
||||
@@ -957,11 +965,11 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
if (!storedEnch) {
|
||||
tag.remove("ench");
|
||||
}
|
||||
tag.put(newEnchantments);
|
||||
tag.put(key, newEnchantments);
|
||||
}
|
||||
|
||||
private void invertShieldAndBannerId(Item item, CompoundTag tag) {
|
||||
if (item.getIdentifier() != 442 && item.getIdentifier() != 425) return;
|
||||
if (item.identifier() != 442 && item.identifier() != 425) return;
|
||||
|
||||
Tag blockEntityTag = tag.get("BlockEntityTag");
|
||||
if (!(blockEntityTag instanceof CompoundTag)) return;
|
||||
@@ -970,7 +978,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
Tag base = blockEntityCompoundTag.get("Base");
|
||||
if (base instanceof IntTag) {
|
||||
IntTag baseTag = (IntTag) base;
|
||||
baseTag.setValue(15 - baseTag.getValue()); // invert color id
|
||||
baseTag.setValue(15 - baseTag.asInt()); // invert color id
|
||||
}
|
||||
|
||||
Tag patterns = blockEntityCompoundTag.get("Patterns");
|
||||
@@ -980,7 +988,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
if (!(pattern instanceof CompoundTag)) continue;
|
||||
|
||||
IntTag colorTag = ((CompoundTag) pattern).get("Color");
|
||||
colorTag.setValue(15 - colorTag.getValue()); // Invert color id
|
||||
colorTag.setValue(15 - colorTag.asInt()); // Invert color id
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -993,23 +1001,23 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
CompoundTag nbt = beProvider.transform(user, position, "minecraft:flower_pot");
|
||||
|
||||
// Remove the flowerpot
|
||||
PacketWrapper blockUpdateRemove = new PacketWrapper(0x0B, null, user);
|
||||
PacketWrapper blockUpdateRemove = PacketWrapper.create(0x0B, null, user);
|
||||
blockUpdateRemove.write(Type.POSITION, position);
|
||||
blockUpdateRemove.write(Type.VAR_INT, 0);
|
||||
blockUpdateRemove.send(Protocol1_12_2To1_13.class, true);
|
||||
blockUpdateRemove.scheduleSend(Protocol1_12_2To1_13.class);
|
||||
|
||||
// Create the flowerpot
|
||||
PacketWrapper blockCreate = new PacketWrapper(0x0B, null, user);
|
||||
PacketWrapper blockCreate = PacketWrapper.create(0x0B, null, user);
|
||||
blockCreate.write(Type.POSITION, position);
|
||||
blockCreate.write(Type.VAR_INT, toOldId(blockState));
|
||||
blockCreate.send(Protocol1_12_2To1_13.class, true);
|
||||
blockCreate.write(Type.VAR_INT, Protocol1_12_2To1_13.MAPPINGS.getNewBlockStateId(blockState));
|
||||
blockCreate.scheduleSend(Protocol1_12_2To1_13.class);
|
||||
|
||||
// Send a block entity update
|
||||
PacketWrapper wrapper = new PacketWrapper(0x09, null, user);
|
||||
PacketWrapper wrapper = PacketWrapper.create(0x09, null, user);
|
||||
wrapper.write(Type.POSITION, position);
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) 5);
|
||||
wrapper.write(Type.NBT, nbt);
|
||||
wrapper.send(Protocol1_12_2To1_13.class, true);
|
||||
wrapper.scheduleSend(Protocol1_12_2To1_13.class);
|
||||
|
||||
}
|
||||
}
|
||||
Loaded 100 of 322 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user