mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-06-26 10:25:04 +02:00
Compare commits
336 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
09be940b25 | ||
|
196dff92f8 | ||
|
395ad80d91 | ||
|
1225016fa9 | ||
|
2c29f84dc7 | ||
|
8863e9eaad | ||
|
0d06dc7fec | ||
|
4f1f044837 | ||
|
b966022f74 | ||
|
ab9fd7edd6 | ||
|
c457a6f4ef | ||
|
f646b8c965 | ||
|
ce94e07c27 | ||
|
9ff009237d | ||
|
0ed772f477 | ||
|
08ed70e4d9 | ||
|
45a1633f0a | ||
|
5c3933118b | ||
|
60ae10c8e5 | ||
|
8a69e037ab | ||
|
8f01f4e35c | ||
|
3a16c4752f | ||
|
0027e681ee | ||
|
44b42fe176 | ||
|
085319fbbe | ||
|
2db9a087a2 | ||
|
3d48023e20 | ||
|
72d575797d | ||
|
36362bd1bc | ||
|
5fcf377366 | ||
|
18fd102a68 | ||
|
0ea07d0e63 | ||
|
46474fcd22 | ||
|
1f8fb02b53 | ||
|
456a5a94b9 | ||
|
aa27837c56 | ||
|
8c34100ee1 | ||
|
ba925d0a65 | ||
|
6eccfc8849 | ||
|
0056a53185 | ||
|
574657b24b | ||
|
1a6a683ebe | ||
|
3984f6a12d | ||
|
4bb0057ced | ||
|
6fd7e3730e | ||
|
a199f553af | ||
|
088290e352 | ||
|
9a9b4a8d88 | ||
|
8525292b09 | ||
|
a1f3552944 | ||
|
b230a9e2f7 | ||
|
3366b6766e | ||
|
f538c56b0e | ||
|
4b2cf8379d | ||
|
25ce9984b6 | ||
|
ef9c9536d6 | ||
|
3ef13d8426 | ||
|
22678ba99b | ||
|
996ad2de0d | ||
|
5eb9401852 | ||
|
49311d479f | ||
|
d0426c82e3 | ||
|
43d5065e1e | ||
|
1c23746dfc | ||
|
9ba4d1d328 | ||
|
64601f91c4 | ||
|
17f57f0c41 | ||
|
c1a34f3d7f | ||
|
07f25f8e26 | ||
|
ef469dcd26 | ||
|
8f9ab00b94 | ||
|
277f483b6a | ||
|
0cf982fec3 | ||
|
06c6cd024a | ||
|
203585875f | ||
|
17ecf0c736 | ||
|
73d21aaf2c | ||
|
a6327fb588 | ||
|
e01522c2fa | ||
|
473fe49b69 | ||
|
249d46470b | ||
|
6b115b712f | ||
|
2e0018b7bc | ||
|
458b4daf15 | ||
|
90dfd7d4a2 | ||
|
e4f91d4808 | ||
|
ad75e36213 | ||
|
68c6310c9d | ||
|
f471068696 | ||
|
d69a3a9bd2 | ||
|
cd3caa9156 | ||
|
aef746bbb2 | ||
|
f5315892fd | ||
|
30e97c41f4 | ||
|
6c372c2127 | ||
|
d9458d1fb7 | ||
|
1f5ac05fcf | ||
|
56ee795de5 | ||
|
38580e328c | ||
|
cd41e5cab3 | ||
|
7c5ce2cc71 | ||
|
14e1fcbeca | ||
|
c20d900aff | ||
|
d2b834a058 | ||
|
41a2139a98 | ||
|
60a26d2bb1 | ||
|
4a6d0b56a0 | ||
|
78094303be | ||
|
adf5ab9456 | ||
|
9c78a71d40 | ||
|
223e1591f9 | ||
|
f84865645e | ||
|
f7eef8fd4b | ||
|
9dfcd7db1a | ||
|
f5cad41e90 | ||
|
efd70ead90 | ||
|
d4070e0a03 | ||
|
27a5da4690 | ||
|
53d2fa65d4 | ||
|
89515390c2 | ||
|
4ef493a68b | ||
|
a6fd03ded2 | ||
|
f45895c547 | ||
|
38a900c78d | ||
|
8b26d75717 | ||
|
ff942ccf09 | ||
|
642b4de7a0 | ||
|
624b6dcbca | ||
|
712d8bbba7 | ||
|
7fc46c4854 | ||
|
5ef8d1bae4 | ||
|
6e21d8d946 | ||
|
6fa75395d5 | ||
|
964d3fbd48 | ||
|
a2f159cb58 | ||
|
710d1bd251 | ||
|
f45b2b0047 | ||
|
ae2c6da14c | ||
|
8cead6bf4a | ||
|
9a52ae4c4a | ||
|
31a7c84a05 | ||
|
05dfdc30d3 | ||
|
971ad3241a | ||
|
185e24e5c8 | ||
|
bc8682b010 | ||
|
e7f9188fbf | ||
|
1422464052 | ||
|
862d040e48 | ||
|
37b8c8e52e | ||
|
39e8866548 | ||
|
6dd2cd6894 | ||
|
ac6d5b8ee6 | ||
|
0b84e59948 | ||
|
4235543dcb | ||
|
51fd8dad1d | ||
|
57564c8488 | ||
|
b41474f257 | ||
|
b3b66c0526 | ||
|
796ae671b8 | ||
|
f6282d34d9 | ||
|
c1a90bd329 | ||
|
ce3349952c | ||
|
036f3e083b | ||
|
77c3a004b4 | ||
|
1a6937a398 | ||
|
8c64fa74a4 | ||
|
5c9b292d36 | ||
|
8f6ad8694d | ||
|
d3bd33cbd0 | ||
|
1f7c0b6c15 | ||
|
7b8bf9edc6 | ||
|
a8e5b243d0 | ||
|
ac9ac18b13 | ||
|
a68a280aee | ||
|
09b0e08853 | ||
|
232cbf45c7 | ||
|
68839a8d22 | ||
|
6b8f979b8f | ||
|
f8704eaab7 | ||
|
d1ad86c8d4 | ||
|
4f611e93ea | ||
|
4c5d58347b | ||
|
6f89102059 | ||
|
23c2077511 | ||
|
7e747396ff | ||
|
407927ff69 | ||
|
f3157a0220 | ||
|
ebc9560ae1 | ||
|
06c72c3211 | ||
|
495d3e0179 | ||
|
32ce497705 | ||
|
601fcbb0fb | ||
|
190f81c5a0 | ||
|
65e25a706f | ||
|
36fe9f595a | ||
|
e0fecb99b1 | ||
|
b83abecc6f | ||
|
2250d8079c | ||
|
ce3464480d | ||
|
973a3df00c | ||
|
ca828d2bc2 | ||
|
6e56ba6eec | ||
|
945a77a713 | ||
|
7bda76f004 | ||
|
de8a6f642c | ||
|
f899271881 | ||
|
5abef51ce9 | ||
|
8f5e4f87e2 | ||
|
62b0ac8a2d | ||
|
f9791f4766 | ||
|
7d6db51762 | ||
|
096afc54b6 | ||
|
8b6715e3a3 | ||
|
309c9f37fb | ||
|
78e30a31dc | ||
|
f82fff59ef | ||
|
5fd59d7f36 | ||
|
17840c5dd9 | ||
|
5d0e5a3f83 | ||
|
09401ff837 | ||
|
4b8d89a4b6 | ||
|
c20fee5dae | ||
|
6abdbbce08 | ||
|
2a5648fcca | ||
|
52d62b0fe1 | ||
|
43d36b9dcf | ||
|
de74e140d7 | ||
|
e0ec0e3c13 | ||
|
fbb66e87c6 | ||
|
4cfd04d4d8 | ||
|
6098c5bbae | ||
|
2840877b61 | ||
|
96dcd0cb98 | ||
|
f11af8465d | ||
|
0670657466 | ||
|
eabb84e938 | ||
|
73711a7174 | ||
|
3107461625 | ||
|
13cc75ed41 | ||
|
db7fd06065 | ||
|
cc4514d0c0 | ||
|
141750c2bd | ||
|
b6845f0c64 | ||
|
e9b060fc3c | ||
|
fe50697f8e | ||
|
67a52bd1e2 | ||
|
87b27861b7 | ||
|
27f8156c47 | ||
|
1c206b83e0 | ||
|
f61cb8b8f6 | ||
|
5c061e503d | ||
|
a3a70a2ac4 | ||
|
aee1575f30 | ||
|
6c8449ac6b | ||
|
5507ad3bc5 | ||
|
aa4be98e71 | ||
|
775eb62ded | ||
|
988268ba13 | ||
|
85d915a6c4 | ||
|
cfb2ca5d5a | ||
|
9fa0ec0df7 | ||
|
e5fff62547 | ||
|
7d5408f7f9 | ||
|
279fe5c617 | ||
|
5f0ac0caea | ||
|
da73e8ba19 | ||
|
9d3877a9f8 | ||
|
b159ce3511 | ||
|
d637e43f55 | ||
|
b85f61708d | ||
|
e91e19473f | ||
|
f54433ce9f | ||
|
787ce37bed | ||
|
34c66e0f09 | ||
|
d8c2a036e9 | ||
|
98926cb794 | ||
|
ab5c1ac872 | ||
|
9eb2adf626 | ||
|
9d791a0c9a | ||
|
6403610e75 | ||
|
de6db35397 | ||
|
ecd38de782 | ||
|
3b29c948f4 | ||
|
ba8cb52d20 | ||
|
f9b74b673b | ||
|
fef4f9922b | ||
|
f9de2c38b2 | ||
|
9f1ce594fe | ||
|
fb8e70246f | ||
|
e402047e63 | ||
|
6bf938424e | ||
|
66ce0c1e08 | ||
|
d6d3494ae6 | ||
|
f105bd8667 | ||
|
5600e3fbfb | ||
|
ac7121be47 | ||
|
b5b677da71 | ||
|
a4f837fb9d | ||
|
bcb3c57832 | ||
|
c31637cdbf | ||
|
55eb34b5a5 | ||
|
cb31189cb8 | ||
|
3fd3bd8a53 | ||
|
52a4d2c5f6 | ||
|
207e309a73 | ||
|
5b4a8a81bf | ||
|
17738de751 | ||
|
83311bfc63 | ||
|
610ae09d69 | ||
|
549fce8b55 | ||
|
72acd33db7 | ||
|
a86cae3f46 | ||
|
b195886642 | ||
|
e8015a864c | ||
|
0d5487632a | ||
|
868519c756 | ||
|
914cd75fb7 | ||
|
21df9acc78 | ||
|
d644e2f8a4 | ||
|
9c164663e2 | ||
|
4c5511f161 | ||
|
ca0afd587e | ||
|
7492d2a6e8 | ||
|
0e3ab35615 | ||
|
e80a99fd77 | ||
|
f899bc5745 | ||
|
e4159c5b0d | ||
|
342604f143 | ||
|
88a1376881 | ||
|
751090cdfd | ||
|
ea72120ff7 | ||
|
35d795ea3d | ||
|
e1a98531df | ||
|
9109c6b5d1 | ||
|
a0b7020315 | ||
|
51019b46cb |
3
.github/FUNDING.yml
vendored
Normal file
3
.github/FUNDING.yml
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
github: FlorianMichael
|
||||
custom: ["https://florianmichael.de/donate"]
|
||||
ko_fi: rk_01
|
6
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
6
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
|
@ -13,9 +13,11 @@ body:
|
|||
attributes:
|
||||
label: General Information
|
||||
description: |
|
||||
Please provide a list of all installed mods
|
||||
Please provide a ViaVersion dump, if you experience a crash, also the crash report (latest.log file). You can get both by
|
||||
going to `ViaFabricPlus -> Report issues` and using the buttons there.
|
||||
placeholder: |
|
||||
Example: "ViaFabricPlus, Fabric-API, Quilted-Fabric-API, ModMenu"
|
||||
ViaVersion dump url: **paste here**
|
||||
Crash report url: **upload to mclo.gs and paste here**
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
|
44
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
44
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
name: Feature Request
|
||||
description: Suggest a feature to be added in ViaFabricPlus
|
||||
labels: [ enhancement ]
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
**Before requesting a new feature, please see if using latest build from https://github.com/ViaVersion/ViaFabricPlus/actions already includes a solution.**
|
||||
Whenever you see fit, you can upload images or videos to any of the text fields.
|
||||
|
||||
- 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
|
14
.github/workflows/build.yml
vendored
14
.github/workflows/build.yml
vendored
|
@ -8,17 +8,17 @@ jobs:
|
|||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
uses: gradle/actions/wrapper-validation@v3
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
java-version: 21
|
||||
check-latest: true
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
- name: Upload Artifacts to GitHub
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Artifacts
|
||||
path: build/libs/
|
||||
path: build/libs/
|
126
README.md
126
README.md
|
@ -14,123 +14,29 @@
|
|||
# Why another protocol translator?
|
||||
ViaFabricPlus is a deep integration of ViaVersion on the Fabric platform, it implements many changes that can't be fixed on protocol level (old animations, old movement/swimming, collisions and general rendering changes).
|
||||
At the time of writing, VFP is the only protocol translation platform for the client with which you can play on all Minecraft multiplayer versions with many QoL features and get the feel of the old versions.
|
||||
### Supported Server versions
|
||||
- Release (1.0.0 - 23w51b)
|
||||
|
||||
## Supported Server versions
|
||||
- Release (1.0.0 - 1.21)
|
||||
- Beta (b1.0 - b1.8.1)
|
||||
- Alpha (a1.0.15 - a1.2.6)
|
||||
- Classic (c0.0.15 - c0.30 including [CPE](https://wiki.vg/Classic_Protocol_Extension))
|
||||
- Snapshots (3D Shareware, 20w14infinite, Combat Test 8C)
|
||||
- Bedrock (1.20.0)
|
||||
- April Fools (3D Shareware, 20w14infinite)
|
||||
- Combat Snapshots (Combat Test 8c)
|
||||
- Bedrock Edition 1.21.0 ([Some features are missing](https://github.com/RaphiMC/ViaBedrock#features))
|
||||
|
||||
# For users
|
||||
### Detailed instructions for use are available [here](docs/USAGE.md)
|
||||
### If you encounter any issues, please report them on the [issue tracker](https://github.com/ViaVersion/ViaFabricPlus/issues) or on the ViaVersion [Discord](https://discord.gg/viaversion)
|
||||
## For players
|
||||
- Tutorial for installing and using the mod can be found [here](docs/USAGE.md)
|
||||
- If you encounter any issues, please report them on the [issue tracker](https://github.com/ViaVersion/ViaFabricPlus/issues) or on the ViaVersion [Discord](https://discord.gg/viaversion)
|
||||
|
||||
## Known incompatibilities
|
||||
### Breaks
|
||||
- ***[ViaFabric (*)](https://github.com/ViaVersion/ViaFabric)***
|
||||
- ***[krypton (<= 0.2.2)](https://github.com/astei/krypton)***
|
||||
- ***[MemoryLeakFix (<= 1.1.0)](https://github.com/fxmorin/MemoryLeakFix)***
|
||||
## For contributors/volunteers
|
||||
- Guidelines for contributions can be found [here](docs/UPDATE_INSTRUCTIONS.md)
|
||||
- The current TODO list can be found [here](https://github.com/ViaVersion/ViaFabricPlus/blob/main/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java)
|
||||
|
||||
### Conflicts
|
||||
- ***[DashLoader (*)](https://github.com/alphaqu/DashLoader/tree/fabric-1.20)*** - Font rendering related fixes aren't working
|
||||
- ***[Armor Skin (*)](https://github.com/IzzyDotExe/ArmorSkin)*** - Beta HUD changes aren't working
|
||||
|
||||
## Feature list
|
||||
<details>
|
||||
<summary>Click to open</summary>
|
||||
|
||||
- [x] Bounding boxes for all versions
|
||||
- [x] Entity interaction and movement related packet fixes
|
||||
- [x] Sync and async mouse/keyboard handling in <= 1.12.2
|
||||
- [x] Mining speeds and item attributes
|
||||
- [x] Filter item creative tabs for only available items
|
||||
- [x] Combat system in <= 1.8
|
||||
- [x] Tons of modifications to ViaVersion, ViaAprilFools, ViaLegacy and ViaBedrock to make it more legit (Metadata fixes, broken packets, edge-cases)
|
||||
- [x] Visual and screen related changes (newer Command Block features, GameMode selection, ...)
|
||||
- [x] Chat signatures (secure login) for all versions (1.19.0, 1.19.1, 1.19.2)
|
||||
- [x] Address parsing for all Minecraft versions
|
||||
- [x] PackFormats and HTTP Header for all resource pack versions
|
||||
- [x] Raytrace related fixes in <= 1.8
|
||||
- [x] Implementing HUD changes for <= b1.7.3
|
||||
- [x] Chat lengths of all versions
|
||||
- [x] Implementing non-sequenced block placement in <= 1.18.2
|
||||
- [x] Animation related fixes (1.7 Sneaking, c0.30 walking animation, ...)
|
||||
- [x] Fixed clientside packet handling (1.16.5 transactions, 1.19.0 tablist, ...)
|
||||
</details>
|
||||
|
||||
# For developers and translators
|
||||
### Contributions in the form of pull requests are always welcome, [here](docs/UPDATE_INSTRUCTIONS.md) are some guidelines for contributing to the project.
|
||||
#### A detailed TODO list can be found at the class header of [this](https://github.com/ViaVersion/ViaFabricPlus/blob/main/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java) file.
|
||||
|
||||
|
||||
### Dependencies
|
||||
For compiling only! **You do not need to install these!**
|
||||
<details>
|
||||
<summary>Click to get a list of all dependencies</summary>
|
||||
|
||||
| Dependency | Download |
|
||||
|------------------------|------------------------------------------------------|
|
||||
| Fabric API | https://github.com/FabricMC/fabric |
|
||||
| Fabric Loader | https://github.com/FabricMC/fabric-loader |
|
||||
| Classic4J | https://github.com/FlorianMichael/Classic4J |
|
||||
| ViaVersion | https://github.com/ViaVersion/ViaVersion |
|
||||
| ViaBackwards | https://github.com/ViaVersion/ViaBackwards |
|
||||
| ViaLoader | https://github.com/ViaVersion/ViaLoader |
|
||||
| ViaLegacy | https://github.com/ViaVersion/ViaLegacy |
|
||||
| ViaAprilFools | https://github.com/ViaVersion/ViaAprilFools |
|
||||
| ViaBedrock | https://github.com/RaphiMC/ViaBedrock |
|
||||
| MinecraftAuth | https://github.com/RaphiMC/MinecraftAuth |
|
||||
| Netty-transport-RakNet | https://github.com/CloudburstMC/Network/tree/develop |
|
||||
| Reflect | https://github.com/Lenni0451/Reflect |
|
||||
| MCPing | https://github.com/Lenni0451/MCPing |
|
||||
| MixinExtras | https://github.com/LlamaLad7/MixinExtras |
|
||||
</details>
|
||||
|
||||
### Setting up a Workspace
|
||||
ViaFabricPlus uses Gradle, to make sure that it is installed properly you can check [Gradle's website](https://gradle.org/install/).
|
||||
1. Clone the repository using `git clone https://github.com/ViaVersion/ViaFabricPlus`.
|
||||
2. CD into the local repository.
|
||||
3. Run `./gradlew genSources`.
|
||||
4. Open the folder as a Gradle project in your preferred IDE.
|
||||
5. Run the mod.
|
||||
|
||||
### Include via Gradle/Maven
|
||||
```groovy
|
||||
repositories {
|
||||
maven {
|
||||
name = "ViaVersion"
|
||||
url = "https://repo.viaversion.com"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
modImplementation("de.florianmichael:viafabricplus:3.0.2") // Get the latest version from releases
|
||||
}
|
||||
```
|
||||
|
||||
```xml
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>viaversion</id>
|
||||
<url>https://repo.viaversion.com</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>de.florianmichael</groupId>
|
||||
<artifactId>viafabricplus</artifactId>
|
||||
<version>3.0.2</version> <!-- Get the latest version from releases -->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
|
||||
### To learn more about the API and about addons, you can simply click [here](docs/DEVELOPER_API.md)
|
||||
## Miscellaneous
|
||||
- API and integration examples can be found [here](docs/DEVELOPER_API.md)
|
||||
- An overview of the different Via* projects can be found [here](https://github.com/ViaVersion)
|
||||
#### If you just want to talk or need help with ViaFabricPlus feel free to join my [Discord](https://discord.gg/BwWhCHUKDf).
|
||||
|
||||
## Disclaimer
|
||||
|
||||
It cannot be guaranteed that this mod is allowed on specific servers as it can possibly cause problems with anti-cheat plugins.\
|
||||
***(USE ONLY WITH CAUTION!)***
|
||||
|
||||
### If you want to talk with me, feel free to join my [Discord](https://discord.gg/BwWhCHUKDf)
|
42
build.gradle
42
build.gradle
|
@ -1,5 +1,5 @@
|
|||
plugins {
|
||||
id "fabric-loom" version "1.4-SNAPSHOT"
|
||||
id "fabric-loom" version "1.6-SNAPSHOT"
|
||||
id "maven-publish"
|
||||
}
|
||||
|
||||
|
@ -20,10 +20,6 @@ configurations {
|
|||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "Jitpack"
|
||||
url = "https://jitpack.io"
|
||||
}
|
||||
maven {
|
||||
name = "ViaVersion"
|
||||
url = "https://repo.viaversion.com"
|
||||
|
@ -32,14 +28,14 @@ repositories {
|
|||
name = "Lenni0451"
|
||||
url = "https://maven.lenni0451.net/everything"
|
||||
}
|
||||
maven {
|
||||
name = "TerraformersMC"
|
||||
url = "https://maven.terraformersmc.com/releases"
|
||||
}
|
||||
maven {
|
||||
name = "OpenCollab Snapshots"
|
||||
url = "https://repo.opencollab.dev/maven-snapshots/"
|
||||
}
|
||||
maven {
|
||||
name = "TerraformersMC"
|
||||
url = "https://maven.terraformersmc.com/releases"
|
||||
}
|
||||
}
|
||||
|
||||
loom {
|
||||
|
@ -69,7 +65,6 @@ dependencies {
|
|||
jij "net.raphimc:ViaLegacy:${project.vialegacy_version}"
|
||||
jij "net.raphimc:ViaAprilFools:${project.viaaprilfools_version}"
|
||||
jij ("net.raphimc:ViaBedrock:${project.viabedrock_version}") {
|
||||
exclude group: "io.netty"
|
||||
exclude group: "io.jsonwebtoken"
|
||||
exclude group: "com.mojang", module: "brigadier"
|
||||
}
|
||||
|
@ -80,7 +75,6 @@ dependencies {
|
|||
|
||||
// RaphiMC Libraries
|
||||
jij ("net.raphimc:MinecraftAuth:${project.minecraftauth_version}") {
|
||||
exclude group: "org.apache.httpcomponents", module: "httpclient"
|
||||
exclude group: "com.google.code.gson", module: "gson"
|
||||
exclude group: "org.slf4j", module: "slf4j-api"
|
||||
}
|
||||
|
@ -99,25 +93,37 @@ dependencies {
|
|||
|
||||
// Fabric's jar in jar system doesn't support transitive dependencies, so we have to manually add them
|
||||
afterEvaluate {
|
||||
configurations.jij.incoming.resolutionResult.allDependencies {
|
||||
dependencies.include(dependencies.implementation(dependencies.compileOnlyApi(requested.toString())))
|
||||
configurations.jij.incoming.resolutionResult.allDependencies.each {
|
||||
dependencies.include(dependencies.implementation(dependencies.compileOnlyApi(it.requested.toString()) {
|
||||
transitive = false
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version
|
||||
expand(
|
||||
"version": project.version,
|
||||
"implVersion": "git-${project.name}-${project.version}:${project.latestCommitHash()}",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
String latestCommitHash() {
|
||||
def stdout = new ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine "git", "rev-parse", "--short", "HEAD"
|
||||
standardOutput = stdout
|
||||
}
|
||||
return stdout.toString().trim()
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
}
|
||||
|
||||
jar {
|
||||
|
|
|
@ -1,6 +1,54 @@
|
|||
# Developer API
|
||||
ViaFabricPlus provides various events and APIs for developers to use. This page explains how to use them.
|
||||
|
||||
## Include via Gradle/Maven
|
||||
```groovy
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "ViaVersion"
|
||||
url = "https://repo.viaversion.com"
|
||||
}
|
||||
maven {
|
||||
name = "Lenni0451"
|
||||
url = "https://maven.lenni0451.net/everything"
|
||||
}
|
||||
maven {
|
||||
name = "OpenCollab Snapshots"
|
||||
url = "https://repo.opencollab.dev/maven-snapshots/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
modImplementation("de.florianmichael:ViaFabricPlus:x.x.x") // Get the latest version from releases
|
||||
}
|
||||
```
|
||||
|
||||
```xml
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>viaversion</id>
|
||||
<url>https://repo.viaversion.com</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>lenni0451</id>
|
||||
<url>https://maven.lenni0451.net/everything</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>opencollab-snapshots</id>
|
||||
<url>https://repo.opencollab.dev/maven-snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>de.florianmichael</groupId>
|
||||
<artifactId>ViaFabricPlus</artifactId>
|
||||
<version>x.x.x</version> <!-- Get the latest version from releases -->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
|
||||
## Events
|
||||
ViaFabricPlus events are using the [Fabric Event API](https://fabricmc.net/wiki/tutorial:events). You can register to them like this:
|
||||
```java
|
||||
|
@ -22,24 +70,24 @@ ChangeProtocolVersionCallback.EVENT.register((oldVersion, newVersion) -> {
|
|||
|
||||
## Get and set the current protocol version
|
||||
```java
|
||||
final VersionEnum version = ProtocolHack.getTargetVersion();
|
||||
if (version == VersionEnum.r1_8) {
|
||||
ProtocolHack.setTargetVersion(VersionEnum.r1_9);
|
||||
final ProtocolVersion version = ProtocolTranslator.getTargetVersion();
|
||||
if (version == ProtocolVersion.v1_8) {
|
||||
ProtocolTranslator.setTargetVersion(ProtocolVersion.v1_9);
|
||||
}
|
||||
```
|
||||
|
||||
## Get a Minecraft ClientConnection by channel
|
||||
```java
|
||||
final ClientConnection connection = channel.attr(ProtocolHack.CLIENT_CONNECTION_ATTRIBUTE_KEY).get();
|
||||
final ClientConnection connection = channel.attr(ProtocolTranslator.CLIENT_CONNECTION_ATTRIBUTE_KEY).get();
|
||||
```
|
||||
|
||||
## Interact with UserConnection objects
|
||||
```java
|
||||
// If ViaVersion is translating, this field will return the user connection of the client
|
||||
final UserConnection userConnection = ProtocolHack.getPlayNetworkUserConnection();
|
||||
final UserConnection userConnection = ProtocolTranslator.getPlayNetworkUserConnection();
|
||||
|
||||
// If you need a dummy user connection for testing, you can use this method
|
||||
final UserConnection cursedDummy = ProtocolHack.createDummyUserConnection(ProtocolHack.NATIVE_VERSION, VersionEnum.r1_18_2);
|
||||
final UserConnection cursedDummy = ProtocolTranslator.createDummyUserConnection(ProtocolTranslator.NATIVE_VERSION, ProtocolVersion.v1_18_2);
|
||||
// The cursedDummy field now contains all protocols from the native version to 1.18.2
|
||||
```
|
||||
|
||||
|
@ -56,35 +104,7 @@ final VersionRange range = ItemRegistryDiff.ITEM_DIFF.get(Items.WRITABLE_BOOK);
|
|||
|
||||
// The Range class then contains all versions in which the item occurs.
|
||||
// https://github.com/ViaVersion/ViaLoader
|
||||
if (ItemRegistryDiff.contains(Items.STONE, VersionRange.andOlder(VersionEnum.r1_8))) {
|
||||
if (ItemRegistryDiff.contains(Items.STONE, VersionRange.andOlder(ProtocolVersion.v1_8))) {
|
||||
// Do something
|
||||
}
|
||||
```
|
||||
|
||||
### Creating own settings for the settings screen
|
||||
```java
|
||||
public class ExampleSettingGroup extends SettingGroup {
|
||||
|
||||
private static final ExampleSettingGroup INSTANCE = new ExampleSettingGroup();
|
||||
|
||||
public final BooleanSetting test = new BooleanSetting(this, Text.of("Test"), false);
|
||||
|
||||
public ExampleSettingGroup() {
|
||||
super("Example");
|
||||
}
|
||||
|
||||
public static ExampleSettingGroup global() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
and then you register the setting group in your onLoad method
|
||||
```java
|
||||
RegisterSettingsCallback.EVENT.register(state -> {
|
||||
if (state == RegisterSettingsCallback.State.POST) {
|
||||
ViaFabricPlus.global().getSettingsManager().addGroup(ExampleSettingGroup.INSTANCE);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
|
|
@ -21,6 +21,14 @@ Translation files are located in `src/main/resources/assets/viafabricplus/lang/`
|
|||
7. Create a pull request and wait for it to be reviewed and merged.
|
||||
8. You're done, congrats!
|
||||
|
||||
## Setting up a Workspace
|
||||
ViaFabricPlus uses Gradle, to make sure that it is installed properly you can check [Gradle's website](https://gradle.org/install/).
|
||||
1. Clone the repository using `git clone https://github.com/ViaVersion/ViaFabricPlus`.
|
||||
2. CD into the local repository.
|
||||
3. Run `./gradlew genSources`.
|
||||
4. Open the folder as a Gradle project in your preferred IDE.
|
||||
5. Run the mod.
|
||||
|
||||
## Update to a new Minecraft version
|
||||
1. Update all upstream versions in `gradle.properties`. The main versions you need to update are:
|
||||
- `minecraft_version`
|
||||
|
@ -30,7 +38,7 @@ Translation files are located in `src/main/resources/assets/viafabricplus/lang/`
|
|||
- `viaversion_version`
|
||||
- `viabackwards_version`
|
||||
- `mod_menu_version`
|
||||
2. Update the `NATIVE_VERSION` field in the ProtocolHack class to the new version
|
||||
2. Update the `NATIVE_VERSION` field in the ProtocolTranslator class to the new version
|
||||
3. Check all mixins in the injection package if they still apply correctly, here is a list of some critical ones:
|
||||
- `MixinClientPlayerEntity#removeBl8Boolean`
|
||||
- `MixinClientWorld#tickEntity` and `MixinClientWorld#tickPassenger`
|
||||
|
@ -49,14 +57,19 @@ Translation files are located in `src/main/resources/assets/viafabricplus/lang/`
|
|||
|
||||
=> If you are unsure if a change is relevant, ask in the ViaVersion discord, in general you should only implement changes
|
||||
which could be detected by a server side anti cheat.
|
||||
7. Check the ViaVersion/upstream protocol implementation for issues and report them if necessary or if these issues can't be fixed,
|
||||
|
||||
From experience, most changes are related to either movement or networking,
|
||||
packages like `gametest` or `server` can be skipped usually when updating. It's important to always diff code inside
|
||||
the `net.minecraft.client` package as well as `net.minecraft.world` package, as these are the most likely to contain changes. (Mojang mappings)
|
||||
7. Update protocol constants in the `ViaFabricPlusProtocol` class
|
||||
8. Check the ViaVersion/upstream protocol implementation for issues and report them if necessary or if these issues can't be fixed,
|
||||
without tons of work, implement a workaround in ViaFabricPlus.
|
||||
8. Run the game and check all GUIs and other visuals for issues.
|
||||
9. Clean your code and make sure it is readable and understandable, clientside fixes are sorted by their protocol versions, having
|
||||
9. Run the game and check all GUIs and other visuals for issues.
|
||||
10. Clean your code and make sure it is readable and understandable, clientside fixes are sorted by their protocol versions, having
|
||||
newer fixes at the top of the file.
|
||||
10. Increment the version number in `gradle.properties` by at least a minor version (e.g. 1.0.0 -> 1.1.0)
|
||||
11. Create a pull request and wait for it to be reviewed and merged.
|
||||
12. You're done, congrats!
|
||||
11. Increment the version number in `gradle.properties` by at least a minor version (e.g. 1.0.0 -> 1.1.0)
|
||||
12. Create a pull request and wait for it to be reviewed and merged.
|
||||
13. You're done, congrats!
|
||||
|
||||
## Git branches
|
||||
- `main`: The main branch, this is where all changes are merged into
|
||||
|
|
|
@ -3,32 +3,33 @@ org.gradle.jvmargs=-Xmx8G
|
|||
org.gradle.parallel=true
|
||||
|
||||
# Minecraft/Fabric
|
||||
minecraft_version=1.20.4
|
||||
yarn_mappings=1.20.4+build.3
|
||||
loader_version=0.15.3
|
||||
fabric_api_version=0.91.3+1.20.4
|
||||
minecraft_version=1.21
|
||||
yarn_mappings=1.21+build.1
|
||||
loader_version=0.15.11
|
||||
fabric_api_version=0.100.1+1.21
|
||||
|
||||
# Project Details
|
||||
mod_version=3.0.5
|
||||
mod_version=3.4.2-SNAPSHOT
|
||||
maven_group=de.florianmichael
|
||||
archives_base_name=viafabricplus
|
||||
archives_base_name=ViaFabricPlus
|
||||
|
||||
# ViaVersion Libraries
|
||||
viaversion_version=4.10.0-23w51b-SNAPSHOT
|
||||
viabackwards_version=4.10.0-23w51b-SNAPSHOT
|
||||
vialegacy_version=2.2.22-SNAPSHOT
|
||||
viaaprilfools_version=2.0.11-SNAPSHOT
|
||||
viabedrock_version=0.0.4-SNAPSHOT
|
||||
vialoader_version=2.2.13-SNAPSHOT
|
||||
viaversion_version=5.0.1
|
||||
viabackwards_version=5.0.1
|
||||
vialegacy_version=3.0.1
|
||||
viaaprilfools_version=3.0.1-SNAPSHOT
|
||||
vialoader_version=3.0.1
|
||||
|
||||
# RaphiMC Libraries
|
||||
minecraftauth_version=3.1.0-SNAPSHOT
|
||||
raknet_transport_version=1.0.0.CR1-SNAPSHOT
|
||||
minecraftauth_version=4.0.0
|
||||
|
||||
viabedrock_version=0.0.9-SNAPSHOT
|
||||
raknet_transport_version=1.0.0.CR3-SNAPSHOT
|
||||
|
||||
# Lenni0451 Libraries
|
||||
reflect_version=1.3.1
|
||||
reflect_version=1.3.2
|
||||
mcping_version=1.4.0
|
||||
|
||||
# Misc Libraries
|
||||
mod_menu_version=9.0.0
|
||||
classic4j_version=2.0.1
|
||||
mod_menu_version=11.0.0-beta.1
|
||||
classic4j_version=2.0.2
|
||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
|
14
gradlew
vendored
14
gradlew
vendored
|
@ -145,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
|
@ -153,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
|
@ -202,11 +202,11 @@ fi
|
|||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
|
|
20
gradlew.bat
vendored
20
gradlew.bat
vendored
|
@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
|
|||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
|
@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# Deploys the latest stable JDK available and sets it to default without having to manually specify it here,
|
||||
# Deploys the latest stable JDK 21 available and sets it to default without having to manually specify it here,
|
||||
# Which includes using temurin as the distribution.
|
||||
before_install:
|
||||
- curl -s "https://get.sdkman.io" | bash
|
||||
- source ~/.sdkman/bin/sdkman-init.sh
|
||||
- sdk install java
|
||||
- curl -s "https://get.sdkman.io" | bash
|
||||
- source ~/.sdkman/bin/sdkman-init.sh
|
||||
- sdk install java 21.0.3-tem
|
||||
- sdk use java 21.0.3-tem
|
||||
|
|
|
@ -21,8 +21,7 @@ package de.florianmichael.viafabricplus;
|
|||
|
||||
import de.florianmichael.viafabricplus.event.PostGameLoadCallback;
|
||||
import de.florianmichael.viafabricplus.fixes.ClientsideFixes;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocolhack.util.VersionEnumExtension;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import de.florianmichael.viafabricplus.save.SaveManager;
|
||||
import de.florianmichael.viafabricplus.settings.SettingsManager;
|
||||
import de.florianmichael.viafabricplus.util.ClassLoaderPriorityUtil;
|
||||
|
@ -34,20 +33,49 @@ import java.io.File;
|
|||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/*
|
||||
* TODO | Port 1.20.6
|
||||
* - ClientPlayerInteractionManager#interactBlockInternal added new condition
|
||||
* - MouseHandling changed (not sure if relevant)
|
||||
* - Command arguments (Probably not everything worth, but least them with nbt)
|
||||
* - Entity attachment calculation got changed completely
|
||||
* - Particle handling has slightly changed
|
||||
*
|
||||
* TODO | Port 1.21
|
||||
* - LocalPlayer#aiStep nether portal logic
|
||||
* - Camera logic got changed again
|
||||
* - ExtraCodecs#QUATERNIONF_COMPONENTS
|
||||
* - Armadilllo removedd shouldPanic
|
||||
* - AbstractHorse canWearBodyArmor->canUseSlot
|
||||
* - horses getInvColumns behaviour
|
||||
* - Wolf hasArmor -> interactions
|
||||
* - HangingEntity, ItemFrame, Painting, PrimedTnt
|
||||
* - Villager offers are server only now
|
||||
* - Player#attack
|
||||
* - Boat floating and interaction
|
||||
* - Entity collide functions and interaction
|
||||
* - LivingEntity#getBlockSpeedFactor, decreaseAirSupply, knockback, travel, getPreciseBodyRotation,
|
||||
* - Mob interact
|
||||
* - AxeItem playerHasShieldUseIntent new
|
||||
* - BucketItem, ChorusFruit, FoodOnAStickItem, KnowledgeBookItem, TridentItem,
|
||||
* - CakeBlock creative check in interaction
|
||||
* - Jukebox overrides new interaction function
|
||||
* - SignBlock, TntBlock creative check
|
||||
* - Check item rarity values
|
||||
* - ItemStack count max changed in codec
|
||||
* - SolidBucketItem useOn
|
||||
*
|
||||
* TODO | General
|
||||
* - Make recipe fixes dynamic instead of a data dump in java classes
|
||||
* - Check if relevant for protocol translation: TakeItemEntityPacket isEmpty case (1.20 -> 1.20.1 change)
|
||||
* - Check previous Donkey interaction fix (see git logs)
|
||||
* - Window interactions in <= 1.16.5 has changed and can be detected by the server
|
||||
* - Most CTS protocol features aren't supported (see https://github.com/ViaVersion/ViaFabricPlus/issues/181)
|
||||
* - Most CPE features aren't implemented correctly (see https://github.com/ViaVersion/ViaFabricPlus/issues/152)
|
||||
* - Check if MixinPlayerScreenHandler.injectTransferSlot is needed? Check git log
|
||||
* - Via: 1.13 -> 1.12.2 block entities recode
|
||||
*
|
||||
* TODO | Movement
|
||||
* - X/Z Face based jump movement in <= 1.13.2 is broken (https://github.com/ViaVersion/ViaFabricPlus/issues/189)
|
||||
* - Collision hit boxes has been changed (https://github.com/ViaVersion/ViaFabricPlus/issues/195)
|
||||
* - Blip-jumping is not supported in <= 1.8.9 (https://github.com/ViaVersion/ViaFabricPlus/issues/225)
|
||||
* - Older versions don't clamp positions when teleporting (Is this important?)
|
||||
* - Blip-jumping is not supported in <= 1.13.2 (https://github.com/ViaVersion/ViaFabricPlus/issues/225)
|
||||
* - 1.8 lava movement
|
||||
* - 1.13.2 water movement
|
||||
*/
|
||||
public class ViaFabricPlus {
|
||||
|
||||
|
@ -61,19 +89,21 @@ public class ViaFabricPlus {
|
|||
|
||||
private CompletableFuture<Void> loadingFuture;
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public void bootstrap() {
|
||||
public void init() {
|
||||
directory.mkdir();
|
||||
ClassLoaderPriorityUtil.loadOverridingJars(directory); // Load overriding jars first so other code can access the new classes
|
||||
VersionEnumExtension.init(); // Register extra VersionEnum values
|
||||
|
||||
settingsManager = new SettingsManager();
|
||||
saveManager = new SaveManager(settingsManager);
|
||||
|
||||
ClientsideFixes.init(); // Init clientside related fixes
|
||||
loadingFuture = ProtocolHack.init(directory); // Init ViaVersion protocol translator platform
|
||||
loadingFuture = ProtocolTranslator.init(directory); // Init ViaVersion protocol translator platform
|
||||
|
||||
PostGameLoadCallback.EVENT.register(() -> loadingFuture.join()); // Block game loading until ViaVersion has loaded
|
||||
// Block game loading until ViaVersion has loaded
|
||||
PostGameLoadCallback.EVENT.register(() -> {
|
||||
loadingFuture.join();
|
||||
saveManager.postInit();
|
||||
});
|
||||
}
|
||||
|
||||
public static ViaFabricPlus global() {
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.event;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
/**
|
||||
* This event is fired when the user changes the target version in the screen, or if the user joins a server with a different version.
|
||||
|
@ -35,6 +35,6 @@ public interface ChangeProtocolVersionCallback {
|
|||
}
|
||||
});
|
||||
|
||||
void onChangeProtocolVersion(final VersionEnum oldVersion, final VersionEnum newVersion);
|
||||
void onChangeProtocolVersion(final ProtocolVersion oldVersion, final ProtocolVersion newVersion);
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ package de.florianmichael.viafabricplus.event;
|
|||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.data.ClassicProtocolExtension;
|
||||
import net.raphimc.vialegacy.protocol.classic.c0_30cpetoc0_28_30.data.ClassicProtocolExtension;
|
||||
|
||||
/**
|
||||
* This event is fired when a classic protocol extension is loaded.
|
||||
|
|
|
@ -19,24 +19,37 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.fixes;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
|
||||
import de.florianmichael.viafabricplus.event.LoadClassicProtocolExtensionCallback;
|
||||
import de.florianmichael.viafabricplus.event.PostGameLoadCallback;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.CPEAdditions;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.GridItemSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.fixes.data.EntityDimensionDiff;
|
||||
import de.florianmichael.viafabricplus.fixes.data.ResourcePackHeaderDiff;
|
||||
import de.florianmichael.viafabricplus.fixes.entity.EntityDimensionReplacements;
|
||||
import de.florianmichael.viafabricplus.fixes.particle.FootStepParticle;
|
||||
import de.florianmichael.viafabricplus.injection.ViaFabricPlusMixinPlugin;
|
||||
import de.florianmichael.viafabricplus.fixes.versioned.classic.CPEAdditions;
|
||||
import de.florianmichael.viafabricplus.fixes.versioned.classic.GridItemSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.fixes.versioned.visual.ArmorHudEmulation1_8;
|
||||
import de.florianmichael.viafabricplus.fixes.versioned.visual.FootStepParticle1_12_2;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import de.florianmichael.viafabricplus.settings.impl.BedrockSettings;
|
||||
import de.florianmichael.viafabricplus.util.DataCustomPayload;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.FontStorage;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.network.RegistryByteBuf;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.data.ClassicProtocolExtension;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.viaaprilfools.api.AprilFoolsProtocolVersion;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import net.raphimc.viabedrock.protocol.data.ProtocolConstants;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocol.classic.c0_30cpetoc0_28_30.data.ClassicProtocolExtension;
|
||||
import net.raphimc.vialegacy.protocol.classic.c0_30cpetoc0_28_30.storage.ExtensionProtocolMetadataStorage;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Consumer;
|
||||
|
@ -49,24 +62,19 @@ public class ClientsideFixes {
|
|||
/**
|
||||
* Contains all tasks that are waiting for a packet to be received, this system can be used to sync ViaVersion tasks with the correct thread
|
||||
*/
|
||||
private static final Map<String, Consumer<PacketByteBuf>> PENDING_EXECUTION_TASKS = new ConcurrentHashMap<>();
|
||||
private static final Map<String, Consumer<RegistryByteBuf>> PENDING_EXECUTION_TASKS = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* This identifier is an internal identifier that is used to identify packets that are sent by ViaFabricPlus
|
||||
* This identifier is an internal identifier used to identify packets that are sent by ViaFabricPlus
|
||||
*/
|
||||
public static final String PACKET_SYNC_IDENTIFIER = UUID.randomUUID() + ":" + UUID.randomUUID();
|
||||
|
||||
/**
|
||||
* This identifier is an internal identifier used to store the item count in <= 1.10 to implement negative item counts
|
||||
* This is an incremental index used for tablist entries to implement FIFO behavior <= 1.7
|
||||
*/
|
||||
public static final String ITEM_COUNT_NBT_TAG = "VFP_1_10_ItemCount_" + System.currentTimeMillis();
|
||||
public static int GLOBAL_TABLIST_INDEX = 0;
|
||||
|
||||
/**
|
||||
* The current chat limit
|
||||
*/
|
||||
private static int currentChatLength = 256;
|
||||
|
||||
public static void init() {
|
||||
static {
|
||||
// Register additional CPE features
|
||||
CPEAdditions.modifyMappings();
|
||||
|
||||
|
@ -75,7 +83,7 @@ public class ClientsideFixes {
|
|||
|
||||
PostGameLoadCallback.EVENT.register(() -> {
|
||||
// Handles and updates entity dimension changes in <= 1.17
|
||||
EntityDimensionReplacements.init();
|
||||
EntityDimensionDiff.init();
|
||||
|
||||
// Ticks the armor hud manually in <= 1.8.x
|
||||
ArmorHudEmulation1_8.init();
|
||||
|
@ -83,23 +91,10 @@ public class ClientsideFixes {
|
|||
|
||||
// Reloads some clientside stuff when the protocol version changes
|
||||
ChangeProtocolVersionCallback.EVENT.register((oldVersion, newVersion) -> MinecraftClient.getInstance().execute(() -> {
|
||||
// Calculates the current chat length limit
|
||||
if (newVersion.isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
currentChatLength = 64 - (MinecraftClient.getInstance().getSession().getUsername().length() + 2);
|
||||
} else if (newVersion.equals(VersionEnum.bedrockLatest)) {
|
||||
currentChatLength = 512;
|
||||
} else if (newVersion.isOlderThanOrEqualTo(VersionEnum.r1_9_3tor1_9_4)) {
|
||||
currentChatLength = 100;
|
||||
} else {
|
||||
currentChatLength = 256;
|
||||
}
|
||||
|
||||
if (!ViaFabricPlusMixinPlugin.DASH_LOADER_PRESENT) {
|
||||
// Clear all font caches to enforce a reload of all fonts (this is needed because we change the font renderer behavior)
|
||||
for (FontStorage storage : MinecraftClient.getInstance().fontManager.fontStorages.values()) {
|
||||
storage.glyphRendererCache.clear();
|
||||
storage.glyphCache.clear();
|
||||
}
|
||||
// Clear all font caches to enforce a reload of all fonts (this is needed because we change the font renderer behavior)
|
||||
for (FontStorage storage : MinecraftClient.getInstance().fontManager.fontStorages.values()) {
|
||||
storage.glyphRendererCache.clear();
|
||||
storage.glyphCache.clear();
|
||||
}
|
||||
|
||||
// Reloads all bounding boxes of the blocks that we changed
|
||||
|
@ -120,20 +115,66 @@ public class ClientsideFixes {
|
|||
}
|
||||
|
||||
// Rebuilds the item selection screen grid
|
||||
if (newVersion.isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
if (newVersion.olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
|
||||
GridItemSelectionScreen.INSTANCE.itemGrid = null;
|
||||
}
|
||||
|
||||
// Reload sound system when switching between 3D Shareware and normal versions
|
||||
if (oldVersion.equals(AprilFoolsProtocolVersion.s3d_shareware) || newVersion.equals(AprilFoolsProtocolVersion.s3d_shareware)) {
|
||||
MinecraftClient.getInstance().getSoundManager().reloadSounds();
|
||||
}
|
||||
}));
|
||||
|
||||
// Calculates the current chat limit, since it changes depending on the protocol version
|
||||
LoadClassicProtocolExtensionCallback.EVENT.register(classicProtocolExtension -> {
|
||||
if (classicProtocolExtension == ClassicProtocolExtension.LONGER_MESSAGES) {
|
||||
currentChatLength = Short.MAX_VALUE * 2;
|
||||
}
|
||||
});
|
||||
|
||||
// Register the footstep particle
|
||||
FootStepParticle.init();
|
||||
FootStepParticle1_12_2.init();
|
||||
|
||||
// Register the custom payload packet for sync tasks
|
||||
DataCustomPayload.init();
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
// Calls the static block
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the maximum chat length for the selected protocol version in {@link ProtocolTranslator#getTargetVersion()}
|
||||
*
|
||||
* @return The maximum chat length
|
||||
*/
|
||||
public static int getChatLength() {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
|
||||
final ClientPlayNetworkHandler handler = MinecraftClient.getInstance().getNetworkHandler();
|
||||
final ExtensionProtocolMetadataStorage extensionProtocol = ((IClientConnection) handler.getConnection()).viaFabricPlus$getUserConnection().get(ExtensionProtocolMetadataStorage.class);
|
||||
|
||||
if (extensionProtocol != null && extensionProtocol.hasServerExtension(ClassicProtocolExtension.LONGER_MESSAGES)) {
|
||||
return Short.MAX_VALUE * 2;
|
||||
} else {
|
||||
return 64 - (MinecraftClient.getInstance().getSession().getUsername().length() + 2);
|
||||
}
|
||||
} else if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) {
|
||||
return 512;
|
||||
} else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_9_3)) {
|
||||
return 100;
|
||||
} else {
|
||||
return 256;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the default port when parsing a server address if the default port should be replaced
|
||||
*
|
||||
* @param address The original address of the server
|
||||
* @param version The protocol version
|
||||
* @return The server address with the replaced default port
|
||||
*/
|
||||
public static ServerAddress replaceDefaultPort(final String address, final ProtocolVersion version) {
|
||||
// If the default port for this entry should be replaced, check if the address already contains a port
|
||||
// We can't just replace vanilla's default port because a bedrock server might be running on the same port
|
||||
if (BedrockSettings.global().replaceDefaultPort.getValue() && Objects.equals(version, BedrockProtocolVersion.bedrockLatest) && !address.contains(":")) {
|
||||
return ServerAddress.parse(address + ":" + ProtocolConstants.BEDROCK_DEFAULT_PORT);
|
||||
} else {
|
||||
return ServerAddress.parse(address);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -142,25 +183,22 @@ public class ClientsideFixes {
|
|||
* @param task The task to execute
|
||||
* @return The uuid of the task
|
||||
*/
|
||||
public static String executeSyncTask(final Consumer<PacketByteBuf> task) {
|
||||
final var uuid = UUID.randomUUID().toString();
|
||||
public static String executeSyncTask(final Consumer<RegistryByteBuf> task) {
|
||||
final String uuid = UUID.randomUUID().toString();
|
||||
PENDING_EXECUTION_TASKS.put(uuid, task);
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void handleSyncTask(final PacketByteBuf buf) {
|
||||
final var uuid = buf.readString();
|
||||
final String uuid = buf.readString();
|
||||
|
||||
if (PENDING_EXECUTION_TASKS.containsKey(uuid)) {
|
||||
MinecraftClient.getInstance().execute(() -> { // Execute the task on the main thread
|
||||
final var task = PENDING_EXECUTION_TASKS.remove(uuid);
|
||||
task.accept(buf);
|
||||
task.accept(new RegistryByteBuf(buf, MinecraftClient.getInstance().getNetworkHandler().getRegistryManager()));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static int getCurrentChatLength() {
|
||||
return currentChatLength;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,260 @@
|
|||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 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 de.florianmichael.viafabricplus.fixes.data;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.EntityAttachmentType;
|
||||
import net.minecraft.entity.EntityAttachments;
|
||||
import net.minecraft.entity.EntityDimensions;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import static de.florianmichael.viafabricplus.util.MapUtil.linkedHashMap;
|
||||
|
||||
/**
|
||||
* Data dump for entity dimension changes between versions.
|
||||
*/
|
||||
public class EntityDimensionDiff {
|
||||
|
||||
/**
|
||||
* A map of entity types to a map of versions to dimensions.
|
||||
*/
|
||||
private static final Map<EntityType<?>, Map<ProtocolVersion, EntityDimensions>> ENTITY_DIMENSIONS = linkedHashMap(
|
||||
EntityType.WITHER, linkedHashMap(
|
||||
ProtocolVersion.v1_7_6, EntityDimensionsBuilder.create(EntityType.WITHER).withChangingDimensions(0.9F, 4.0F).build(),
|
||||
ProtocolVersion.v1_8, EntityType.WITHER.getDimensions()
|
||||
),
|
||||
EntityType.SILVERFISH, linkedHashMap(
|
||||
ProtocolVersion.v1_7_6, EntityDimensionsBuilder.create(EntityType.SILVERFISH).withChangingDimensions(0.3F, 0.7F).build(),
|
||||
ProtocolVersion.v1_8, EntityType.SILVERFISH.getDimensions()
|
||||
),
|
||||
EntityType.SNOW_GOLEM, linkedHashMap(
|
||||
ProtocolVersion.v1_7_6, EntityDimensionsBuilder.create(EntityType.SNOW_GOLEM).withChangingDimensions(0.4F, 1.8F).build(),
|
||||
ProtocolVersion.v1_8, EntityType.SNOW_GOLEM.getDimensions()
|
||||
),
|
||||
EntityType.ZOMBIE, linkedHashMap(
|
||||
ProtocolVersion.v1_7_6, EntityDimensionsBuilder.create(EntityType.ZOMBIE).withChangingDimensions(0.6F, 1.8F).build(),
|
||||
ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.ZOMBIE).withFixedDimensions(0.6F, 1.95F).build(),
|
||||
ProtocolVersion.v1_9, EntityType.ZOMBIE.getDimensions()
|
||||
),
|
||||
EntityType.CHICKEN, linkedHashMap(
|
||||
LegacyProtocolVersion.b1_7tob1_7_3, EntityDimensionsBuilder.create(EntityType.CHICKEN).withChangingDimensions(0.3F, 0.4F).build(),
|
||||
ProtocolVersion.v1_7_6, EntityDimensionsBuilder.create(EntityType.CHICKEN).withChangingDimensions(0.3F, 0.7F).build(),
|
||||
ProtocolVersion.v1_8, EntityType.CHICKEN.getDimensions()
|
||||
),
|
||||
EntityType.SHEEP, linkedHashMap(
|
||||
LegacyProtocolVersion.c0_28toc0_30, EntityDimensionsBuilder.create(EntityType.SHEEP).withChangingDimensions(1.4F, 1.72F).build(),
|
||||
LegacyProtocolVersion.a1_0_15, EntityType.SHEEP.getDimensions()
|
||||
),
|
||||
EntityType.OCELOT, linkedHashMap(
|
||||
ProtocolVersion.v1_7_6, EntityDimensionsBuilder.create(EntityType.OCELOT).withChangingDimensions(0.6F, 0.8F).build(),
|
||||
ProtocolVersion.v1_8, EntityType.OCELOT.getDimensions()
|
||||
),
|
||||
EntityType.BOAT, linkedHashMap(
|
||||
ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.BOAT).withChangingDimensions(1.5F, 0.6F).build(),
|
||||
ProtocolVersion.v1_9, EntityType.BOAT.getDimensions()
|
||||
),
|
||||
EntityType.CREEPER, linkedHashMap(
|
||||
ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.CREEPER).withChangingDimensions(0.6F, 1.8F).build(),
|
||||
ProtocolVersion.v1_9, EntityType.CREEPER.getDimensions()
|
||||
),
|
||||
EntityType.IRON_GOLEM, linkedHashMap(
|
||||
ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.IRON_GOLEM).withChangingDimensions(1.4F, 2.9F).build(),
|
||||
ProtocolVersion.v1_9, EntityType.IRON_GOLEM.getDimensions()
|
||||
),
|
||||
EntityType.SKELETON, linkedHashMap(
|
||||
ProtocolVersion.v1_7_6, EntityDimensionsBuilder.create(EntityType.SKELETON).withChangingDimensions(0.6F, 1.8F).build(),
|
||||
ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.SKELETON).withChangingDimensions(0.6F, 1.95F).build(),
|
||||
ProtocolVersion.v1_9, EntityType.SKELETON.getDimensions()
|
||||
),
|
||||
EntityType.WITHER_SKELETON, linkedHashMap(
|
||||
LegacyProtocolVersion.r1_4_6tor1_4_7, EntityDimensionsBuilder.create(EntityType.WITHER_SKELETON).withChangingDimensions(0.72F, 2.16F).build(),
|
||||
ProtocolVersion.v1_7_6, EntityDimensionsBuilder.create(EntityType.WITHER_SKELETON).withChangingDimensions(0.72F, 2.34F).build(),
|
||||
ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.WITHER_SKELETON).withChangingDimensions(0.72F, 2.535F).build(),
|
||||
ProtocolVersion.v1_9, EntityType.WITHER_SKELETON.getDimensions()
|
||||
),
|
||||
EntityType.COW, linkedHashMap(
|
||||
ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.COW).withChangingDimensions(0.9F, 1.3F).build(),
|
||||
ProtocolVersion.v1_9, EntityType.COW.getDimensions()
|
||||
),
|
||||
EntityType.HORSE, linkedHashMap(
|
||||
ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.HORSE).withChangingDimensions(1.4F, 1.6F).build(),
|
||||
ProtocolVersion.v1_9, EntityType.HORSE.getDimensions()
|
||||
),
|
||||
EntityType.MOOSHROOM, linkedHashMap(
|
||||
ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.MOOSHROOM).withChangingDimensions(0.9F, 1.3F).build(),
|
||||
ProtocolVersion.v1_9, EntityType.MOOSHROOM.getDimensions()
|
||||
),
|
||||
EntityType.RABBIT, linkedHashMap(
|
||||
ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.RABBIT).withChangingDimensions(0.6F, 0.7F).build(),
|
||||
ProtocolVersion.v1_9, EntityType.RABBIT.getDimensions()
|
||||
),
|
||||
EntityType.SQUID, linkedHashMap(
|
||||
ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.SQUID).withChangingDimensions(0.95F, 0.95F).build(),
|
||||
ProtocolVersion.v1_9, EntityType.SQUID.getDimensions()
|
||||
),
|
||||
EntityType.VILLAGER, linkedHashMap(
|
||||
ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.VILLAGER).withChangingDimensions(0.6F, 1.8F).build(),
|
||||
ProtocolVersion.v1_9, EntityType.VILLAGER.getDimensions()
|
||||
),
|
||||
EntityType.WOLF, linkedHashMap(
|
||||
LegacyProtocolVersion.r1_1, EntityDimensionsBuilder.create(EntityType.WOLF).withChangingDimensions(0.8F, 0.8F).build(),
|
||||
ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.WOLF).withChangingDimensions(0.6F, 0.8F).build(),
|
||||
ProtocolVersion.v1_9, EntityType.WOLF.getDimensions()
|
||||
),
|
||||
EntityType.DRAGON_FIREBALL, linkedHashMap(
|
||||
ProtocolVersion.v1_10, EntityDimensionsBuilder.create(EntityType.DRAGON_FIREBALL).withChangingDimensions(0.3125F, 0.3125F).build(),
|
||||
ProtocolVersion.v1_11, EntityType.DRAGON_FIREBALL.getDimensions()
|
||||
),
|
||||
EntityType.LEASH_KNOT, linkedHashMap(
|
||||
ProtocolVersion.v1_16_4, EntityDimensionsBuilder.create(EntityType.LEASH_KNOT).withChangingDimensions(0.5F, 0.5F).build(),
|
||||
ProtocolVersion.v1_17, EntityType.LEASH_KNOT.getDimensions()
|
||||
),
|
||||
EntityType.SLIME, linkedHashMap(
|
||||
ProtocolVersion.v1_13_2, EntityDimensionsBuilder.create(EntityType.SLIME).withChangingDimensions(2F * 0.255F, 2F * 0.255F).build(),
|
||||
ProtocolVersion.v1_14, EntityDimensionsBuilder.create(EntityType.SLIME).withChangingDimensions(2.04F * 0.255F, 2.04F * 0.255F).build(),
|
||||
ProtocolVersion.v1_20_5, EntityType.SLIME.getDimensions()
|
||||
),
|
||||
EntityType.MAGMA_CUBE, linkedHashMap(
|
||||
ProtocolVersion.v1_13_2, EntityDimensionsBuilder.create(EntityType.MAGMA_CUBE).withChangingDimensions(2F * 0.255F, 2F * 0.255F).build(),
|
||||
ProtocolVersion.v1_14, EntityDimensionsBuilder.create(EntityType.MAGMA_CUBE).withChangingDimensions(2.04F * 0.255F, 2.04F * 0.255F).build(),
|
||||
ProtocolVersion.v1_20_5, EntityType.MAGMA_CUBE.getDimensions()
|
||||
),
|
||||
EntityType.ARROW, linkedHashMap(
|
||||
LegacyProtocolVersion.c0_28toc0_30, EntityDimensionsBuilder.create(EntityType.ARROW).withChangingDimensions(0.3F, 0.5F).build(),
|
||||
LegacyProtocolVersion.a1_0_15, EntityType.ARROW.getDimensions()
|
||||
)
|
||||
);
|
||||
|
||||
static {
|
||||
ChangeProtocolVersionCallback.EVENT.register((oldVersion, newVersion) -> MinecraftClient.getInstance().execute(() -> ENTITY_DIMENSIONS.forEach((entityType, dimensionMap) -> {
|
||||
for (Map.Entry<ProtocolVersion, EntityDimensions> entry : dimensionMap.entrySet()) {
|
||||
final ProtocolVersion version = entry.getKey();
|
||||
final EntityDimensions dimensions = entry.getValue();
|
||||
if (oldVersion.newerThan(version) && newVersion.olderThanOrEqualTo(version)) {
|
||||
entityType.dimensions = dimensions;
|
||||
break;
|
||||
}
|
||||
if (newVersion.newerThanOrEqualTo(version) && oldVersion.olderThanOrEqualTo(version)) {
|
||||
entityType.dimensions = dimensions;
|
||||
}
|
||||
}
|
||||
})));
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
// Calls the static block
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entityType The {@link EntityType} to get the dimensions for.
|
||||
* @return The dimensions for the given {@link EntityType} or null if there are none. The map is unmodifiable.
|
||||
*/
|
||||
public static Map<ProtocolVersion, EntityDimensions> getEntityDimensions(final EntityType<?> entityType) {
|
||||
if (!ENTITY_DIMENSIONS.containsKey(entityType)) {
|
||||
return null;
|
||||
}
|
||||
return Collections.unmodifiableMap(ENTITY_DIMENSIONS.get(entityType));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entityType The {@link EntityType} to get the dimensions for.
|
||||
* @param version The {@link ProtocolVersion} to get the dimensions for.
|
||||
* @return The closest dimensions for the given {@link EntityType} and {@link ProtocolVersion} or null if there are none.
|
||||
*/
|
||||
public static EntityDimensions getEntityDimensions(final EntityType<?> entityType, final ProtocolVersion version) {
|
||||
final Map<ProtocolVersion, EntityDimensions> dimensionMap = getEntityDimensions(entityType);
|
||||
if (dimensionMap == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
EntityDimensions closestDimensions = null;
|
||||
ProtocolVersion closestVersion = null;
|
||||
|
||||
for (Map.Entry<ProtocolVersion, EntityDimensions> entry : dimensionMap.entrySet()) {
|
||||
final var currentVersion = entry.getKey();
|
||||
final var currentDimensions = entry.getValue();
|
||||
|
||||
if (currentVersion == version) { // If the version is exactly the same, return the dimensions
|
||||
return currentDimensions;
|
||||
}
|
||||
|
||||
// If the current version is closer to the version you are looking for
|
||||
if (closestVersion == null || ProtocolTranslator.isCloserTo(version, currentVersion, closestVersion)) {
|
||||
closestVersion = currentVersion;
|
||||
closestDimensions = currentDimensions;
|
||||
}
|
||||
}
|
||||
|
||||
return closestDimensions;
|
||||
}
|
||||
|
||||
private static class EntityDimensionsBuilder {
|
||||
|
||||
private EntityDimensions entityDimensions;
|
||||
private EntityAttachments.Builder attachments = EntityAttachments.builder();
|
||||
|
||||
public static EntityDimensionsBuilder create() {
|
||||
return new EntityDimensionsBuilder();
|
||||
}
|
||||
|
||||
public static EntityDimensionsBuilder create(final EntityType<?> template) {
|
||||
final EntityDimensionsBuilder entityDimensionsBuilder = new EntityDimensionsBuilder();
|
||||
entityDimensionsBuilder.entityDimensions = template.getDimensions();
|
||||
return entityDimensionsBuilder;
|
||||
}
|
||||
|
||||
public EntityDimensionsBuilder withChangingDimensions(final float width, final float height) {
|
||||
this.entityDimensions = new EntityDimensions(width, height, this.entityDimensions.eyeHeight(), this.entityDimensions.attachments(), false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityDimensionsBuilder withFixedDimensions(final float width, final float height) {
|
||||
this.entityDimensions = new EntityDimensions(width, height, this.entityDimensions.eyeHeight(), this.entityDimensions.attachments(), true);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityDimensionsBuilder withEyeHeight(final float eyeHeight) {
|
||||
this.entityDimensions = this.entityDimensions.withEyeHeight(eyeHeight);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityDimensionsBuilder withPassengerAttachments(final float... offsetYs) {
|
||||
for (float f : offsetYs) {
|
||||
this.attachments = this.attachments.add(EntityAttachmentType.PASSENGER, 0.0F, f, 0.0F);
|
||||
}
|
||||
this.entityDimensions = this.entityDimensions.withAttachments(this.attachments);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityDimensions build() {
|
||||
return this.entityDimensions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -19,11 +19,13 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.fixes.data;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.protocol.version.VersionType;
|
||||
import net.minecraft.GameVersion;
|
||||
import net.minecraft.SaveVersion;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.resource.ResourceType;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
@ -34,57 +36,61 @@ import java.util.Map;
|
|||
*/
|
||||
public class ResourcePackHeaderDiff {
|
||||
|
||||
private final static Map<VersionEnum, GameVersion> GAME_VERSION_DIFF = new HashMap<>();
|
||||
private final static Map<ProtocolVersion, GameVersion> GAME_VERSION_DIFF = new HashMap<>();
|
||||
|
||||
static {
|
||||
registerVersion(VersionEnum.r1_20_3tor1_20_4, 22, "1.20.4");
|
||||
registerVersion(VersionEnum.r1_20_2, 18, "1.20.2");
|
||||
registerVersion(VersionEnum.r1_20tor1_20_1, 15, "1.20.1");
|
||||
registerVersion(VersionEnum.r1_19_4, 13, "1.19.4");
|
||||
registerVersion(VersionEnum.r1_19_3, 12, "1.19.3");
|
||||
registerVersion(VersionEnum.r1_19_1tor1_19_2, 9, "1.19.2");
|
||||
registerVersion(VersionEnum.r1_19, 9, "1.19");
|
||||
registerVersion(VersionEnum.r1_18_2, 8, "1.18.2");
|
||||
registerVersion(VersionEnum.r1_18tor1_18_1, 8, "1.18.1");
|
||||
registerVersion(VersionEnum.r1_17_1, 7, "1.17.1");
|
||||
registerVersion(VersionEnum.r1_17, 7, "1.17");
|
||||
registerVersion(VersionEnum.r1_16_4tor1_16_5, 6, "1.16.5");
|
||||
registerVersion(VersionEnum.r1_16_3, 6, "1.16.3");
|
||||
registerVersion(VersionEnum.r1_16_2, 6, "1.16.2");
|
||||
registerVersion(VersionEnum.r1_16_1, 5, "1.16.1");
|
||||
registerVersion(VersionEnum.r1_16, 5, "1.16");
|
||||
registerVersion(VersionEnum.r1_15_2, 5, "1.15.2");
|
||||
registerVersion(VersionEnum.r1_15_1, 5, "1.15.1");
|
||||
registerVersion(VersionEnum.r1_15, 5, "1.15");
|
||||
registerVersion(VersionEnum.r1_14_4, 4, "1.14.4");
|
||||
registerVersion(VersionEnum.r1_14_3, 4, "1.14.3");
|
||||
registerVersion(VersionEnum.r1_14_2, 4, "1.14.2");
|
||||
registerVersion(VersionEnum.r1_14_1, 4, "1.14.1");
|
||||
registerVersion(VersionEnum.r1_14, 4, "1.14");
|
||||
registerVersion(VersionEnum.r1_13_2, 4, "1.13.2");
|
||||
registerVersion(VersionEnum.r1_13_1, 4, "1.13.1");
|
||||
registerVersion(VersionEnum.r1_13, 4, "1.13");
|
||||
registerVersion(VersionEnum.r1_12_2, 3, "1.12.2");
|
||||
registerVersion(VersionEnum.r1_12_1, 3, "1.12.1");
|
||||
registerVersion(VersionEnum.r1_12, 3, "1.12");
|
||||
registerVersion(VersionEnum.r1_11_1to1_11_2, 3, "1.11.2");
|
||||
registerVersion(VersionEnum.r1_11, 3, "1.11");
|
||||
registerVersion(VersionEnum.r1_10, 2, "1.10.2");
|
||||
registerVersion(VersionEnum.r1_9_3tor1_9_4, 2, "1.9.4");
|
||||
registerVersion(VersionEnum.r1_9_2, 2, "1.9.2");
|
||||
registerVersion(VersionEnum.r1_9_1, 2, "1.9.1");
|
||||
registerVersion(VersionEnum.r1_9, 2, "1.9");
|
||||
registerVersion(VersionEnum.r1_8, 1, "1.8.9");
|
||||
registerVersion(VersionEnum.r1_7_6tor1_7_10, 1, "1.7.10");
|
||||
registerVersion(VersionEnum.r1_7_2tor1_7_5, 1, "1.7.5");
|
||||
registerVersion(ProtocolVersion.v1_21, 34, "1.21");
|
||||
registerVersion(ProtocolVersion.v1_20_5, 32, "1.20.6");
|
||||
registerVersion(ProtocolVersion.v1_20_3, 22, "1.20.4");
|
||||
registerVersion(ProtocolVersion.v1_20_2, 18, "1.20.2");
|
||||
registerVersion(ProtocolVersion.v1_20, 15, "1.20.1");
|
||||
registerVersion(ProtocolVersion.v1_19_4, 13, "1.19.4");
|
||||
registerVersion(ProtocolVersion.v1_19_3, 12, "1.19.3");
|
||||
registerVersion(ProtocolVersion.v1_19_1, 9, "1.19.2");
|
||||
registerVersion(ProtocolVersion.v1_19, 9, "1.19");
|
||||
registerVersion(ProtocolVersion.v1_18_2, 8, "1.18.2");
|
||||
registerVersion(ProtocolVersion.v1_18, 8, "1.18.1");
|
||||
registerVersion(ProtocolVersion.v1_17_1, 7, "1.17.1");
|
||||
registerVersion(ProtocolVersion.v1_17, 7, "1.17");
|
||||
registerVersion(ProtocolVersion.v1_16_4, 6, "1.16.5");
|
||||
registerVersion(ProtocolVersion.v1_16_3, 6, "1.16.3");
|
||||
registerVersion(ProtocolVersion.v1_16_2, 6, "1.16.2");
|
||||
registerVersion(ProtocolVersion.v1_16_1, 5, "1.16.1");
|
||||
registerVersion(ProtocolVersion.v1_16, 5, "1.16");
|
||||
registerVersion(ProtocolVersion.v1_15_2, 5, "1.15.2");
|
||||
registerVersion(ProtocolVersion.v1_15_1, 5, "1.15.1");
|
||||
registerVersion(ProtocolVersion.v1_15, 5, "1.15");
|
||||
registerVersion(ProtocolVersion.v1_14_4, 4, "1.14.4");
|
||||
registerVersion(ProtocolVersion.v1_14_3, 4, "1.14.3");
|
||||
registerVersion(ProtocolVersion.v1_14_2, 4, "1.14.2");
|
||||
registerVersion(ProtocolVersion.v1_14_1, 4, "1.14.1");
|
||||
registerVersion(ProtocolVersion.v1_14, 4, "1.14");
|
||||
registerVersion(ProtocolVersion.v1_13_2, 4, "1.13.2");
|
||||
registerVersion(ProtocolVersion.v1_13_1, 4, "1.13.1");
|
||||
registerVersion(ProtocolVersion.v1_13, 4, "1.13");
|
||||
registerVersion(ProtocolVersion.v1_12_2, 3, "1.12.2");
|
||||
registerVersion(ProtocolVersion.v1_12_1, 3, "1.12.1");
|
||||
registerVersion(ProtocolVersion.v1_12, 3, "1.12");
|
||||
registerVersion(ProtocolVersion.v1_11_1, 3, "1.11.2");
|
||||
registerVersion(ProtocolVersion.v1_11, 3, "1.11");
|
||||
registerVersion(ProtocolVersion.v1_10, 2, "1.10.2");
|
||||
registerVersion(ProtocolVersion.v1_9_3, 2, "1.9.4");
|
||||
registerVersion(ProtocolVersion.v1_9_2, 2, "1.9.2");
|
||||
registerVersion(ProtocolVersion.v1_9_1, 2, "1.9.1");
|
||||
registerVersion(ProtocolVersion.v1_9, 2, "1.9");
|
||||
registerVersion(ProtocolVersion.v1_8, 1, "1.8.9");
|
||||
registerVersion(ProtocolVersion.v1_7_6, 1, "1.7.10");
|
||||
registerVersion(ProtocolVersion.v1_7_2, 1, "1.7.5");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the registry is outdated.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public static void checkOutdated() {
|
||||
for (VersionEnum version : VersionEnum.OFFICIAL_SUPPORTED_PROTOCOLS) {
|
||||
if (version.getProtocol().isSnapshot()) continue;
|
||||
for (ProtocolVersion version : ProtocolVersion.getProtocols()) {
|
||||
if (version.isSnapshot()) continue;
|
||||
if (version.getVersionType() != VersionType.RELEASE) continue;
|
||||
if (!GAME_VERSION_DIFF.containsKey(version)) {
|
||||
throw new RuntimeException("The version " + version + " has no pack format registered");
|
||||
}
|
||||
|
@ -92,21 +98,22 @@ public class ResourcePackHeaderDiff {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param version The {@link VersionEnum} to get the {@link GameVersion} for.
|
||||
* @return The {@link GameVersion} for the given {@link VersionEnum}.
|
||||
* @param version The {@link ProtocolVersion} to get the {@link GameVersion} for.
|
||||
* @return The {@link GameVersion} for the given {@link ProtocolVersion}.
|
||||
*/
|
||||
public static GameVersion get(final VersionEnum version) {
|
||||
public static GameVersion get(final ProtocolVersion version) {
|
||||
if (!GAME_VERSION_DIFF.containsKey(version)) {
|
||||
return SharedConstants.getGameVersion();
|
||||
} else {
|
||||
return GAME_VERSION_DIFF.get(version);
|
||||
}
|
||||
return GAME_VERSION_DIFF.get(version);
|
||||
}
|
||||
|
||||
private static void registerVersion(final VersionEnum version, final int packFormat, final String name) {
|
||||
private static void registerVersion(final ProtocolVersion version, final int packFormat, final String name) {
|
||||
registerVersion(version, packFormat, name, name);
|
||||
}
|
||||
|
||||
private static void registerVersion(final VersionEnum version, final int packFormat, final String name, final String id) {
|
||||
private static void registerVersion(final ProtocolVersion version, final int packFormat, final String name, final String id) {
|
||||
GAME_VERSION_DIFF.put(version, new GameVersion() {
|
||||
|
||||
@Override
|
||||
|
@ -126,7 +133,7 @@ public class ResourcePackHeaderDiff {
|
|||
|
||||
@Override
|
||||
public int getProtocolVersion() {
|
||||
return version.getProtocol().getOriginalVersion();
|
||||
return version.getOriginalVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,23 +19,23 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.fixes.data.recipe;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.entity.BannerBlockEntity;
|
||||
import net.minecraft.inventory.RecipeInputInventory;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.BannerPatternsComponent;
|
||||
import net.minecraft.item.BannerItem;
|
||||
import net.minecraft.item.DyeItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtList;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.recipe.SpecialCraftingRecipe;
|
||||
import net.minecraft.recipe.SpecialRecipeSerializer;
|
||||
import net.minecraft.recipe.book.CraftingRecipeCategory;
|
||||
import net.minecraft.registry.DynamicRegistryManager;
|
||||
import net.minecraft.recipe.input.CraftingRecipeInput;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
public class AddBannerPatternRecipe extends SpecialCraftingRecipe {
|
||||
|
||||
|
@ -46,14 +46,14 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(RecipeInputInventory inv, World world) {
|
||||
public boolean matches(CraftingRecipeInput inv, World world) {
|
||||
boolean foundBanner = false;
|
||||
for (int i = 0; i < inv.size(); i++) {
|
||||
ItemStack stack = inv.getStack(i);
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if (stack.getItem() instanceof BannerItem) {
|
||||
if (foundBanner)
|
||||
return false;
|
||||
if (BannerBlockEntity.getPatternCount(stack) >= 6)
|
||||
if (stack.getOrDefault(DataComponentTypes.BANNER_PATTERNS, BannerPatternsComponent.DEFAULT).layers().size() >= 6)
|
||||
return false;
|
||||
foundBanner = true;
|
||||
}
|
||||
|
@ -62,11 +62,11 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack craft(RecipeInputInventory inv, DynamicRegistryManager registryManager) {
|
||||
public ItemStack craft(CraftingRecipeInput inv, RegistryWrapper.WrapperLookup lookup) {
|
||||
ItemStack result = ItemStack.EMPTY;
|
||||
|
||||
for (int i = 0; i < inv.size(); i++) {
|
||||
ItemStack stack = inv.getStack(i);
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if (!stack.isEmpty() && stack.getItem() instanceof BannerItem) {
|
||||
result = stack.copy();
|
||||
result.setCount(1);
|
||||
|
@ -74,28 +74,23 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe {
|
|||
}
|
||||
}
|
||||
|
||||
BannerPattern_1_13_2 pattern = getBannerPattern(inv);
|
||||
final BannerPattern_1_13_2 pattern = getBannerPattern(inv);
|
||||
if (pattern != null) {
|
||||
DyeColor color = ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2) ? DyeColor.BLACK : DyeColor.WHITE;
|
||||
for (int i = 0; i < inv.size(); i++) {
|
||||
Item item = inv.getStack(i).getItem();
|
||||
final var patternKey = lookup.getWrapperOrThrow(RegistryKeys.BANNER_PATTERN).getOrThrow(pattern.getKey());
|
||||
DyeColor color = ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2) ? DyeColor.BLACK : DyeColor.WHITE;
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
Item item = inv.getStackInSlot(i).getItem();
|
||||
if (item instanceof DyeItem dyeItem) {
|
||||
color = dyeItem.getColor();
|
||||
}
|
||||
}
|
||||
|
||||
NbtCompound tileEntityNbt = result.getOrCreateSubNbt("BlockEntityTag");
|
||||
NbtList patterns;
|
||||
if (tileEntityNbt.contains("Patterns", 9)) {
|
||||
patterns = tileEntityNbt.getList("Patterns", 10);
|
||||
} else {
|
||||
patterns = new NbtList();
|
||||
tileEntityNbt.put("Patterns", patterns);
|
||||
final BannerPatternsComponent.Builder patternsBuilder = new BannerPatternsComponent.Builder();
|
||||
if (result.contains(DataComponentTypes.BANNER_PATTERNS)) {
|
||||
patternsBuilder.addAll(result.get(DataComponentTypes.BANNER_PATTERNS));
|
||||
}
|
||||
NbtCompound patternNbt = new NbtCompound();
|
||||
patternNbt.putString("Pattern", pattern.getId());
|
||||
patternNbt.putInt("Color", color.getId());
|
||||
patterns.add(patternNbt);
|
||||
patternsBuilder.add(new BannerPatternsComponent.Layer(patternKey, color));
|
||||
result.set(DataComponentTypes.BANNER_PATTERNS, patternsBuilder.build());
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -111,7 +106,7 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe {
|
|||
return SERIALIZER;
|
||||
}
|
||||
|
||||
private static BannerPattern_1_13_2 getBannerPattern(RecipeInputInventory inv) {
|
||||
private static BannerPattern_1_13_2 getBannerPattern(CraftingRecipeInput inv) {
|
||||
for (BannerPattern_1_13_2 pattern : BannerPattern_1_13_2.values()) {
|
||||
if (!pattern.isCraftable())
|
||||
continue;
|
||||
|
@ -120,8 +115,8 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe {
|
|||
if (pattern.hasBaseStack()) {
|
||||
boolean foundBaseItem = false;
|
||||
boolean foundDye = false;
|
||||
for (int i = 0; i < inv.size(); i++) {
|
||||
ItemStack stack = inv.getStack(i);
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if (!stack.isEmpty() && !(stack.getItem() instanceof BannerItem)) {
|
||||
if (stack.getItem() instanceof DyeItem) {
|
||||
if (foundDye) {
|
||||
|
@ -138,13 +133,13 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!foundBaseItem || (!foundDye && ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_10))) matches = false;
|
||||
} else if (inv.size() == pattern.getRecipePattern().length * pattern.getRecipePattern()[0].length()) {
|
||||
if (!foundBaseItem || (!foundDye && ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_10))) matches = false;
|
||||
} else if (inv.getSize() == pattern.getRecipePattern().length * pattern.getRecipePattern()[0].length()) {
|
||||
DyeColor patternColor = null;
|
||||
for (int i = 0; i < inv.size(); i++) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
int row = i / 3;
|
||||
int col = i % 3;
|
||||
ItemStack stack = inv.getStack(i);
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
Item item = stack.getItem();
|
||||
if (!stack.isEmpty() && !(item instanceof BannerItem)) {
|
||||
if (!(item instanceof DyeItem)) {
|
||||
|
|
|
@ -20,76 +20,79 @@
|
|||
package de.florianmichael.viafabricplus.fixes.data.recipe;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.BannerPattern;
|
||||
import net.minecraft.block.entity.BannerPatterns;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
|
||||
public enum BannerPattern_1_13_2 {
|
||||
|
||||
BASE("b"),
|
||||
SQUARE_BOTTOM_LEFT("bl", " ", " ", "# "),
|
||||
SQUARE_BOTTOM_RIGHT("br", " ", " ", " #"),
|
||||
SQUARE_TOP_LEFT("tl", "# ", " ", " "),
|
||||
SQUARE_TOP_RIGHT("tr", " #", " ", " "),
|
||||
STRIPE_BOTTOM("bs", " ", " ", "###"),
|
||||
STRIPE_TOP("ts", "###", " ", " "),
|
||||
STRIPE_LEFT("ls", "# ", "# ", "# "),
|
||||
STRIPE_RIGHT("rs", " #", " #", " #"),
|
||||
STRIPE_CENTER("cs", " # ", " # ", " # "),
|
||||
STRIPE_MIDDLE("ms", " ", "###", " "),
|
||||
STRIPE_DOWNRIGHT("drs", "# ", " # ", " #"),
|
||||
STRIPE_DOWNLEFT("dls", " #", " # ", "# "),
|
||||
STRIPE_SMALL("ss", "# #", "# #", " "),
|
||||
CROSS("cr", "# #", " # ", "# #"),
|
||||
STRAIGHT_CROSS("sc", " # ", "###", " # "),
|
||||
TRIANGLE_BOTTOM("bt", " ", " # ", "# #"),
|
||||
TRIANGLE_TOP("tt", "# #", " # ", " "),
|
||||
TRIANGLES_BOTTOM("bts", " ", "# #", " # "),
|
||||
TRIANGLES_TOP("tts", " # ", "# #", " "),
|
||||
DIAGONAL_LEFT("ld", "## ", "# ", " "),
|
||||
DIAGONAL_RIGHT("rd", " ", " #", " ##"),
|
||||
DIAGONAL_LEFT_MIRROR("lud", " ", "# ", "## "),
|
||||
DIAGONAL_RIGHT_MIRROR("rud", " ##", " #", " "),
|
||||
CIRCLE_MIDDLE("mc", " ", " # ", " "),
|
||||
RHOMBUS_MIDDLE("mr", " # ", "# #", " # "),
|
||||
HALF_VERTICAL("vh", "## ", "## ", "## "),
|
||||
HALF_HORIZONTAL("hh", "###", "###", " "),
|
||||
HALF_VERTICAL_MIRROR("vhr", " ##", " ##", " ##"),
|
||||
HALF_HORIZONTAL_MIRROR("hhb", " ", "###", "###"),
|
||||
BORDER("bo", "###", "# #", "###"),
|
||||
CURLY_BORDER("cbo", new ItemStack(Blocks.VINE)),
|
||||
GRADIENT("gra", "# #", " # ", " # "),
|
||||
GRADIENT_UP("gru", " # ", " # ", "# #"),
|
||||
BRICKS("bri", new ItemStack(Blocks.BRICKS)),
|
||||
GLOBE("glb"),
|
||||
CREEPER("cre", new ItemStack(Items.CREEPER_HEAD)),
|
||||
SKULL("sku", new ItemStack(Items.WITHER_SKELETON_SKULL)),
|
||||
FLOWER("flo", new ItemStack(Blocks.OXEYE_DAISY)),
|
||||
MOJANG("moj", new ItemStack(Items.ENCHANTED_GOLDEN_APPLE));
|
||||
BASE(BannerPatterns.BASE),
|
||||
SQUARE_BOTTOM_LEFT(BannerPatterns.SQUARE_BOTTOM_LEFT, " ", " ", "# "),
|
||||
SQUARE_BOTTOM_RIGHT(BannerPatterns.SQUARE_BOTTOM_RIGHT, " ", " ", " #"),
|
||||
SQUARE_TOP_LEFT(BannerPatterns.SQUARE_TOP_LEFT, "# ", " ", " "),
|
||||
SQUARE_TOP_RIGHT(BannerPatterns.SQUARE_TOP_RIGHT, " #", " ", " "),
|
||||
STRIPE_BOTTOM(BannerPatterns.STRIPE_BOTTOM, " ", " ", "###"),
|
||||
STRIPE_TOP(BannerPatterns.STRIPE_TOP, "###", " ", " "),
|
||||
STRIPE_LEFT(BannerPatterns.STRIPE_LEFT, "# ", "# ", "# "),
|
||||
STRIPE_RIGHT(BannerPatterns.STRIPE_RIGHT, " #", " #", " #"),
|
||||
STRIPE_CENTER(BannerPatterns.STRIPE_CENTER, " # ", " # ", " # "),
|
||||
STRIPE_MIDDLE(BannerPatterns.STRIPE_MIDDLE, " ", "###", " "),
|
||||
STRIPE_DOWNRIGHT(BannerPatterns.STRIPE_DOWNRIGHT, "# ", " # ", " #"),
|
||||
STRIPE_DOWNLEFT(BannerPatterns.STRIPE_DOWNLEFT, " #", " # ", "# "),
|
||||
STRIPE_SMALL(BannerPatterns.SMALL_STRIPES, "# #", "# #", " "),
|
||||
CROSS(BannerPatterns.CROSS, "# #", " # ", "# #"),
|
||||
STRAIGHT_CROSS(BannerPatterns.STRAIGHT_CROSS, " # ", "###", " # "),
|
||||
TRIANGLE_BOTTOM(BannerPatterns.TRIANGLE_BOTTOM, " ", " # ", "# #"),
|
||||
TRIANGLE_TOP(BannerPatterns.TRIANGLE_TOP, "# #", " # ", " "),
|
||||
TRIANGLES_BOTTOM(BannerPatterns.TRIANGLES_BOTTOM, " ", "# #", " # "),
|
||||
TRIANGLES_TOP(BannerPatterns.TRIANGLES_TOP, " # ", "# #", " "),
|
||||
DIAGONAL_LEFT(BannerPatterns.DIAGONAL_LEFT, "## ", "# ", " "),
|
||||
DIAGONAL_RIGHT(BannerPatterns.DIAGONAL_RIGHT, " ", " #", " ##"),
|
||||
DIAGONAL_LEFT_MIRROR(BannerPatterns.DIAGONAL_UP_LEFT, " ", "# ", "## "),
|
||||
DIAGONAL_RIGHT_MIRROR(BannerPatterns.DIAGONAL_UP_RIGHT, " ##", " #", " "),
|
||||
CIRCLE_MIDDLE(BannerPatterns.CIRCLE, " ", " # ", " "),
|
||||
RHOMBUS_MIDDLE(BannerPatterns.RHOMBUS, " # ", "# #", " # "),
|
||||
HALF_VERTICAL(BannerPatterns.HALF_VERTICAL, "## ", "## ", "## "),
|
||||
HALF_HORIZONTAL(BannerPatterns.HALF_HORIZONTAL, "###", "###", " "),
|
||||
HALF_VERTICAL_MIRROR(BannerPatterns.HALF_VERTICAL_RIGHT, " ##", " ##", " ##"),
|
||||
HALF_HORIZONTAL_MIRROR(BannerPatterns.HALF_HORIZONTAL_BOTTOM, " ", "###", "###"),
|
||||
BORDER(BannerPatterns.BORDER, "###", "# #", "###"),
|
||||
CURLY_BORDER(BannerPatterns.CURLY_BORDER, new ItemStack(Blocks.VINE)),
|
||||
GRADIENT(BannerPatterns.GRADIENT, "# #", " # ", " # "),
|
||||
GRADIENT_UP(BannerPatterns.GRADIENT_UP, " # ", " # ", "# #"),
|
||||
BRICKS(BannerPatterns.BRICKS, new ItemStack(Blocks.BRICKS)),
|
||||
GLOBE(BannerPatterns.GLOBE),
|
||||
CREEPER(BannerPatterns.CREEPER, new ItemStack(Items.CREEPER_HEAD)),
|
||||
SKULL(BannerPatterns.SKULL, new ItemStack(Items.WITHER_SKELETON_SKULL)),
|
||||
FLOWER(BannerPatterns.FLOWER, new ItemStack(Blocks.OXEYE_DAISY)),
|
||||
MOJANG(BannerPatterns.MOJANG, new ItemStack(Items.ENCHANTED_GOLDEN_APPLE));
|
||||
|
||||
private final String id;
|
||||
private final RegistryKey<BannerPattern> pattern;
|
||||
private final String[] recipePattern;
|
||||
private ItemStack baseStack;
|
||||
|
||||
BannerPattern_1_13_2(String id) {
|
||||
BannerPattern_1_13_2(final RegistryKey<BannerPattern> pattern) {
|
||||
this.recipePattern = new String[3];
|
||||
this.baseStack = ItemStack.EMPTY;
|
||||
this.id = id;
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
BannerPattern_1_13_2(String id, ItemStack baseStack) {
|
||||
this(id);
|
||||
BannerPattern_1_13_2(final RegistryKey<BannerPattern> pattern, final ItemStack baseStack) {
|
||||
this(pattern);
|
||||
this.baseStack = baseStack;
|
||||
}
|
||||
|
||||
BannerPattern_1_13_2(String id, String recipe1, String recipe2, String recipe3) {
|
||||
this(id);
|
||||
BannerPattern_1_13_2(final RegistryKey<BannerPattern> pattern, final String recipe1, final String recipe2, final String recipe3) {
|
||||
this(pattern);
|
||||
this.recipePattern[0] = recipe1;
|
||||
this.recipePattern[1] = recipe2;
|
||||
this.recipePattern[2] = recipe3;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
public RegistryKey<BannerPattern> getKey() {
|
||||
return this.pattern;
|
||||
}
|
||||
|
||||
public boolean isCraftable() {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.fixes.data.recipe;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.inventory.RecipeInputInventory;
|
||||
|
@ -30,7 +31,8 @@ import net.minecraft.recipe.*;
|
|||
import net.minecraft.recipe.book.CraftingRecipeCategory;
|
||||
import net.minecraft.registry.tag.ItemTags;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -43,30 +45,30 @@ public class Recipes1_11_2 {
|
|||
/**
|
||||
* @return A list of all recipes for the given version.
|
||||
*/
|
||||
public static List<RecipeInfo> getRecipes(final VersionEnum targetVersion) {
|
||||
public static List<RecipeInfo> getRecipes(final ProtocolVersion targetVersion) {
|
||||
final List<RecipeInfo> recipes = new ArrayList<>();
|
||||
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_4_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_4_2)) {
|
||||
recipes.add(RecipeInfo.of(() -> new ArmorDyeRecipe(CraftingRecipeCategory.MISC)));
|
||||
recipes.add(RecipeInfo.of(() -> new MapCloningRecipe(CraftingRecipeCategory.MISC)));
|
||||
recipes.add(RecipeInfo.of(() -> new MapExtendingRecipe(CraftingRecipeCategory.MISC)));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_4_6tor1_4_7)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_4_6tor1_4_7)) {
|
||||
recipes.add(RecipeInfo.of(() -> new FireworkRocketRecipe(CraftingRecipeCategory.MISC)));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_11)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_11)) {
|
||||
recipes.add(RecipeInfo.of(() -> new ShulkerBoxColoringRecipe(CraftingRecipeCategory.MISC)));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_9)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_9)) {
|
||||
recipes.add(RecipeInfo.of(() -> new TippedArrowRecipe(CraftingRecipeCategory.MISC)));
|
||||
recipes.add(RecipeInfo.of(() -> new ShieldDecorationRecipe(CraftingRecipeCategory.MISC)));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
recipes.add(RecipeInfo.of(() -> new RepairItemRecipe(CraftingRecipeCategory.MISC)));
|
||||
recipes.add(RecipeInfo.of(() -> new BannerDuplicateRecipe(CraftingRecipeCategory.MISC)));
|
||||
recipes.add(RecipeInfo.of(() -> new AddBannerPatternRecipe(CraftingRecipeCategory.MISC)));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_7_2tor1_7_5)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_7_2)) {
|
||||
recipes.add(RecipeInfo.of(() -> new BookCloningRecipe(CraftingRecipeCategory.MISC)));
|
||||
}
|
||||
|
||||
|
@ -144,7 +146,7 @@ public class Recipes1_11_2 {
|
|||
recipes.add(RecipeInfo.shaped(Blocks.BOOKSHELF, "###", "XXX", "###", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS, 'X', Items.BOOK));
|
||||
recipes.add(RecipeInfo.shaped(4, Items.ARROW, "X", "#", "Y", '#', Items.STICK, 'X', Items.FLINT, 'Y', Items.FEATHER));
|
||||
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_12)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_12)) {
|
||||
recipes.add(RecipeInfo.shapeless("concrete_powder", 8, Blocks.YELLOW_CONCRETE_POWDER, Items.YELLOW_DYE, Blocks.SAND, Blocks.SAND, Blocks.SAND, Blocks.SAND, Blocks.GRAVEL, Blocks.GRAVEL, Blocks.GRAVEL, Blocks.GRAVEL));
|
||||
recipes.add(RecipeInfo.shapeless("concrete_powder", 8, Blocks.WHITE_CONCRETE_POWDER, Items.BONE_MEAL, Blocks.SAND, Blocks.SAND, Blocks.SAND, Blocks.SAND, Blocks.GRAVEL, Blocks.GRAVEL, Blocks.GRAVEL, Blocks.GRAVEL));
|
||||
recipes.add(RecipeInfo.shapeless("concrete_powder", 8, Blocks.RED_CONCRETE_POWDER, Items.RED_DYE, Blocks.SAND, Blocks.SAND, Blocks.SAND, Blocks.SAND, Blocks.GRAVEL, Blocks.GRAVEL, Blocks.GRAVEL, Blocks.GRAVEL));
|
||||
|
@ -194,26 +196,26 @@ public class Recipes1_11_2 {
|
|||
recipes.add(RecipeInfo.shaped("bed", Blocks.BLACK_BED, "###", "XXX", '#', Blocks.BLACK_WOOL, 'X', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS));
|
||||
} else {
|
||||
recipes.add(RecipeInfo.shapeless(Blocks.WHITE_WOOL, Blocks.WHITE_WOOL, Items.BONE_MEAL));
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_3tob1_3_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_3tob1_3_1)) {
|
||||
recipes.add(RecipeInfo.shaped("bed", Blocks.RED_BED, "###", "XXX", '#', Blocks.YELLOW_WOOL, Blocks.BLACK_WOOL, Blocks.BLUE_WOOL, Blocks.BROWN_WOOL, Blocks.CYAN_WOOL, Blocks.GRAY_WOOL, Blocks.GREEN_WOOL, Blocks.LIGHT_BLUE_WOOL, Blocks.LIGHT_GRAY_WOOL, Blocks.WHITE_WOOL, Blocks.RED_WOOL, Blocks.PURPLE_WOOL, Blocks.PINK_WOOL, Blocks.ORANGE_WOOL, Blocks.LIME_WOOL, Blocks.MAGENTA_WOOL, 'X', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS));
|
||||
}
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_11_1to1_11_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_11_1)) {
|
||||
recipes.add(RecipeInfo.shaped(9, Items.IRON_NUGGET, "#", '#', Items.IRON_INGOT));
|
||||
recipes.add(RecipeInfo.shaped("iron_ingot", Items.IRON_INGOT, "###", "###", "###", '#', Items.IRON_NUGGET));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_11)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_11)) {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.OBSERVER, "###", "RRQ", "###", 'Q', Items.QUARTZ, 'R', Blocks.REDSTONE_WIRE, '#', Blocks.COBBLESTONE));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.PURPLE_SHULKER_BOX, "-", "#", "-", '#', Blocks.CHEST, '-', Items.SHULKER_SHELL));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_10)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_10)) {
|
||||
recipes.add(RecipeInfo.shapeless("bonemeal", 9, Items.BONE_MEAL, Blocks.BONE_BLOCK));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.BONE_BLOCK, "XXX", "XXX", "XXX", 'X', Items.BONE_MEAL));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.MAGMA_BLOCK, "##", "##", '#', Items.MAGMA_CREAM));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.NETHER_WART_BLOCK, "###", "###", "###", '#', Blocks.NETHER_WART));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.RED_NETHER_BRICKS, "NW", "WN", 'W', Blocks.NETHER_WART, 'N', Items.NETHER_BRICK));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_9)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_9)) {
|
||||
recipes.add(RecipeInfo.shapeless(Blocks.TRAPPED_CHEST, Blocks.CHEST, Blocks.TRIPWIRE_HOOK));
|
||||
recipes.add(RecipeInfo.shaped(Items.SHIELD, "WoW", "WWW", " W ", 'W', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS, 'o', Items.IRON_INGOT));
|
||||
recipes.add(RecipeInfo.shaped(4, Blocks.PURPUR_BLOCK, "FF", "FF", 'F', Items.POPPED_CHORUS_FRUIT));
|
||||
|
@ -233,15 +235,15 @@ public class Recipes1_11_2 {
|
|||
recipes.add(RecipeInfo.shapeless("red_dye", Items.RED_DYE, Items.BEETROOT));
|
||||
recipes.add(RecipeInfo.shaped(Items.BEETROOT_SOUP, "OOO", "OOO", " B ", 'B', Items.BOWL, 'O', Items.BEETROOT));
|
||||
} else {
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_5tor1_5_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_5tor1_5_1)) {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.TRAPPED_CHEST, "#-", '#', Blocks.CHEST, '-', Blocks.TRIPWIRE_HOOK));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_3_1tor1_3_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_3_1tor1_3_2)) {
|
||||
recipes.add(RecipeInfo.shaped(Items.ENCHANTED_GOLDEN_APPLE, "###", "#X#", "###", '#', Items.GOLD_BLOCK, 'X', Items.APPLE));
|
||||
}
|
||||
recipes.add(RecipeInfo.shaped("boat", Items.OAK_BOAT, "# #", "###", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.DARK_OAK_PLANKS, Blocks.BIRCH_PLANKS, Blocks.ACACIA_PLANKS));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
recipes.add(RecipeInfo.shapeless(Blocks.MOSSY_COBBLESTONE, Blocks.COBBLESTONE, Blocks.VINE));
|
||||
recipes.add(RecipeInfo.shapeless(Blocks.MOSSY_STONE_BRICKS, Blocks.STONE_BRICKS, Blocks.VINE));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.CHISELED_STONE_BRICKS, "#", "#", '#', Blocks.STONE_BRICK_SLAB));
|
||||
|
@ -305,13 +307,13 @@ public class Recipes1_11_2 {
|
|||
recipes.add(RecipeInfo.shaped(4, Blocks.POLISHED_ANDESITE, "SS", "SS", 'S', Blocks.ANDESITE));
|
||||
} else {
|
||||
recipes.add(RecipeInfo.shaped("wooden_fence", 2, Blocks.OAK_FENCE, "###", "###", '#', Items.STICK));
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
|
||||
recipes.add(RecipeInfo.shaped("wooden_fence_gate", Blocks.OAK_FENCE_GATE, "#W#", "#W#", '#', Items.STICK, 'W', Blocks.OAK_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.DARK_OAK_PLANKS, Blocks.BIRCH_PLANKS, Blocks.ACACIA_PLANKS));
|
||||
}
|
||||
recipes.add(RecipeInfo.shaped(Blocks.IRON_DOOR, "##", "##", "##", '#', Items.IRON_INGOT));
|
||||
recipes.add(RecipeInfo.shaped("wooden_door", Blocks.OAK_DOOR, "##", "##", "##", '#', Blocks.OAK_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.DARK_OAK_PLANKS, Blocks.BIRCH_PLANKS, Blocks.ACACIA_PLANKS));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_7_2tor1_7_5)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_7_2)) {
|
||||
recipes.add(RecipeInfo.shaped("stained_glass", 8, Blocks.YELLOW_STAINED_GLASS, "###", "#X#", "###", '#', Blocks.GLASS, 'X', Items.YELLOW_DYE));
|
||||
recipes.add(RecipeInfo.shaped("stained_glass", 8, Blocks.WHITE_STAINED_GLASS, "###", "#X#", "###", '#', Blocks.GLASS, 'X', Items.BONE_MEAL));
|
||||
recipes.add(RecipeInfo.shaped("stained_glass", 8, Blocks.RED_STAINED_GLASS, "###", "#X#", "###", '#', Blocks.GLASS, 'X', Items.RED_DYE));
|
||||
|
@ -368,7 +370,7 @@ public class Recipes1_11_2 {
|
|||
recipes.add(RecipeInfo.shaped(Items.FLINT_AND_STEEL, "A ", " B", 'A', Items.IRON_INGOT, 'B', Items.FLINT));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.TNT, "X#X", "#X#", "X#X", '#', Blocks.SAND, 'X', Items.GUNPOWDER));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_6_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_6_1)) {
|
||||
recipes.add(RecipeInfo.shaped(Items.GOLDEN_APPLE, "###", "#X#", "###", '#', Items.GOLD_INGOT, 'X', Items.APPLE));
|
||||
recipes.add(RecipeInfo.shaped(Items.GLISTERING_MELON_SLICE, "###", "#X#", "###", '#', Items.GOLD_NUGGET, 'X', Items.MELON_SLICE));
|
||||
recipes.add(RecipeInfo.shaped("carpet", 3, Blocks.YELLOW_CARPET, "##", '#', Blocks.YELLOW_WOOL));
|
||||
|
@ -410,11 +412,11 @@ public class Recipes1_11_2 {
|
|||
recipes.add(RecipeInfo.shaped(9, Items.COAL, "#", '#', Blocks.COAL_BLOCK));
|
||||
} else {
|
||||
recipes.add(RecipeInfo.shaped(Items.GOLDEN_APPLE, "###", "#X#", "###", '#', Items.GOLD_NUGGET, 'X', Items.APPLE));
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_0_0tor1_0_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_0_0tor1_0_1)) {
|
||||
recipes.add(RecipeInfo.shapeless(Items.GLISTERING_MELON_SLICE, Items.GOLD_NUGGET, Items.MELON_SLICE));
|
||||
}
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_5tor1_5_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_5tor1_5_1)) {
|
||||
recipes.add(RecipeInfo.shaped(6, Blocks.SNOW, "###", '#', Blocks.SNOW_BLOCK));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.QUARTZ_BLOCK, "##", "##", '#', Items.QUARTZ));
|
||||
recipes.add(RecipeInfo.shaped(2, Blocks.QUARTZ_PILLAR, "#", "#", '#', Blocks.QUARTZ_BLOCK));
|
||||
|
@ -434,10 +436,10 @@ public class Recipes1_11_2 {
|
|||
recipes.add(RecipeInfo.shaped(Blocks.REDSTONE_BLOCK, "###", "###", "###", '#', Blocks.REDSTONE_WIRE));
|
||||
recipes.add(RecipeInfo.shaped(9, Blocks.REDSTONE_WIRE, "#", '#', Blocks.REDSTONE_BLOCK));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_4_6tor1_4_7)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_4_6tor1_4_7)) {
|
||||
recipes.add(RecipeInfo.shaped(6, Blocks.NETHER_BRICK_SLAB, "###", '#', Blocks.NETHER_BRICKS));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_4_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_4_2)) {
|
||||
recipes.add(RecipeInfo.shaped(6, Blocks.COBBLESTONE_WALL, "###", "###", '#', Blocks.COBBLESTONE));
|
||||
recipes.add(RecipeInfo.shaped(6, Blocks.MOSSY_COBBLESTONE_WALL, "###", "###", '#', Blocks.MOSSY_COBBLESTONE));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.FLOWER_POT, "# #", " # ", '#', Items.BRICK));
|
||||
|
@ -449,7 +451,7 @@ public class Recipes1_11_2 {
|
|||
recipes.add(RecipeInfo.shaped(Blocks.BEACON, "GGG", "GSG", "OOO", 'S', Items.NETHER_STAR, 'G', Blocks.GLASS, 'O', Blocks.OBSIDIAN));
|
||||
recipes.add(RecipeInfo.shapeless(Items.PUMPKIN_PIE, Blocks.CARVED_PUMPKIN, Items.SUGAR, Items.EGG));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_3_1tor1_3_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_3_1tor1_3_2)) {
|
||||
recipes.add(RecipeInfo.shapeless(Items.WRITABLE_BOOK, Items.BOOK, Items.INK_SAC, Items.FEATHER));
|
||||
recipes.add(RecipeInfo.shapeless(Items.BOOK, Items.PAPER, Items.PAPER, Items.PAPER, Items.LEATHER));
|
||||
recipes.add(RecipeInfo.shaped(3, Blocks.OAK_SIGN, "###", "###", " X ", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS, 'X', Items.STICK));
|
||||
|
@ -466,17 +468,17 @@ public class Recipes1_11_2 {
|
|||
recipes.add(RecipeInfo.shaped(Blocks.EMERALD_BLOCK, "###", "###", "###", '#', Items.EMERALD));
|
||||
recipes.add(RecipeInfo.shaped(9, Items.EMERALD, "#", '#', Blocks.EMERALD_BLOCK));
|
||||
} else {
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_2_1tor1_2_3)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_2_1tor1_2_3)) {
|
||||
recipes.add(RecipeInfo.shaped("wooden_slab", 6, Blocks.OAK_SLAB, "###", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS));
|
||||
} else {
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_3tob1_3_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_3tob1_3_1)) {
|
||||
recipes.add(RecipeInfo.shaped("wooden_slab", 3, Blocks.OAK_SLAB, "###", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS));
|
||||
}
|
||||
}
|
||||
recipes.add(RecipeInfo.shaped(Items.BOOK, "#", "#", "#", '#', Items.PAPER));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.OAK_SIGN, "###", "###", " X ", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS, 'X', Items.STICK));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_2_4tor1_2_5)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_2_4tor1_2_5)) {
|
||||
recipes.add(RecipeInfo.shaped("planks", 4, Blocks.BIRCH_PLANKS, "#", '#', Blocks.BIRCH_LOG));
|
||||
recipes.add(RecipeInfo.shaped("planks", 4, Blocks.SPRUCE_PLANKS, "#", '#', Blocks.SPRUCE_LOG));
|
||||
recipes.add(RecipeInfo.shaped("planks", 4, Blocks.JUNGLE_PLANKS, "#", '#', Blocks.JUNGLE_LOG));
|
||||
|
@ -485,7 +487,7 @@ public class Recipes1_11_2 {
|
|||
} else {
|
||||
recipes.add(RecipeInfo.shaped("planks", 4, Blocks.OAK_PLANKS, "#", '#', Blocks.BIRCH_LOG, Blocks.SPRUCE_LOG, Blocks.JUNGLE_LOG));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_2_1tor1_2_3)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_2_1tor1_2_3)) {
|
||||
recipes.add(RecipeInfo.shaped(3, Blocks.LADDER, "# #", "###", "# #", '#', Items.STICK));
|
||||
recipes.add(RecipeInfo.shaped(6, Blocks.SMOOTH_STONE_SLAB, "###", '#', Blocks.STONE));
|
||||
recipes.add(RecipeInfo.shaped(6, Blocks.SANDSTONE_SLAB, "###", '#', Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE));
|
||||
|
@ -495,22 +497,22 @@ public class Recipes1_11_2 {
|
|||
recipes.add(RecipeInfo.shaped(Blocks.REDSTONE_LAMP, " R ", "RGR", " R ", 'R', Blocks.REDSTONE_WIRE, 'G', Blocks.GLOWSTONE));
|
||||
recipes.add(RecipeInfo.shapeless(3, Items.FIRE_CHARGE, new ItemConvertible[]{Items.GUNPOWDER}, new ItemConvertible[]{Items.BLAZE_POWDER}, new ItemConvertible[]{Items.COAL, Items.CHARCOAL}));
|
||||
} else {
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_5tob1_5_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_5tob1_5_2)) {
|
||||
recipes.add(RecipeInfo.shaped(2, Blocks.LADDER, "# #", "###", "# #", '#', Items.STICK));
|
||||
} else {
|
||||
recipes.add(RecipeInfo.shaped(1, Blocks.LADDER, "# #", "###", "# #", '#', Items.STICK));
|
||||
}
|
||||
recipes.add(RecipeInfo.shaped(3, Blocks.SMOOTH_STONE_SLAB, "###", '#', Blocks.STONE));
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_3tob1_3_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_3tob1_3_1)) {
|
||||
recipes.add(RecipeInfo.shaped(3, Blocks.SANDSTONE_SLAB, "###", '#', Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE));
|
||||
recipes.add(RecipeInfo.shaped(3, Blocks.COBBLESTONE_SLAB, "###", '#', Blocks.COBBLESTONE));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
|
||||
recipes.add(RecipeInfo.shaped(3, Blocks.BRICK_SLAB, "###", '#', Blocks.BRICKS));
|
||||
recipes.add(RecipeInfo.shaped(3, Blocks.STONE_BRICK_SLAB, "###", '#', Blocks.STONE_BRICKS, Blocks.MOSSY_STONE_BRICKS, Blocks.CRACKED_STONE_BRICKS, Blocks.CHISELED_STONE_BRICKS));
|
||||
}
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_0_0tor1_0_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_0_0tor1_0_1)) {
|
||||
recipes.add(RecipeInfo.shapeless(Items.MUSHROOM_STEW, Blocks.BROWN_MUSHROOM, Blocks.RED_MUSHROOM, Items.BOWL));
|
||||
recipes.add(RecipeInfo.shaped(4, Blocks.NETHER_BRICK_STAIRS, "# ", "## ", "###", '#', Blocks.NETHER_BRICKS));
|
||||
recipes.add(RecipeInfo.shaped(6, Blocks.NETHER_BRICK_FENCE, "###", "###", '#', Blocks.NETHER_BRICKS));
|
||||
|
@ -529,7 +531,7 @@ public class Recipes1_11_2 {
|
|||
recipes.add(RecipeInfo.shaped(Items.MUSHROOM_STEW, "Y", "X", "#", 'X', Blocks.BROWN_MUSHROOM, 'Y', Blocks.RED_MUSHROOM, '#', Items.BOWL));
|
||||
recipes.add(RecipeInfo.shaped(Items.MUSHROOM_STEW, "Y", "X", "#", 'X', Blocks.RED_MUSHROOM, 'Y', Blocks.BROWN_MUSHROOM, '#', Items.BOWL));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
|
||||
recipes.add(RecipeInfo.shaped(4, Blocks.BRICK_STAIRS, "# ", "## ", "###", '#', Blocks.BRICKS));
|
||||
recipes.add(RecipeInfo.shaped(4, Blocks.STONE_BRICK_STAIRS, "# ", "## ", "###", '#', Blocks.STONE_BRICKS, Blocks.MOSSY_STONE_BRICKS, Blocks.CRACKED_STONE_BRICKS, Blocks.CHISELED_STONE_BRICKS));
|
||||
recipes.add(RecipeInfo.shaped(4, Blocks.STONE_BRICKS, "##", "##", '#', Blocks.STONE));
|
||||
|
@ -538,30 +540,30 @@ public class Recipes1_11_2 {
|
|||
recipes.add(RecipeInfo.shaped(Blocks.MELON, "MMM", "MMM", "MMM", 'M', Items.MELON_SLICE));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.MELON_STEM, "M", 'M', Items.MELON_SLICE));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_7tob1_7_3)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_7tob1_7_3)) {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.STICKY_PISTON, "S", "P", 'P', Blocks.PISTON, 'S', Items.SLIME_BALL));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.PISTON, "TTT", "#X#", "#R#", 'R', Blocks.REDSTONE_WIRE, '#', Blocks.COBBLESTONE, 'T', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS, 'X', Items.IRON_INGOT));
|
||||
recipes.add(RecipeInfo.shaped(Items.SHEARS, " #", "# ", '#', Items.IRON_INGOT));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_6tob1_6_6)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_6tob1_6_6)) {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.GLOWSTONE, "##", "##", '#', Items.GLOWSTONE_DUST));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.WHITE_WOOL, "##", "##", '#', Blocks.TRIPWIRE));
|
||||
recipes.add(RecipeInfo.shaped(2, Blocks.OAK_TRAPDOOR, "###", "###", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS));
|
||||
recipes.add(RecipeInfo.shaped(Items.MAP, "###", "#X#", "###", '#', Items.PAPER, 'X', Items.COMPASS));
|
||||
} else {
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.a1_2_0toa1_2_1_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.a1_2_0toa1_2_1_1)) {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.GLOWSTONE, "###", "###", "###", '#', Items.GLOWSTONE_DUST));
|
||||
}
|
||||
recipes.add(RecipeInfo.shaped(Blocks.WHITE_WOOL, "###", "###", "###", '#', Blocks.TRIPWIRE));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_5tob1_5_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_5tob1_5_2)) {
|
||||
recipes.add(RecipeInfo.shaped(6, Blocks.DETECTOR_RAIL, "X X", "X#X", "XRX", 'R', Blocks.REDSTONE_WIRE, '#', Blocks.STONE_PRESSURE_PLATE, 'X', Items.IRON_INGOT));
|
||||
recipes.add(RecipeInfo.shaped(6, Blocks.POWERED_RAIL, "X X", "X#X", "XRX", 'R', Blocks.REDSTONE_WIRE, '#', Items.STICK, 'X', Items.GOLD_INGOT));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_4tob1_4_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_4tob1_4_1)) {
|
||||
recipes.add(RecipeInfo.shaped(8, Items.COOKIE, "#X#", '#', Items.WHEAT, 'X', Blocks.COCOA));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_3tob1_3_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_3tob1_3_1)) {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.REPEATER, "#X#", "III", '#', Blocks.REDSTONE_TORCH, 'X', Blocks.REDSTONE_WIRE, 'I', Blocks.STONE));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.OAK_PRESSURE_PLATE, "##", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.STONE_PRESSURE_PLATE, "##", '#', Blocks.STONE));
|
||||
|
@ -569,7 +571,7 @@ public class Recipes1_11_2 {
|
|||
recipes.add(RecipeInfo.shaped(Blocks.OAK_PRESSURE_PLATE, "###", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.STONE_PRESSURE_PLATE, "###", '#', Blocks.STONE));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_2_0tob1_2_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_2_0tob1_2_2)) {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.NOTE_BLOCK, "###", "#X#", "###", '#', Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS, 'X', Blocks.REDSTONE_WIRE));
|
||||
recipes.add(RecipeInfo.shaped(Blocks.CAKE, "AAA", "BEB", "CCC", 'A', Items.MILK_BUCKET, 'B', Items.SUGAR, 'C', Items.WHEAT, 'E', Items.EGG));
|
||||
recipes.add(RecipeInfo.shaped(Items.SUGAR, "#", '#', Blocks.SUGAR_CANE));
|
||||
|
@ -611,11 +613,11 @@ public class Recipes1_11_2 {
|
|||
} else {
|
||||
recipes.add(RecipeInfo.shaped(4, Blocks.TORCH, "X", "#", '#', Items.STICK, 'X', Items.COAL));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.a1_2_0toa1_2_1_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.a1_2_0toa1_2_1_1)) {
|
||||
recipes.add(RecipeInfo.shaped(Blocks.JACK_O_LANTERN, "A", "B", 'A', Blocks.CARVED_PUMPKIN, 'B', Blocks.TORCH));
|
||||
recipes.add(RecipeInfo.shaped(Items.CLOCK, " # ", "#X#", " # ", '#', Items.GOLD_INGOT, 'X', Blocks.REDSTONE_WIRE));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.a1_1_0toa1_1_2_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.a1_1_0toa1_1_2_1)) {
|
||||
recipes.add(RecipeInfo.shaped(Items.FISHING_ROD, " #", " #X", "# X", '#', Items.STICK, 'X', Blocks.TRIPWIRE));
|
||||
recipes.add(RecipeInfo.shaped(Items.COMPASS, " # ", "#X#", " # ", '#', Items.IRON_INGOT, 'X', Blocks.REDSTONE_WIRE));
|
||||
}
|
||||
|
@ -628,7 +630,7 @@ public class Recipes1_11_2 {
|
|||
recipes.add(RecipeInfo.smelting(Items.STONE, Items.COBBLESTONE, 0.1F));
|
||||
recipes.add(RecipeInfo.smelting(Items.BRICK, Items.CLAY_BALL, 0.3F));
|
||||
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_12)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_12)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.WHITE_GLAZED_TERRACOTTA, Items.WHITE_TERRACOTTA, 0.1F));
|
||||
recipes.add(RecipeInfo.smelting(Items.ORANGE_GLAZED_TERRACOTTA, Items.ORANGE_TERRACOTTA, 0.1F));
|
||||
recipes.add(RecipeInfo.smelting(Items.MAGENTA_GLAZED_TERRACOTTA, Items.MAGENTA_TERRACOTTA, 0.1F));
|
||||
|
@ -646,47 +648,47 @@ public class Recipes1_11_2 {
|
|||
recipes.add(RecipeInfo.smelting(Items.RED_GLAZED_TERRACOTTA, Items.RED_TERRACOTTA, 0.1F));
|
||||
recipes.add(RecipeInfo.smelting(Items.BLACK_GLAZED_TERRACOTTA, Items.BLACK_TERRACOTTA, 0.1F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_11_1to1_11_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_11_1)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.IRON_NUGGET, Ingredient.ofItems(Items.CHAINMAIL_HELMET, Items.CHAINMAIL_CHESTPLATE, Items.CHAINMAIL_LEGGINGS, Items.CHAINMAIL_BOOTS, Items.IRON_PICKAXE, Items.IRON_SHOVEL, Items.IRON_AXE, Items.IRON_HOE, Items.IRON_SWORD, Items.IRON_HELMET, Items.IRON_CHESTPLATE, Items.IRON_LEGGINGS, Items.IRON_BOOTS, Items.IRON_HORSE_ARMOR), 0.1F));
|
||||
recipes.add(RecipeInfo.smelting(Items.GOLD_NUGGET, Ingredient.ofItems(Items.GOLDEN_PICKAXE, Items.GOLDEN_SHOVEL, Items.GOLDEN_AXE, Items.GOLDEN_HOE, Items.GOLDEN_SWORD, Items.GOLDEN_HELMET, Items.GOLDEN_CHESTPLATE, Items.GOLDEN_LEGGINGS, Items.GOLDEN_BOOTS, Items.GOLDEN_HORSE_ARMOR), 0.1F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_9)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_9)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.POPPED_CHORUS_FRUIT, Items.CHORUS_FRUIT, 0.1F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_7_2tor1_7_5)) {
|
||||
if (targetVersion.newerThanOrEqualTo(ProtocolVersion.v1_7_2)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.COOKED_RABBIT, Items.RABBIT, 0.35F));
|
||||
recipes.add(RecipeInfo.smelting(Items.COOKED_MUTTON, Items.MUTTON, 0.35F));
|
||||
recipes.add(RecipeInfo.smelting(Items.CRACKED_STONE_BRICKS, Items.STONE_BRICKS, 0.1F));
|
||||
recipes.add(RecipeInfo.smelting(Items.SPONGE, Items.WET_SPONGE, 0.15F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_6_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_6_1)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.TERRACOTTA, Items.CLAY, 0.35F));
|
||||
recipes.add(RecipeInfo.smelting(Items.COOKED_SALMON, Items.SALMON, 0.35F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_5tor1_5_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_5tor1_5_1)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.NETHER_BRICK, Items.NETHERRACK, 0.1F));
|
||||
recipes.add(RecipeInfo.smelting(Items.QUARTZ, Items.NETHER_QUARTZ_ORE, 0.2F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_4_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_4_2)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.BAKED_POTATO, Items.POTATO, 0.35F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_3_1tor1_3_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_3_1tor1_3_2)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.EMERALD, Items.EMERALD_ORE, 1.0F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.r1_0_0tor1_0_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.r1_0_0tor1_0_1)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.COAL, Items.COAL_ORE, 0.1F));
|
||||
recipes.add(RecipeInfo.smelting(Items.REDSTONE, Items.REDSTONE_ORE, 0.7F));
|
||||
recipes.add(RecipeInfo.smelting(Items.LAPIS_LAZULI, Items.LAPIS_ORE, 0.2F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.COOKED_CHICKEN, Items.CHICKEN, 0.35F));
|
||||
recipes.add(RecipeInfo.smelting(Items.COOKED_BEEF, Items.BEEF, 0.35F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.b1_2_0tob1_2_2)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.b1_2_0tob1_2_2)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.CHARCOAL, Ingredient.fromTag(ItemTags.LOGS), 0.15F));
|
||||
recipes.add(RecipeInfo.smelting(Items.GREEN_DYE, Items.CACTUS, 0.2F));
|
||||
}
|
||||
if (targetVersion.isNewerThanOrEqualTo(VersionEnum.a1_2_0toa1_2_1_1)) {
|
||||
if (targetVersion.newerThanOrEqualTo(LegacyProtocolVersion.a1_2_0toa1_2_1_1)) {
|
||||
recipes.add(RecipeInfo.smelting(Items.COOKED_COD, Items.COD, 0.35F));
|
||||
}
|
||||
|
||||
|
@ -702,13 +704,15 @@ public class Recipes1_11_2 {
|
|||
* @param screenHandler The screen handler
|
||||
* @param inventory The inventory of the screen handler
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public static void setCraftingResultSlot(final int syncId, final ScreenHandler screenHandler, final RecipeInputInventory inventory) {
|
||||
final var network = MinecraftClient.getInstance().getNetworkHandler();
|
||||
final var world = MinecraftClient.getInstance().world;
|
||||
final var craftingRecipeInput = inventory.createRecipeInput();
|
||||
|
||||
final var result = network.getRecipeManager()
|
||||
.getFirstMatch(RecipeType.CRAFTING, inventory, world) // Get the first matching recipe
|
||||
.map(recipe -> recipe.value().craft(inventory, network.getRegistryManager())) // Craft the recipe to get the result
|
||||
.getFirstMatch(RecipeType.CRAFTING, craftingRecipeInput, world) // Get the first matching recipe
|
||||
.map(recipe -> recipe.value().craft(craftingRecipeInput, network.getRegistryManager())) // Craft the recipe to get the result
|
||||
.orElse(ItemStack.EMPTY); // If there is no recipe, set the result to air
|
||||
|
||||
// Update the result slot
|
||||
|
|
|
@ -1,209 +0,0 @@
|
|||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 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 de.florianmichael.viafabricplus.fixes.entity;
|
||||
|
||||
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.EntityDimensions;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import static de.florianmichael.viafabricplus.util.MapUtil.linkedHashMap;
|
||||
|
||||
/**
|
||||
* Data dump for entity dimension changes between versions.
|
||||
*/
|
||||
public class EntityDimensionReplacements {
|
||||
|
||||
/**
|
||||
* A map of entity types to a map of versions to dimensions.
|
||||
*/
|
||||
private static final Map<EntityType<?>, Map<VersionEnum, EntityDimensions>> ENTITY_DIMENSIONS = linkedHashMap(
|
||||
EntityType.WITHER, linkedHashMap(
|
||||
VersionEnum.r1_7_6tor1_7_10, EntityDimensions.changing(0.9F, 4.0F),
|
||||
VersionEnum.r1_8, EntityType.WITHER.getDimensions()
|
||||
),
|
||||
EntityType.SILVERFISH, linkedHashMap(
|
||||
VersionEnum.r1_7_6tor1_7_10, EntityDimensions.changing(0.3F, 0.7F),
|
||||
VersionEnum.r1_8, EntityType.SILVERFISH.getDimensions()
|
||||
),
|
||||
EntityType.SNOW_GOLEM, linkedHashMap(
|
||||
VersionEnum.r1_7_6tor1_7_10, EntityDimensions.changing(0.4F, 1.8F),
|
||||
VersionEnum.r1_8, EntityType.SNOW_GOLEM.getDimensions()
|
||||
),
|
||||
EntityType.ZOMBIE, linkedHashMap(
|
||||
VersionEnum.r1_7_6tor1_7_10, EntityDimensions.changing(0.6F, 1.8F),
|
||||
VersionEnum.r1_8, EntityDimensions.fixed(EntityType.ZOMBIE.getDimensions().width, EntityType.ZOMBIE.getDimensions().height),
|
||||
VersionEnum.r1_9, EntityType.ZOMBIE.getDimensions()
|
||||
),
|
||||
EntityType.CHICKEN, linkedHashMap(
|
||||
VersionEnum.b1_7tob1_7_3, EntityDimensions.changing(0.3F, 0.4F),
|
||||
VersionEnum.r1_7_6tor1_7_10, EntityDimensions.changing(0.3F, 0.7F),
|
||||
VersionEnum.r1_8, EntityType.CHICKEN.getDimensions()
|
||||
),
|
||||
EntityType.SHEEP, linkedHashMap(
|
||||
VersionEnum.c0_28toc0_30, EntityDimensions.changing(1.4F, 1.72F),
|
||||
VersionEnum.a1_0_15, EntityType.SHEEP.getDimensions()
|
||||
),
|
||||
EntityType.OCELOT, linkedHashMap(
|
||||
VersionEnum.r1_7_6tor1_7_10, EntityDimensions.changing(0.6F, 0.8F),
|
||||
VersionEnum.r1_8, EntityType.OCELOT.getDimensions()
|
||||
),
|
||||
EntityType.BOAT, linkedHashMap(
|
||||
VersionEnum.r1_8, EntityDimensions.changing(1.5F, 0.6F),
|
||||
VersionEnum.r1_9, EntityType.BOAT.getDimensions()
|
||||
),
|
||||
EntityType.CREEPER, linkedHashMap(
|
||||
VersionEnum.r1_8, EntityDimensions.changing(0.6F, 1.8F),
|
||||
VersionEnum.r1_9, EntityType.CREEPER.getDimensions()
|
||||
),
|
||||
EntityType.IRON_GOLEM, linkedHashMap(
|
||||
VersionEnum.r1_8, EntityDimensions.changing(1.4F, 2.9F),
|
||||
VersionEnum.r1_9, EntityType.IRON_GOLEM.getDimensions()
|
||||
),
|
||||
EntityType.SKELETON, linkedHashMap(
|
||||
VersionEnum.r1_7_6tor1_7_10, EntityDimensions.changing(0.6F, 1.8F),
|
||||
VersionEnum.r1_8, EntityDimensions.changing(0.6F, 1.95F),
|
||||
VersionEnum.r1_9, EntityType.SKELETON.getDimensions()
|
||||
),
|
||||
EntityType.WITHER_SKELETON, linkedHashMap(
|
||||
VersionEnum.r1_4_6tor1_4_7, EntityDimensions.changing(0.72F, 2.16F),
|
||||
VersionEnum.r1_7_6tor1_7_10, EntityDimensions.changing(0.72F, 2.34F),
|
||||
VersionEnum.r1_8, EntityDimensions.changing(0.72F, 2.535F),
|
||||
VersionEnum.r1_9, EntityType.WITHER_SKELETON.getDimensions()
|
||||
),
|
||||
EntityType.COW, linkedHashMap(
|
||||
VersionEnum.r1_8, EntityDimensions.changing(0.9F, 1.3F),
|
||||
VersionEnum.r1_9, EntityType.COW.getDimensions()
|
||||
),
|
||||
EntityType.HORSE, linkedHashMap(
|
||||
VersionEnum.r1_8, EntityDimensions.changing(1.4F, 1.6F),
|
||||
VersionEnum.r1_9, EntityType.HORSE.getDimensions()
|
||||
),
|
||||
EntityType.MOOSHROOM, linkedHashMap(
|
||||
VersionEnum.r1_8, EntityDimensions.changing(0.9F, 1.3F),
|
||||
VersionEnum.r1_9, EntityType.MOOSHROOM.getDimensions()
|
||||
),
|
||||
EntityType.RABBIT, linkedHashMap(
|
||||
VersionEnum.r1_8, EntityDimensions.changing(0.6F, 0.7F),
|
||||
VersionEnum.r1_9, EntityType.RABBIT.getDimensions()
|
||||
),
|
||||
EntityType.SQUID, linkedHashMap(
|
||||
VersionEnum.r1_8, EntityDimensions.changing(0.95F, 0.95F),
|
||||
VersionEnum.r1_9, EntityType.SQUID.getDimensions()
|
||||
),
|
||||
EntityType.VILLAGER, linkedHashMap(
|
||||
VersionEnum.r1_8, EntityDimensions.changing(0.6F, 1.8F),
|
||||
VersionEnum.r1_9, EntityType.VILLAGER.getDimensions()
|
||||
),
|
||||
EntityType.WOLF, linkedHashMap(
|
||||
VersionEnum.r1_1, EntityDimensions.changing(0.8F, 0.8F),
|
||||
VersionEnum.r1_8, EntityDimensions.changing(0.6F, 0.8F),
|
||||
VersionEnum.r1_9, EntityType.WOLF.getDimensions()
|
||||
),
|
||||
EntityType.DRAGON_FIREBALL, linkedHashMap(
|
||||
VersionEnum.r1_10, EntityDimensions.changing(0.3125F, 0.3125F),
|
||||
VersionEnum.r1_11, EntityType.DRAGON_FIREBALL.getDimensions()
|
||||
),
|
||||
EntityType.LEASH_KNOT, linkedHashMap(
|
||||
VersionEnum.r1_16_4tor1_16_5, EntityDimensions.changing(0.5F, 0.5F),
|
||||
VersionEnum.r1_17, EntityType.LEASH_KNOT.getDimensions()
|
||||
),
|
||||
EntityType.SLIME, linkedHashMap(
|
||||
VersionEnum.r1_13_2, EntityDimensions.changing(2F, 2F),
|
||||
VersionEnum.r1_14, EntityType.SLIME.getDimensions()
|
||||
),
|
||||
EntityType.MAGMA_CUBE, linkedHashMap(
|
||||
VersionEnum.r1_13_2, EntityDimensions.changing(2F, 2F),
|
||||
VersionEnum.r1_14, EntityType.MAGMA_CUBE.getDimensions()
|
||||
),
|
||||
EntityType.ARROW, linkedHashMap(
|
||||
VersionEnum.c0_28toc0_30, EntityDimensions.changing(0.3F, 0.5F),
|
||||
VersionEnum.a1_0_15, EntityType.ARROW.getDimensions()
|
||||
)
|
||||
);
|
||||
|
||||
static {
|
||||
ChangeProtocolVersionCallback.EVENT.register((oldVersion, newVersion) -> MinecraftClient.getInstance().execute(() -> ENTITY_DIMENSIONS.forEach((entityType, dimensionMap) -> {
|
||||
for (Map.Entry<VersionEnum, EntityDimensions> entry : dimensionMap.entrySet()) {
|
||||
final VersionEnum version = entry.getKey();
|
||||
final EntityDimensions dimensions = entry.getValue();
|
||||
if (oldVersion.isNewerThan(version) && newVersion.isOlderThanOrEqualTo(version)) {
|
||||
entityType.dimensions = dimensions;
|
||||
break;
|
||||
}
|
||||
if (newVersion.isNewerThanOrEqualTo(version) && oldVersion.isOlderThanOrEqualTo(version)) {
|
||||
entityType.dimensions = dimensions;
|
||||
}
|
||||
}
|
||||
})));
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
// Loads the class and triggers the static initializer.
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entityType The {@link EntityType} to get the dimensions for.
|
||||
* @return The dimensions for the given {@link EntityType} or null if there are none. The map is unmodifiable.
|
||||
*/
|
||||
public static Map<VersionEnum, EntityDimensions> getEntityDimensions(final EntityType<?> entityType) {
|
||||
if (!ENTITY_DIMENSIONS.containsKey(entityType)) {
|
||||
return null;
|
||||
}
|
||||
return Collections.unmodifiableMap(ENTITY_DIMENSIONS.get(entityType));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entityType The {@link EntityType} to get the dimensions for.
|
||||
* @param version The {@link VersionEnum} to get the dimensions for.
|
||||
* @return The closest dimensions for the given {@link EntityType} and {@link VersionEnum} or null if there are none.
|
||||
*/
|
||||
public static EntityDimensions getEntityDimensions(final EntityType<?> entityType, final VersionEnum version) {
|
||||
final Map<VersionEnum, EntityDimensions> dimensionMap = getEntityDimensions(entityType);
|
||||
if (dimensionMap == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
EntityDimensions closestDimensions = null;
|
||||
VersionEnum closestVersion = null;
|
||||
|
||||
for (Map.Entry<VersionEnum, EntityDimensions> entry : dimensionMap.entrySet()) {
|
||||
final var currentVersion = entry.getKey();
|
||||
final var currentDimensions = entry.getValue();
|
||||
|
||||
if (currentVersion == version) { // If the version is exactly the same, return the dimensions
|
||||
return currentDimensions;
|
||||
}
|
||||
|
||||
// If the current version is closer to the version you are looking for
|
||||
if (closestVersion == null || Math.abs(version.ordinal() - currentVersion.ordinal()) < Math.abs(version.ordinal() - closestVersion.ordinal())) {
|
||||
closestVersion = currentVersion;
|
||||
closestDimensions = currentDimensions;
|
||||
}
|
||||
}
|
||||
|
||||
return closestDimensions;
|
||||
}
|
||||
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes;
|
||||
package de.florianmichael.viafabricplus.fixes.versioned;
|
||||
|
||||
import net.minecraft.util.ActionResult;
|
||||
|
|
@ -17,19 +17,20 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes;
|
||||
package de.florianmichael.viafabricplus.fixes.versioned;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class ClientPlayerInteractionManager1_18_2 {
|
||||
|
@ -37,10 +38,10 @@ public class ClientPlayerInteractionManager1_18_2 {
|
|||
private final Object2ObjectLinkedOpenHashMap<Pair<BlockPos, PlayerActionC2SPacket.Action>, Pair<Vec3d, Vec2f>> unAckedActions = new Object2ObjectLinkedOpenHashMap<>();
|
||||
|
||||
public void trackPlayerAction(final PlayerActionC2SPacket.Action action, final BlockPos blockPos) {
|
||||
final var player = MinecraftClient.getInstance().player;
|
||||
final ClientPlayerEntity player = MinecraftClient.getInstance().player;
|
||||
|
||||
final Vec2f rotation;
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_1)) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_1)) {
|
||||
rotation = null;
|
||||
} else {
|
||||
rotation = new Vec2f(player.getYaw(), player.getPitch());
|
||||
|
@ -51,14 +52,15 @@ public class ClientPlayerInteractionManager1_18_2 {
|
|||
public void handleBlockBreakAck(final BlockPos blockPos, final BlockState expectedState, final PlayerActionC2SPacket.Action action, final boolean allGood) {
|
||||
final var player = MinecraftClient.getInstance().player;
|
||||
if (player == null) return;
|
||||
|
||||
final var world = MinecraftClient.getInstance().getNetworkHandler().getWorld();
|
||||
|
||||
final var oldPlayerState = unAckedActions.remove(Pair.of(blockPos, action));
|
||||
final var actualState = world.getBlockState(blockPos);
|
||||
|
||||
if ((oldPlayerState == null || !allGood || action != PlayerActionC2SPacket.Action.START_DESTROY_BLOCK && actualState != expectedState) && (actualState != expectedState || ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2))) {
|
||||
if ((oldPlayerState == null || !allGood || action != PlayerActionC2SPacket.Action.START_DESTROY_BLOCK && actualState != expectedState) && (actualState != expectedState || ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2))) {
|
||||
world.setBlockState(blockPos, expectedState, Block.NOTIFY_ALL | Block.FORCE_STATE);
|
||||
if (oldPlayerState != null && (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_1) || (world == player.getWorld() && player.collidesWithStateAtPos(blockPos, expectedState)))) {
|
||||
if (oldPlayerState != null && (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_1) || (world == player.getWorld() && player.collidesWithStateAtPos(blockPos, expectedState)))) {
|
||||
final Vec3d oldPlayerPosition = oldPlayerState.getKey();
|
||||
if (oldPlayerState.getValue() != null) {
|
||||
player.updatePositionAndAngles(oldPlayerPosition.x, oldPlayerPosition.y, oldPlayerPosition.z, oldPlayerState.getValue().x, oldPlayerState.getValue().y);
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 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 de.florianmichael.viafabricplus.fixes.versioned;
|
||||
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.Enchantments;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class Enchantments1_14_4 {
|
||||
|
||||
private static final Map<String, RegistryKey<Enchantment>> ENCHANTMENT_REGISTRY = new HashMap<>();
|
||||
|
||||
static {
|
||||
ENCHANTMENT_REGISTRY.put("protection", Enchantments.PROTECTION);
|
||||
ENCHANTMENT_REGISTRY.put("fire_protection", Enchantments.FIRE_PROTECTION);
|
||||
ENCHANTMENT_REGISTRY.put("feather_falling", Enchantments.FEATHER_FALLING);
|
||||
ENCHANTMENT_REGISTRY.put("blast_protection", Enchantments.BLAST_PROTECTION);
|
||||
ENCHANTMENT_REGISTRY.put("projectile_protection", Enchantments.PROJECTILE_PROTECTION);
|
||||
ENCHANTMENT_REGISTRY.put("respiration", Enchantments.RESPIRATION);
|
||||
ENCHANTMENT_REGISTRY.put("aqua_affinity", Enchantments.AQUA_AFFINITY);
|
||||
ENCHANTMENT_REGISTRY.put("thorns", Enchantments.THORNS);
|
||||
ENCHANTMENT_REGISTRY.put("depth_strider", Enchantments.DEPTH_STRIDER);
|
||||
ENCHANTMENT_REGISTRY.put("frost_walker", Enchantments.FROST_WALKER);
|
||||
ENCHANTMENT_REGISTRY.put("binding_curse", Enchantments.BINDING_CURSE);
|
||||
ENCHANTMENT_REGISTRY.put("sharpness", Enchantments.SHARPNESS);
|
||||
ENCHANTMENT_REGISTRY.put("smite", Enchantments.SMITE);
|
||||
ENCHANTMENT_REGISTRY.put("bane_of_arthropods", Enchantments.BANE_OF_ARTHROPODS);
|
||||
ENCHANTMENT_REGISTRY.put("knockback", Enchantments.KNOCKBACK);
|
||||
ENCHANTMENT_REGISTRY.put("fire_aspect", Enchantments.FIRE_ASPECT);
|
||||
ENCHANTMENT_REGISTRY.put("looting", Enchantments.LOOTING);
|
||||
ENCHANTMENT_REGISTRY.put("sweeping", Enchantments.SWEEPING_EDGE);
|
||||
ENCHANTMENT_REGISTRY.put("efficiency", Enchantments.EFFICIENCY);
|
||||
ENCHANTMENT_REGISTRY.put("silk_touch", Enchantments.SILK_TOUCH);
|
||||
ENCHANTMENT_REGISTRY.put("unbreaking", Enchantments.UNBREAKING);
|
||||
ENCHANTMENT_REGISTRY.put("fortune", Enchantments.FORTUNE);
|
||||
ENCHANTMENT_REGISTRY.put("power", Enchantments.POWER);
|
||||
ENCHANTMENT_REGISTRY.put("punch", Enchantments.PUNCH);
|
||||
ENCHANTMENT_REGISTRY.put("flame", Enchantments.FLAME);
|
||||
ENCHANTMENT_REGISTRY.put("infinity", Enchantments.INFINITY);
|
||||
ENCHANTMENT_REGISTRY.put("luck_of_the_sea", Enchantments.LUCK_OF_THE_SEA);
|
||||
ENCHANTMENT_REGISTRY.put("lure", Enchantments.LURE);
|
||||
ENCHANTMENT_REGISTRY.put("loyalty", Enchantments.LOYALTY);
|
||||
ENCHANTMENT_REGISTRY.put("impaling", Enchantments.IMPALING);
|
||||
ENCHANTMENT_REGISTRY.put("riptide", Enchantments.RIPTIDE);
|
||||
ENCHANTMENT_REGISTRY.put("channeling", Enchantments.CHANNELING);
|
||||
ENCHANTMENT_REGISTRY.put("multishot", Enchantments.MULTISHOT);
|
||||
ENCHANTMENT_REGISTRY.put("quick_charge", Enchantments.QUICK_CHARGE);
|
||||
ENCHANTMENT_REGISTRY.put("piercing", Enchantments.PIERCING);
|
||||
ENCHANTMENT_REGISTRY.put("mending", Enchantments.MENDING);
|
||||
ENCHANTMENT_REGISTRY.put("vanishing_curse", Enchantments.VANISHING_CURSE);
|
||||
}
|
||||
|
||||
public static Optional<RegistryKey<Enchantment>> getOrEmpty(final String identifier) {
|
||||
if (identifier == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.ofNullable(ENCHANTMENT_REGISTRY.get(Key.stripMinecraftNamespace(identifier)));
|
||||
}
|
||||
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.replacement;
|
||||
package de.florianmichael.viafabricplus.fixes.versioned;
|
||||
|
||||
import com.mojang.authlib.yggdrasil.response.KeyPairResponse;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.replacement;
|
||||
package de.florianmichael.viafabricplus.fixes.versioned;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
|
@ -17,13 +17,13 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.classic;
|
||||
package de.florianmichael.viafabricplus.fixes.versioned.classic;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.lenni0451.reflect.Enums;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.ClientboundPacketsc0_30cpe;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.data.ClassicProtocolExtension;
|
||||
import net.raphimc.vialegacy.protocol.classic.c0_30cpetoc0_28_30.data.ClassicProtocolExtension;
|
||||
import net.raphimc.vialegacy.protocol.classic.c0_30cpetoc0_28_30.packet.ClientboundPacketsc0_30cpe;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
|
@ -17,14 +17,16 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.classic;
|
||||
package de.florianmichael.viafabricplus.fixes.versioned.classic;
|
||||
|
||||
import de.florianmichael.viafabricplus.fixes.data.ItemRegistryDiff;
|
||||
import de.florianmichael.viafabricplus.screen.VFPScreen;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.resource.featuretoggle.FeatureFlags;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -55,6 +57,7 @@ public class GridItemSelectionScreen extends VFPScreen {
|
|||
final List<Item> allowedItems = new ArrayList<>();
|
||||
// Calculate all visible items
|
||||
for (Item item : Registries.ITEM) {
|
||||
if (item == Items.AIR || !item.getRequiredFeatures().contains(FeatureFlags.VANILLA)) continue;
|
||||
if (ItemRegistryDiff.keepItem(item)) {
|
||||
allowedItems.add(item);
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.classic;
|
||||
package de.florianmichael.viafabricplus.fixes.versioned.classic;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
|
@ -25,21 +25,20 @@ import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
|||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_17;
|
||||
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;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.model.ClassicLevel;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.providers.ClassicWorldHeightProvider;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.storage.ClassicLevelStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocol.classic.c0_28_30toa1_0_15.model.ClassicLevel;
|
||||
import net.raphimc.vialegacy.protocol.classic.c0_28_30toa1_0_15.provider.ClassicWorldHeightProvider;
|
||||
import net.raphimc.vialegacy.protocol.classic.c0_28_30toa1_0_15.storage.ClassicLevelStorage;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class WorldHeightSupport {
|
||||
|
||||
public static PacketHandler handleJoinGame(final PacketHandler parentHandler) {
|
||||
|
@ -47,11 +46,11 @@ public class WorldHeightSupport {
|
|||
parentHandler.handle(wrapper);
|
||||
if (wrapper.isCancelled()) return;
|
||||
|
||||
if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
for (Tag dimension : wrapper.get(Type.NAMED_COMPOUND_TAG, 0).<CompoundTag>get("minecraft:dimension_type").<ListTag>get("value")) {
|
||||
changeDimensionTagHeight(wrapper.user(), ((CompoundTag) dimension).get("element"));
|
||||
if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
|
||||
for (CompoundTag dimension : wrapper.get(Types.NAMED_COMPOUND_TAG, 0).getCompoundTag("minecraft:dimension_type").getListTag("value", CompoundTag.class)) {
|
||||
changeDimensionTagHeight(wrapper.user(), dimension.getCompoundTag("element"));
|
||||
}
|
||||
changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NAMED_COMPOUND_TAG, 1));
|
||||
changeDimensionTagHeight(wrapper.user(), wrapper.get(Types.NAMED_COMPOUND_TAG, 1));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -61,8 +60,8 @@ public class WorldHeightSupport {
|
|||
parentHandler.handle(wrapper);
|
||||
if (wrapper.isCancelled()) return;
|
||||
|
||||
if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NAMED_COMPOUND_TAG, 0));
|
||||
if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
|
||||
changeDimensionTagHeight(wrapper.user(), wrapper.get(Types.NAMED_COMPOUND_TAG, 0));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -72,7 +71,7 @@ public class WorldHeightSupport {
|
|||
parentHandler.handle(wrapper);
|
||||
if (wrapper.isCancelled()) return;
|
||||
|
||||
if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
|
||||
wrapper.resetReader();
|
||||
final Chunk chunk = wrapper.read(new ChunkType1_17(16));
|
||||
wrapper.write(new ChunkType1_17(chunk.getSections().length), chunk);
|
||||
|
@ -106,14 +105,14 @@ public class WorldHeightSupport {
|
|||
final PacketHandler classicLightHandler = new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // x
|
||||
map(Type.VAR_INT); // y
|
||||
map(Type.BOOLEAN); // trust edges
|
||||
map(Types.VAR_INT); // x
|
||||
map(Types.VAR_INT); // y
|
||||
map(Types.BOOLEAN); // trust edges
|
||||
handler(wrapper -> {
|
||||
wrapper.read(Type.VAR_INT); // sky light mask
|
||||
wrapper.read(Type.VAR_INT); // block light mask
|
||||
final int emptySkyLightMask = wrapper.read(Type.VAR_INT); // empty sky light mask
|
||||
final int emptyBlockLightMask = wrapper.read(Type.VAR_INT); // empty block light mask
|
||||
wrapper.read(Types.VAR_INT); // sky light mask
|
||||
wrapper.read(Types.VAR_INT); // block light mask
|
||||
final int emptySkyLightMask = wrapper.read(Types.VAR_INT); // empty sky light mask
|
||||
final int emptyBlockLightMask = wrapper.read(Types.VAR_INT); // empty block light mask
|
||||
|
||||
final ClassicLevel level = wrapper.user().get(ClassicLevelStorage.class).getClassicLevel();
|
||||
final ClassicWorldHeightProvider heightProvider = Via.getManager().getProviders().get(ClassicWorldHeightProvider.class);
|
||||
|
@ -125,8 +124,8 @@ public class WorldHeightSupport {
|
|||
}
|
||||
|
||||
final List<byte[]> lightArrays = new ArrayList<>();
|
||||
while (wrapper.isReadable(Type.BYTE_ARRAY_PRIMITIVE, 0)) {
|
||||
lightArrays.add(wrapper.read(Type.BYTE_ARRAY_PRIMITIVE));
|
||||
while (wrapper.isReadable(Types.BYTE_ARRAY_PRIMITIVE, 0)) {
|
||||
lightArrays.add(wrapper.read(Types.BYTE_ARRAY_PRIMITIVE));
|
||||
}
|
||||
|
||||
int skyLightCount = 16;
|
||||
|
@ -144,25 +143,25 @@ public class WorldHeightSupport {
|
|||
skyLightMask.set(0, skyLightCount);
|
||||
blockLightMask.set(0, blockLightCount);
|
||||
|
||||
wrapper.write(Type.LONG_ARRAY_PRIMITIVE, skyLightMask.toLongArray());
|
||||
wrapper.write(Type.LONG_ARRAY_PRIMITIVE, blockLightMask.toLongArray());
|
||||
wrapper.write(Type.LONG_ARRAY_PRIMITIVE, new long[emptySkyLightMask]);
|
||||
wrapper.write(Type.LONG_ARRAY_PRIMITIVE, new long[emptyBlockLightMask]);
|
||||
wrapper.write(Types.LONG_ARRAY_PRIMITIVE, skyLightMask.toLongArray());
|
||||
wrapper.write(Types.LONG_ARRAY_PRIMITIVE, blockLightMask.toLongArray());
|
||||
wrapper.write(Types.LONG_ARRAY_PRIMITIVE, new long[emptySkyLightMask]);
|
||||
wrapper.write(Types.LONG_ARRAY_PRIMITIVE, new long[emptyBlockLightMask]);
|
||||
|
||||
wrapper.write(Type.VAR_INT, skyLightCount);
|
||||
wrapper.write(Types.VAR_INT, skyLightCount);
|
||||
for (int i = 0; i < skyLightCount; i++) {
|
||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, lightArrays.remove(0));
|
||||
wrapper.write(Types.BYTE_ARRAY_PRIMITIVE, lightArrays.remove(0));
|
||||
}
|
||||
wrapper.write(Type.VAR_INT, blockLightCount);
|
||||
wrapper.write(Types.VAR_INT, blockLightCount);
|
||||
for (int i = 0; i < blockLightCount; i++) {
|
||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, lightArrays.remove(0));
|
||||
wrapper.write(Types.BYTE_ARRAY_PRIMITIVE, lightArrays.remove(0));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return wrapper -> {
|
||||
if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
|
||||
classicLightHandler.handle(wrapper);
|
||||
} else {
|
||||
parentHandler.handle(wrapper);
|
||||
|
@ -171,7 +170,7 @@ public class WorldHeightSupport {
|
|||
}
|
||||
|
||||
private static void changeDimensionTagHeight(final UserConnection user, final CompoundTag tag) {
|
||||
tag.put("height", new IntTag(Via.getManager().getProviders().get(ClassicWorldHeightProvider.class).getMaxChunkSectionCount(user) << 4));
|
||||
tag.putInt("height", Via.getManager().getProviders().get(ClassicWorldHeightProvider.class).getMaxChunkSectionCount(user) << 4);
|
||||
}
|
||||
|
||||
}
|
|
@ -17,17 +17,16 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.classic.command;
|
||||
package de.florianmichael.viafabricplus.fixes.versioned.classic.command;
|
||||
|
||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.injection.access.IExtensionProtocolMetadataStorage;
|
||||
import de.florianmichael.viafabricplus.protocolhack.impl.command.VFPViaSubCommand;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.impl.command.VFPViaSubCommand;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.storage.ExtensionProtocolMetadataStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocol.classic.c0_30cpetoc0_28_30.storage.ExtensionProtocolMetadataStorage;
|
||||
|
||||
public class ListExtensionsCommand extends VFPViaSubCommand {
|
||||
public class ListExtensionsCommand implements VFPViaSubCommand {
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
|
@ -36,17 +35,16 @@ public class ListExtensionsCommand extends VFPViaSubCommand {
|
|||
|
||||
@Override
|
||||
public String description() {
|
||||
return "Shows all classic extensions (only for " + VersionEnum.c0_30cpe.getName() + ")";
|
||||
return "Shows all classic extensions (only for " + LegacyProtocolVersion.c0_30cpe.getName() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(ViaCommandSender sender, String[] args) {
|
||||
final UserConnection connection = getUser();
|
||||
if (!connection.has(ExtensionProtocolMetadataStorage.class)) {
|
||||
sendMessage(sender, Formatting.RED + "Only for " + VersionEnum.c0_30cpe.getName());
|
||||
if (getUser() == null || !getUser().has(ExtensionProtocolMetadataStorage.class)) {
|
||||
sendMessage(sender, Formatting.RED + "Only for " + LegacyProtocolVersion.c0_30cpe.getName());
|
||||
return true;
|
||||
}
|
||||
((IExtensionProtocolMetadataStorage) connection.get(ExtensionProtocolMetadataStorage.class)).viaFabricPlus$getServerExtensions().forEach((extension, version) -> {
|
||||
((IExtensionProtocolMetadataStorage) getUser().get(ExtensionProtocolMetadataStorage.class)).viaFabricPlus$getServerExtensions().forEach((extension, version) -> {
|
||||
sendMessage(sender, Formatting.GREEN + extension.getName() + Formatting.GOLD + " v" + version);
|
||||
});
|
||||
return true;
|
|
@ -17,16 +17,15 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.classic.command;
|
||||
package de.florianmichael.viafabricplus.fixes.versioned.classic.command;
|
||||
|
||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.protocolhack.impl.command.VFPViaSubCommand;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.impl.command.VFPViaSubCommand;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.raphimc.vialegacy.protocols.alpha.protocola1_0_17_1_0_17_4toa1_0_16_2.storage.TimeLockStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocol.alpha.a1_0_16_2toa1_0_17_1_0_17_4.storage.TimeLockStorage;
|
||||
|
||||
public class SetTimeCommand extends VFPViaSubCommand {
|
||||
public class SetTimeCommand implements VFPViaSubCommand {
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
|
@ -35,7 +34,7 @@ public class SetTimeCommand extends VFPViaSubCommand {
|
|||
|
||||
@Override
|
||||
public String description() {
|
||||
return "Changes the time (Only for <= " + VersionEnum.a1_0_16toa1_0_16_2.getName() + ")";
|
||||
return "Changes the time (Only for <= " + LegacyProtocolVersion.a1_0_16toa1_0_16_2.getName() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,15 +44,14 @@ public class SetTimeCommand extends VFPViaSubCommand {
|
|||
|
||||
@Override
|
||||
public boolean execute(ViaCommandSender sender, String[] args) {
|
||||
final UserConnection connection = getUser();
|
||||
if (!connection.has(TimeLockStorage.class)) {
|
||||
sendMessage(sender, Formatting.RED + "Only for <= " + VersionEnum.a1_0_16toa1_0_16_2.getName());
|
||||
if (getUser() == null || !getUser().has(TimeLockStorage.class)) {
|
||||
sendMessage(sender, Formatting.RED + "Only for <= " + LegacyProtocolVersion.a1_0_16toa1_0_16_2.getName());
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
if (args.length == 1) {
|
||||
final long time = Long.parseLong(args[0]) % 24_000L;
|
||||
connection.get(TimeLockStorage.class).setTime(time);
|
||||
getUser().get(TimeLockStorage.class).setTime(time);
|
||||
sendMessage(sender, Formatting.GREEN + "Time has been set to " + Formatting.GOLD + time);
|
||||
} else {
|
||||
return false;
|
|
@ -17,16 +17,16 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes;
|
||||
package de.florianmichael.viafabricplus.fixes.versioned.visual;
|
||||
|
||||
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_9to1_8.ArmorType;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.data.ArmorTypes1_8;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_9;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
@ -48,7 +48,7 @@ public class ArmorHudEmulation1_8 {
|
|||
}
|
||||
|
||||
if (MinecraftClient.getInstance().player != null) {
|
||||
final UserConnection userConnection = ProtocolHack.getPlayNetworkUserConnection();
|
||||
final UserConnection userConnection = ProtocolTranslator.getPlayNetworkUserConnection();
|
||||
if (userConnection != null) {
|
||||
try {
|
||||
sendArmorUpdate(userConnection);
|
||||
|
@ -62,11 +62,11 @@ public class ArmorHudEmulation1_8 {
|
|||
});
|
||||
}
|
||||
|
||||
private static void sendArmorUpdate(final UserConnection userConnection) throws Exception {
|
||||
private static void sendArmorUpdate(final UserConnection userConnection) {
|
||||
// Calculate the armor points.
|
||||
int armor = 0;
|
||||
for (final ItemStack stack : MinecraftClient.getInstance().player.getInventory().armor) {
|
||||
armor += ArmorType.findByType(Registries.ITEM.getId(stack.getItem()).toString()).getArmorPoints();
|
||||
armor += ArmorTypes1_8.findByType(Registries.ITEM.getId(stack.getItem()).toString()).getArmorPoints();
|
||||
}
|
||||
|
||||
// We only want to update the armor points if they actually changed.
|
||||
|
@ -75,16 +75,16 @@ public class ArmorHudEmulation1_8 {
|
|||
}
|
||||
previousArmorPoints = armor;
|
||||
|
||||
final PacketWrapper entityProperties = PacketWrapper.create(ClientboundPackets1_9.ENTITY_PROPERTIES, userConnection);
|
||||
entityProperties.write(Type.VAR_INT, MinecraftClient.getInstance().player.getId());
|
||||
entityProperties.write(Type.INT, 1);
|
||||
entityProperties.write(Type.STRING, "generic.armor");
|
||||
entityProperties.write(Type.DOUBLE, 0.0D);
|
||||
entityProperties.write(Type.VAR_INT, 1);
|
||||
entityProperties.write(Type.UUID, ARMOR_POINTS_UUID);
|
||||
entityProperties.write(Type.DOUBLE, (double) armor);
|
||||
entityProperties.write(Type.BYTE, (byte) 0);
|
||||
entityProperties.scheduleSend(Protocol1_9To1_8.class);
|
||||
final PacketWrapper updateAttributes = PacketWrapper.create(ClientboundPackets1_9.UPDATE_ATTRIBUTES, userConnection);
|
||||
updateAttributes.write(Types.VAR_INT, MinecraftClient.getInstance().player.getId());
|
||||
updateAttributes.write(Types.INT, 1);
|
||||
updateAttributes.write(Types.STRING, "generic.armor");
|
||||
updateAttributes.write(Types.DOUBLE, 0.0D);
|
||||
updateAttributes.write(Types.VAR_INT, 1);
|
||||
updateAttributes.write(Types.UUID, ARMOR_POINTS_UUID);
|
||||
updateAttributes.write(Types.DOUBLE, (double) armor);
|
||||
updateAttributes.write(Types.BYTE, (byte) 0);
|
||||
updateAttributes.scheduleSend(Protocol1_8To1_9.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.entity;
|
||||
package de.florianmichael.viafabricplus.fixes.versioned.visual;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.client.model.*;
|
||||
|
@ -31,7 +31,7 @@ import net.minecraft.util.Identifier;
|
|||
*/
|
||||
public class BoatModel1_8 extends CompositeEntityModel<BoatEntity> {
|
||||
|
||||
public static final EntityModelLayer MODEL_LAYER = new EntityModelLayer(new Identifier("viafabricplus", "boat1_8"), "main");
|
||||
public static final EntityModelLayer MODEL_LAYER = new EntityModelLayer(Identifier.of("viafabricplus", "boat1_8"), "main");
|
||||
private final ImmutableList<ModelPart> parts;
|
||||
|
||||
public BoatModel1_8(ModelPart root) {
|
|
@ -17,7 +17,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.entity;
|
||||
package de.florianmichael.viafabricplus.fixes.versioned.visual;
|
||||
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
|
@ -35,7 +35,7 @@ import net.minecraft.util.math.RotationAxis;
|
|||
*/
|
||||
public class BoatRenderer1_8 extends EntityRenderer<BoatEntity> {
|
||||
|
||||
private static final Identifier TEXTURE = new Identifier("viafabricplus", "textures/boat1_8.png");
|
||||
private static final Identifier TEXTURE = Identifier.of("viafabricplus", "textures/boat1_8.png");
|
||||
private final BoatModel1_8 model;
|
||||
|
||||
public BoatRenderer1_8(EntityRendererFactory.Context ctx) {
|
||||
|
@ -68,7 +68,7 @@ public class BoatRenderer1_8 extends EntityRenderer<BoatEntity> {
|
|||
matrices.scale(-1, -1, 1);
|
||||
model.setAngles(entity, tickDelta, 0, -0.1f, 0, 0);
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(model.getLayer(TEXTURE));
|
||||
model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
|
||||
model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
|
||||
matrices.pop();
|
||||
super.render(entity, yaw, tickDelta, matrices, vertexConsumers, light);
|
|
@ -17,7 +17,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.replacement;
|
||||
package de.florianmichael.viafabricplus.fixes.versioned.visual;
|
||||
|
||||
import net.minecraft.client.font.Glyph;
|
||||
import net.minecraft.client.font.GlyphRenderer;
|
|
@ -17,9 +17,10 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.entity;
|
||||
package de.florianmichael.viafabricplus.fixes.versioned.visual;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityDimensions;
|
||||
import net.minecraft.entity.EntityPose;
|
||||
|
@ -33,8 +34,7 @@ import net.minecraft.entity.vehicle.AbstractMinecartEntity;
|
|||
import net.minecraft.entity.vehicle.BoatEntity;
|
||||
import net.minecraft.entity.vehicle.ChestBoatEntity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.joml.Vector3f;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
/**
|
||||
* Minecraft 1.20.2 changed the calculation of the mounted height offset for all entities, this class contains the old
|
||||
|
@ -49,18 +49,18 @@ public class EntityRidingOffsetsPre1_20_2 {
|
|||
* @param passenger The passenger of the entity.
|
||||
* @return The mounted height offset.
|
||||
*/
|
||||
public static Vector3f getMountedHeightOffset(final Entity entity, final Entity passenger) {
|
||||
float yOffset = entity.getHeight() * 0.75F;
|
||||
public static Vec3d getMountedHeightOffset(final Entity entity, final Entity passenger) {
|
||||
double yOffset = entity.getHeight() * 0.75F;
|
||||
|
||||
if (entity instanceof BoatEntity boatEntity) {
|
||||
if (!boatEntity.hasPassenger(passenger)) return new Vector3f();
|
||||
if (!boatEntity.hasPassenger(passenger)) return Vec3d.ZERO;
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
yOffset = -0.3F;
|
||||
final float xOffset = MathHelper.cos(boatEntity.getYaw() * MathHelper.PI / 180F);
|
||||
final float zOffset = MathHelper.sin(boatEntity.getYaw() * MathHelper.PI / 180F);
|
||||
final double xOffset = MathHelper.cos(boatEntity.getYaw() * MathHelper.PI / 180F);
|
||||
final double zOffset = MathHelper.sin(boatEntity.getYaw() * MathHelper.PI / 180F);
|
||||
|
||||
return new Vector3f(0.4F * xOffset, yOffset, 0.4F * zOffset);
|
||||
return new Vec3d(0.4F * xOffset, yOffset, 0.4F * zOffset);
|
||||
} else {
|
||||
if (boatEntity.isRemoved()) {
|
||||
yOffset = 0.01F;
|
||||
|
@ -68,7 +68,7 @@ public class EntityRidingOffsetsPre1_20_2 {
|
|||
yOffset = boatEntity.getVariant() == BoatEntity.Type.BAMBOO ? 0.25F : -0.1F;
|
||||
}
|
||||
|
||||
float xOffset = boatEntity instanceof ChestBoatEntity ? 0.15F : 0F;
|
||||
double xOffset = boatEntity instanceof ChestBoatEntity ? 0.15F : 0F;
|
||||
if (boatEntity.getPassengerList().size() > 1) {
|
||||
final int idx = boatEntity.getPassengerList().indexOf(passenger);
|
||||
if (idx == 0) {
|
||||
|
@ -80,34 +80,34 @@ public class EntityRidingOffsetsPre1_20_2 {
|
|||
if (passenger instanceof AnimalEntity) xOffset += 0.2F;
|
||||
}
|
||||
|
||||
return new Vector3f(xOffset, yOffset, 0F);
|
||||
return new Vec3d(xOffset, yOffset, 0F);
|
||||
}
|
||||
} else if (entity instanceof CamelEntity camelEntity) {
|
||||
if (!camelEntity.hasPassenger(passenger)) return new Vector3f();
|
||||
if (!camelEntity.hasPassenger(passenger)) return Vec3d.ZERO;
|
||||
|
||||
final boolean firstPassenger = camelEntity.getPassengerList().indexOf(passenger) == 0;
|
||||
yOffset = camelEntity.getDimensions(camelEntity.isSitting() ? EntityPose.SITTING : EntityPose.STANDING).height - (camelEntity.isBaby() ? 0.35F : 0.6F);
|
||||
yOffset = camelEntity.getDimensions(camelEntity.isSitting() ? EntityPose.SITTING : EntityPose.STANDING).height() - (camelEntity.isBaby() ? 0.35F : 0.6F);
|
||||
if (camelEntity.isRemoved()) {
|
||||
yOffset = 0.01F;
|
||||
} else {
|
||||
yOffset = (float) camelEntity.getPassengerAttachmentY(firstPassenger, 0F, EntityDimensions.fixed(0F, (0.375F * camelEntity.getScaleFactor()) + yOffset), camelEntity.getScaleFactor());
|
||||
yOffset = camelEntity.getPassengerAttachmentY(firstPassenger, 0F, EntityDimensions.fixed(0F, (float) ((0.375F * camelEntity.getScaleFactor()) + yOffset)), camelEntity.getScaleFactor());
|
||||
}
|
||||
|
||||
float zOffset = 0.5F;
|
||||
double zOffset = 0.5F;
|
||||
if (camelEntity.getPassengerList().size() > 1) {
|
||||
if (!firstPassenger) zOffset = -0.7F;
|
||||
if (passenger instanceof AnimalEntity) zOffset += 0.2F;
|
||||
}
|
||||
|
||||
return new Vector3f(0, yOffset, zOffset);
|
||||
return new Vec3d(0, yOffset, zOffset);
|
||||
} else if (entity instanceof ChickenEntity chickenEntity) {
|
||||
return new Vector3f(0, (float) (chickenEntity.getBodyY(0.5D) - chickenEntity.getY()), -0.1F);
|
||||
return new Vec3d(0, chickenEntity.getBodyY(0.5D) - chickenEntity.getY(), -0.1F);
|
||||
} else if (entity instanceof EnderDragonEntity enderDragonEntity) {
|
||||
yOffset = enderDragonEntity.body.getHeight();
|
||||
} else if (entity instanceof HoglinEntity hoglinEntity) {
|
||||
yOffset = hoglinEntity.getHeight() - (hoglinEntity.isBaby() ? 0.2F : 0.15F);
|
||||
} else if (entity instanceof LlamaEntity) {
|
||||
return new Vector3f(0, entity.getHeight() * 0.6F, -0.3F);
|
||||
return new Vec3d(0, entity.getHeight() * 0.6F, -0.3F);
|
||||
} else if (entity instanceof PhantomEntity) {
|
||||
yOffset = entity.getStandingEyeHeight();
|
||||
} else if (entity instanceof PiglinEntity) {
|
||||
|
@ -133,12 +133,12 @@ public class EntityRidingOffsetsPre1_20_2 {
|
|||
}
|
||||
|
||||
if (entity instanceof AbstractHorseEntity abstractHorseEntity) {
|
||||
if (abstractHorseEntity.lastAngryAnimationProgress > 0.0f) {
|
||||
return new Vector3f(0, yOffset + 0.15F * abstractHorseEntity.lastAngryAnimationProgress, -0.7F * abstractHorseEntity.lastAngryAnimationProgress);
|
||||
if (abstractHorseEntity.lastAngryAnimationProgress > 0.0F) {
|
||||
return new Vec3d(0, yOffset + 0.15F * abstractHorseEntity.lastAngryAnimationProgress, -0.7F * abstractHorseEntity.lastAngryAnimationProgress);
|
||||
}
|
||||
}
|
||||
|
||||
return new Vector3f(0, yOffset, 0);
|
||||
return new Vec3d(0, yOffset, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,7 +149,7 @@ public class EntityRidingOffsetsPre1_20_2 {
|
|||
*/
|
||||
public static double getHeightOffset(final Entity entity) {
|
||||
if (entity instanceof AllayEntity || entity instanceof VexEntity) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
|
||||
return 0D;
|
||||
} else {
|
||||
return 0.4D;
|
|
@ -17,28 +17,29 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.particle;
|
||||
package de.florianmichael.viafabricplus.fixes.versioned.visual;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
|
||||
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
|
||||
import net.minecraft.client.particle.*;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.particle.SimpleParticleType;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
public class FootStepParticle extends SpriteBillboardParticle {
|
||||
public class FootStepParticle1_12_2 extends SpriteBillboardParticle {
|
||||
|
||||
public static int ID;
|
||||
public static final Identifier ID = Identifier.of("viafabricplus", "footstep");
|
||||
public static int RAW_ID;
|
||||
|
||||
protected FootStepParticle(ClientWorld clientWorld, double x, double y, double z) {
|
||||
protected FootStepParticle1_12_2(ClientWorld clientWorld, double x, double y, double z) {
|
||||
super(clientWorld, x, y, z);
|
||||
|
||||
this.scale = 0.125F;
|
||||
|
@ -71,22 +72,22 @@ public class FootStepParticle extends SpriteBillboardParticle {
|
|||
final float maxV = this.getMaxV();
|
||||
|
||||
final int light = this.getBrightness(tickDelta); // This is missing in the original code, that's why the particles are broken
|
||||
vertexConsumer.vertex(x - scale, y, z + scale).texture(maxU, maxV).color(this.red, this.green, this.blue, this.alpha).light(light).next();
|
||||
vertexConsumer.vertex(x + scale, y, z + scale).texture(maxU, minV).color(this.red, this.green, this.blue, this.alpha).light(light).next();
|
||||
vertexConsumer.vertex(x + scale, y, z - scale).texture(minU, minV).color(this.red, this.green, this.blue, this.alpha).light(light).next();
|
||||
vertexConsumer.vertex(x - scale, y, z - scale).texture(minU, maxV).color(this.red, this.green, this.blue, this.alpha).light(light).next();
|
||||
vertexConsumer.vertex(x - scale, y, z + scale).texture(maxU, maxV).color(this.red, this.green, this.blue, this.alpha).light(light);
|
||||
vertexConsumer.vertex(x + scale, y, z + scale).texture(maxU, minV).color(this.red, this.green, this.blue, this.alpha).light(light);
|
||||
vertexConsumer.vertex(x + scale, y, z - scale).texture(minU, minV).color(this.red, this.green, this.blue, this.alpha).light(light);
|
||||
vertexConsumer.vertex(x - scale, y, z - scale).texture(minU, maxV).color(this.red, this.green, this.blue, this.alpha).light(light);
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
final DefaultParticleType footStepType = FabricParticleTypes.simple(true);
|
||||
final SimpleParticleType footStepType = FabricParticleTypes.simple(true);
|
||||
|
||||
Registry.register(Registries.PARTICLE_TYPE, new Identifier("viafabricplus", "footstep"), footStepType);
|
||||
ParticleFactoryRegistry.getInstance().register(footStepType, FootStepParticle.Factory::new);
|
||||
Registry.register(Registries.PARTICLE_TYPE, ID, footStepType);
|
||||
ParticleFactoryRegistry.getInstance().register(footStepType, FootStepParticle1_12_2.Factory::new);
|
||||
|
||||
ID = Registries.PARTICLE_TYPE.getRawId(footStepType);
|
||||
RAW_ID = Registries.PARTICLE_TYPE.getRawId(footStepType);
|
||||
}
|
||||
|
||||
public static class Factory implements ParticleFactory<DefaultParticleType> {
|
||||
public static class Factory implements ParticleFactory<SimpleParticleType> {
|
||||
|
||||
private final SpriteProvider spriteProvider;
|
||||
|
||||
|
@ -95,12 +96,12 @@ public class FootStepParticle extends SpriteBillboardParticle {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Particle createParticle(DefaultParticleType parameters, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) {
|
||||
if (ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_12_2)) {
|
||||
public Particle createParticle(SimpleParticleType parameters, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) {
|
||||
if (ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_12_2)) {
|
||||
throw new UnsupportedOperationException("FootStepParticle is not supported on versions newer than 1.12.2");
|
||||
}
|
||||
|
||||
final FootStepParticle particle = new FootStepParticle(world, x, y, z);
|
||||
final FootStepParticle1_12_2 particle = new FootStepParticle1_12_2(world, x, y, z);
|
||||
particle.setSprite(this.spriteProvider);
|
||||
return particle;
|
||||
}
|
|
@ -17,21 +17,16 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.tracker;
|
||||
package de.florianmichael.viafabricplus.fixes.viaversion;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class JoinGameDataTracker extends StoredObject {
|
||||
public class BedrockJoinGameTracker implements StorableObject {
|
||||
|
||||
private long seed;
|
||||
private String levelId;
|
||||
private long enchantmentSeed;
|
||||
|
||||
public JoinGameDataTracker(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public long getSeed() {
|
||||
return seed;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 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 de.florianmichael.viafabricplus.fixes.viaversion;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class SnowTrackerc0_30cpe implements StorableObject {
|
||||
|
||||
public static final SnowTrackerc0_30cpe INSTANCE = new SnowTrackerc0_30cpe();
|
||||
|
||||
}
|
|
@ -17,19 +17,14 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.tracker;
|
||||
package de.florianmichael.viafabricplus.fixes.viaversion;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class TeleportTracker extends StoredObject {
|
||||
public class TeleportTracker1_7_6_10 implements StorableObject {
|
||||
|
||||
private Boolean onGround = null;
|
||||
|
||||
public TeleportTracker(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public Boolean getPending() {
|
||||
return onGround;
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 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 de.florianmichael.viafabricplus.fixes.viaversion;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractSimpleProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5;
|
||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPackets1_21;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.network.packet.BrandCustomPayload;
|
||||
import net.minecraft.network.packet.CustomPayload;
|
||||
import net.minecraft.network.packet.s2c.custom.DebugGameTestAddMarkerCustomPayload;
|
||||
import net.minecraft.network.packet.s2c.custom.DebugGameTestClearCustomPayload;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Pair;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
// Protocol to handle error handling changes in older protocols, always last element of the pipeline
|
||||
public class ViaFabricPlusProtocol extends AbstractSimpleProtocol {
|
||||
|
||||
public static final ViaFabricPlusProtocol INSTANCE = new ViaFabricPlusProtocol();
|
||||
|
||||
private final Map<String, Pair<ProtocolVersion, PacketReader>> payloadDiff = new HashMap<>();
|
||||
|
||||
public ViaFabricPlusProtocol() {
|
||||
registerMapping(BrandCustomPayload.ID, LegacyProtocolVersion.c0_0_15a_1, wrapper -> wrapper.passthrough(Types.STRING));
|
||||
registerMapping(DebugGameTestAddMarkerCustomPayload.ID, ProtocolVersion.v1_14, wrapper -> {
|
||||
wrapper.passthrough(Types.BLOCK_POSITION1_14);
|
||||
wrapper.passthrough(Types.INT);
|
||||
wrapper.passthrough(Types.STRING);
|
||||
wrapper.passthrough(Types.INT);
|
||||
});
|
||||
registerMapping(DebugGameTestClearCustomPayload.ID, ProtocolVersion.v1_14, wrapper -> {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerClientbound(State.PLAY, getCustomPayload().getId(), getCustomPayload().getId(), wrapper -> {
|
||||
final String channel = Key.namespaced(wrapper.passthrough(Types.STRING));
|
||||
if (!channel.startsWith(Identifier.DEFAULT_NAMESPACE)) {
|
||||
// Mods might add custom payloads that we don't want to filter, so we check for the namespace.
|
||||
// Mods should NEVER use the default namespace of the game, not only to not break this code,
|
||||
// but also to not break other mods and the game itself.
|
||||
return;
|
||||
}
|
||||
|
||||
final ProtocolVersion version = wrapper.user().getProtocolInfo().serverProtocolVersion();
|
||||
if (!payloadDiff.containsKey(channel) || version.olderThan(payloadDiff.get(channel).getLeft())) {
|
||||
// Technically, it's wrong to just drop all payloads. However, ViaVersion doesn't translate them and the server can't detect if
|
||||
// we handled the payload or not, so dropping them is easier than adding a bunch of useless translations for payloads
|
||||
// which don't do anything on the client anyway.
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (version.olderThanOrEqualTo(ProtocolVersion.v1_20)) {
|
||||
// Skip all remaining bytes after reading the payload and cancel if the payload fails to read
|
||||
final PacketReader reader = payloadDiff.get(channel).getRight();
|
||||
try {
|
||||
reader.read(wrapper);
|
||||
wrapper.read(Types.REMAINING_BYTES);
|
||||
} catch (Exception ignored) {
|
||||
wrapper.cancel();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection connection) {
|
||||
super.init(connection);
|
||||
|
||||
final ProtocolVersion serverVersion = ProtocolTranslator.getTargetVersion(connection.getChannel());
|
||||
|
||||
// Add storages we need for different fixes here
|
||||
if (serverVersion.equals(BedrockProtocolVersion.bedrockLatest)) {
|
||||
connection.put(new BedrockJoinGameTracker());
|
||||
} else {
|
||||
if (serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
|
||||
connection.put(new WolfHealthTracker1_14_4());
|
||||
}
|
||||
if (serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_7_6)) {
|
||||
connection.put(new TeleportTracker1_7_6_10());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerMapping(final CustomPayload.Id<?> id, final ProtocolVersion version, final PacketReader reader) {
|
||||
payloadDiff.put(id.id().toString(), new Pair<>(version, reader));
|
||||
}
|
||||
|
||||
public static ServerboundPacketType getSetCreativeModeSlot() {
|
||||
return ServerboundPackets1_20_5.SET_CREATIVE_MODE_SLOT;
|
||||
}
|
||||
|
||||
public static ClientboundPacketType getCustomPayload() {
|
||||
return ClientboundPackets1_21.CUSTOM_PAYLOAD;
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
interface PacketReader {
|
||||
|
||||
void read(PacketWrapper wrapper);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -17,21 +17,16 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.fixes.tracker;
|
||||
package de.florianmichael.viafabricplus.fixes.viaversion;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import it.unimi.dsi.fastutil.ints.Int2FloatMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
|
||||
|
||||
public class WolfHealthTracker extends StoredObject {
|
||||
public class WolfHealthTracker1_14_4 implements StorableObject {
|
||||
|
||||
private final Int2FloatMap healthDataMap = new Int2FloatOpenHashMap();
|
||||
|
||||
public WolfHealthTracker(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public float getWolfHealth(final int entityId, final float fallback) {
|
||||
return this.healthDataMap.getOrDefault(entityId, fallback);
|
||||
}
|
||||
|
@ -40,13 +35,4 @@ public class WolfHealthTracker extends StoredObject {
|
|||
this.healthDataMap.put(entityId, wolfHealth);
|
||||
}
|
||||
|
||||
public static WolfHealthTracker get(final UserConnection userConnection) {
|
||||
var tracker = userConnection.get(WolfHealthTracker.class);
|
||||
if (tracker == null) {
|
||||
userConnection.put(tracker = new WolfHealthTracker(userConnection));
|
||||
}
|
||||
|
||||
return tracker;
|
||||
}
|
||||
|
||||
}
|
|
@ -20,6 +20,7 @@
|
|||
package de.florianmichael.viafabricplus.injection;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.metadata.ModMetadata;
|
||||
import net.lenni0451.reflect.stream.RStream;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
|
@ -32,24 +33,26 @@ public class ViaFabricPlusMixinPlugin implements IMixinConfigPlugin {
|
|||
|
||||
public static final String INJECTOR_PACKAGE = "de.florianmichael.viafabricplus.injection.mixin.";
|
||||
|
||||
private static final String MC_FIXES_PACKAGE = "fixes.minecraft.";
|
||||
private static final String COMPAT_PACKAGE = "compat.";
|
||||
|
||||
public static String VFP_VERSION;
|
||||
public static String VFP_IMPL_VERSION;
|
||||
|
||||
public static boolean DASH_LOADER_PRESENT;
|
||||
public static boolean ARMOR_SKIN_PRESENT;
|
||||
public static boolean IPNEXT_PRESENT;
|
||||
public static boolean MORE_CULLING_PRESENT;
|
||||
public static boolean LITHIUM_PRESENT;
|
||||
|
||||
@Override
|
||||
public void onLoad(String mixinPackage) {
|
||||
final FabricLoader loader = FabricLoader.getInstance();
|
||||
|
||||
VFP_VERSION = loader.getModContainer("viafabricplus").get().getMetadata().getVersion().getFriendlyString();
|
||||
final ModMetadata metadata = loader.getModContainer("viafabricplus").get().getMetadata();
|
||||
VFP_VERSION = metadata.getVersion().getFriendlyString();
|
||||
VFP_IMPL_VERSION = metadata.getCustomValue("vfp:implVersion").getAsString();
|
||||
|
||||
DASH_LOADER_PRESENT = loader.isModLoaded("dashloader");
|
||||
ARMOR_SKIN_PRESENT = loader.isModLoaded("armorskin");
|
||||
IPNEXT_PRESENT = loader.isModLoaded("inventoryprofilesnext");
|
||||
MORE_CULLING_PRESENT = loader.isModLoaded("moreculling");
|
||||
LITHIUM_PRESENT = loader.isModLoaded("lithium");
|
||||
|
||||
// Force unload some FabricAPI mixins because FabricAPI overwrites some of the elytra code
|
||||
final Set<String> loadedMixins = RStream.of("org.spongepowered.asm.mixin.transformer.MixinConfig").fields().by("globalMixinList").get();
|
||||
|
@ -65,17 +68,11 @@ public class ViaFabricPlusMixinPlugin implements IMixinConfigPlugin {
|
|||
|
||||
@Override
|
||||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||
if (mixinClassName.equals(INJECTOR_PACKAGE + MC_FIXES_PACKAGE + "MixinFontStorage")) {
|
||||
return !DASH_LOADER_PRESENT;
|
||||
}
|
||||
if (mixinClassName.equals(INJECTOR_PACKAGE + MC_FIXES_PACKAGE + "MixinInGameHud")) {
|
||||
return !ARMOR_SKIN_PRESENT;
|
||||
}
|
||||
if (mixinClassName.equals(INJECTOR_PACKAGE + COMPAT_PACKAGE + "ipnext.MixinAutoRefillHandler_ItemSlotMonitor")) {
|
||||
return IPNEXT_PRESENT;
|
||||
}
|
||||
|
||||
return true;
|
||||
return switch (mixinClassName) {
|
||||
case INJECTOR_PACKAGE + COMPAT_PACKAGE + "ipnext.MixinAutoRefillHandler_ItemSlotMonitor" -> IPNEXT_PRESENT;
|
||||
case INJECTOR_PACKAGE + COMPAT_PACKAGE + "lithium.MixinEntity" -> LITHIUM_PRESENT;
|
||||
default -> true;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,14 +20,14 @@
|
|||
package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
|
||||
public interface IClientConnection {
|
||||
|
||||
void viaFabricPlus$setupPreNettyDecryption();
|
||||
|
||||
VersionEnum viaFabricPlus$getTargetVersion();
|
||||
void viaFabricPlus$setTargetVersion(final VersionEnum serverVersion);
|
||||
ProtocolVersion viaFabricPlus$getTargetVersion();
|
||||
void viaFabricPlus$setTargetVersion(final ProtocolVersion serverVersion);
|
||||
|
||||
UserConnection viaFabricPlus$getUserConnection();
|
||||
void viaFabricPlus$setUserConnection(final UserConnection userConnection);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
import de.florianmichael.viafabricplus.fixes.ClientPlayerInteractionManager1_18_2;
|
||||
import de.florianmichael.viafabricplus.fixes.versioned.ClientPlayerInteractionManager1_18_2;
|
||||
|
||||
public interface IClientPlayerInteractionManager {
|
||||
|
||||
|
|
|
@ -19,11 +19,12 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.data.ClassicProtocolExtension;
|
||||
import net.raphimc.vialegacy.protocol.classic.c0_30cpetoc0_28_30.data.ClassicProtocolExtension;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
public interface IExtensionProtocolMetadataStorage {
|
||||
|
||||
EnumMap<ClassicProtocolExtension, Integer> viaFabricPlus$getServerExtensions();
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 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 de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
|
||||
public interface IMultiValueDebugSampleLogImpl {
|
||||
|
||||
ProtocolVersion viaFabricPlus$getForcedVersion();
|
||||
void viaFabricPlus$setForcedVersion(final ProtocolVersion version);
|
||||
|
||||
}
|
|
@ -19,12 +19,8 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
public interface IItemStack {
|
||||
public interface IPlayerListEntry {
|
||||
|
||||
boolean viaFabricPlus$has1_10ViaFabricPlusTag();
|
||||
|
||||
int viaFabricPlus$get1_10Count();
|
||||
|
||||
void viaFabricPlus$set1_10Count(final int count);
|
||||
int viaFabricPlus$getIndex();
|
||||
|
||||
}
|
|
@ -19,11 +19,8 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
public interface IPlayerListHud {
|
||||
|
||||
public interface IPerformanceLog {
|
||||
|
||||
VersionEnum viaFabricPlus$getForcedVersion();
|
||||
void viaFabricPlus$setForcedVersion(final VersionEnum version);
|
||||
void viaFabricPlus$setMaxPlayers(final int maxPlayers);
|
||||
|
||||
}
|
|
@ -19,17 +19,17 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
|
||||
public interface IServerInfo {
|
||||
|
||||
VersionEnum viaFabricPlus$forcedVersion();
|
||||
void viaFabricPlus$forceVersion(final VersionEnum version);
|
||||
ProtocolVersion viaFabricPlus$forcedVersion();
|
||||
void viaFabricPlus$forceVersion(final ProtocolVersion version);
|
||||
|
||||
boolean viaFabricPlus$passedDirectConnectScreen();
|
||||
void viaFabricPlus$passDirectConnectScreen();
|
||||
void viaFabricPlus$passDirectConnectScreen(final boolean state);
|
||||
|
||||
VersionEnum viaFabricPlus$translatingVersion();
|
||||
void viaFabricPlus$setTranslatingVersion(final VersionEnum version);
|
||||
ProtocolVersion viaFabricPlus$translatingVersion();
|
||||
void viaFabricPlus$setTranslatingVersion(final ProtocolVersion version);
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public abstract class MixinMain {
|
|||
@Inject(method = "main", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Util;startTimerHack()V"))
|
||||
private static void bootstrap(CallbackInfo ci) {
|
||||
LoadCallback.EVENT.invoker().onLoad(LoadCallback.State.PRE);
|
||||
ViaFabricPlus.global().bootstrap();
|
||||
ViaFabricPlus.global().init();
|
||||
LoadCallback.EVENT.invoker().onLoad(LoadCallback.State.POST);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,13 +19,16 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.connect;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import de.florianmichael.viafabricplus.injection.access.IPerformanceLog;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocolhack.netty.ViaFabricPlusVLLegacyPipeline;
|
||||
import de.florianmichael.viafabricplus.protocolhack.util.VersionEnumExtension;
|
||||
import de.florianmichael.viafabricplus.injection.access.IMultiValueDebugSampleLogImpl;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.netty.ViaFabricPlusVLLegacyPipeline;
|
||||
import io.netty.bootstrap.AbstractBootstrap;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.*;
|
||||
|
@ -35,13 +38,15 @@ import io.netty.channel.socket.nio.NioDatagramChannel;
|
|||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.encryption.PacketDecryptor;
|
||||
import net.minecraft.network.encryption.PacketEncryptor;
|
||||
import net.minecraft.network.handler.HandlerNames;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.util.profiler.PerformanceLog;
|
||||
import net.minecraft.util.profiler.MultiValueDebugSampleLogImpl;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.netty.CompressionReorderEvent;
|
||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
||||
import net.raphimc.vialoader.netty.VLPipeline;
|
||||
import net.raphimc.vialoader.netty.viabedrock.PingEncapsulationCodec;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.cloudburstmc.netty.channel.raknet.RakChannelFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -73,7 +78,7 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
|||
private UserConnection viaFabricPlus$userConnection;
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaFabricPlus$serverVersion;
|
||||
private ProtocolVersion viaFabricPlus$serverVersion;
|
||||
|
||||
@Unique
|
||||
private Cipher viaFabricPlus$decryptionCipher;
|
||||
|
@ -86,13 +91,13 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
|||
|
||||
@Inject(method = "setupEncryption", at = @At("HEAD"), cancellable = true)
|
||||
private void storeDecryptionCipher(Cipher decryptionCipher, Cipher encryptionCipher, CallbackInfo ci) {
|
||||
if (this.viaFabricPlus$serverVersion != null /* This happens when opening a lan server and people are joining */ && this.viaFabricPlus$serverVersion.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (this.viaFabricPlus$serverVersion != null /* This happens when opening a lan server and people are joining */ && this.viaFabricPlus$serverVersion.olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
// Minecraft's encryption code is bad for us, we need to reorder the pipeline
|
||||
ci.cancel();
|
||||
|
||||
// Minecraft 1.6.4 supports split encryption/decryption which means the server can only enable one side of the encryption
|
||||
// So we only enable the encryption side and later enable the decryption side if the 1.7 -> 1.6 protocol
|
||||
// tells us to do, therefore we need to store the cipher instance.
|
||||
// tells us to do, therefore, we need to store the cipher instance.
|
||||
this.viaFabricPlus$decryptionCipher = decryptionCipher;
|
||||
|
||||
// Enabling the encryption side
|
||||
|
@ -101,88 +106,77 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
|||
}
|
||||
|
||||
this.encrypted = true;
|
||||
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new PacketEncryptor(encryptionCipher));
|
||||
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, HandlerNames.ENCRYPT, new PacketEncryptor(encryptionCipher));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
|
||||
super.channelRegistered(ctx);
|
||||
if (VersionEnum.bedrockLatest.equals(this.viaFabricPlus$serverVersion)) {
|
||||
// Call channelActive manually when the channel is registered
|
||||
if (BedrockProtocolVersion.bedrockLatest.equals(this.viaFabricPlus$serverVersion)) { // Call channelActive manually when the channel is registered
|
||||
this.channelActive(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "channelActive", at = @At(value = "INVOKE", target = "Lio/netty/channel/SimpleChannelInboundHandler;channelActive(Lio/netty/channel/ChannelHandlerContext;)V"), remap = false)
|
||||
private void dontCallChannelActive(SimpleChannelInboundHandler<Packet<?>> instance, ChannelHandlerContext ctx) throws Exception {
|
||||
if (!VersionEnum.bedrockLatest.equals(this.viaFabricPlus$serverVersion)) { // Don't call channelActive twice
|
||||
super.channelActive(ctx);
|
||||
}
|
||||
@WrapWithCondition(method = "channelActive", at = @At(value = "INVOKE", target = "Lio/netty/channel/SimpleChannelInboundHandler;channelActive(Lio/netty/channel/ChannelHandlerContext;)V", remap = false))
|
||||
private boolean dontCallChannelActiveTwice(SimpleChannelInboundHandler<Packet<?>> instance, ChannelHandlerContext channelHandlerContext) {
|
||||
return !BedrockProtocolVersion.bedrockLatest.equals(this.viaFabricPlus$serverVersion);
|
||||
}
|
||||
|
||||
@Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/PerformanceLog;)Lnet/minecraft/network/ClientConnection;", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", shift = At.Shift.BEFORE))
|
||||
private static void setTargetVersion(InetSocketAddress address, boolean useEpoll, PerformanceLog packetSizeLog, CallbackInfoReturnable<ClientConnection> cir, @Local ClientConnection clientConnection) {
|
||||
@Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/MultiValueDebugSampleLogImpl;)Lnet/minecraft/network/ClientConnection;", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", shift = At.Shift.BEFORE))
|
||||
private static void setTargetVersion(InetSocketAddress address, boolean useEpoll, MultiValueDebugSampleLogImpl packetSizeLog, CallbackInfoReturnable<ClientConnection> cir, @Local ClientConnection clientConnection) {
|
||||
// Set the target version stored in the PerformanceLog field to the ClientConnection instance
|
||||
if (packetSizeLog instanceof IPerformanceLog mixinPerformanceLog && mixinPerformanceLog.viaFabricPlus$getForcedVersion() != null) {
|
||||
((IClientConnection) clientConnection).viaFabricPlus$setTargetVersion(mixinPerformanceLog.viaFabricPlus$getForcedVersion());
|
||||
if (packetSizeLog instanceof IMultiValueDebugSampleLogImpl mixinMultiValueDebugSampleLogImpl && mixinMultiValueDebugSampleLogImpl.viaFabricPlus$getForcedVersion() != null) {
|
||||
((IClientConnection) clientConnection).viaFabricPlus$setTargetVersion(mixinMultiValueDebugSampleLogImpl.viaFabricPlus$getForcedVersion());
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/PerformanceLog;)Lnet/minecraft/network/ClientConnection;", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;resetPacketSizeLog(Lnet/minecraft/util/profiler/PerformanceLog;)V"))
|
||||
private static void dontSetPerformanceLog(ClientConnection instance, PerformanceLog performanceLog) {
|
||||
// Since the PerformanceLog is never null due to our changes, we need to restore vanilla behavior
|
||||
if (performanceLog instanceof IPerformanceLog mixinPerformanceLog && mixinPerformanceLog.viaFabricPlus$getForcedVersion() != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
instance.resetPacketSizeLog(performanceLog);
|
||||
@WrapWithCondition(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/MultiValueDebugSampleLogImpl;)Lnet/minecraft/network/ClientConnection;", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;resetPacketSizeLog(Lnet/minecraft/util/profiler/MultiValueDebugSampleLogImpl;)V"))
|
||||
private static boolean dontSetPerformanceLog(ClientConnection instance, MultiValueDebugSampleLogImpl packetSizeLog) {
|
||||
// We need to restore vanilla behaviour since we use the PerformanceLog as a way to store the target version
|
||||
return !(packetSizeLog instanceof IMultiValueDebugSampleLogImpl mixinMultiValueDebugSampleLogImpl) || mixinMultiValueDebugSampleLogImpl.viaFabricPlus$getForcedVersion() == null;
|
||||
}
|
||||
|
||||
@Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At("HEAD"))
|
||||
private static void setTargetVersion(InetSocketAddress address, boolean useEpoll, ClientConnection connection, CallbackInfoReturnable<ChannelFuture> cir) {
|
||||
VersionEnum targetVersion = ((IClientConnection) connection).viaFabricPlus$getTargetVersion();
|
||||
ProtocolVersion targetVersion = ((IClientConnection) connection).viaFabricPlus$getTargetVersion();
|
||||
if (targetVersion == null) { // No server specific override
|
||||
targetVersion = ProtocolHack.getTargetVersion();
|
||||
targetVersion = ProtocolTranslator.getTargetVersion();
|
||||
}
|
||||
if (targetVersion == VersionEnumExtension.AUTO_DETECT) { // Auto-detect enabled (when pinging always use native version). Auto-detect is resolved in ConnectScreen mixin
|
||||
targetVersion = ProtocolHack.NATIVE_VERSION;
|
||||
if (targetVersion == ProtocolTranslator.AUTO_DETECT_PROTOCOL) { // Auto-detect enabled (when pinging always use native version). Auto-detect is resolved in ConnectScreen mixin
|
||||
targetVersion = ProtocolTranslator.NATIVE_VERSION;
|
||||
}
|
||||
|
||||
((IClientConnection) connection).viaFabricPlus$setTargetVersion(targetVersion);
|
||||
}
|
||||
|
||||
@Redirect(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;channel(Ljava/lang/Class;)Lio/netty/bootstrap/AbstractBootstrap;", remap = false))
|
||||
private static AbstractBootstrap<?, ?> useRakNetChannelFactory(Bootstrap instance, Class<? extends Channel> channelTypeClass, @Local(argsOnly = true) ClientConnection clientConnection) {
|
||||
if (VersionEnum.bedrockLatest.equals(((IClientConnection) clientConnection).viaFabricPlus$getTargetVersion())) {
|
||||
return instance.channelFactory(channelTypeClass == EpollSocketChannel.class ?
|
||||
RakChannelFactory.client(EpollDatagramChannel.class) :
|
||||
RakChannelFactory.client(NioDatagramChannel.class)
|
||||
);
|
||||
@WrapOperation(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;channel(Ljava/lang/Class;)Lio/netty/bootstrap/AbstractBootstrap;", remap = false))
|
||||
private static AbstractBootstrap<?, ?> useRakNetChannelFactory(Bootstrap instance, Class<? extends Channel> channelTypeClass, Operation<AbstractBootstrap<Bootstrap, Channel>> original, @Local(argsOnly = true) ClientConnection clientConnection) {
|
||||
if (BedrockProtocolVersion.bedrockLatest.equals(((IClientConnection) clientConnection).viaFabricPlus$getTargetVersion())) {
|
||||
return instance.channelFactory(channelTypeClass == EpollSocketChannel.class ? RakChannelFactory.client(EpollDatagramChannel.class) : RakChannelFactory.client(NioDatagramChannel.class));
|
||||
} else {
|
||||
return original.call(instance, channelTypeClass);
|
||||
}
|
||||
|
||||
return instance.channel(channelTypeClass);
|
||||
}
|
||||
|
||||
@Redirect(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;connect(Ljava/net/InetAddress;I)Lio/netty/channel/ChannelFuture;", remap = false))
|
||||
private static ChannelFuture useRakNetPingHandlers(Bootstrap instance, InetAddress inetHost, int inetPort, @Local(argsOnly = true) ClientConnection clientConnection, @Local(argsOnly = true) boolean isConnecting) {
|
||||
if (VersionEnum.bedrockLatest.equals(((IClientConnection) clientConnection).viaFabricPlus$getTargetVersion()) && !isConnecting) {
|
||||
if (BedrockProtocolVersion.bedrockLatest.equals(((IClientConnection) clientConnection).viaFabricPlus$getTargetVersion()) && !isConnecting) {
|
||||
// Bedrock edition / RakNet has different handlers for pinging a server
|
||||
return instance.register().syncUninterruptibly().channel().bind(new InetSocketAddress(0)).
|
||||
addListeners(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE, (ChannelFutureListener) f -> {
|
||||
if (f.isSuccess()) {
|
||||
f.channel().pipeline().replace(
|
||||
VLPipeline.VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME,
|
||||
ViaFabricPlusVLLegacyPipeline.VIABEDROCK_PING_ENCAPSULATION_HANDLER_NAME,
|
||||
new PingEncapsulationCodec(new InetSocketAddress(inetHost, inetPort))
|
||||
);
|
||||
f.channel().pipeline().remove(VLPipeline.VIABEDROCK_PACKET_ENCAPSULATION_HANDLER_NAME);
|
||||
f.channel().pipeline().remove("splitter");
|
||||
}
|
||||
});
|
||||
return instance.register().syncUninterruptibly().channel().bind(new InetSocketAddress(0)).addListeners(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE, (ChannelFutureListener) f -> {
|
||||
if (f.isSuccess()) {
|
||||
f.channel().pipeline().replace(
|
||||
VLPipeline.VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME,
|
||||
ViaFabricPlusVLLegacyPipeline.VIABEDROCK_PING_ENCAPSULATION_HANDLER_NAME,
|
||||
new PingEncapsulationCodec(new InetSocketAddress(inetHost, inetPort))
|
||||
);
|
||||
f.channel().pipeline().remove(VLPipeline.VIABEDROCK_PACKET_ENCAPSULATION_HANDLER_NAME);
|
||||
f.channel().pipeline().remove(HandlerNames.SPLITTER);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return instance.connect(inetHost, inetPort);
|
||||
}
|
||||
|
||||
return instance.connect(inetHost, inetPort);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -193,7 +187,7 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
|||
|
||||
this.encrypted = true;
|
||||
// Enabling the decryption side for 1.6.4 if the 1.7 -> 1.6 protocol tells us to do
|
||||
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_PREPENDER_NAME, "decrypt", new PacketDecryptor(this.viaFabricPlus$decryptionCipher));
|
||||
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_PREPENDER_NAME, HandlerNames.DECRYPT, new PacketDecryptor(this.viaFabricPlus$decryptionCipher));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -207,12 +201,12 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
|||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaFabricPlus$getTargetVersion() {
|
||||
public ProtocolVersion viaFabricPlus$getTargetVersion() {
|
||||
return this.viaFabricPlus$serverVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabricPlus$setTargetVersion(final VersionEnum serverVersion) {
|
||||
public void viaFabricPlus$setTargetVersion(final ProtocolVersion serverVersion) {
|
||||
this.viaFabricPlus$serverVersion = serverVersion;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.connect;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import io.netty.channel.Channel;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
|
@ -38,7 +38,7 @@ public abstract class MixinClientConnection_1 {
|
|||
|
||||
@Inject(method = "initChannel", at = @At("RETURN"))
|
||||
private void injectViaIntoPipeline(Channel channel, CallbackInfo ci) {
|
||||
ProtocolHack.injectViaPipeline(this.field_11663, channel);
|
||||
ProtocolTranslator.injectViaPipeline(this.field_11663, channel);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
|||
import net.minecraft.client.network.ClientLoginNetworkHandler;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.text.Text;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.ProtocolMetadataStorage;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -43,7 +43,7 @@ public abstract class MixinClientLoginNetworkHandler {
|
|||
@Inject(method = "joinServerSession", at = @At("HEAD"), cancellable = true)
|
||||
public void onlyVerifySessionInOnlineMode(String serverId, CallbackInfoReturnable<Text> cir) {
|
||||
final IClientConnection mixinClientConnection = (IClientConnection) connection;
|
||||
if (mixinClientConnection.viaFabricPlus$getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (mixinClientConnection.viaFabricPlus$getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
// We are in the 1.7 -> 1.6 protocol, so we need to skip the joinServer call
|
||||
// if the server is in offline mode, due the packet changes <-> networking changes
|
||||
// Minecraft's networking code is bad for us.
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 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 de.florianmichael.viafabricplus.injection.mixin.base.connect;
|
||||
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import net.minecraft.client.option.GameOptions;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(GameOptions.class)
|
||||
public abstract class MixinGameOptions {
|
||||
|
||||
@Shadow
|
||||
public boolean useNativeTransport;
|
||||
|
||||
/**
|
||||
* @author RK_01
|
||||
* @reason Needed as an indicator if the client wants to ping a server or connect to a server
|
||||
*/
|
||||
@Overwrite
|
||||
public boolean shouldUseNativeTransport() {
|
||||
if (!this.useNativeTransport) {
|
||||
ViaFabricPlus.global().getLogger().error("Native transport is disabled, but enabling it anyway since we use it as an indicator if the client wants to ping a server or connect to a server.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.screen.base.PerServerVersionScreen;
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
|
@ -28,7 +29,6 @@ import net.minecraft.client.gui.widget.ButtonWidget;
|
|||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.text.Text;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -62,7 +62,12 @@ public abstract class MixinAddServerScreen extends Screen {
|
|||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
private void addVersionSetterButton(CallbackInfo ci) {
|
||||
final VersionEnum forcedVersion = ((IServerInfo) server).viaFabricPlus$forcedVersion();
|
||||
final int buttonPosition = GeneralSettings.global().addServerScreenButtonOrientation.getIndex();
|
||||
if (buttonPosition == 0) { // Off
|
||||
return;
|
||||
}
|
||||
|
||||
final ProtocolVersion forcedVersion = ((IServerInfo) server).viaFabricPlus$forcedVersion();
|
||||
|
||||
// Restore input if the user cancels the version selection screen (or if the user is editing an existing server)
|
||||
if (viaFabricPlus$nameField != null && viaFabricPlus$addressField != null) {
|
||||
|
@ -73,7 +78,6 @@ public abstract class MixinAddServerScreen extends Screen {
|
|||
viaFabricPlus$addressField = null;
|
||||
}
|
||||
|
||||
// Create the button
|
||||
ButtonWidget.Builder buttonBuilder = ButtonWidget.builder(forcedVersion == null ? Text.translatable("base.viafabricplus.set_version") : Text.literal(forcedVersion.getName()), button -> {
|
||||
// Store current input in case the user cancels the version selection
|
||||
viaFabricPlus$nameField = serverNameField.getText();
|
||||
|
@ -82,11 +86,8 @@ public abstract class MixinAddServerScreen extends Screen {
|
|||
client.setScreen(new PerServerVersionScreen(this, version -> ((IServerInfo) server).viaFabricPlus$forceVersion(version)));
|
||||
}).size(98, 20);
|
||||
|
||||
// Set the button's position according to the configured orientation
|
||||
buttonBuilder = GeneralSettings.withOrientation(buttonBuilder, GeneralSettings.global().addServerScreenButtonOrientation.getIndex(), width, height);
|
||||
|
||||
// Add the button to the screen
|
||||
this.addDrawableChild(buttonBuilder.build());
|
||||
// Set the button's position according to the configured orientation and add the button to the screen
|
||||
this.addDrawableChild(GeneralSettings.withOrientation(buttonBuilder, buttonPosition, width, height).build());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,26 +17,25 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.viaversion;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import com.viaversion.viaversion.util.Config;
|
||||
import de.florianmichael.viafabricplus.protocolhack.util.ConfigPatcher;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Map;
|
||||
@Mixin(ClientConnection.class)
|
||||
public abstract class MixinClientConnection {
|
||||
|
||||
@Mixin(value = Config.class, remap = false)
|
||||
public abstract class MixinConfig {
|
||||
|
||||
@Redirect(method = "loadConfig(Ljava/io/File;Ljava/net/URL;)Ljava/util/Map;", at = @At(value = "INVOKE", target = "Ljava/util/Map;containsKey(Ljava/lang/Object;)Z"))
|
||||
private boolean allowConfigPatching(final Map<String, Object> map, final Object key) {
|
||||
if (((Object) this) instanceof ConfigPatcher) {
|
||||
return true;
|
||||
@Inject(method = "exceptionCaught", at = @At("HEAD"))
|
||||
private void printNetworkingErrors(ChannelHandlerContext context, Throwable ex, CallbackInfo ci) {
|
||||
if (DebugSettings.global().printNetworkingErrorsToLogs.getValue()) {
|
||||
ViaFabricPlus.global().getLogger().error("An exception occurred while handling a packet", ex);
|
||||
}
|
||||
|
||||
return map.containsKey(key);
|
||||
}
|
||||
|
||||
}
|
|
@ -21,12 +21,12 @@ package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
|||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocolhack.impl.provider.vialegacy.ViaFabricPlusClassicMPPassProvider;
|
||||
import de.florianmichael.viafabricplus.protocolhack.util.ProtocolVersionDetector;
|
||||
import de.florianmichael.viafabricplus.protocolhack.util.VersionEnumExtension;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.impl.provider.vialegacy.ViaFabricPlusClassicMPPassProvider;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.util.ProtocolVersionDetector;
|
||||
import de.florianmichael.viafabricplus.settings.impl.AuthenticationSettings;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import net.minecraft.client.gui.screen.multiplayer.ConnectScreen;
|
||||
|
@ -34,7 +34,6 @@ import net.minecraft.client.network.ServerInfo;
|
|||
import net.minecraft.client.session.Session;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.text.Text;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -62,20 +61,21 @@ public abstract class MixinConnectScreen_1 {
|
|||
private ChannelFuture setServerInfoAndHandleDisconnect(InetSocketAddress address, boolean useEpoll, ClientConnection connection, Operation<ChannelFuture> original) {
|
||||
final IServerInfo mixinServerInfo = (IServerInfo) this.field_40415;
|
||||
|
||||
VersionEnum targetVersion = ProtocolHack.getTargetVersion();
|
||||
ProtocolVersion targetVersion = ProtocolTranslator.getTargetVersion();
|
||||
if (mixinServerInfo.viaFabricPlus$forcedVersion() != null && !mixinServerInfo.viaFabricPlus$passedDirectConnectScreen()) {
|
||||
targetVersion = mixinServerInfo.viaFabricPlus$forcedVersion();
|
||||
mixinServerInfo.viaFabricPlus$passDirectConnectScreen(false); // reset state
|
||||
}
|
||||
if (targetVersion == VersionEnumExtension.AUTO_DETECT) {
|
||||
if (targetVersion == ProtocolTranslator.AUTO_DETECT_PROTOCOL) {
|
||||
this.field_2416.setStatus(Text.translatable("base.viafabricplus.detecting_server_version"));
|
||||
targetVersion = ProtocolVersionDetector.get(address, ProtocolHack.NATIVE_VERSION);
|
||||
targetVersion = ProtocolVersionDetector.get(address, ProtocolTranslator.NATIVE_VERSION);
|
||||
}
|
||||
ProtocolHack.setTargetVersion(targetVersion, true);
|
||||
ProtocolTranslator.setTargetVersion(targetVersion, true);
|
||||
|
||||
this.viaFabricPlus$useClassiCubeAccount = AuthenticationSettings.global().setSessionNameToClassiCubeNameInServerList.getValue() && ViaFabricPlusClassicMPPassProvider.classicMpPassForNextJoin != null;
|
||||
|
||||
final ChannelFuture future = original.call(address, useEpoll, connection);
|
||||
future.channel().closeFuture().addListener(channel -> ProtocolHack.resetPreviousVersion());
|
||||
ProtocolTranslator.injectPreviousVersionReset(future.channel());
|
||||
|
||||
return future;
|
||||
}
|
||||
|
@ -84,11 +84,8 @@ public abstract class MixinConnectScreen_1 {
|
|||
private String useClassiCubeUsername(Session instance) {
|
||||
if (this.viaFabricPlus$useClassiCubeAccount) {
|
||||
final var account = ViaFabricPlus.global().getSaveManager().getAccountsSave().getClassicubeAccount();
|
||||
if (account != null) {
|
||||
return account.username();
|
||||
}
|
||||
if (account != null) return account.username();
|
||||
}
|
||||
|
||||
return instance.getUsername();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,23 +21,23 @@ package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
|||
|
||||
import com.viaversion.viaversion.api.connection.ProtocolInfo;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.fixes.tracker.JoinGameDataTracker;
|
||||
import de.florianmichael.viafabricplus.fixes.viaversion.BedrockJoinGameTracker;
|
||||
import de.florianmichael.viafabricplus.injection.ViaFabricPlusMixinPlugin;
|
||||
import de.florianmichael.viafabricplus.injection.access.IChunkTracker;
|
||||
import de.florianmichael.viafabricplus.injection.access.IRakSessionCodec;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import de.florianmichael.viafabricplus.util.ChatUtil;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.hud.DebugHud;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.raphimc.viabedrock.protocol.data.enums.bedrock.ServerMovementModes;
|
||||
import net.raphimc.viabedrock.protocol.data.enums.bedrock.ServerAuthMovementMode;
|
||||
import net.raphimc.viabedrock.protocol.storage.ChunkTracker;
|
||||
import net.raphimc.viabedrock.protocol.storage.GameSessionStorage;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.storage.ExtensionProtocolMetadataStorage;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.storage.SeedStorage;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.storage.EntityTracker;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocol.classic.c0_30cpetoc0_28_30.storage.ExtensionProtocolMetadataStorage;
|
||||
import net.raphimc.vialegacy.protocol.release.r1_1tor1_2_1_3.storage.SeedStorage;
|
||||
import net.raphimc.vialegacy.protocol.release.r1_7_6_10tor1_8.storage.EntityTracker;
|
||||
import org.cloudburstmc.netty.channel.raknet.RakClientChannel;
|
||||
import org.cloudburstmc.netty.handler.codec.raknet.common.RakSessionCodec;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -54,14 +54,14 @@ public abstract class MixinDebugHud {
|
|||
|
||||
@Inject(method = "getLeftText", at = @At("RETURN"))
|
||||
public void addViaFabricPlusInformation(CallbackInfoReturnable<List<String>> cir) {
|
||||
if (!GeneralSettings.global().showExtraInformationInDebugHud.getValue()) {
|
||||
if (!GeneralSettings.global().showExtraInformationInDebugHud.getValue()) { // Only show if enabled
|
||||
return;
|
||||
}
|
||||
if (MinecraftClient.getInstance().isInSingleplayer() && MinecraftClient.getInstance().player != null) {
|
||||
if (MinecraftClient.getInstance().isInSingleplayer() && MinecraftClient.getInstance().player != null) { // Don't show in singleplayer
|
||||
return;
|
||||
}
|
||||
final UserConnection userConnection = ProtocolHack.getPlayNetworkUserConnection();
|
||||
if (userConnection == null) { // Via is not translating this session
|
||||
final UserConnection userConnection = ProtocolTranslator.getPlayNetworkUserConnection();
|
||||
if (userConnection == null) { // Only show if ViaVersion is active
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -71,47 +71,33 @@ public abstract class MixinDebugHud {
|
|||
// Title
|
||||
information.add(ChatUtil.PREFIX + Formatting.RESET + " " + ViaFabricPlusMixinPlugin.VFP_VERSION);
|
||||
|
||||
// common
|
||||
// Connection
|
||||
final ProtocolInfo info = userConnection.getProtocolInfo();
|
||||
information.add(
|
||||
"P: " + info.getPipeline().pipes().size() +
|
||||
" C: " + ProtocolVersion.getProtocol(info.getProtocolVersion()) +
|
||||
" S: " + ProtocolVersion.getProtocol(info.getServerProtocolVersion())
|
||||
);
|
||||
information.add("P: " + info.getPipeline().pipes().size() + " C: " + info.protocolVersion() + " S: " + info.serverProtocolVersion());
|
||||
|
||||
// r1_7_10
|
||||
// 1.7.10
|
||||
final EntityTracker entityTracker1_7_10 = userConnection.get(EntityTracker.class);
|
||||
if (entityTracker1_7_10 != null) {
|
||||
information.add(
|
||||
"1.7 Entities: " + entityTracker1_7_10.getTrackedEntities().size() +
|
||||
", Virtual holograms: " + entityTracker1_7_10.getVirtualHolograms().size()
|
||||
);
|
||||
information.add("1.7 Entities: " + entityTracker1_7_10.getTrackedEntities().size() + ", Virtual holograms: " + entityTracker1_7_10.getVirtualHolograms().size());
|
||||
}
|
||||
|
||||
// r1_1
|
||||
// 1.1
|
||||
final SeedStorage seedStorage = userConnection.get(SeedStorage.class);
|
||||
if (seedStorage != null) {
|
||||
if (seedStorage != null && userConnection.getProtocolInfo().serverProtocolVersion().newerThanOrEqualTo(LegacyProtocolVersion.a1_2_0toa1_2_1_1)) {
|
||||
information.add("World Seed: " + seedStorage.seed);
|
||||
}
|
||||
|
||||
// c0.30cpe
|
||||
// c0.30 cpe
|
||||
final ExtensionProtocolMetadataStorage extensionProtocolMetadataStorage = userConnection.get(ExtensionProtocolMetadataStorage.class);
|
||||
if (extensionProtocolMetadataStorage != null) {
|
||||
information.add("CPE extensions: " + extensionProtocolMetadataStorage.getExtensionCount());
|
||||
}
|
||||
|
||||
// bedrock
|
||||
final JoinGameDataTracker joinGameDataTracker = userConnection.get(JoinGameDataTracker.class);
|
||||
// Bedrock
|
||||
final BedrockJoinGameTracker joinGameDataTracker = userConnection.get(BedrockJoinGameTracker.class);
|
||||
if (joinGameDataTracker != null) {
|
||||
final int movementMode = userConnection.get(GameSessionStorage.class).getMovementMode();
|
||||
String movement = "Server with rewind";
|
||||
if (movementMode == ServerMovementModes.CLIENT) {
|
||||
movement = "Client";
|
||||
} else if (movementMode == ServerMovementModes.SERVER) {
|
||||
movement = "Server";
|
||||
}
|
||||
|
||||
information.add("Bedrock Level: " + joinGameDataTracker.getLevelId() + ", Enchantment Seed: " + joinGameDataTracker.getEnchantmentSeed() + ", Movement: " + movement);
|
||||
final ServerAuthMovementMode movementMode = userConnection.get(GameSessionStorage.class).getMovementMode();
|
||||
information.add("Bedrock Level: " + joinGameDataTracker.getLevelId() + ", Enchantment Seed: " + joinGameDataTracker.getEnchantmentSeed() + ", Movement: " + movementMode.name());
|
||||
}
|
||||
if (joinGameDataTracker != null) {
|
||||
information.add("World Seed: " + joinGameDataTracker.getSeed());
|
||||
|
|
|
@ -17,33 +17,36 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import de.florianmichael.viafabricplus.screen.base.ProtocolSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.option.OptionsScreen;
|
||||
import net.minecraft.client.gui.screen.multiplayer.DirectConnectScreen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.GridWidget;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(OptionsScreen.class)
|
||||
public abstract class MixinOptionsScreen extends Screen {
|
||||
@Mixin(DirectConnectScreen.class)
|
||||
public abstract class MixinDirectConnectScreen extends Screen {
|
||||
|
||||
protected MixinOptionsScreen(Text title) {
|
||||
public MixinDirectConnectScreen(Text title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/GridWidget$Adder;add(Lnet/minecraft/client/gui/widget/Widget;)Lnet/minecraft/client/gui/widget/Widget;", ordinal = 10, shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void showSuperSecretSettings(CallbackInfo ci, GridWidget gridWidget, GridWidget.Adder adder) {
|
||||
if (VisualSettings.global().showSuperSecretSettings.isEnabled() && MinecraftClient.getInstance().player != null) {
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.literal("Super Secret Settings..."), button -> MinecraftClient.getInstance().gameRenderer.cycleSuperSecretSetting()).dimensions(this.width / 2 + 5, this.height / 6 + 18, 150, 20).build());
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
private void addProtocolSelectionButton(CallbackInfo ci) {
|
||||
final int buttonPosition = GeneralSettings.global().directConnectScreenButtonOrientation.getIndex();
|
||||
if (buttonPosition == 0) { // Off
|
||||
return;
|
||||
}
|
||||
ButtonWidget.Builder builder = ButtonWidget.builder(Text.literal("ViaFabricPlus"), button -> ProtocolSelectionScreen.INSTANCE.open(this)).size(98, 20);
|
||||
|
||||
// Set the button's position according to the configured orientation and add the button to the screen
|
||||
this.addDrawableChild(GeneralSettings.withOrientation(builder, buttonPosition, width, height).build());
|
||||
}
|
||||
|
||||
}
|
|
@ -20,14 +20,14 @@
|
|||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import de.florianmichael.viafabricplus.util.ChatUtil;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.DownloadingTerrainScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.storage.ClassicProgressStorage;
|
||||
import net.raphimc.vialegacy.protocol.classic.c0_28_30toa1_0_15.storage.ClassicProgressStorage;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
@ -44,7 +44,7 @@ public abstract class MixinDownloadingTerrainScreen extends Screen {
|
|||
private void renderClassicProgress(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
if (GeneralSettings.global().showClassicLoadingProgressInConnectScreen.getValue()) {
|
||||
// Check if ViaVersion is translating
|
||||
final UserConnection connection = ProtocolHack.getPlayNetworkUserConnection();
|
||||
final UserConnection connection = ProtocolTranslator.getPlayNetworkUserConnection();
|
||||
if (connection == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -19,10 +19,15 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import de.florianmichael.viafabricplus.event.PostGameLoadCallback;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.RunArgs;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.resource.ResourcePackManager;
|
||||
import net.minecraft.server.SaveLoader;
|
||||
import net.minecraft.world.level.storage.LevelStorage;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
@ -36,11 +41,10 @@ public abstract class MixinMinecraftClient {
|
|||
PostGameLoadCallback.EVENT.invoker().postGameLoad();
|
||||
}
|
||||
|
||||
@Inject(method = "startIntegratedServer", at = @At("HEAD"))
|
||||
private void disableProtocolHack(CallbackInfo ci) {
|
||||
// Set the target version to the native version when starting a singleplayer world
|
||||
// This will automatically reload all the mappings and reset the target version to the forced version
|
||||
ProtocolHack.setTargetVersion(ProtocolHack.NATIVE_VERSION);
|
||||
@Inject(method = "startIntegratedServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/lang/String;ILnet/minecraft/network/listener/ClientLoginPacketListener;)V", shift = At.Shift.BEFORE))
|
||||
private void disableProtocolTranslator(LevelStorage.Session session, ResourcePackManager dataPackManager, SaveLoader saveLoader, boolean newWorld, CallbackInfo ci, @Local ClientConnection clientConnection) {
|
||||
ProtocolTranslator.setTargetVersion(ProtocolTranslator.NATIVE_VERSION, true);
|
||||
ProtocolTranslator.injectPreviousVersionReset(clientConnection.channel);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,15 +19,22 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import de.florianmichael.viafabricplus.fixes.ClientsideFixes;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import de.florianmichael.viafabricplus.screen.base.ProtocolSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(MultiplayerScreen.class)
|
||||
|
@ -39,14 +46,25 @@ public abstract class MixinMultiplayerScreen extends Screen {
|
|||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
private void addProtocolSelectionButton(CallbackInfo ci) {
|
||||
// Create the button
|
||||
var builder = ButtonWidget.builder(Text.literal("ViaFabricPlus"), button -> ProtocolSelectionScreen.INSTANCE.open(this)).size(98, 20);
|
||||
final int buttonPosition = GeneralSettings.global().multiplayerScreenButtonOrientation.getIndex();
|
||||
if (buttonPosition == 0) { // Off
|
||||
return;
|
||||
}
|
||||
ButtonWidget.Builder builder = ButtonWidget.builder(Text.literal("ViaFabricPlus"), button -> ProtocolSelectionScreen.INSTANCE.open(this)).size(98, 20);
|
||||
|
||||
// Set the button's position according to the configured orientation
|
||||
builder = GeneralSettings.withOrientation(builder, GeneralSettings.global().multiplayerScreenButtonOrientation.getIndex(), width, height);
|
||||
// Set the button's position according to the configured orientation and add the button to the screen
|
||||
this.addDrawableChild(GeneralSettings.withOrientation(builder, buttonPosition, width, height).build());
|
||||
}
|
||||
|
||||
// Add the button to the screen
|
||||
this.addDrawableChild(builder.build());
|
||||
@Redirect(method = "connect(Lnet/minecraft/client/network/ServerInfo;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ServerAddress;parse(Ljava/lang/String;)Lnet/minecraft/client/network/ServerAddress;"))
|
||||
private ServerAddress replaceDefaultPort(String address, @Local(argsOnly = true) ServerInfo entry) {
|
||||
if (((IServerInfo) entry).viaFabricPlus$passedDirectConnectScreen()) {
|
||||
// If the user has already passed the direct connect screen, we use the target version
|
||||
return ClientsideFixes.replaceDefaultPort(address, ProtocolTranslator.getTargetVersion());
|
||||
} else {
|
||||
// Otherwise the forced version is used
|
||||
return ClientsideFixes.replaceDefaultPort(address, ((IServerInfo) entry).viaFabricPlus$forcedVersion());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import net.minecraft.SharedConstants;
|
||||
|
@ -28,7 +29,6 @@ import net.minecraft.network.listener.ClientQueryPacketListener;
|
|||
import net.minecraft.network.packet.s2c.query.QueryResponseS2CPacket;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -57,31 +57,11 @@ public abstract class MixinMultiplayerServerListPinger_1 implements ClientQueryP
|
|||
}
|
||||
|
||||
@Inject(method = "onResponse", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;send(Lnet/minecraft/network/packet/Packet;)V", shift = At.Shift.AFTER))
|
||||
private void setProtocolVersion(CallbackInfo ci) {
|
||||
final VersionEnum version = ((IClientConnection) this.field_3774).viaFabricPlus$getTargetVersion();
|
||||
|
||||
// ViaVersion is not translating the current connection, so we don't need to do anything
|
||||
if (version == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean isCompatible;
|
||||
if (version.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
// Because of ViaVersion not supporting legacy minecraft versions where protocol ids are overlapping, ViaLegacy
|
||||
// has its own protocol id offset, where realVersion = -(ViaLegacyVersion >> 2). Normally ViaVersion sends the client
|
||||
// version to the client so its detection doesn't break when checking for serverVersion == clientVersion, but since
|
||||
// ViaLegacy doesn't do that, we have to do it ourselves
|
||||
isCompatible = LegacyProtocolVersion.getRealProtocolVersion(version.getVersion()) == this.field_3776.protocolVersion;
|
||||
} else if (version.equals(VersionEnum.bedrockLatest)) {
|
||||
// Bedrock edition doesn't have a protocol id like the Java edition, ViaBedrock also has its own protocol id offset
|
||||
// Which we need to remove to get the real protocol id
|
||||
isCompatible = version.getVersion() - BedrockProtocolVersion.PROTOCOL_ID_OVERLAP_PREVENTION_OFFSET == this.field_3776.protocolVersion;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
private void fixVersionComparison(CallbackInfo ci) {
|
||||
final ProtocolVersion version = ((IClientConnection) this.field_3774).viaFabricPlus$getTargetVersion();
|
||||
|
||||
// If the server is compatible with the client, we set the protocol version to the client version
|
||||
if (isCompatible) {
|
||||
if (version != null && version.getVersion() == this.field_3776.protocolVersion) {
|
||||
this.field_3776.protocolVersion = SharedConstants.getProtocolVersion();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,22 +19,31 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget;
|
||||
import net.minecraft.client.gui.screen.world.WorldIcon;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.text.OrderedText;
|
||||
import net.minecraft.text.StringVisitable;
|
||||
import net.minecraft.text.Text;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.*;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
@Mixin(MultiplayerServerListWidget.ServerEntry.class)
|
||||
public abstract class MixinMultiplayerServerListWidget_ServerEntry {
|
||||
|
@ -43,19 +52,86 @@ public abstract class MixinMultiplayerServerListWidget_ServerEntry {
|
|||
@Final
|
||||
private ServerInfo server;
|
||||
|
||||
@WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setMultiplayerScreenTooltip(Ljava/util/List;)V", ordinal = 0))
|
||||
private void drawTranslatingState(MultiplayerScreen instance, List<Text> tooltip, Operation<Void> original) {
|
||||
final List<Text> tooltipCopy = new ArrayList<>(tooltip);
|
||||
if (GeneralSettings.global().showAdvertisedServerVersion.getValue()) {
|
||||
final VersionEnum versionEnum = ((IServerInfo) server).viaFabricPlus$translatingVersion();
|
||||
@Mutable
|
||||
@Shadow
|
||||
@Final
|
||||
private WorldIcon icon;
|
||||
|
||||
if (versionEnum != null) {
|
||||
tooltipCopy.add(Text.translatable("base.viafabricplus.via_translates_to", versionEnum.getName() + " (" + versionEnum.getOriginalVersion() + ")"));
|
||||
tooltipCopy.add(Text.translatable("base.viafabricplus.server_version", server.version.getString() + " (" + server.protocolVersion + ")"));
|
||||
@Unique
|
||||
private boolean viaFabricPlus$disableServerPinging = false;
|
||||
|
||||
@WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Ljava/util/concurrent/ThreadPoolExecutor;submit(Ljava/lang/Runnable;)Ljava/util/concurrent/Future;"))
|
||||
private boolean disableServerPinging(ThreadPoolExecutor instance, Runnable runnable) {
|
||||
ProtocolVersion version = ((IServerInfo) server).viaFabricPlus$forcedVersion();
|
||||
if (version == null) version = ProtocolTranslator.getTargetVersion();
|
||||
|
||||
viaFabricPlus$disableServerPinging = VisualSettings.global().disableServerPinging.isEnabled(version);
|
||||
if (viaFabricPlus$disableServerPinging) {
|
||||
this.server.version = Text.of(version.getName()); // Show target version
|
||||
}
|
||||
return !viaFabricPlus$disableServerPinging;
|
||||
}
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ServerInfo$Status;INCOMPATIBLE:Lnet/minecraft/client/network/ServerInfo$Status;"))
|
||||
private ServerInfo.Status disableServerPinging() {
|
||||
if (viaFabricPlus$disableServerPinging) {
|
||||
return this.server.getStatus(); // server version will always be shown (as we don't have a player count anyway)
|
||||
} else {
|
||||
return ServerInfo.Status.INCOMPATIBLE;
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;wrapLines(Lnet/minecraft/text/StringVisitable;I)Ljava/util/List;"))
|
||||
private List<OrderedText> disableServerPinging(TextRenderer instance, StringVisitable text, int width) {
|
||||
if (viaFabricPlus$disableServerPinging) { // server label will just show the server address
|
||||
return instance.wrapLines(Text.of(server.address), width);
|
||||
} else {
|
||||
return instance.wrapLines(text, width);
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawText(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;IIIZ)I"), index = 2)
|
||||
private int disableServerPinging(int x) {
|
||||
if (viaFabricPlus$disableServerPinging) { // Move server label to the right (as we remove the ping bar)
|
||||
x += 15 /* ping bar width */ - 3 /* magical offset */;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
@WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V", ordinal = 0))
|
||||
private boolean disableServerPinging(DrawContext instance, Identifier texture, int x, int y, int width, int height) {
|
||||
return !viaFabricPlus$disableServerPinging; // Remove ping bar
|
||||
}
|
||||
|
||||
@WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setTooltip(Ljava/util/List;)V"))
|
||||
private boolean disableServerPinging(MultiplayerScreen instance, List<Text> tooltip) {
|
||||
return !viaFabricPlus$disableServerPinging; // Remove player list tooltip
|
||||
}
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/world/WorldIcon;getTextureId()Lnet/minecraft/util/Identifier;"))
|
||||
private Identifier disableServerPinging(WorldIcon instance) {
|
||||
if (viaFabricPlus$disableServerPinging) { // Remove server icon
|
||||
return WorldIcon.UNKNOWN_SERVER_ID;
|
||||
} else {
|
||||
return this.icon.getTextureId();
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setTooltip(Lnet/minecraft/text/Text;)V"))
|
||||
private void drawTranslatingState(MultiplayerScreen instance, Text text) {
|
||||
if (viaFabricPlus$disableServerPinging) { // Remove ping bar tooltip
|
||||
return;
|
||||
}
|
||||
final List<Text> tooltips = new ArrayList<>();
|
||||
tooltips.add(text);
|
||||
if (GeneralSettings.global().showAdvertisedServerVersion.getValue()) {
|
||||
final ProtocolVersion version = ((IServerInfo) server).viaFabricPlus$translatingVersion();
|
||||
if (version != null) {
|
||||
tooltips.add(Text.translatable("base.viafabricplus.via_translates_to", version.getName() + " (" + version.getOriginalVersion() + ")"));
|
||||
tooltips.add(Text.translatable("base.viafabricplus.server_version", server.version.getString() + " (" + server.protocolVersion + ")"));
|
||||
}
|
||||
}
|
||||
|
||||
original.call(instance, tooltipCopy);
|
||||
instance.setTooltip(Lists.transform(tooltips, Text::asOrderedText));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,25 +19,25 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.perserverversion;
|
||||
|
||||
import de.florianmichael.viafabricplus.injection.access.IPerformanceLog;
|
||||
import net.minecraft.util.profiler.PerformanceLog;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IMultiValueDebugSampleLogImpl;
|
||||
import net.minecraft.util.profiler.MultiValueDebugSampleLogImpl;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(PerformanceLog.class)
|
||||
public abstract class MixinPerformanceLog implements IPerformanceLog {
|
||||
@Mixin(MultiValueDebugSampleLogImpl.class)
|
||||
public abstract class MixinMultiValueDebugSampleLogImpl implements IMultiValueDebugSampleLogImpl {
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaFabricPlus$forcedVersion;
|
||||
private ProtocolVersion viaFabricPlus$forcedVersion;
|
||||
|
||||
@Override
|
||||
public VersionEnum viaFabricPlus$getForcedVersion() {
|
||||
public ProtocolVersion viaFabricPlus$getForcedVersion() {
|
||||
return this.viaFabricPlus$forcedVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabricPlus$setForcedVersion(VersionEnum version) {
|
||||
public void viaFabricPlus$setForcedVersion(ProtocolVersion version) {
|
||||
this.viaFabricPlus$forcedVersion = version;
|
||||
}
|
||||
|
|
@ -19,23 +19,24 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.perserverversion;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(MultiplayerScreen.class)
|
||||
public abstract class MixinMultiplayerScreen {
|
||||
|
||||
@Shadow protected abstract void connect(ServerInfo entry);
|
||||
|
||||
@Redirect(method = "directConnect", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;connect(Lnet/minecraft/client/network/ServerInfo;)V"))
|
||||
private void storeDirectConnectionPhase(MultiplayerScreen instance, ServerInfo entry) {
|
||||
((IServerInfo) entry).viaFabricPlus$passDirectConnectScreen();
|
||||
connect(entry);
|
||||
@WrapOperation(method = "directConnect", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;connect(Lnet/minecraft/client/network/ServerInfo;)V"))
|
||||
private void storeDirectConnectionPhase(MultiplayerScreen instance, ServerInfo entry, Operation<Void> original) {
|
||||
((IServerInfo) entry).viaFabricPlus$passDirectConnectScreen(true);
|
||||
original.call(instance, entry);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,13 +20,14 @@
|
|||
package de.florianmichael.viafabricplus.injection.mixin.base.perserverversion;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import de.florianmichael.viafabricplus.injection.access.IPerformanceLog;
|
||||
import de.florianmichael.viafabricplus.fixes.ClientsideFixes;
|
||||
import de.florianmichael.viafabricplus.injection.access.IMultiValueDebugSampleLogImpl;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import net.minecraft.client.network.MultiplayerServerListPinger;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.util.profiler.PerformanceLog;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.minecraft.util.profiler.MultiValueDebugSampleLogImpl;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
@ -36,20 +37,27 @@ import java.net.InetSocketAddress;
|
|||
@Mixin(MultiplayerServerListPinger.class)
|
||||
public abstract class MixinMultiplayerServerListPinger {
|
||||
|
||||
@Redirect(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/PerformanceLog;)Lnet/minecraft/network/ClientConnection;"))
|
||||
private ClientConnection setForcedVersion(InetSocketAddress address, boolean useEpoll, PerformanceLog packetSizeLog, @Local ServerInfo serverInfo) {
|
||||
final VersionEnum forcedVersion = ((IServerInfo) serverInfo).viaFabricPlus$forcedVersion();
|
||||
@Redirect(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ServerAddress;parse(Ljava/lang/String;)Lnet/minecraft/client/network/ServerAddress;"))
|
||||
private ServerAddress replaceDefaultPort(String address, @Local(argsOnly = true) ServerInfo entry) {
|
||||
// Replace port when pinging the server and the forced version is set
|
||||
return ClientsideFixes.replaceDefaultPort(address, ((IServerInfo) entry).viaFabricPlus$forcedVersion());
|
||||
}
|
||||
|
||||
if (forcedVersion != null && !((IServerInfo) serverInfo).viaFabricPlus$passedDirectConnectScreen()) {
|
||||
@Redirect(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/MultiValueDebugSampleLogImpl;)Lnet/minecraft/network/ClientConnection;"))
|
||||
private ClientConnection setForcedVersion(InetSocketAddress address, boolean useEpoll, MultiValueDebugSampleLogImpl packetSizeLog, @Local(argsOnly = true) ServerInfo serverInfo) {
|
||||
final IServerInfo mixinServerInfo = (IServerInfo) serverInfo;
|
||||
|
||||
if (mixinServerInfo.viaFabricPlus$forcedVersion() != null && !mixinServerInfo.viaFabricPlus$passedDirectConnectScreen()) {
|
||||
// We use the PerformanceLog field to store the forced version since it's always null when pinging a server
|
||||
// So we can create a dummy instance, store the forced version in it and later destroy the instance again
|
||||
// To avoid any side effects, we also support cases where a mod is also creating a PerformanceLog instance
|
||||
if (packetSizeLog == null) {
|
||||
packetSizeLog = new PerformanceLog();
|
||||
packetSizeLog = new MultiValueDebugSampleLogImpl(1);
|
||||
}
|
||||
|
||||
// Attach the forced version to the PerformanceLog instance
|
||||
((IPerformanceLog) packetSizeLog).viaFabricPlus$setForcedVersion(forcedVersion);
|
||||
((IMultiValueDebugSampleLogImpl) packetSizeLog).viaFabricPlus$setForcedVersion(mixinServerInfo.viaFabricPlus$forcedVersion());
|
||||
mixinServerInfo.viaFabricPlus$passDirectConnectScreen(false);
|
||||
}
|
||||
|
||||
return ClientConnection.connect(address, useEpoll, packetSizeLog);
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.perserverversion;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
@ -39,30 +39,26 @@ public abstract class MixinServerInfo implements IServerInfo {
|
|||
public String name;
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaFabricPlus$forcedVersion = null;
|
||||
private ProtocolVersion viaFabricPlus$forcedVersion = null;
|
||||
|
||||
@Unique
|
||||
private boolean viaFabricPlus$passedDirectConnectScreen;
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaFabricPlus$translatingVersion;
|
||||
private ProtocolVersion viaFabricPlus$translatingVersion;
|
||||
|
||||
@Inject(method = "toNbt", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void saveForcedVersion(CallbackInfoReturnable<NbtCompound> cir, NbtCompound nbtCompound) {
|
||||
if (viaFabricPlus$forcedVersion == null) {
|
||||
return;
|
||||
if (viaFabricPlus$forcedVersion != null) {
|
||||
nbtCompound.putString("viafabricplus_forcedversion", viaFabricPlus$forcedVersion.getName());
|
||||
}
|
||||
|
||||
nbtCompound.putInt("viafabricplus_forcedversion", viaFabricPlus$forcedVersion.getOriginalVersion());
|
||||
}
|
||||
|
||||
@Inject(method = "fromNbt", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private static void loadForcedVersion(NbtCompound root, CallbackInfoReturnable<ServerInfo> cir, ServerInfo serverInfo) {
|
||||
if (root.contains("viafabricplus_forcedversion")) {
|
||||
final VersionEnum version = VersionEnum.fromProtocolId(root.getInt("viafabricplus_forcedversion"));
|
||||
if (VersionEnum.UNKNOWN.equals(version)) {
|
||||
((IServerInfo) serverInfo).viaFabricPlus$forceVersion(null);
|
||||
} else {
|
||||
final ProtocolVersion version = ProtocolVersion.getClosest(root.getString("viafabricplus_forcedversion"));
|
||||
if (version != null) {
|
||||
((IServerInfo) serverInfo).viaFabricPlus$forceVersion(version);
|
||||
}
|
||||
}
|
||||
|
@ -74,35 +70,32 @@ public abstract class MixinServerInfo implements IServerInfo {
|
|||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaFabricPlus$forcedVersion() {
|
||||
public ProtocolVersion viaFabricPlus$forcedVersion() {
|
||||
return viaFabricPlus$forcedVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabricPlus$forceVersion(VersionEnum version) {
|
||||
public void viaFabricPlus$forceVersion(ProtocolVersion version) {
|
||||
viaFabricPlus$forcedVersion = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean viaFabricPlus$passedDirectConnectScreen() {
|
||||
final boolean previous = viaFabricPlus$passedDirectConnectScreen;
|
||||
viaFabricPlus$passedDirectConnectScreen = false;
|
||||
|
||||
return previous;
|
||||
return viaFabricPlus$passedDirectConnectScreen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabricPlus$passDirectConnectScreen() {
|
||||
viaFabricPlus$passedDirectConnectScreen = true;
|
||||
public void viaFabricPlus$passDirectConnectScreen(boolean state) {
|
||||
viaFabricPlus$passedDirectConnectScreen = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaFabricPlus$translatingVersion() {
|
||||
public ProtocolVersion viaFabricPlus$translatingVersion() {
|
||||
return viaFabricPlus$translatingVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabricPlus$setTranslatingVersion(VersionEnum version) {
|
||||
public void viaFabricPlus$setTranslatingVersion(ProtocolVersion version) {
|
||||
viaFabricPlus$translatingVersion = version;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
package de.florianmichael.viafabricplus.injection.mixin.compat.classic4j;
|
||||
|
||||
import de.florianmichael.viafabricplus.injection.access.ITextFieldWidget;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.util.StringHelper;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -37,22 +37,18 @@ public abstract class MixinTextFieldWidget implements ITextFieldWidget {
|
|||
@Unique
|
||||
private boolean viaFabricPlus$forbiddenCharactersUnlocked = false;
|
||||
|
||||
@Redirect(method = "charTyped", at = @At(value = "INVOKE", target = "Lnet/minecraft/SharedConstants;isValidChar(C)Z"))
|
||||
@Redirect(method = "charTyped", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/StringHelper;isValidChar(C)Z"))
|
||||
private boolean allowForbiddenCharacters(char c) {
|
||||
if (this.viaFabricPlus$forbiddenCharactersUnlocked) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return SharedConstants.isValidChar(c);
|
||||
return this.viaFabricPlus$forbiddenCharactersUnlocked || StringHelper.isValidChar(c);
|
||||
}
|
||||
|
||||
@Redirect(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/SharedConstants;stripInvalidChars(Ljava/lang/String;)Ljava/lang/String;"))
|
||||
@Redirect(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/StringHelper;stripInvalidChars(Ljava/lang/String;)Ljava/lang/String;"))
|
||||
private String allowForbiddenCharacters(String string) {
|
||||
if (this.viaFabricPlus$forbiddenCharactersUnlocked) {
|
||||
return string;
|
||||
} else {
|
||||
return StringHelper.stripInvalidChars(string);
|
||||
}
|
||||
|
||||
return SharedConstants.stripInvalidChars(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 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 de.florianmichael.viafabricplus.injection.mixin.compat.fabricapi;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.fixes.versioned.visual.FootStepParticle1_12_2;
|
||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import net.fabricmc.fabric.impl.registry.sync.RegistrySyncManager;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(RegistrySyncManager.class)
|
||||
public abstract class MixinRegistrySyncManager {
|
||||
|
||||
@WrapOperation(method = "createAndPopulateRegistryMap", at = @At(value = "INVOKE", target = "Lnet/minecraft/registry/Registry;getId(Ljava/lang/Object;)Lnet/minecraft/util/Identifier;"), require = 0)
|
||||
private static Identifier skipFootStepParticle(Registry instance, Object t, Operation<Identifier> original) {
|
||||
final Identifier id = original.call(instance, t);
|
||||
if (id == FootStepParticle1_12_2.ID) {
|
||||
return null;
|
||||
} else {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "checkRemoteRemap", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;)V", ordinal = 0), cancellable = true, remap = false)
|
||||
private static void ignoreFabricSyncErrors(Map<Identifier, Object2IntMap<Identifier>> map, CallbackInfo ci) {
|
||||
if (DebugSettings.global().ignoreFabricSyncErrors.getValue()) {
|
||||
ViaFabricPlus.global().getLogger().warn("Ignoring missing registries from Fabric API");
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -19,8 +19,8 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.compat.ipnext;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -34,6 +34,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
*
|
||||
* Fixes https://github.com/ViaVersion/ViaFabricPlus/issues/209
|
||||
*/
|
||||
@SuppressWarnings("UnresolvedMixinReference")
|
||||
@Pseudo
|
||||
@Mixin(targets = "org.anti_ad.mc.ipnext.event.AutoRefillHandler$ItemSlotMonitor", remap = false)
|
||||
public abstract class MixinAutoRefillHandler_ItemSlotMonitor {
|
||||
|
@ -43,14 +44,14 @@ public abstract class MixinAutoRefillHandler_ItemSlotMonitor {
|
|||
|
||||
@Inject(method = { "checkHandle", "checkShouldHandle" }, at = @At("HEAD"), cancellable = true)
|
||||
public void dontHandleOffhandSlot(CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
if (currentSlotId == 45) ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "updateCurrent", at = @At(value = "FIELD", target = "Lorg/anti_ad/mc/ipnext/event/AutoRefillHandler$ItemSlotMonitor;currentSlotId:I", shift = At.Shift.AFTER), cancellable = true)
|
||||
public void dontUpdateCurrentOffhandSlot(CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
if (currentSlotId == 45) ci.cancel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
/*
|
||||
* JsonWebToken is used by MinecraftAuth and since it's using Java services, it's not working with the fabric loader
|
||||
* JsonWebToken is used by MinecraftAuth, and since it's using Java services, it's not working with the fabric loader,
|
||||
* So we have to change all services usages by using the normal Java API
|
||||
*/
|
||||
@Mixin(value = Classes.class, remap = false)
|
||||
|
|
|
@ -26,14 +26,14 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
/*
|
||||
* JsonWebToken is used by MinecraftAuth and since it's using Java services, it's not working with the fabric loader
|
||||
* JsonWebToken is used by MinecraftAuth, and since it's using Java services, it's not working with the fabric loader,
|
||||
* So we have to change all services usages by using the normal Java API
|
||||
*/
|
||||
@Mixin(value = DefaultJwtParserBuilder.class, remap = false)
|
||||
public abstract class MixinDefaultJwtParserBuilder {
|
||||
|
||||
@Redirect(method = "build()Lio/jsonwebtoken/JwtParser;", at = @At(value = "INVOKE", target = "Lio/jsonwebtoken/impl/lang/Services;loadFirst(Ljava/lang/Class;)Ljava/lang/Object;"))
|
||||
public Object removeServicesSupport(Class<Object> result) {
|
||||
public Object removeServicesSupport(Class<?> spi) {
|
||||
return new GsonDeserializer<>();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 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 de.florianmichael.viafabricplus.injection.mixin.compat.lithium;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
// Lithium is overriding the sorting with an optimized implementation
|
||||
// https://github.com/CaffeineMC/lithium-fabric/blob/develop/src/main/java/me/jellysquid/mods/lithium/mixin/entity/collisions/movement/EntityMixin.java#L84
|
||||
@Mixin(value = Entity.class, priority = 1001 /* Lithium has to be applied first */)
|
||||
public abstract class MixinEntity {
|
||||
|
||||
@SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"})
|
||||
@Redirect(method = "lithium$CollideMovement", at = @At(value = "INVOKE", target = "Ljava/lang/Math;abs(D)D", ordinal = 0), remap = false)
|
||||
private static double alwaysSortYXZ(double a) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
return Double.MAX_VALUE;
|
||||
} else {
|
||||
return Math.abs(a);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -23,7 +23,7 @@ import com.mojang.authlib.minecraft.client.MinecraftClient;
|
|||
import com.mojang.authlib.yggdrasil.YggdrasilUserApiService;
|
||||
import com.mojang.authlib.yggdrasil.response.KeyPairResponse;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.fixes.replacement.KeyPairResponse1_19_0;
|
||||
import de.florianmichael.viafabricplus.fixes.versioned.KeyPairResponse1_19_0;
|
||||
import de.florianmichael.viafabricplus.injection.access.ILegacyKeySignatureStorage;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
|
|
@ -16,28 +16,29 @@
|
|||
* 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 de.florianmichael.viafabricplus.protocolhack.util;
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import net.lenni0451.reflect.Enums;
|
||||
import net.lenni0451.reflect.stream.RStream;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Map;
|
||||
@Mixin(ActionResult.class)
|
||||
public abstract class MixinActionResult {
|
||||
|
||||
public class VersionEnumExtension {
|
||||
@Shadow
|
||||
public abstract boolean isAccepted();
|
||||
|
||||
private static final ProtocolVersion autoDetect = ProtocolVersion.register(-2, "Auto Detect (1.7+ servers)");
|
||||
public static final VersionEnum AUTO_DETECT = Enums.newInstance(VersionEnum.class, "AUTO_DETECT", VersionEnum.UNKNOWN.ordinal(), new Class<?>[]{ProtocolVersion.class}, new Object[]{autoDetect});
|
||||
|
||||
static {
|
||||
Enums.addEnumInstance(VersionEnum.class, AUTO_DETECT);
|
||||
RStream.of(VersionEnum.class).fields().by("VERSION_REGISTRY").<Map<ProtocolVersion, VersionEnum>>get().put(autoDetect, AUTO_DETECT);
|
||||
VersionEnum.SORTED_VERSIONS.add(AUTO_DETECT);
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
// calls static initializer
|
||||
@Inject(method = "shouldSwingHand", at = @At("HEAD"), cancellable = true)
|
||||
private void swingWhenConsume(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
|
||||
cir.setReturnValue(this.isAccepted());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -19,12 +19,13 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.client.network.Address;
|
||||
import net.minecraft.client.network.AddressResolver;
|
||||
import net.minecraft.client.network.AllowedAddressResolver;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -43,7 +44,7 @@ public abstract class MixinAllowedAddressResolver {
|
|||
|
||||
@Inject(method = "resolve", at = @At("HEAD"), cancellable = true)
|
||||
private void oldResolveBehaviour(ServerAddress address, CallbackInfoReturnable<Optional<Address>> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5) || ProtocolHack.getTargetVersion().equals(VersionEnum.bedrockLatest)) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4) || ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) {
|
||||
cir.setReturnValue(this.addressResolver.resolve(address));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.client.render.chunk.ChunkBuilder;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
@ -32,7 +32,7 @@ public abstract class MixinBuiltChunk {
|
|||
|
||||
@Inject(method = "shouldBuild", at = @At("HEAD"), cancellable = true)
|
||||
private void modifyRenderCondition(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public abstract class MixinCamera {
|
|||
|
||||
@Inject(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;setPos(DDD)V", shift = At.Shift.BEFORE))
|
||||
private void onUpdateHeight(BlockView area, Entity focusedEntity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) {
|
||||
if (!DebugSettings.global().replaceSneaking.isEnabled() && DebugSettings.global().sneakInstant.isEnabled()) {
|
||||
if (!DebugSettings.global().replaceSneaking.isEnabled() && DebugSettings.global().sneakInstantly.isEnabled()) {
|
||||
cameraY = lastCameraY = focusedEntity.getStandingEyeHeight();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,13 +19,12 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.ChatInputSuggestor;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.text.OrderedText;
|
||||
import net.minecraft.text.Style;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
|
@ -59,43 +58,37 @@ public abstract class MixinChatInputSuggestor {
|
|||
|
||||
@Inject(method = "provideRenderText", at = @At(value = "HEAD"), cancellable = true)
|
||||
private void disableTextFieldColors(String original, int firstCharacterIndex, CallbackInfoReturnable<OrderedText> cir) {
|
||||
if (!this.viaFabricPlus$cancelTabComplete()) {
|
||||
return;
|
||||
if (this.viaFabricPlus$cancelTabComplete()) {
|
||||
cir.setReturnValue(OrderedText.styledForwardsVisitedString(original, Style.EMPTY));
|
||||
}
|
||||
|
||||
cir.setReturnValue(OrderedText.styledForwardsVisitedString(original, Style.EMPTY));
|
||||
}
|
||||
|
||||
@Inject(method = "keyPressed", at = @At("HEAD"), cancellable = true)
|
||||
private void handle1_12_2KeyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (!this.viaFabricPlus$cancelTabComplete()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (keyCode == GLFW.GLFW_KEY_TAB && this.window == null) {
|
||||
this.refresh();
|
||||
} else if (this.window != null) {
|
||||
if (this.window.keyPressed(keyCode, scanCode, modifiers)) {
|
||||
cir.setReturnValue(true);
|
||||
return;
|
||||
if (this.viaFabricPlus$cancelTabComplete()) {
|
||||
if (keyCode == GLFW.GLFW_KEY_TAB && this.window == null) {
|
||||
this.refresh();
|
||||
} else if (this.window != null) {
|
||||
if (this.window.keyPressed(keyCode, scanCode, modifiers)) {
|
||||
cir.setReturnValue(true);
|
||||
return;
|
||||
}
|
||||
this.textField.setSuggestion(null);
|
||||
this.window = null;
|
||||
}
|
||||
this.textField.setSuggestion(null);
|
||||
this.window = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "render", at = @At("HEAD"))
|
||||
private void clearMessages(DrawContext drawContext, int mouseX, int mouseY, CallbackInfo ci) {
|
||||
if (!this.viaFabricPlus$cancelTabComplete()) {
|
||||
return;
|
||||
if (this.viaFabricPlus$cancelTabComplete()) {
|
||||
this.messages.clear();
|
||||
}
|
||||
|
||||
this.messages.clear();
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean viaFabricPlus$cancelTabComplete() {
|
||||
return ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2) && this.textField.getText().startsWith("/");
|
||||
return DebugSettings.global().legacyTabCompletions.isEnabled() && this.textField.getText().startsWith("/");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.client.network.ClientCommandSource;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -41,7 +41,7 @@ public abstract class MixinClientCommandSource {
|
|||
|
||||
@Inject(method = {"getPlayerNames", "getChatSuggestions"}, at = @At("HEAD"), cancellable = true)
|
||||
private void returnChatSuggestions(CallbackInfoReturnable<Collection<String>> cir) {
|
||||
if (ProtocolHack.getTargetVersion().equals(VersionEnum.bedrockLatest)) {
|
||||
if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) {
|
||||
cir.setReturnValue(this.chatSuggestions);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import de.florianmichael.viafabricplus.fixes.replacement.PendingUpdateManager1_18_2;
|
||||
import de.florianmichael.viafabricplus.fixes.versioned.PendingUpdateManager1_18_2;
|
||||
import de.florianmichael.viafabricplus.injection.access.IEntity;
|
||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 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 de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
@Mixin(EnchantmentHelper.class)
|
||||
public abstract class MixinEnchantmentHelper {
|
||||
|
||||
@ModifyConstant(method = "getLevelFromNbt", constant = @Constant(intValue = 0))
|
||||
private static int usePossibleMinLevel(int constant) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
return Short.MIN_VALUE;
|
||||
}
|
||||
|
||||
return constant;
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "getLevelFromNbt", constant = @Constant(intValue = 255))
|
||||
private static int usePossibleMaxLevel(int constant) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
return Short.MAX_VALUE;
|
||||
}
|
||||
|
||||
return constant;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,14 +19,14 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import de.florianmichael.viafabricplus.fixes.data.Material1_19_4;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.impl.ViaFabricPlusMappingDataLoader;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.fluid.FlowableFluid;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
@ -36,9 +36,10 @@ public abstract class MixinFlowableFluid {
|
|||
|
||||
@Redirect(method = "isFlowBlocked", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isSideSolidFullSquare(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;)Z"))
|
||||
private boolean modifyIsSolidBlock(BlockState instance, BlockView blockView, BlockPos blockPos, Direction direction) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_11_1to1_11_2)) {
|
||||
return Material1_19_4.getMaterial(instance).solid();
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_11_1)) {
|
||||
final ViaFabricPlusMappingDataLoader.Material material = ViaFabricPlusMappingDataLoader.MATERIALS.get(ViaFabricPlusMappingDataLoader.getBlockMaterial(instance.getBlock()));
|
||||
return material.solid();
|
||||
} else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
final Block block = instance.getBlock();
|
||||
if (block instanceof ShulkerBoxBlock || block instanceof LeavesBlock || block instanceof TrapdoorBlock ||
|
||||
block == Blocks.BEACON || block == Blocks.CAULDRON || block == Blocks.GLASS ||
|
||||
|
@ -48,7 +49,6 @@ public abstract class MixinFlowableFluid {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return instance.isSideSolidFullSquare(blockView, blockPos, direction);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,8 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import de.florianmichael.viafabricplus.fixes.data.RenderableGlyphDiff;
|
||||
import de.florianmichael.viafabricplus.fixes.replacement.BuiltinEmptyGlyph1_12_2;
|
||||
import de.florianmichael.viafabricplus.fixes.versioned.visual.BuiltinEmptyGlyph1_12_2;
|
||||
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.*;
|
||||
|
@ -36,8 +35,6 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
|||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(FontStorage.class)
|
||||
public abstract class MixinFontStorage {
|
||||
|
||||
|
@ -54,20 +51,20 @@ public abstract class MixinFontStorage {
|
|||
@Unique
|
||||
private GlyphRenderer viaFabricPlus$blankGlyphRenderer1_12_2;
|
||||
|
||||
@Inject(method = "setFonts", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/BuiltinEmptyGlyph;bake(Ljava/util/function/Function;)Lnet/minecraft/client/font/GlyphRenderer;", ordinal = 0))
|
||||
private void bakeBlankGlyph1_12_2(List<Font> fonts, CallbackInfo ci) {
|
||||
@Inject(method = "clear", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/BuiltinEmptyGlyph;bake(Ljava/util/function/Function;)Lnet/minecraft/client/font/GlyphRenderer;", ordinal = 0))
|
||||
private void bakeBlankGlyph1_12_2(CallbackInfo ci) {
|
||||
this.viaFabricPlus$blankGlyphRenderer1_12_2 = BuiltinEmptyGlyph1_12_2.INSTANCE.bake(this::getGlyphRenderer);
|
||||
}
|
||||
|
||||
@Inject(method = "findGlyph", at = @At("RETURN"), cancellable = true)
|
||||
private void filterGlyphs1(int codePoint, CallbackInfoReturnable<FontStorage.GlyphPair> cir, @Local Font font) {
|
||||
private void filterGlyphs(int codePoint, CallbackInfoReturnable<FontStorage.GlyphPair> cir) {
|
||||
if (this.viaFabricPlus$shouldBeInvisible(codePoint)) {
|
||||
cir.setReturnValue(this.viaFabricPlus$getBlankGlyphPair());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "findGlyphRenderer", at = @At("RETURN"), cancellable = true)
|
||||
private void filterGlyphs2(int codePoint, CallbackInfoReturnable<GlyphRenderer> cir, @Local Font font) {
|
||||
private void filterGlyphRenderer(int codePoint, CallbackInfoReturnable<GlyphRenderer> cir) {
|
||||
if (this.viaFabricPlus$shouldBeInvisible(codePoint)) {
|
||||
cir.setReturnValue(this.viaFabricPlus$getBlankGlyphRenderer());
|
||||
}
|
||||
|
|
|
@ -19,39 +19,23 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.client.option.GameOptions;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
||||
@Mixin(GameOptions.class)
|
||||
public abstract class MixinGameOptions {
|
||||
|
||||
@Shadow
|
||||
public boolean useNativeTransport;
|
||||
|
||||
@ModifyVariable(method = "setServerViewDistance", at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
||||
private int changeServerViewDistance(int viewDistance) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_17_1)) return 0;
|
||||
return viewDistance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author RK_01
|
||||
* @reason Needed as an indicator if the client wants to ping a server or connect to a server
|
||||
*/
|
||||
@Overwrite
|
||||
public boolean shouldUseNativeTransport() {
|
||||
if (!this.useNativeTransport) {
|
||||
ViaFabricPlus.global().getLogger().error("Native transport is disabled, but enabling it anyway since we use it as an indicator if the client wants to ping a server or connect to a server.");
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_17_1)) {
|
||||
return 0;
|
||||
} else {
|
||||
return viewDistance;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -28,7 +28,7 @@ import net.minecraft.util.hit.BlockHitResult;
|
|||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -42,9 +42,9 @@ public abstract class MixinGameRenderer {
|
|||
@Final
|
||||
MinecraftClient client;
|
||||
|
||||
@ModifyExpressionValue(method = "updateTargetedEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;raycast(DFZ)Lnet/minecraft/util/hit/HitResult;"))
|
||||
@ModifyExpressionValue(method = "findCrosshairTarget", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;raycast(DFZ)Lnet/minecraft/util/hit/HitResult;"))
|
||||
private HitResult bedrockReachAroundRaycast(HitResult hitResult) {
|
||||
if (ProtocolHack.getTargetVersion().equals(VersionEnum.bedrockLatest)) {
|
||||
if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) {
|
||||
final Entity entity = this.client.getCameraEntity();
|
||||
if (hitResult.getType() != HitResult.Type.MISS) return hitResult;
|
||||
if (!this.viaFabricPlus$canReachAround(entity)) return hitResult;
|
||||
|
|
|
@ -45,7 +45,7 @@ public abstract class MixinKeyboard implements IMouseKeyboard {
|
|||
|
||||
@Redirect(method = {"method_22676", "method_22675"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;execute(Ljava/lang/Runnable;)V"))
|
||||
private void storeEvent(MinecraftClient instance, Runnable runnable) {
|
||||
if (this.client.getNetworkHandler() != null && this.client.currentScreen != null && DebugSettings.global().executeInputsInSync.isEnabled()) {
|
||||
if (this.client.getNetworkHandler() != null && this.client.currentScreen != null && DebugSettings.global().executeInputsSynchronously.isEnabled()) {
|
||||
this.viaFabricPlus$pendingScreenEvents.offer(runnable);
|
||||
} else {
|
||||
instance.execute(runnable);
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.input.Input;
|
||||
import net.minecraft.client.input.KeyboardInput;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
@ -33,12 +33,13 @@ public abstract class MixinKeyboardInput extends Input {
|
|||
|
||||
@ModifyVariable(method = "tick", at = @At(value = "LOAD", ordinal = 0), argsOnly = true)
|
||||
private boolean changeSneakSlowdownCondition(boolean slowDown) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
return this.sneaking;
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
} else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
|
||||
return !MinecraftClient.getInstance().player.isSpectator() && (this.sneaking || slowDown);
|
||||
} else {
|
||||
return slowDown;
|
||||
}
|
||||
return slowDown;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,14 +20,15 @@
|
|||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.injector.WrapWithCondition;
|
||||
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.protocols.v1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
|
||||
import de.florianmichael.viafabricplus.fixes.data.ItemRegistryDiff;
|
||||
import de.florianmichael.viafabricplus.injection.access.IMouseKeyboard;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
import net.minecraft.client.Keyboard;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
@ -38,7 +39,6 @@ import net.minecraft.entity.player.PlayerInventory;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -60,7 +60,7 @@ public abstract class MixinMinecraftClient {
|
|||
public ClientPlayerEntity player;
|
||||
|
||||
@Shadow
|
||||
public int attackCooldown;
|
||||
protected int attackCooldown;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
|
@ -89,18 +89,17 @@ public abstract class MixinMinecraftClient {
|
|||
|
||||
@Redirect(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ActionResult;shouldSwingHand()Z", ordinal = 0))
|
||||
private boolean disableSwing(ActionResult instance) {
|
||||
return instance.shouldSwingHand() && ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_15);
|
||||
return instance.shouldSwingHand() && ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_15);
|
||||
}
|
||||
|
||||
@Redirect(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ActionResult;shouldSwingHand()Z", ordinal = 2))
|
||||
private boolean disableSwing2(ActionResult instance) {
|
||||
return instance.shouldSwingHand() && ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_15);
|
||||
return instance.shouldSwingHand() && ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_15);
|
||||
}
|
||||
|
||||
@Redirect(method = "handleInputEvents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V"))
|
||||
private void disableSwing(ClientPlayerEntity instance, Hand hand) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) return;
|
||||
instance.swingHand(hand);
|
||||
@WrapWithCondition(method = "handleInputEvents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V"))
|
||||
private boolean disableSwing(ClientPlayerEntity instance, Hand hand) {
|
||||
return ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_15);
|
||||
}
|
||||
|
||||
@Inject(method = "tick",
|
||||
|
@ -111,7 +110,7 @@ public abstract class MixinMinecraftClient {
|
|||
)
|
||||
)
|
||||
private void processInputQueues(CallbackInfo ci) {
|
||||
if (DebugSettings.global().executeInputsInSync.isEnabled()) {
|
||||
if (DebugSettings.global().executeInputsSynchronously.isEnabled()) {
|
||||
Queue<Runnable> inputEvents = ((IMouseKeyboard) this.mouse).viaFabricPlus$getPendingScreenEvents();
|
||||
while (!inputEvents.isEmpty()) inputEvents.poll().run();
|
||||
|
||||
|
@ -121,37 +120,38 @@ public abstract class MixinMinecraftClient {
|
|||
}
|
||||
|
||||
@Inject(method = "handleInputEvents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/tutorial/TutorialManager;onInventoryOpened()V", shift = At.Shift.AFTER))
|
||||
private void sendOpenInventoryPacket(CallbackInfo ci) throws Exception {
|
||||
private void sendOpenInventoryPacket(CallbackInfo ci) {
|
||||
if (DebugSettings.global().sendOpenInventoryPacket.isEnabled()) {
|
||||
final PacketWrapper clientStatus = PacketWrapper.create(ServerboundPackets1_9_3.CLIENT_STATUS, ProtocolHack.getPlayNetworkUserConnection());
|
||||
clientStatus.write(Type.VAR_INT, 2); // Open Inventory Achievement
|
||||
clientStatus.scheduleSendToServer(Protocol1_12To1_11_1.class);
|
||||
final PacketWrapper clientCommand = PacketWrapper.create(ServerboundPackets1_9_3.CLIENT_COMMAND, ProtocolTranslator.getPlayNetworkUserConnection());
|
||||
clientCommand.write(Types.VAR_INT, 2); // Open Inventory Achievement
|
||||
clientCommand.scheduleSendToServer(Protocol1_11_1To1_12.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "doAttack", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;crosshairTarget:Lnet/minecraft/util/hit/HitResult;", shift = At.Shift.BEFORE, ordinal = 0))
|
||||
private void fixSwingPacketOrder(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
this.player.swingHand(Hand.MAIN_HAND);
|
||||
}
|
||||
}
|
||||
|
||||
@WrapWithCondition(method = "doAttack", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V"))
|
||||
private boolean fixSwingPacketOrder(ClientPlayerEntity instance, Hand hand) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_8);
|
||||
return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_8);
|
||||
}
|
||||
|
||||
@Redirect(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;attackCooldown:I", ordinal = 1))
|
||||
private int dontIncrementCooldown(MinecraftClient instance) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
private int moveCooldownIncrement(MinecraftClient instance) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
return 0;
|
||||
} else {
|
||||
return attackCooldown;
|
||||
}
|
||||
return attackCooldown;
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;handleInputEvents()V", shift = At.Shift.BEFORE))
|
||||
private void postIncrementCooldown(CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
private void moveCooldownIncrement(CallbackInfo ci) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
if (this.attackCooldown > 0) {
|
||||
--this.attackCooldown;
|
||||
}
|
||||
|
@ -160,10 +160,7 @@ public abstract class MixinMinecraftClient {
|
|||
|
||||
@ModifyExpressionValue(method = "handleBlockBreaking", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z"))
|
||||
private boolean allowBlockBreakAndItemUsageAtTheSameTime(boolean original) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
|
||||
return false;
|
||||
}
|
||||
return original;
|
||||
return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_7_6) && original;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,14 +21,14 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
|||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IMouseKeyboard;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocolhack.util.MathUtil;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.util.MathUtil;
|
||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.Mouse;
|
||||
import net.minecraft.client.option.SimpleOption;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -51,7 +51,7 @@ public abstract class MixinMouse implements IMouseKeyboard {
|
|||
|
||||
@Redirect(method = {"method_22684", "method_22685"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;execute(Ljava/lang/Runnable;)V"))
|
||||
private void storeEvent(MinecraftClient instance, Runnable runnable) {
|
||||
if (this.client.getNetworkHandler() != null && this.client.currentScreen != null && DebugSettings.global().executeInputsInSync.isEnabled()) {
|
||||
if (this.client.getNetworkHandler() != null && this.client.currentScreen != null && DebugSettings.global().executeInputsSynchronously.isEnabled()) {
|
||||
this.viaFabricPlus$pendingScreenEvents.offer(runnable);
|
||||
} else {
|
||||
instance.execute(runnable);
|
||||
|
@ -62,7 +62,7 @@ public abstract class MixinMouse implements IMouseKeyboard {
|
|||
private Object adjustMouseSensitivity1_13_2(SimpleOption<Double> instance, Operation<Double> original) {
|
||||
final Double value = original.call(instance);
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
|
||||
return (double) MathUtil.get1_13SliderValue(value.floatValue()).keyFloat();
|
||||
} else {
|
||||
return value;
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
@ -35,7 +35,7 @@ public abstract class MixinPlayerInventory {
|
|||
|
||||
@Redirect(method = "<init>", slice = @Slice(from = @At(value = "CONSTANT", args = "intValue=1")), at = @At(value = "INVOKE", target = "Lnet/minecraft/util/collection/DefaultedList;ofSize(ILjava/lang/Object;)Lnet/minecraft/util/collection/DefaultedList;", ordinal = 0))
|
||||
private <T> DefaultedList<T> redirectOffhandInventory(int size, T def) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
//noinspection MixinInnerClass
|
||||
return new DefaultedList<>(new AbstractList<T>() {
|
||||
@Override
|
||||
|
@ -54,9 +54,9 @@ public abstract class MixinPlayerInventory {
|
|||
}
|
||||
}, def) {
|
||||
};
|
||||
} else {
|
||||
return DefaultedList.ofSize(size, def);
|
||||
}
|
||||
|
||||
return DefaultedList.ofSize(size, def);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,13 +21,13 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
|||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.yggdrasil.ProfileResult;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.PlayerListEntry;
|
||||
import net.minecraft.client.texture.PlayerSkinProvider;
|
||||
import net.minecraft.client.util.SkinTextures;
|
||||
import net.minecraft.util.Util;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
@ -39,7 +39,7 @@ public abstract class MixinPlayerListEntry {
|
|||
|
||||
@Redirect(method = "texturesSupplier", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/PlayerSkinProvider;fetchSkinTextures(Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture;"))
|
||||
private static CompletableFuture<SkinTextures> fetchGameProfileProperties(PlayerSkinProvider instance, GameProfile profile) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1) && !profile.getProperties().containsKey("textures")) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20) && !profile.getProperties().containsKey("textures")) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
final ProfileResult profileResult = MinecraftClient.getInstance().getSessionService().fetchProfile(profile.getId(), true);
|
||||
return profileResult == null ? profile : profileResult.profile();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user