Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1b5f9223a | ||
|
|
e4a1530aa8 | ||
|
|
09b67fad63 | ||
|
|
1b3c5b4032 | ||
|
|
b7d8a3c8d5 | ||
|
|
9a515df0f3 | ||
|
|
c6103f2f51 | ||
|
|
5c0eda76e8 | ||
|
|
544a28b06b | ||
|
|
5c145d0184 | ||
|
|
ed55bccfe4 | ||
|
|
5acc2fefbc | ||
|
|
7f748b5c68 | ||
|
|
0ec03f8b09 | ||
|
|
a70034e0b5 | ||
|
|
98a0fdca94 | ||
|
|
82961cc153 | ||
|
|
6c0d891c9f | ||
|
|
6fa387e6ab | ||
|
|
07bdb57694 | ||
|
|
75dd79347a | ||
|
|
9257890d3c | ||
|
|
891f55192d | ||
|
|
7adadc0d21 | ||
|
|
638378cddf | ||
|
|
56d772df34 | ||
|
|
7bb5cf3ae9 | ||
|
|
b67e3c30fd | ||
|
|
a2e214ae18 | ||
|
|
54d8e29a7e | ||
|
|
a2daa9c989 | ||
|
|
74cc42fecf | ||
|
|
dd59ddbd4f | ||
|
|
bcfc77aa7d | ||
|
|
1a46346789 | ||
|
|
394be165fd | ||
|
|
20d86374b5 | ||
|
|
8864b161f9 | ||
|
|
7b0160d6c3 | ||
|
|
7e5173982d | ||
|
|
ee75f19790 | ||
|
|
e54f6d1999 | ||
|
|
c46bb5bcf5 | ||
|
|
d08f15c095 | ||
|
|
8aa7898755 | ||
|
|
9682b68251 | ||
|
|
364cfad9d8 | ||
|
|
641171a14f | ||
|
|
23f045feee | ||
|
|
f1bde8ba2a | ||
|
|
9ccc3aed30 | ||
|
|
ad56caeb88 | ||
|
|
573201c0b1 | ||
|
|
e298a7efac | ||
|
|
2e59a51734 | ||
|
|
d4894ca4b5 | ||
|
|
7f7c6241de | ||
|
|
51606eb5ef | ||
|
|
c9883c2638 | ||
|
|
74fb55d96b | ||
|
|
4e844a0095 | ||
|
|
da7f8ea3b6 | ||
|
|
81c4e530e9 | ||
|
|
b1524642aa | ||
|
|
a828c43f99 | ||
|
|
fccfadf1b7 | ||
|
|
18b41c82c4 | ||
|
|
27ee6f519e | ||
|
|
7aa0aed5ec | ||
|
|
10c4d9408e | ||
|
|
e8b4496289 | ||
|
|
10737f17e2 | ||
|
|
7c9c602cec | ||
|
|
2ee2819759 | ||
|
|
72197ddca8 | ||
|
|
9781b7962f | ||
|
|
d180c8fe2f | ||
|
|
d8a9480bf1 | ||
|
|
a3efb676cf | ||
|
|
68d1843496 | ||
|
|
3ced95903a | ||
|
|
b3825e637e | ||
|
|
c765f20558 | ||
|
|
b5259beef7 | ||
|
|
712bbcdc02 | ||
|
|
b94c71b699 | ||
|
|
51d4e11b5f | ||
|
|
d94ed4ebd4 | ||
|
|
9ce3d8e567 | ||
|
|
9fd0d3e565 | ||
|
|
7b91c25379 | ||
|
|
7161377794 | ||
|
|
8f97f43f12 | ||
|
|
57f0d58d58 | ||
|
|
b45be1944e | ||
|
|
c4019fadd8 | ||
|
|
5cad29c754 | ||
|
|
a6e1cb6534 | ||
|
|
26615a11d3 | ||
|
|
3e2ee37829 | ||
|
|
35263e36ff | ||
|
|
bf4e4d771f | ||
|
|
1157029f23 | ||
|
|
7b5cb92982 | ||
|
|
d74f91d606 | ||
|
|
1376312449 | ||
|
|
1faf1f3f49 | ||
|
|
fb0381e76a | ||
|
|
45fcc9ef7d | ||
|
|
f5ddc6550d | ||
|
|
cb2165eb93 | ||
|
|
de5b7bf828 | ||
|
|
98c645f7ed | ||
|
|
b03765a828 | ||
|
|
088f654159 | ||
|
|
1a5f83619d | ||
|
|
734bc9e88c | ||
|
|
93654b8eaf | ||
|
|
64b3771899 | ||
|
|
4031429430 | ||
|
|
50b94abcb1 | ||
|
|
50adff90f2 | ||
|
|
7d0b838474 | ||
|
|
4fb95581ce | ||
|
|
0ae64203f5 | ||
|
|
4067107b52 | ||
|
|
8d7270a2ff | ||
|
|
ece8857535 | ||
|
|
9688b3df5d | ||
|
|
58442ec177 | ||
|
|
2a49fc0bf8 | ||
|
|
7fb8675271 | ||
|
|
57a8744a53 | ||
|
|
09222f1024 | ||
|
|
b4870a49e3 | ||
|
|
f7a48d028b | ||
|
|
382ef3953a | ||
|
|
9be32ca18b | ||
|
|
e0cd121a58 | ||
|
|
96631cee0c | ||
|
|
8c0487fc05 | ||
|
|
aec60f8cef | ||
|
|
a3080800b0 | ||
|
|
85f9414b95 | ||
|
|
e7f07d1fdb | ||
|
|
83efd0a267 | ||
|
|
5c05c61fbf | ||
|
|
fad350c811 | ||
|
|
d3d8d1cab3 | ||
|
|
a3437ca6ba | ||
|
|
17bd048d10 | ||
|
|
955b76f599 | ||
|
|
e3dc9e5b66 | ||
|
|
6095128007 | ||
|
|
0355447d53 | ||
|
|
58fd0bdc9e | ||
|
|
cdc35aa5dc | ||
|
|
10efba31cf | ||
|
|
ef204c2ab2 | ||
|
|
555e1a7722 | ||
|
|
7400784e4f | ||
|
|
2154f0a2cf | ||
|
|
14b11bdd10 | ||
|
|
c5738a2203 | ||
|
|
43ad855499 | ||
|
|
2533619339 | ||
|
|
b133dad642 | ||
|
|
464a85c52b | ||
|
|
7698ee7683 | ||
|
|
c7eb2e4b97 | ||
|
|
e71c88f860 | ||
|
|
c96b2bd859 | ||
|
|
ce4f21b7d8 | ||
|
|
2a55025e99 | ||
|
|
c86da22f4e | ||
|
|
adb10f5fe7 | ||
|
|
a268d3d298 | ||
|
|
b60771e96e | ||
|
|
435a986068 | ||
|
|
6c58f0980c | ||
|
|
e3dde71821 | ||
|
|
47b15e5fef | ||
|
|
ed196bdf99 | ||
|
|
9247e87bbf | ||
|
|
08727f959f | ||
|
|
78342da180 | ||
|
|
2b735172bd | ||
|
|
b032a868bb | ||
|
|
c4fa3b0ff8 | ||
|
|
0c3a1803e1 | ||
|
|
04f9971dee | ||
|
|
9c3395b76b | ||
|
|
f9bbb5b1a3 | ||
|
|
087bbdce1f | ||
|
|
494bf62535 | ||
|
|
4f2a5bb7e2 | ||
|
|
1c511a82b2 | ||
|
|
0c39723d1a | ||
|
|
322af00e80 | ||
|
|
a88747d904 | ||
|
|
e194d27bea | ||
|
|
22daa60eb6 | ||
|
|
6eca07966c | ||
|
|
56cc711c01 | ||
|
|
c2ee558235 | ||
|
|
c8a010c390 | ||
|
|
53c54485eb | ||
|
|
f42a308f2c | ||
|
|
44250cbb99 | ||
|
|
55ffe72198 | ||
|
|
a47dd2ecdb | ||
|
|
8a5233b6a1 | ||
|
|
c8a1279e75 | ||
|
|
57ef90e851 | ||
|
|
2262681351 | ||
|
|
56e1d0a69d | ||
|
|
63ffb51df5 | ||
|
|
b33bd2ac2b | ||
|
|
1afff77a0f | ||
|
|
26af09f2a4 | ||
|
|
a8e475dbf0 | ||
|
|
6388021c6d | ||
|
|
f4aa96a5f8 | ||
|
|
6baae5e4f7 | ||
|
|
189b244a3a | ||
|
|
12d538fe0d | ||
|
|
34f0dbf642 | ||
|
|
548f80bb7c | ||
|
|
9113a77331 | ||
|
|
e3e85db02a | ||
|
|
c4d9209c81 | ||
|
|
24d887a53d | ||
|
|
702ced200e | ||
|
|
40f5cb6e71 | ||
|
|
7ab0c41be6 | ||
|
|
66b21431f2 | ||
|
|
c6cd655f7e | ||
|
|
e9bccda259 | ||
|
|
9a34ff2a51 | ||
|
|
f01d9408de | ||
|
|
15ff7b4c9d | ||
|
|
d47765ce45 | ||
|
|
b82b067745 | ||
|
|
b7005f2400 | ||
|
|
312fe3a851 | ||
|
|
69d50fa992 | ||
|
|
1308dcb8dd | ||
|
|
b4ecba8382 | ||
|
|
3529d6a229 | ||
|
|
4213c4cce5 | ||
|
|
3d3e09977c | ||
|
|
90feac8c83 | ||
|
|
80a807e366 | ||
|
|
3eba8ba922 | ||
|
|
71a68bf36e | ||
|
|
e67501cde3 | ||
|
|
9aa7f5e879 | ||
|
|
854ecf0b47 | ||
|
|
f538f25d63 | ||
|
|
48a7fdc1d1 | ||
|
|
1d5ae0e3e0 | ||
|
|
f0462085d3 | ||
|
|
7dc7b62cc9 | ||
|
|
b9f80754e0 | ||
|
|
5b9f775743 | ||
|
|
0e66228a96 | ||
|
|
8df48bc378 | ||
|
|
d36d5d6def | ||
|
|
8b51430555 | ||
|
|
f71288e299 | ||
|
|
c0fc8195ce | ||
|
|
dd189411e6 | ||
|
|
4693b95bea | ||
|
|
596a42e312 | ||
|
|
71944be482 | ||
|
|
d1699fbb8d | ||
|
|
bd880b608f | ||
|
|
3386431749 | ||
|
|
c3fc8b5f18 | ||
|
|
ec740476da | ||
|
|
a536ad1d10 | ||
|
|
a1ae7818a2 | ||
|
|
365b3a8a38 | ||
|
|
823eb1f392 | ||
|
|
a12dfa405f | ||
|
|
9798ec296a | ||
|
|
c1b993c01b | ||
|
|
f55696a605 |
No files matched your search
@@ -7,7 +7,7 @@ body:
|
||||
attributes:
|
||||
value: |
|
||||
**Before reporting a bug, please see if using master/dev builds from https://ci.viaversion.com/ fixes your issue.**
|
||||
Whenever you see fit, you can upload images or video to any of the textfields.
|
||||
Whenever you see fit, you can upload images or videos to any of the text fields.
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
name: Feature Request
|
||||
description: Suggest a feature to be added
|
||||
labels: [Feature Request]
|
||||
|
||||
body:
|
||||
- type: textarea
|
||||
@@ -34,4 +35,4 @@ body:
|
||||
description: |
|
||||
Does the feature apply to any specific version or environment?
|
||||
validations:
|
||||
required: false
|
||||
required: false
|
||||
@@ -10,19 +10,19 @@ jobs:
|
||||
# Only run on PRs if the source branch is on a different repo. We do not need to run everything twice.
|
||||
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: gradle/wrapper-validation-action@v1
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v2
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 11
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: artifact
|
||||
path: build/libs
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion Copyright (C) 2016-2022 ViaVersion and contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>." />
|
||||
<option name="notice" value="This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion Copyright (C) &#36;originalComment.match("Copyright \(C\) (\d+)", 1, "-")&#36;today.year ViaVersion and contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>." />
|
||||
<option name="myName" value="viaversion-gpl" />
|
||||
</copyright>
|
||||
</component>
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion Copyright (C) 2016-2022 ViaVersion and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." />
|
||||
<option name="notice" value="This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion Copyright (C) &#36;originalComment.match("Copyright \(C\) (\d+)", 1, "-")&#36;today.year ViaVersion and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." />
|
||||
<option name="myName" value="viaversion-mit" />
|
||||
</copyright>
|
||||
</component>
|
||||
@@ -8,23 +8,27 @@
|
||||
|
||||
Supported Versions:
|
||||
|
||||

|
||||

|
||||
|
||||
On Paper you may also use ProtocolSupport, but ensure you have the right build for your server version.
|
||||
|
||||
**User Docs:** https://docs.viaversion.com/display/VIAVERSION/
|
||||
|
||||
|
||||
Sources:
|
||||
Sources
|
||||
--------
|
||||
**[wiki.vg](https://wiki.vg)** (Used for information regarding packet structure, we also contribute back)
|
||||
**[OpenNBT](https://github.com/ViaVersion/OpenNBT)**
|
||||
|
||||
**[Via Mappings Generator](https://github.com/ViaVersion/Mappings)**
|
||||
|
||||
**[Mojang mappings](https://minecraft.fandom.com/wiki/Obfuscation_map)** (Thank you, Mojang, very cool)
|
||||
|
||||
**[wiki.vg](https://wiki.vg)** (Used for historic information regarding packet structure, we also contribute back)
|
||||
|
||||
**[Burger](https://github.com/Pokechu22/Burger)** (See [PAaaS](https://github.com/Matsv/Paaas))
|
||||
|
||||
**[OpenNBT](https://github.com/ViaVersion/OpenNBT)**
|
||||
|
||||
|
||||
Releases / Dev Builds:
|
||||
Releases / Dev Builds
|
||||
--------
|
||||
You can find official releases here:
|
||||
|
||||
@@ -39,7 +43,9 @@ You can find official dev builds here:
|
||||
**JavaDocs:** https://jd.viaversion.com
|
||||
|
||||
**Maven Repository:**
|
||||
|
||||
```xml
|
||||
|
||||
<repository>
|
||||
<id>viaversion-repo</id>
|
||||
<url>https://repo.viaversion.com</url>
|
||||
@@ -47,11 +53,13 @@ You can find official dev builds here:
|
||||
```
|
||||
|
||||
**API-artifact:**
|
||||
|
||||
```xml
|
||||
|
||||
<dependency>
|
||||
<groupId>com.viaversion</groupId>
|
||||
<artifactId>viaversion-api</artifactId>
|
||||
<version>LATEST</version>
|
||||
<version>[4.0.0,5.0.0)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
```
|
||||
@@ -62,15 +70,22 @@ If you need access to the existing protocol or platform implementations, use the
|
||||
Please note the [differences in licensing](#license).
|
||||
|
||||
|
||||
Building:
|
||||
Building
|
||||
--------
|
||||
After cloning this repository, build the project with Gradle by running `./gradlew build` and take the created jar out of
|
||||
After cloning this repository, build the project with Gradle by running `./gradlew build` and take the created jar out
|
||||
of
|
||||
the `build/libs` directory.
|
||||
|
||||
|
||||
License:
|
||||
Mapping Files
|
||||
--------------
|
||||
Mapping files are generated and managed in our [Mappings repository](https://github.com/ViaVersion/Mappings).
|
||||
|
||||
|
||||
License
|
||||
--------
|
||||
The entirety of the [API directory](api) (including the legacy API directory) is licensed under the MIT License; see [licenses/MIT.md](licenses/MIT.md) for
|
||||
The entirety of the [API directory](api) (including the legacy API directory) is licensed under the MIT License;
|
||||
see [licenses/MIT.md](licenses/MIT.md) for
|
||||
details.
|
||||
|
||||
Everything else, unless explicitly stated otherwise, is licensed under the GNU General Public License, including the end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,13 +23,12 @@
|
||||
package us.myles.ViaVersion.api;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.SortedSet;
|
||||
import java.util.UUID;
|
||||
import us.myles.ViaVersion.api.boss.BossBar;
|
||||
import us.myles.ViaVersion.api.boss.BossColor;
|
||||
import us.myles.ViaVersion.api.boss.BossStyle;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @deprecated may be removed at some point, use {@link com.viaversion.viaversion.api.Via}
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,13 +24,12 @@ package us.myles.ViaVersion.api;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.SortedSet;
|
||||
import java.util.UUID;
|
||||
import us.myles.ViaVersion.api.boss.BossBar;
|
||||
import us.myles.ViaVersion.api.boss.BossColor;
|
||||
import us.myles.ViaVersion.api.boss.BossStyle;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @deprecated may be removed at some point, use {@link Via#getAPI()}
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,14 +26,13 @@ import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.protocol.version.VersionRange;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* @deprecated will no longer be updated and may be removed at some point, use {@link com.viaversion.viaversion.api.protocol.version.ProtocolVersion}
|
||||
@@ -83,6 +82,11 @@ public class ProtocolVersion {
|
||||
public static final ProtocolVersion v1_17_1 = register(756, "1.17.1");
|
||||
public static final ProtocolVersion v1_18 = register(757, "1.18/1.18.1", new VersionRange("1.18", 0, 1));
|
||||
public static final ProtocolVersion v1_18_2 = register(758, "1.18.2");
|
||||
public static final ProtocolVersion v1_19 = register(759, "1.19");
|
||||
public static final ProtocolVersion v1_19_1 = register(760, "1.19.1");
|
||||
public static final ProtocolVersion v1_19_3 = register(761, "1.19.3");
|
||||
public static final ProtocolVersion v1_19_4 = register(762, "1.19.4");
|
||||
public static final ProtocolVersion v1_20 = register(763, "1.20");
|
||||
public static final ProtocolVersion unknown = register(-1, "UNKNOWN");
|
||||
|
||||
public static ProtocolVersion register(int version, String name) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,6 +25,7 @@ package com.viaversion.viaversion.api;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
|
||||
import com.viaversion.viaversion.api.platform.ViaPlatform;
|
||||
import com.viaversion.viaversion.api.platform.ViaServerProxyPlatform;
|
||||
|
||||
public final class Via {
|
||||
private static ViaManager manager;
|
||||
@@ -63,6 +64,11 @@ public final class Via {
|
||||
return manager().getPlatform();
|
||||
}
|
||||
|
||||
public static ViaServerProxyPlatform<?> proxyPlatform() {
|
||||
Preconditions.checkArgument(manager().getPlatform() instanceof ViaServerProxyPlatform, "Platform is not proxying Minecraft servers!");
|
||||
return (ViaServerProxyPlatform<?>) manager().getPlatform();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the ViaManager associated with the platform.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,10 +29,9 @@ import com.viaversion.viaversion.api.platform.ViaPlatform;
|
||||
import com.viaversion.viaversion.api.protocol.ProtocolManager;
|
||||
import com.viaversion.viaversion.api.protocol.version.ServerProtocolVersion;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* General api point. For more specialized api methods, see {@link Via#getManager()}.
|
||||
@@ -64,7 +63,7 @@ public interface ViaAPI<T> {
|
||||
* @return API version incremented with meaningful API changes
|
||||
*/
|
||||
default int apiVersion() {
|
||||
return 10;
|
||||
return 19;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,7 +135,7 @@ public interface ViaAPI<T> {
|
||||
* Returns the supported protocol versions.
|
||||
* This method removes any blocked protocol versions.
|
||||
*
|
||||
* @return a list of protocol versions
|
||||
* @return a sorted set of protocol versions
|
||||
* @see #getFullSupportedVersions() for a full list
|
||||
*/
|
||||
SortedSet<Integer> getSupportedVersions();
|
||||
@@ -144,7 +143,7 @@ public interface ViaAPI<T> {
|
||||
/**
|
||||
* Returns the supported protocol versions, including blocked protocols.
|
||||
*
|
||||
* @return a list of protocol versions
|
||||
* @return a sorted set of protocol versions
|
||||
*/
|
||||
SortedSet<Integer> getFullSupportedVersions();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -30,7 +30,7 @@ import com.viaversion.viaversion.api.platform.ViaPlatform;
|
||||
import com.viaversion.viaversion.api.platform.ViaPlatformLoader;
|
||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||
import com.viaversion.viaversion.api.protocol.ProtocolManager;
|
||||
|
||||
import com.viaversion.viaversion.api.scheduler.Scheduler;
|
||||
import java.util.Set;
|
||||
|
||||
public interface ViaManager {
|
||||
@@ -84,12 +84,18 @@ public interface ViaManager {
|
||||
*/
|
||||
ViaPlatformLoader getLoader();
|
||||
|
||||
/**
|
||||
* Returns the async task scheduler.
|
||||
*
|
||||
* @return async task scheduler
|
||||
*/
|
||||
Scheduler getScheduler();
|
||||
|
||||
/**
|
||||
* If debug is enabled, packets and other otherwise suppressed warnings will be logged.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean isDebug() {
|
||||
return debugHandler().enabled();
|
||||
}
|
||||
@@ -125,4 +131,11 @@ public interface ViaManager {
|
||||
* @param runnable runnable to be executed
|
||||
*/
|
||||
void addEnableListener(Runnable runnable);
|
||||
|
||||
/**
|
||||
* Returns whether the manager has been initialized (and protocols have been loaded).
|
||||
*
|
||||
* @return whether the manager has been initialized
|
||||
*/
|
||||
boolean isInitialized();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,7 +23,6 @@
|
||||
package com.viaversion.viaversion.api.command;
|
||||
|
||||
import com.viaversion.viaversion.util.ChatColorUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,9 +22,8 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.command;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface ViaVersionCommand {
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.WorldIdentifiers;
|
||||
import com.viaversion.viaversion.api.protocol.version.BlockedProtocolVersions;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface ViaVersionConfig {
|
||||
|
||||
@@ -185,13 +186,6 @@ public interface ViaVersionConfig {
|
||||
*/
|
||||
String getMaxWarningsKickMessage();
|
||||
|
||||
/**
|
||||
* Is anti-xray enabled?
|
||||
*
|
||||
* @return A boolean
|
||||
*/
|
||||
boolean isAntiXRay();
|
||||
|
||||
/**
|
||||
* Send supported versions in the status response packet
|
||||
*
|
||||
@@ -262,6 +256,8 @@ public interface ViaVersionConfig {
|
||||
*/
|
||||
boolean is1_13TeamColourFix();
|
||||
|
||||
boolean shouldRegisterUserConnectionOnJoin();
|
||||
|
||||
/**
|
||||
* Should we fix shift quick move action for 1.12 clients
|
||||
*
|
||||
@@ -455,4 +451,8 @@ public interface ViaVersionConfig {
|
||||
WorldIdentifiers get1_16WorldNamesMap();
|
||||
|
||||
boolean cache1_17Light();
|
||||
|
||||
@Nullable String chatTypeFormat(String translationKey);
|
||||
|
||||
boolean isArmorToggleFix();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,11 +22,10 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.connection;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Handles injected UserConnections
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,9 +24,8 @@ package com.viaversion.viaversion.api.connection;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.ProtocolPipeline;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface ProtocolInfo {
|
||||
|
||||
@@ -93,5 +92,6 @@ public interface ProtocolInfo {
|
||||
*
|
||||
* @return user connection
|
||||
*/
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
UserConnection getUser();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,4 +29,13 @@ package com.viaversion.viaversion.api.connection;
|
||||
* @see UserConnection#put(StorableObject)
|
||||
*/
|
||||
public interface StorableObject {
|
||||
|
||||
/**
|
||||
* Returns whether the object should be uncached on a server switch.
|
||||
*
|
||||
* @return whether the object should be uncached on a server switch
|
||||
*/
|
||||
default boolean clearOnServerSwitch() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -32,12 +32,11 @@ import com.viaversion.viaversion.exception.InformativeException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface UserConnection {
|
||||
|
||||
@@ -58,6 +57,15 @@ public interface UserConnection {
|
||||
*/
|
||||
boolean has(Class<? extends StorableObject> objectClass);
|
||||
|
||||
/**
|
||||
* Removes and returns an object from the storage.
|
||||
*
|
||||
* @param objectClass class of the object to get
|
||||
* @param <T> type of the class you want to get
|
||||
* @return removed storable object if present
|
||||
*/
|
||||
@Nullable <T extends StorableObject> T remove(Class<T> objectClass);
|
||||
|
||||
/**
|
||||
* Put an object into the stored objects based on class.
|
||||
*
|
||||
@@ -83,6 +91,7 @@ public interface UserConnection {
|
||||
|
||||
/**
|
||||
* Adds an entity tracker to the user connection.
|
||||
* Does not override existing entity trackers.
|
||||
*
|
||||
* @param protocolClass protocol class
|
||||
* @param tracker entity tracker
|
||||
@@ -91,9 +100,18 @@ public interface UserConnection {
|
||||
|
||||
/**
|
||||
* Clear stored objects and entity trackers.
|
||||
* Used for Bungee when switching servers.
|
||||
*/
|
||||
void clearStoredObjects();
|
||||
default void clearStoredObjects() {
|
||||
clearStoredObjects(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear stored objects and entity trackers.
|
||||
* If cleared for a proxy server switch, some stored objects and tracker data will be retained.
|
||||
*
|
||||
* @param isServerSwitch whether the clear is due to a server switch
|
||||
*/
|
||||
void clearStoredObjects(boolean isServerSwitch);
|
||||
|
||||
/**
|
||||
* Sends a raw packet to the connection on the current thread.
|
||||
|
||||
+15
-20
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,28 +20,23 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.type.types.minecraft;
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
public interface BiMappings extends Mappings {
|
||||
|
||||
public class OptPositionType extends Type<Position> {
|
||||
public OptPositionType() {
|
||||
super(Position.class);
|
||||
/**
|
||||
* Returns the inverse of the bimappings.
|
||||
*
|
||||
* @return inverse of the bimappings
|
||||
*/
|
||||
@Override
|
||||
BiMappings inverse();
|
||||
|
||||
static BiMappings of(final Mappings mappings) {
|
||||
return of(mappings, mappings.inverse());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position read(ByteBuf buffer) throws Exception {
|
||||
boolean present = buffer.readBoolean();
|
||||
if (!present) return null;
|
||||
return Type.POSITION.read(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buffer, Position object) throws Exception {
|
||||
buffer.writeBoolean(object != null);
|
||||
if (object != null)
|
||||
Type.POSITION.write(buffer, object);
|
||||
static BiMappings of(final Mappings mappings, final Mappings inverse) {
|
||||
return new BiMappingsBase(mappings, inverse);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
public class BiMappingsBase implements BiMappings {
|
||||
|
||||
protected final Mappings mappings;
|
||||
private final BiMappingsBase inverse;
|
||||
|
||||
protected BiMappingsBase(final Mappings mappings, final Mappings inverse) {
|
||||
this.mappings = mappings;
|
||||
this.inverse = new BiMappingsBase(inverse, this);
|
||||
}
|
||||
|
||||
private BiMappingsBase(final Mappings mappings, final BiMappingsBase inverse) {
|
||||
this.mappings = mappings;
|
||||
this.inverse = inverse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewId(final int id) {
|
||||
return mappings.getNewId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNewId(final int id, final int mappedId) {
|
||||
mappings.setNewId(id, mappedId);
|
||||
inverse.mappings.setNewId(mappedId, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return mappings.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mappedSize() {
|
||||
return mappings.mappedSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiMappings inverse() {
|
||||
return this.inverse;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Mappings containing the full string identifier mappings.
|
||||
*/
|
||||
public interface FullMappings extends Mappings {
|
||||
|
||||
@Deprecated
|
||||
default Mappings mappings() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unmapped integer id for the given identifier, or -1 if not found.
|
||||
*
|
||||
* @param identifier unmapped string identifier
|
||||
* @return unmapped int id, or -1 if not found
|
||||
*/
|
||||
int id(String identifier);
|
||||
|
||||
/**
|
||||
* Returns the mapped integer id for the given mapped identifier, or -1 if not found.
|
||||
*
|
||||
* @param mappedIdentifier mapped string identifier
|
||||
* @return mapped int id, or -1 if not found
|
||||
*/
|
||||
int mappedId(String mappedIdentifier);
|
||||
|
||||
/**
|
||||
* Returns the unmapped string identifier for the given mapped id.
|
||||
*
|
||||
* @param id unmapped id
|
||||
* @return unmapped string identifier
|
||||
*/
|
||||
String identifier(int id);
|
||||
|
||||
/**
|
||||
* Returns the mapped string identifier for the given mapped id.
|
||||
*
|
||||
* @param mappedId mapped id
|
||||
* @return mapped string identifier
|
||||
*/
|
||||
String mappedIdentifier(int mappedId);
|
||||
|
||||
/**
|
||||
* Returns the mapped string identifier for the given unmapped identifier.
|
||||
*
|
||||
* @param identifier unmapped identifier
|
||||
* @return mapped string identifier, or null if not found
|
||||
*/
|
||||
@Nullable String mappedIdentifier(String identifier);
|
||||
|
||||
@Override
|
||||
FullMappings inverse();
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class FullMappingsBase implements FullMappings {
|
||||
private static final String[] EMPTY_ARRAY = new String[0];
|
||||
private final Object2IntMap<String> stringToId;
|
||||
private final Object2IntMap<String> mappedStringToId;
|
||||
private final String[] idToString;
|
||||
private final String[] mappedIdToString;
|
||||
private final Mappings mappings;
|
||||
|
||||
public FullMappingsBase(final List<String> unmappedIdentifiers, final List<String> mappedIdentifiers, final Mappings mappings) {
|
||||
this.mappings = mappings;
|
||||
this.stringToId = toInverseMap(unmappedIdentifiers);
|
||||
this.mappedStringToId = toInverseMap(mappedIdentifiers);
|
||||
this.idToString = unmappedIdentifiers.toArray(EMPTY_ARRAY);
|
||||
this.mappedIdToString = mappedIdentifiers.toArray(EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
private FullMappingsBase(final Object2IntMap<String> stringToId, final Object2IntMap<String> mappedStringToId, final String[] idToString, final String[] mappedIdToString, final Mappings mappings) {
|
||||
this.stringToId = stringToId;
|
||||
this.mappedStringToId = mappedStringToId;
|
||||
this.idToString = idToString;
|
||||
this.mappedIdToString = mappedIdToString;
|
||||
this.mappings = mappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mappings mappings() {
|
||||
return mappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id(final String identifier) {
|
||||
return stringToId.getInt(Key.stripMinecraftNamespace(identifier));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mappedId(final String mappedIdentifier) {
|
||||
return mappedStringToId.getInt(Key.stripMinecraftNamespace(mappedIdentifier));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier(final int id) {
|
||||
final String identifier = idToString[id];
|
||||
return Key.namespaced(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String mappedIdentifier(final int mappedId) {
|
||||
final String identifier = mappedIdToString[mappedId];
|
||||
return Key.namespaced(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String mappedIdentifier(final String identifier) {
|
||||
final int id = id(identifier);
|
||||
if (id == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final int mappedId = mappings.getNewId(id);
|
||||
return mappedId != -1 ? mappedIdentifier(mappedId) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewId(int id) {
|
||||
return mappings.getNewId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNewId(int id, int mappedId) {
|
||||
mappings.setNewId(id, mappedId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return mappings.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mappedSize() {
|
||||
return mappings.mappedSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FullMappings inverse() {
|
||||
return new FullMappingsBase(mappedStringToId, stringToId, mappedIdToString, idToString, mappings.inverse());
|
||||
}
|
||||
|
||||
private static Object2IntMap<String> toInverseMap(final List<String> list) {
|
||||
final Object2IntMap<String> map = new Object2IntOpenHashMap<>(list.size());
|
||||
map.defaultReturnValue(-1);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
map.put(list.get(i), i);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
public class IdentityMappings implements Mappings {
|
||||
|
||||
private final int size;
|
||||
private final int mappedSize;
|
||||
|
||||
public IdentityMappings(final int size, final int mappedSize) {
|
||||
this.size = size;
|
||||
this.mappedSize = mappedSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewId(final int id) {
|
||||
return id >= 0 && id < size ? id : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNewId(final int id, final int mappedId) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mappedSize() {
|
||||
return mappedSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mappings inverse() {
|
||||
return new IdentityMappings(mappedSize, size);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.viaversion.viaversion.util.Int2IntBiMap;
|
||||
|
||||
public class Int2IntMapBiMappings implements BiMappings {
|
||||
|
||||
private final Int2IntBiMap mappings;
|
||||
private final Int2IntMapBiMappings inverse;
|
||||
|
||||
protected Int2IntMapBiMappings(final Int2IntBiMap mappings) {
|
||||
this.mappings = mappings;
|
||||
this.inverse = new Int2IntMapBiMappings(mappings.inverse(), this);
|
||||
mappings.defaultReturnValue(-1);
|
||||
}
|
||||
|
||||
private Int2IntMapBiMappings(final Int2IntBiMap mappings, final Int2IntMapBiMappings inverse) {
|
||||
this.mappings = mappings;
|
||||
this.inverse = inverse;
|
||||
}
|
||||
|
||||
public static Int2IntMapBiMappings of(final Int2IntBiMap mappings) {
|
||||
return new Int2IntMapBiMappings(mappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewId(final int id) {
|
||||
return mappings.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNewId(final int id, final int mappedId) {
|
||||
mappings.put(id, mappedId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return mappings.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mappedSize() {
|
||||
return mappings.inverse().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiMappings inverse() {
|
||||
return this.inverse;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
|
||||
public class Int2IntMapMappings implements Mappings {
|
||||
private final Int2IntMap mappings;
|
||||
private final int mappedIds;
|
||||
|
||||
protected Int2IntMapMappings(final Int2IntMap mappings, final int mappedIds) {
|
||||
this.mappings = mappings;
|
||||
this.mappedIds = mappedIds;
|
||||
mappings.defaultReturnValue(-1);
|
||||
}
|
||||
|
||||
public static Int2IntMapMappings of(final Int2IntMap mappings, final int mappedIds) {
|
||||
return new Int2IntMapMappings(mappings, mappedIds);
|
||||
}
|
||||
|
||||
public static Int2IntMapMappings of() {
|
||||
return new Int2IntMapMappings(new Int2IntOpenHashMap(), -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewId(final int id) {
|
||||
return mappings.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNewId(final int id, final int mappedId) {
|
||||
mappings.put(id, mappedId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return mappings.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mappedSize() {
|
||||
return mappedIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mappings inverse() {
|
||||
final Int2IntMap inverse = new Int2IntOpenHashMap();
|
||||
inverse.defaultReturnValue(-1);
|
||||
for (final Int2IntMap.Entry entry : mappings.int2IntEntrySet()) {
|
||||
if (entry.getIntValue() != -1) {
|
||||
inverse.putIfAbsent(entry.getIntValue(), entry.getIntKey());
|
||||
}
|
||||
}
|
||||
return of(inverse, size());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,106 +22,39 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class IntArrayMappings implements Mappings {
|
||||
private final int[] oldToNew;
|
||||
private final int[] mappings;
|
||||
private final int mappedIds;
|
||||
|
||||
protected IntArrayMappings(final int[] oldToNew, final int mappedIds) {
|
||||
this.oldToNew = oldToNew;
|
||||
protected IntArrayMappings(final int[] mappings, final int mappedIds) {
|
||||
this.mappings = mappings;
|
||||
this.mappedIds = mappedIds;
|
||||
}
|
||||
|
||||
public static IntArrayMappings of(final int[] oldToNew, final int mappedIds) {
|
||||
return new IntArrayMappings(oldToNew, mappedIds);
|
||||
public static IntArrayMappings of(final int[] mappings, final int mappedIds) {
|
||||
return new IntArrayMappings(mappings, mappedIds);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Builder<IntArrayMappings> builder() {
|
||||
return Mappings.builder(IntArrayMappings::new);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(int[] oldToNew) {
|
||||
this(oldToNew, -1);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(int size, JsonObject oldMapping, JsonObject newMapping, @Nullable JsonObject diffMapping) {
|
||||
oldToNew = new int[size];
|
||||
Arrays.fill(oldToNew, -1);
|
||||
this.mappedIds = newMapping.size();
|
||||
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(JsonObject oldMapping, JsonObject newMapping, @Nullable JsonObject diffMapping) {
|
||||
this(oldMapping.entrySet().size(), oldMapping, newMapping, diffMapping);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(int size, JsonObject oldMapping, JsonObject newMapping) {
|
||||
oldToNew = new int[size];
|
||||
Arrays.fill(oldToNew, -1);
|
||||
mappedIds = -1;
|
||||
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(JsonObject oldMapping, JsonObject newMapping) {
|
||||
this(oldMapping.entrySet().size(), oldMapping, newMapping);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(int size, JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping, boolean warnOnMissing) {
|
||||
oldToNew = new int[size];
|
||||
Arrays.fill(oldToNew, -1);
|
||||
mappedIds = -1;
|
||||
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping, warnOnMissing);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(int size, JsonArray oldMapping, JsonArray newMapping, boolean warnOnMissing) {
|
||||
this(size, oldMapping, newMapping, null, warnOnMissing);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(JsonArray oldMapping, JsonArray newMapping, boolean warnOnMissing) {
|
||||
this(oldMapping.size(), oldMapping, newMapping, warnOnMissing);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(int size, JsonArray oldMapping, JsonArray newMapping) {
|
||||
this(size, oldMapping, newMapping, true);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping) {
|
||||
this(oldMapping.size(), oldMapping, newMapping, diffMapping, true);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(JsonArray oldMapping, JsonArray newMapping) {
|
||||
this(oldMapping.size(), oldMapping, newMapping, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewId(int id) {
|
||||
return id >= 0 && id < oldToNew.length ? oldToNew[id] : -1;
|
||||
return id >= 0 && id < mappings.length ? mappings[id] : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNewId(int id, int newId) {
|
||||
oldToNew[id] = newId;
|
||||
public void setNewId(int id, int mappedId) {
|
||||
mappings[id] = mappedId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return oldToNew.length;
|
||||
return mappings.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -129,7 +62,20 @@ public class IntArrayMappings implements Mappings {
|
||||
return mappedIds;
|
||||
}
|
||||
|
||||
public int[] getOldToNew() {
|
||||
return oldToNew;
|
||||
@Override
|
||||
public Mappings inverse() {
|
||||
final int[] inverse = new int[mappedIds];
|
||||
Arrays.fill(inverse, -1);
|
||||
for (int id = 0; id < mappings.length; id++) {
|
||||
final int mappedId = mappings[id];
|
||||
if (mappedId != -1 && inverse[mappedId] == -1) {
|
||||
inverse[mappedId] = id;
|
||||
}
|
||||
}
|
||||
return of(inverse, mappings.length);
|
||||
}
|
||||
|
||||
public int[] raw() {
|
||||
return mappings;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,10 +24,8 @@ package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.TagData;
|
||||
import com.viaversion.viaversion.util.Int2IntBiMap;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface MappingData {
|
||||
|
||||
@@ -89,7 +87,7 @@ public interface MappingData {
|
||||
*/
|
||||
@Nullable List<TagData> getTags(RegistryType type);
|
||||
|
||||
@Nullable Int2IntBiMap getItemMappings();
|
||||
@Nullable BiMappings getItemMappings();
|
||||
|
||||
@Nullable ParticleMappings getParticleMappings();
|
||||
|
||||
@@ -102,4 +100,14 @@ public interface MappingData {
|
||||
@Nullable Mappings getSoundMappings();
|
||||
|
||||
@Nullable Mappings getStatisticsMappings();
|
||||
|
||||
@Nullable Mappings getMenuMappings();
|
||||
|
||||
@Nullable Mappings getEnchantmentMappings();
|
||||
|
||||
@Nullable FullMappings getEntityMappings();
|
||||
|
||||
@Nullable FullMappings getArgumentTypeMappings();
|
||||
|
||||
@Nullable Mappings getPaintingMappings();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,142 +22,155 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.TagData;
|
||||
import com.viaversion.viaversion.util.Int2IntBiHashMap;
|
||||
import com.viaversion.viaversion.util.Int2IntBiMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class MappingDataBase implements MappingData {
|
||||
protected final String oldVersion;
|
||||
protected final String newVersion;
|
||||
protected final boolean hasDiffFile;
|
||||
protected Int2IntBiMap itemMappings;
|
||||
|
||||
protected final String unmappedVersion;
|
||||
protected final String mappedVersion;
|
||||
protected BiMappings itemMappings;
|
||||
protected FullMappings argumentTypeMappings;
|
||||
protected FullMappings entityMappings;
|
||||
protected ParticleMappings particleMappings;
|
||||
protected Mappings blockMappings;
|
||||
protected Mappings blockStateMappings;
|
||||
protected Mappings blockEntityMappings;
|
||||
protected Mappings soundMappings;
|
||||
protected Mappings statisticsMappings;
|
||||
protected Mappings enchantmentMappings;
|
||||
protected Mappings paintingMappings;
|
||||
protected Mappings menuMappings;
|
||||
protected Map<RegistryType, List<TagData>> tags;
|
||||
protected boolean loadItems = true;
|
||||
|
||||
public MappingDataBase(String oldVersion, String newVersion) {
|
||||
this(oldVersion, newVersion, false);
|
||||
}
|
||||
|
||||
public MappingDataBase(String oldVersion, String newVersion, boolean hasDiffFile) {
|
||||
this.oldVersion = oldVersion;
|
||||
this.newVersion = newVersion;
|
||||
this.hasDiffFile = hasDiffFile;
|
||||
public MappingDataBase(final String unmappedVersion, final String mappedVersion) {
|
||||
this.unmappedVersion = unmappedVersion;
|
||||
this.mappedVersion = mappedVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
getLogger().info("Loading " + oldVersion + " -> " + newVersion + " mappings...");
|
||||
JsonObject diffmapping = hasDiffFile ? loadDiffFile() : null;
|
||||
JsonObject oldMappings = MappingDataLoader.loadData("mapping-" + oldVersion + ".json", true);
|
||||
JsonObject newMappings = MappingDataLoader.loadData("mapping-" + newVersion + ".json", true);
|
||||
|
||||
blockMappings = loadFromObject(oldMappings, newMappings, diffmapping, "blocks");
|
||||
blockStateMappings = loadFromObject(oldMappings, newMappings, diffmapping, "blockstates");
|
||||
blockEntityMappings = loadFromArray(oldMappings, newMappings, diffmapping, "blockentities");
|
||||
soundMappings = loadFromArray(oldMappings, newMappings, diffmapping, "sounds");
|
||||
statisticsMappings = loadFromArray(oldMappings, newMappings, diffmapping, "statistics");
|
||||
|
||||
Mappings particles = loadFromArray(oldMappings, newMappings, diffmapping, "particles");
|
||||
if (particles != null) {
|
||||
particleMappings = new ParticleMappings(oldMappings.getAsJsonArray("particles"), newMappings.getAsJsonArray("particles"), particles);
|
||||
if (Via.getManager().isDebug()) {
|
||||
getLogger().info("Loading " + unmappedVersion + " -> " + mappedVersion + " mappings...");
|
||||
}
|
||||
|
||||
if (loadItems && newMappings.has("items")) {
|
||||
itemMappings = new Int2IntBiHashMap();
|
||||
itemMappings.defaultReturnValue(-1);
|
||||
MappingDataLoader.mapIdentifiers(itemMappings, oldMappings.getAsJsonObject("items"), newMappings.getAsJsonObject("items"),
|
||||
diffmapping != null ? diffmapping.getAsJsonObject("items") : null, true);
|
||||
}
|
||||
final CompoundTag data = readNBTFile("mappings-" + unmappedVersion + "to" + mappedVersion + ".nbt");
|
||||
blockMappings = loadMappings(data, "blocks");
|
||||
blockStateMappings = loadMappings(data, "blockstates");
|
||||
blockEntityMappings = loadMappings(data, "blockentities");
|
||||
soundMappings = loadMappings(data, "sounds");
|
||||
statisticsMappings = loadMappings(data, "statistics");
|
||||
menuMappings = loadMappings(data, "menus");
|
||||
enchantmentMappings = loadMappings(data, "enchantments");
|
||||
paintingMappings = loadMappings(data, "paintings");
|
||||
itemMappings = loadBiMappings(data, "items");
|
||||
|
||||
if (diffmapping != null && diffmapping.has("tags")) {
|
||||
this.tags = new EnumMap<>(RegistryType.class);
|
||||
JsonObject tags = diffmapping.getAsJsonObject("tags");
|
||||
if (tags.has(RegistryType.ITEM.resourceLocation())) {
|
||||
loadTags(RegistryType.ITEM, tags, MappingDataLoader.indexedObjectToMap(newMappings.getAsJsonObject("items")));
|
||||
}
|
||||
if (tags.has(RegistryType.BLOCK.resourceLocation())) {
|
||||
loadTags(RegistryType.BLOCK, tags, MappingDataLoader.indexedObjectToMap(newMappings.getAsJsonObject("blocks")));
|
||||
}
|
||||
}
|
||||
final CompoundTag unmappedIdentifierData = MappingDataLoader.loadNBT("identifiers-" + unmappedVersion + ".nbt", true);
|
||||
final CompoundTag mappedIdentifierData = MappingDataLoader.loadNBT("identifiers-" + mappedVersion + ".nbt", true);
|
||||
if (unmappedIdentifierData != null && mappedIdentifierData != null) {
|
||||
entityMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "entities");
|
||||
argumentTypeMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "argumenttypes");
|
||||
|
||||
loadExtras(oldMappings, newMappings, diffmapping);
|
||||
}
|
||||
|
||||
private void loadTags(RegistryType type, JsonObject object, Object2IntMap<String> typeMapping) {
|
||||
JsonObject tags = object.getAsJsonObject(type.resourceLocation());
|
||||
List<TagData> tagsList = new ArrayList<>(tags.size());
|
||||
for (Map.Entry<String, JsonElement> entry : tags.entrySet()) {
|
||||
JsonArray array = entry.getValue().getAsJsonArray();
|
||||
int[] entries = new int[array.size()];
|
||||
int i = 0;
|
||||
for (JsonElement element : array) {
|
||||
String stringId = element.getAsString();
|
||||
if (!typeMapping.containsKey(stringId) && !typeMapping.containsKey(stringId = stringId.replace("minecraft:", ""))) { // aaa
|
||||
getLogger().warning(type + " Tags contains invalid type identifier " + stringId + " in tag " + entry.getKey());
|
||||
continue;
|
||||
final ListTag unmappedParticles = unmappedIdentifierData.get("particles");
|
||||
final ListTag mappedParticles = mappedIdentifierData.get("particles");
|
||||
if (unmappedParticles != null && mappedParticles != null) {
|
||||
Mappings particleMappings = loadMappings(data, "particles");
|
||||
if (particleMappings == null) {
|
||||
particleMappings = new IdentityMappings(unmappedParticles.size(), mappedParticles.size());
|
||||
}
|
||||
|
||||
entries[i++] = typeMapping.getInt(stringId);
|
||||
final List<String> identifiers = unmappedParticles.getValue().stream().map(t -> (String) t.getValue()).collect(Collectors.toList());
|
||||
final List<String> mappedIdentifiers = mappedParticles.getValue().stream().map(t -> (String) t.getValue()).collect(Collectors.toList());
|
||||
this.particleMappings = new ParticleMappings(identifiers, mappedIdentifiers, particleMappings);
|
||||
}
|
||||
tagsList.add(new TagData(entry.getKey(), entries));
|
||||
}
|
||||
|
||||
final CompoundTag tagsTag = data.get("tags");
|
||||
if (tagsTag != null) {
|
||||
this.tags = new EnumMap<>(RegistryType.class);
|
||||
loadTags(RegistryType.ITEM, tagsTag);
|
||||
loadTags(RegistryType.BLOCK, tagsTag);
|
||||
}
|
||||
|
||||
loadExtras(data);
|
||||
}
|
||||
|
||||
protected @Nullable CompoundTag readNBTFile(final String name) {
|
||||
return MappingDataLoader.loadNBT(name);
|
||||
}
|
||||
|
||||
protected @Nullable Mappings loadMappings(final CompoundTag data, final String key) {
|
||||
return MappingDataLoader.loadMappings(data, key);
|
||||
}
|
||||
|
||||
protected @Nullable FullMappings loadFullMappings(final CompoundTag data, final CompoundTag unmappedIdentifiers, final CompoundTag mappedIdentifiers, final String key) {
|
||||
return MappingDataLoader.loadFullMappings(data, unmappedIdentifiers, mappedIdentifiers, key);
|
||||
}
|
||||
|
||||
protected @Nullable BiMappings loadBiMappings(final CompoundTag data, final String key) {
|
||||
final Mappings mappings = loadMappings(data, key);
|
||||
return mappings != null ? BiMappings.of(mappings) : null;
|
||||
}
|
||||
|
||||
private void loadTags(final RegistryType type, final CompoundTag data) {
|
||||
final CompoundTag tag = data.get(type.resourceLocation());
|
||||
if (tag == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<TagData> tagsList = new ArrayList<>(tags.size());
|
||||
for (final Map.Entry<String, Tag> entry : tag.entrySet()) {
|
||||
final IntArrayTag entries = (IntArrayTag) entry.getValue();
|
||||
tagsList.add(new TagData(entry.getKey(), entries.getValue()));
|
||||
}
|
||||
|
||||
this.tags.put(type, tagsList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewBlockStateId(int id) {
|
||||
public int getNewBlockStateId(final int id) {
|
||||
return checkValidity(id, blockStateMappings.getNewId(id), "blockstate");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewBlockId(int id) {
|
||||
public int getNewBlockId(final int id) {
|
||||
return checkValidity(id, blockMappings.getNewId(id), "block");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewItemId(int id) {
|
||||
return checkValidity(id, itemMappings.get(id), "item");
|
||||
public int getNewItemId(final int id) {
|
||||
return checkValidity(id, itemMappings.getNewId(id), "item");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOldItemId(int id) {
|
||||
int oldId = itemMappings.inverse().get(id);
|
||||
// Remap new items to stone
|
||||
return oldId != -1 ? oldId : 1;
|
||||
public int getOldItemId(final int id) {
|
||||
return itemMappings.inverse().getNewIdOrDefault(id, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewParticleId(int id) {
|
||||
return checkValidity(id, particleMappings.getMappings().getNewId(id), "particles");
|
||||
public int getNewParticleId(final int id) {
|
||||
return checkValidity(id, particleMappings.getNewId(id), "particles");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<TagData> getTags(RegistryType type) {
|
||||
public @Nullable List<TagData> getTags(final RegistryType type) {
|
||||
return tags != null ? tags.get(type) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Int2IntBiMap getItemMappings() {
|
||||
public @Nullable BiMappings getItemMappings() {
|
||||
return itemMappings;
|
||||
}
|
||||
|
||||
@@ -191,24 +204,29 @@ public class MappingDataBase implements MappingData {
|
||||
return statisticsMappings;
|
||||
}
|
||||
|
||||
protected @Nullable Mappings loadFromArray(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
|
||||
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
|
||||
|
||||
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
|
||||
return IntArrayMappings.builder().unmapped(oldMappings.getAsJsonArray(key))
|
||||
.mapped(newMappings.getAsJsonArray(key)).diffMappings(diff).build();
|
||||
@Override
|
||||
public @Nullable Mappings getMenuMappings() {
|
||||
return menuMappings;
|
||||
}
|
||||
|
||||
protected @Nullable Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
|
||||
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
|
||||
|
||||
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
|
||||
return IntArrayMappings.builder().unmapped(oldMappings.getAsJsonObject(key))
|
||||
.mapped(newMappings.getAsJsonObject(key)).diffMappings(diff).build();
|
||||
@Override
|
||||
public @Nullable Mappings getEnchantmentMappings() {
|
||||
return enchantmentMappings;
|
||||
}
|
||||
|
||||
protected @Nullable JsonObject loadDiffFile() {
|
||||
return MappingDataLoader.loadData("mappingdiff-" + oldVersion + "to" + newVersion + ".json");
|
||||
@Override
|
||||
public @Nullable FullMappings getEntityMappings() {
|
||||
return entityMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FullMappings getArgumentTypeMappings() {
|
||||
return argumentTypeMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Mappings getPaintingMappings() {
|
||||
return paintingMappings;
|
||||
}
|
||||
|
||||
protected Logger getLogger() {
|
||||
@@ -223,21 +241,16 @@ public class MappingDataBase implements MappingData {
|
||||
* @param type mapping type (e.g. "item")
|
||||
* @return the given mapped id if valid, else 0
|
||||
*/
|
||||
protected int checkValidity(int id, int mappedId, String type) {
|
||||
protected int checkValidity(final int id, final int mappedId, final String type) {
|
||||
if (mappedId == -1) {
|
||||
getLogger().warning(String.format("Missing %s %s for %s %s %d", newVersion, type, oldVersion, type, id));
|
||||
if (!Via.getConfig().isSuppressConversionWarnings()) {
|
||||
getLogger().warning(String.format("Missing %s %s for %s %s %d", mappedVersion, type, unmappedVersion, type, id));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return mappedId;
|
||||
}
|
||||
|
||||
/**
|
||||
* To be overridden.
|
||||
*
|
||||
* @param oldMappings old mappings
|
||||
* @param newMappings new mappings
|
||||
* @param diffMappings diff mappings if present
|
||||
*/
|
||||
protected void loadExtras(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings) {
|
||||
protected void loadExtras(final CompoundTag data) {
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,6 +22,13 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.github.steveice10.opennbt.NBTIO;
|
||||
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonIOException;
|
||||
@@ -29,46 +36,36 @@ import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.util.GsonUtil;
|
||||
import com.viaversion.viaversion.util.Int2IntBiMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class MappingDataLoader {
|
||||
public final class MappingDataLoader {
|
||||
|
||||
private static final Map<String, JsonObject> MAPPINGS_CACHE = new ConcurrentHashMap<>();
|
||||
private static boolean cacheJsonMappings;
|
||||
|
||||
/**
|
||||
* Returns true if a selected number of mappings should be cached.
|
||||
* If enabled, cleanup should be done after the cache is no longer needed.
|
||||
*
|
||||
* @return true if mappings should be cached
|
||||
*/
|
||||
public static boolean isCacheJsonMappings() {
|
||||
return cacheJsonMappings;
|
||||
}
|
||||
private static final byte DIRECT_ID = 0;
|
||||
private static final byte SHIFTS_ID = 1;
|
||||
private static final byte CHANGES_ID = 2;
|
||||
private static final byte IDENTITY_ID = 3;
|
||||
private static final Map<String, CompoundTag> MAPPINGS_CACHE = new HashMap<>();
|
||||
private static boolean cacheValid = true;
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public static void enableMappingsCache() {
|
||||
cacheJsonMappings = true;
|
||||
// Always enabled
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cached mappings. Cleared after ViaVersion has been fully loaded.
|
||||
*
|
||||
* @return cached mapping file json objects
|
||||
* @see #isCacheJsonMappings()
|
||||
*/
|
||||
public static Map<String, JsonObject> getMappingsCache() {
|
||||
return MAPPINGS_CACHE;
|
||||
public static void clearCache() {
|
||||
MAPPINGS_CACHE.clear();
|
||||
cacheValid = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,143 +73,228 @@ public class MappingDataLoader {
|
||||
*
|
||||
* @return loaded json object, or null if not found or invalid
|
||||
*/
|
||||
public static @Nullable JsonObject loadFromDataDir(String name) {
|
||||
File file = new File(Via.getPlatform().getDataFolder(), name);
|
||||
if (!file.exists()) return loadData(name);
|
||||
public static @Nullable JsonObject loadFromDataDir(final String name) {
|
||||
final File file = new File(Via.getPlatform().getDataFolder(), name);
|
||||
if (!file.exists()) {
|
||||
return loadData(name);
|
||||
}
|
||||
|
||||
// Load the file from the platform's directory if present
|
||||
try (FileReader reader = new FileReader(file)) {
|
||||
try (final FileReader reader = new FileReader(file)) {
|
||||
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
|
||||
} catch (JsonSyntaxException e) {
|
||||
} catch (final JsonSyntaxException e) {
|
||||
// Users might mess up the format, so let's catch the syntax error
|
||||
Via.getPlatform().getLogger().warning(name + " is badly formatted!");
|
||||
e.printStackTrace();
|
||||
} catch (IOException | JsonIOException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
} catch (final IOException | JsonIOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the file from the bundled resources. Uses the cache if enabled.
|
||||
* Loads the file from the bundled resources.
|
||||
*
|
||||
* @return loaded json object from bundled resources if present
|
||||
*/
|
||||
public static @Nullable JsonObject loadData(String name) {
|
||||
return loadData(name, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the file from the bundled resources. Uses the cache if enabled.
|
||||
*
|
||||
* @param cacheIfEnabled whether loaded files should be cached
|
||||
* @return loaded json object from bundled resources if present
|
||||
*/
|
||||
public static @Nullable JsonObject loadData(String name, boolean cacheIfEnabled) {
|
||||
if (cacheJsonMappings) {
|
||||
JsonObject cached = MAPPINGS_CACHE.get(name);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
public static @Nullable JsonObject loadData(final String name) {
|
||||
final InputStream stream = getResource(name);
|
||||
if (stream == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
InputStream stream = getResource(name);
|
||||
if (stream == null) return null;
|
||||
|
||||
InputStreamReader reader = new InputStreamReader(stream);
|
||||
try {
|
||||
JsonObject object = GsonUtil.getGson().fromJson(reader, JsonObject.class);
|
||||
if (cacheIfEnabled && cacheJsonMappings) {
|
||||
MAPPINGS_CACHE.put(name, object);
|
||||
}
|
||||
return object;
|
||||
} finally {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException ignored) {
|
||||
// Ignored
|
||||
}
|
||||
try (final InputStreamReader reader = new InputStreamReader(stream)) {
|
||||
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void mapIdentifiers(Int2IntBiMap output, JsonObject oldIdentifiers, JsonObject newIdentifiers, @Nullable JsonObject diffIdentifiers, boolean warnOnMissing) {
|
||||
Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(newIdentifiers);
|
||||
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
|
||||
int value = mapIdentifierEntry(entry, newIdentifierMap, diffIdentifiers, warnOnMissing);
|
||||
if (value != -1) {
|
||||
output.put(Integer.parseInt(entry.getKey()), value);
|
||||
}
|
||||
public static @Nullable CompoundTag loadNBT(final String name, final boolean cache) {
|
||||
if (!cacheValid) {
|
||||
return loadNBTFromFile(name);
|
||||
}
|
||||
|
||||
CompoundTag data = MAPPINGS_CACHE.get(name);
|
||||
if (data != null) {
|
||||
return data;
|
||||
}
|
||||
|
||||
data = loadNBTFromFile(name);
|
||||
|
||||
if (cache && data != null) {
|
||||
MAPPINGS_CACHE.put(name, data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public static @Nullable CompoundTag loadNBT(final String name) {
|
||||
return loadNBT(name, false);
|
||||
}
|
||||
|
||||
private static @Nullable CompoundTag loadNBTFromFile(final String name) {
|
||||
final InputStream resource = getResource(name);
|
||||
if (resource == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try (final InputStream stream = resource) {
|
||||
return NBTIO.readTag(stream);
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
|
||||
mapIdentifiers(output, oldIdentifiers, newIdentifiers, null);
|
||||
public static @Nullable Mappings loadMappings(final CompoundTag mappingsTag, final String key) {
|
||||
return loadMappings(mappingsTag, key, size -> {
|
||||
final int[] array = new int[size];
|
||||
Arrays.fill(array, -1);
|
||||
return array;
|
||||
}, (array, id, mappedId) -> array[id] = mappedId, IntArrayMappings::of);
|
||||
}
|
||||
|
||||
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, @Nullable JsonObject diffIdentifiers, boolean warnOnMissing) {
|
||||
Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(newIdentifiers);
|
||||
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
|
||||
int value = mapIdentifierEntry(entry, newIdentifierMap, diffIdentifiers, warnOnMissing);
|
||||
if (value != -1) {
|
||||
output[Integer.parseInt(entry.getKey())] = value;
|
||||
}
|
||||
@Beta
|
||||
public static <M extends Mappings, V> @Nullable Mappings loadMappings(
|
||||
final CompoundTag mappingsTag,
|
||||
final String key,
|
||||
final MappingHolderSupplier<V> holderSupplier,
|
||||
final AddConsumer<V> addConsumer,
|
||||
final MappingsSupplier<M, V> mappingsSupplier
|
||||
) {
|
||||
final CompoundTag tag = mappingsTag.get(key);
|
||||
if (tag == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, @Nullable JsonObject diffIdentifiers) {
|
||||
mapIdentifiers(output, oldIdentifiers, newIdentifiers, diffIdentifiers, true);
|
||||
}
|
||||
final ByteTag serializationStragetyTag = tag.get("id");
|
||||
final IntTag mappedSizeTag = tag.get("mappedSize");
|
||||
final byte strategy = serializationStragetyTag.asByte();
|
||||
final V mappings;
|
||||
if (strategy == DIRECT_ID) {
|
||||
final IntArrayTag valuesTag = tag.get("val");
|
||||
return IntArrayMappings.of(valuesTag.getValue(), mappedSizeTag.asInt());
|
||||
} else if (strategy == SHIFTS_ID) {
|
||||
final IntArrayTag shiftsAtTag = tag.get("at");
|
||||
final IntArrayTag shiftsTag = tag.get("to");
|
||||
final IntTag sizeTag = tag.get("size");
|
||||
final int[] shiftsAt = shiftsAtTag.getValue();
|
||||
final int[] shiftsTo = shiftsTag.getValue();
|
||||
final int size = sizeTag.asInt();
|
||||
mappings = holderSupplier.get(size);
|
||||
|
||||
private static int mapIdentifierEntry(Map.Entry<String, JsonElement> entry, Object2IntMap newIdentifierMap, @Nullable JsonObject diffIdentifiers, boolean warnOnMissing) {
|
||||
int value = newIdentifierMap.getInt(entry.getValue().getAsString());
|
||||
if (value == -1) {
|
||||
// Search in diff mappings
|
||||
if (diffIdentifiers != null) {
|
||||
JsonElement diffElement = diffIdentifiers.get(entry.getKey());
|
||||
if (diffElement != null) {
|
||||
value = newIdentifierMap.getInt(diffElement.getAsString());
|
||||
// Handle values until first shift
|
||||
if (shiftsAt[0] != 0) {
|
||||
final int to = shiftsAt[0];
|
||||
for (int id = 0; id < to; id++) {
|
||||
addConsumer.addTo(mappings, id, id);
|
||||
}
|
||||
}
|
||||
if (value == -1) {
|
||||
|
||||
// Handle shifts
|
||||
for (int i = 0; i < shiftsAt.length; i++) {
|
||||
final int from = shiftsAt[i];
|
||||
final int to = i == shiftsAt.length - 1 ? size : shiftsAt[i + 1];
|
||||
int mappedId = shiftsTo[i];
|
||||
for (int id = from; id < to; id++) {
|
||||
addConsumer.addTo(mappings, id, mappedId++);
|
||||
}
|
||||
}
|
||||
} else if (strategy == CHANGES_ID) {
|
||||
final IntArrayTag changesAtTag = tag.get("at");
|
||||
final IntArrayTag valuesTag = tag.get("val");
|
||||
final IntTag sizeTag = tag.get("size");
|
||||
final boolean fillBetween = tag.get("nofill") == null;
|
||||
final int[] changesAt = changesAtTag.getValue();
|
||||
final int[] values = valuesTag.getValue();
|
||||
mappings = holderSupplier.get(sizeTag.asInt());
|
||||
|
||||
for (int i = 0; i < changesAt.length; i++) {
|
||||
final int id = changesAt[i];
|
||||
if (fillBetween) {
|
||||
// Fill from after the last change to before this change with unchanged ids
|
||||
final int previousId = i != 0 ? changesAt[i - 1] + 1 : 0;
|
||||
for (int identity = previousId; identity < id; identity++) {
|
||||
addConsumer.addTo(mappings, identity, identity);
|
||||
}
|
||||
}
|
||||
|
||||
// Assign the changed value
|
||||
addConsumer.addTo(mappings, id, values[i]);
|
||||
}
|
||||
} else if (strategy == IDENTITY_ID) {
|
||||
final IntTag sizeTag = tag.get("size");
|
||||
return new IdentityMappings(sizeTag.asInt(), mappedSizeTag.asInt());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown serialization strategy: " + strategy);
|
||||
}
|
||||
return mappingsSupplier.create(mappings, mappedSizeTag.asInt());
|
||||
}
|
||||
|
||||
public static FullMappings loadFullMappings(final CompoundTag mappingsTag, final CompoundTag unmappedIdentifiers, final CompoundTag mappedIdentifiers, final String key) {
|
||||
final ListTag unmappedElements = unmappedIdentifiers.get(key);
|
||||
final ListTag mappedElements = mappedIdentifiers.get(key);
|
||||
if (unmappedElements == null || mappedElements == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Mappings mappings = loadMappings(mappingsTag, key);
|
||||
if (mappings == null) {
|
||||
mappings = new IdentityMappings(unmappedElements.size(), mappedElements.size());
|
||||
}
|
||||
|
||||
return new FullMappingsBase(
|
||||
unmappedElements.getValue().stream().map(t -> (String) t.getValue()).collect(Collectors.toList()),
|
||||
mappedElements.getValue().stream().map(t -> (String) t.getValue()).collect(Collectors.toList()),
|
||||
mappings
|
||||
);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void mapIdentifiers(final int[] output, final JsonObject unmappedIdentifiers, final JsonObject mappedIdentifiers, @Nullable final JsonObject diffIdentifiers, final boolean warnOnMissing) {
|
||||
final Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(mappedIdentifiers);
|
||||
for (final Map.Entry<String, JsonElement> entry : unmappedIdentifiers.entrySet()) {
|
||||
final int id = Integer.parseInt(entry.getKey());
|
||||
final int mappedId = mapIdentifierEntry(id, entry.getValue().getAsString(), newIdentifierMap, diffIdentifiers, warnOnMissing);
|
||||
if (mappedId != -1) {
|
||||
output[id] = mappedId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int mapIdentifierEntry(final int id, final String val, final Object2IntMap<String> mappedIdentifiers, @Nullable final JsonObject diffIdentifiers, final boolean warnOnMissing) {
|
||||
int mappedId = mappedIdentifiers.getInt(val);
|
||||
if (mappedId == -1) {
|
||||
// Search in diff mappings
|
||||
if (diffIdentifiers != null) {
|
||||
JsonElement diffElement = diffIdentifiers.get(val);
|
||||
if (diffElement != null || (diffElement = diffIdentifiers.get(Integer.toString(id))) != null) {
|
||||
final String mappedName = diffElement.getAsString();
|
||||
if (mappedName.isEmpty()) {
|
||||
return -1; // "empty" remaps without warnings
|
||||
}
|
||||
|
||||
mappedId = mappedIdentifiers.getInt(mappedName);
|
||||
|
||||
}
|
||||
}
|
||||
if (mappedId == -1) {
|
||||
if (warnOnMissing && !Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
|
||||
Via.getPlatform().getLogger().warning("No key for " + val + " :( ");
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
return mappedId;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public static void mapIdentifiers(int[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, boolean warnOnMissing) {
|
||||
mapIdentifiers(output, oldIdentifiers, newIdentifiers, null, warnOnMissing);
|
||||
}
|
||||
|
||||
public static void mapIdentifiers(int[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, @Nullable JsonObject diffIdentifiers, boolean warnOnMissing) {
|
||||
Object2IntMap<String> newIdentifierMap = MappingDataLoader.arrayToMap(newIdentifiers);
|
||||
for (int i = 0; i < oldIdentifiers.size(); i++) {
|
||||
JsonElement oldIdentifier = oldIdentifiers.get(i);
|
||||
int mappedId = newIdentifierMap.getInt(oldIdentifier.getAsString());
|
||||
if (mappedId == -1) {
|
||||
// Search in diff mappings
|
||||
if (diffIdentifiers != null) {
|
||||
JsonElement diffElement = diffIdentifiers.get(oldIdentifier.getAsString());
|
||||
if (diffElement != null) {
|
||||
String mappedName = diffElement.getAsString();
|
||||
if (mappedName.isEmpty()) continue; // "empty" remaps
|
||||
|
||||
mappedId = newIdentifierMap.getInt(mappedName);
|
||||
}
|
||||
}
|
||||
if (mappedId == -1) {
|
||||
if (warnOnMissing && !Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("No key for " + oldIdentifier + " :( ");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@Deprecated
|
||||
public static void mapIdentifiers(final int[] output, final JsonArray unmappedIdentifiers, final JsonArray mappedIdentifiers, @Nullable final JsonObject diffIdentifiers, final boolean warnOnMissing) {
|
||||
final Object2IntMap<String> newIdentifierMap = MappingDataLoader.arrayToMap(mappedIdentifiers);
|
||||
for (int id = 0; id < unmappedIdentifiers.size(); id++) {
|
||||
final JsonElement unmappedIdentifier = unmappedIdentifiers.get(id);
|
||||
final int mappedId = mapIdentifierEntry(id, unmappedIdentifier.getAsString(), newIdentifierMap, diffIdentifiers, warnOnMissing);
|
||||
if (mappedId != -1) {
|
||||
output[id] = mappedId;
|
||||
}
|
||||
output[i] = mappedId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,10 +304,10 @@ public class MappingDataLoader {
|
||||
* @param object json object
|
||||
* @return map with indexes hashed by their id value
|
||||
*/
|
||||
public static Object2IntMap<String> indexedObjectToMap(JsonObject object) {
|
||||
Object2IntMap<String> map = new Object2IntOpenHashMap<>(object.size(), .99F);
|
||||
public static Object2IntMap<String> indexedObjectToMap(final JsonObject object) {
|
||||
final Object2IntMap<String> map = new Object2IntOpenHashMap<>(object.size(), .99F);
|
||||
map.defaultReturnValue(-1);
|
||||
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
for (final Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
map.put(entry.getValue().getAsString(), Integer.parseInt(entry.getKey()));
|
||||
}
|
||||
return map;
|
||||
@@ -237,8 +319,8 @@ public class MappingDataLoader {
|
||||
* @param array json array
|
||||
* @return map with indexes hashed by their id value
|
||||
*/
|
||||
public static Object2IntMap<String> arrayToMap(JsonArray array) {
|
||||
Object2IntMap<String> map = new Object2IntOpenHashMap<>(array.size(), .99F);
|
||||
public static Object2IntMap<String> arrayToMap(final JsonArray array) {
|
||||
final Object2IntMap<String> map = new Object2IntOpenHashMap<>(array.size(), .99F);
|
||||
map.defaultReturnValue(-1);
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
map.put(array.get(i).getAsString(), i);
|
||||
@@ -246,7 +328,25 @@ public class MappingDataLoader {
|
||||
return map;
|
||||
}
|
||||
|
||||
public static @Nullable InputStream getResource(String name) {
|
||||
public static @Nullable InputStream getResource(final String name) {
|
||||
return MappingDataLoader.class.getClassLoader().getResourceAsStream("assets/viaversion/data/" + name);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface AddConsumer<T> {
|
||||
|
||||
void addTo(T holder, int id, int mappedId);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface MappingHolderSupplier<T> {
|
||||
|
||||
T get(int expectedSize);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface MappingsSupplier<T extends Mappings, V> {
|
||||
|
||||
T create(V mappings, int mappedSize);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,7 +25,6 @@ package com.viaversion.viaversion.api.data;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public interface Mappings {
|
||||
@@ -38,14 +37,36 @@ public interface Mappings {
|
||||
*/
|
||||
int getNewId(int id);
|
||||
|
||||
/**
|
||||
* Returns the mapped id from the given id, or the given default if unmapped/invalid.
|
||||
*
|
||||
* @param id unmapped id
|
||||
* @param def fallback return value
|
||||
* @return mapped id, or def if invalid/out of bounds
|
||||
*/
|
||||
default int getNewIdOrDefault(int id, int def) {
|
||||
final int mappedId = getNewId(id);
|
||||
return mappedId != -1 ? mappedId : def;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the id has a mapping.
|
||||
*
|
||||
* @param id unmapped id
|
||||
* @return whether the id has a mapped id
|
||||
*/
|
||||
default boolean contains(int id) {
|
||||
return getNewId(id) != -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually maps a specific id.
|
||||
*
|
||||
* @param id unmapped id
|
||||
* @param newId mapped id
|
||||
* @param id unmapped id
|
||||
* @param mappedId mapped id
|
||||
* @throws IndexOutOfBoundsException if the unmapped id is invalid
|
||||
*/
|
||||
void setNewId(int id, int newId);
|
||||
void setNewId(int id, int mappedId);
|
||||
|
||||
/**
|
||||
* Returns amount of unmapped entries, being the size of the mapping.
|
||||
@@ -62,8 +83,15 @@ public interface Mappings {
|
||||
*/
|
||||
int mappedSize();
|
||||
|
||||
/**
|
||||
* Mappings with keys and values swapped.
|
||||
*
|
||||
* @return mappings with keys and values swapped
|
||||
*/
|
||||
Mappings inverse();
|
||||
|
||||
static <T extends Mappings> Builder<T> builder(final MappingsSupplier<T> supplier) {
|
||||
return new Builder(supplier);
|
||||
return new Builder<>(supplier);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
@@ -72,6 +100,7 @@ public interface Mappings {
|
||||
T supply(int[] mappings, int mappedIds);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
class Builder<T extends Mappings> {
|
||||
|
||||
protected final MappingsSupplier<T> supplier;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,54 +22,22 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ParticleMappings {
|
||||
private final Object2IntMap<String> stringToId;
|
||||
private final Object2IntMap<String> mappedStringToId;
|
||||
private final Mappings mappings;
|
||||
private final IntList itemParticleIds = new IntArrayList(2);
|
||||
public class ParticleMappings extends FullMappingsBase {
|
||||
private final IntList itemParticleIds = new IntArrayList(4);
|
||||
private final IntList blockParticleIds = new IntArrayList(4);
|
||||
|
||||
public ParticleMappings(JsonArray oldMappings, JsonArray newMappings, Mappings mappings) {
|
||||
this.mappings = mappings;
|
||||
stringToId = MappingDataLoader.arrayToMap(oldMappings);
|
||||
mappedStringToId = MappingDataLoader.arrayToMap(newMappings);
|
||||
stringToId.defaultReturnValue(-1);
|
||||
mappedStringToId.defaultReturnValue(-1);
|
||||
public ParticleMappings(final List<String> unmappedIdentifiers, final List<String> mappedIdentifiers, final Mappings mappings) {
|
||||
super(unmappedIdentifiers, mappedIdentifiers, mappings);
|
||||
addBlockParticle("block");
|
||||
addBlockParticle("falling_dust");
|
||||
addBlockParticle("block_marker");
|
||||
addItemParticle("item");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unmapped integer id for the given identifier, or -1 if not found.
|
||||
*
|
||||
* @param identifier unmapped string identifier
|
||||
* @return unmapped int id, or -1 if not found
|
||||
*/
|
||||
public int id(String identifier) {
|
||||
return stringToId.getInt(identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mapped integer id for the given mapped identifier, or -1 if not found.
|
||||
*
|
||||
* @param mappedIdentifier mapped string identifier
|
||||
* @return mapped int id, or -1 if not found
|
||||
*/
|
||||
public int mappedId(String mappedIdentifier) {
|
||||
return mappedStringToId.getInt(mappedIdentifier);
|
||||
}
|
||||
|
||||
public Mappings getMappings() {
|
||||
return mappings;
|
||||
}
|
||||
|
||||
public boolean addItemParticle(final String identifier) {
|
||||
final int id = id(identifier);
|
||||
return id != -1 && itemParticleIds.add(id);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data.entity;
|
||||
|
||||
public interface DimensionData {
|
||||
|
||||
int minY();
|
||||
|
||||
int height();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.data.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface EntityTracker {
|
||||
@@ -51,6 +52,14 @@ public interface EntityTracker {
|
||||
*/
|
||||
boolean hasEntity(int id);
|
||||
|
||||
/**
|
||||
* Returns the tracked entity for the given entity id if present.
|
||||
*
|
||||
* @param entityId entity id
|
||||
* @return tracked entity if tracked
|
||||
*/
|
||||
@Nullable TrackedEntity entity(int entityId);
|
||||
|
||||
/**
|
||||
* Entity type of the entity if tracked.
|
||||
* This returning null does not necessarily mean no entity by the id exists.
|
||||
@@ -151,4 +160,18 @@ public interface EntityTracker {
|
||||
int biomesSent();
|
||||
|
||||
void setBiomesSent(int biomesSent);
|
||||
|
||||
EntityType playerType();
|
||||
|
||||
@Nullable DimensionData dimensionData(String dimension);
|
||||
|
||||
void setDimensions(Map<String, DimensionData> dimensions);
|
||||
|
||||
/**
|
||||
* Adds the client player entity to the tracker.
|
||||
* If the client entity has not been set yet, this will return false.
|
||||
*
|
||||
* @return whether the client has been tracked
|
||||
*/
|
||||
boolean trackClientEntity();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -51,6 +51,15 @@ public interface StoredEntityData {
|
||||
*/
|
||||
@Nullable <T> T get(Class<T> objectClass);
|
||||
|
||||
/**
|
||||
* Removes and returns an object from the storage if present.
|
||||
*
|
||||
* @param objectClass class of the object to remove
|
||||
* @param <T> object type
|
||||
* @return removed object if present
|
||||
*/
|
||||
@Nullable <T> T remove(Class<T> objectClass);
|
||||
|
||||
/**
|
||||
* Stores an object based on its class.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
|
||||
public interface TrackedEntity {
|
||||
|
||||
/**
|
||||
* Returns the type of the stored entity.
|
||||
*
|
||||
* @return type of the entity
|
||||
*/
|
||||
EntityType entityType();
|
||||
|
||||
/**
|
||||
* Object to hold arbitrary additional data.
|
||||
*
|
||||
* @return entity data
|
||||
*/
|
||||
StoredEntityData data();
|
||||
|
||||
/**
|
||||
* Returns whether the stored entity currently has any additional data.
|
||||
*
|
||||
* @return whether the stored entity currently has additional data
|
||||
*/
|
||||
boolean hasData();
|
||||
|
||||
/**
|
||||
* Returns whether metadata has already been sent at least once for this entity.
|
||||
*
|
||||
* @return whether metadata has already been sent at least once for this entity
|
||||
*/
|
||||
boolean hasSentMetadata();
|
||||
|
||||
void sentMetadata(boolean sentMetadata);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,8 +22,12 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.debug;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
|
||||
@Beta
|
||||
public interface DebugHandler {
|
||||
|
||||
/**
|
||||
@@ -47,6 +51,14 @@ public interface DebugHandler {
|
||||
*/
|
||||
void addPacketTypeNameToLog(String packetTypeName);
|
||||
|
||||
/**
|
||||
* Adds a packet id to the list of packet types to log.
|
||||
* Packets will be checked on each protocol transformer, so this is best used on single protocol pipes.
|
||||
*
|
||||
* @param packetType packet type
|
||||
*/
|
||||
void addPacketTypeToLog(PacketType packetType);
|
||||
|
||||
/**
|
||||
* Removes a packet type name from the list of packet types to log.
|
||||
*
|
||||
@@ -78,8 +90,16 @@ public interface DebugHandler {
|
||||
* Returns whether the given packet should be logged.
|
||||
* If no specific packet type has been added, all packet types will be logged.
|
||||
*
|
||||
* @param wrapper packet wrapper
|
||||
* @param wrapper packet wrapper
|
||||
* @param direction packet direction
|
||||
* @return whether the packet should be logged
|
||||
*/
|
||||
boolean shouldLog(PacketWrapper wrapper);
|
||||
boolean shouldLog(PacketWrapper wrapper, Direction direction);
|
||||
|
||||
default void enableAndLogIds(final PacketType... packetTypes) {
|
||||
setEnabled(true);
|
||||
for (final PacketType packetType : packetTypes) {
|
||||
addPacketTypeToLog(packetType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,7 +23,6 @@
|
||||
package com.viaversion.viaversion.api.legacy.bossbar;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -54,10 +54,10 @@ public interface BlockChangeRecord {
|
||||
short getY(int chunkSectionY);
|
||||
|
||||
/**
|
||||
* Returns the absolute y coordinate - only works for sub 1.16 protocols.
|
||||
*
|
||||
* @return absolute y coordinate
|
||||
* @deprecated 1.16+ stores the relative y coordinate
|
||||
*/
|
||||
@Deprecated
|
||||
default short getY() {
|
||||
return getY(-1);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum BlockFace {
|
||||
@@ -33,9 +33,9 @@ public enum BlockFace {
|
||||
TOP((byte) 0, (byte) 1, (byte) 0, EnumAxis.Y),
|
||||
BOTTOM((byte) 0, (byte) -1, (byte) 0, EnumAxis.Y);
|
||||
|
||||
public static final BlockFace[] HORIZONTAL = new BlockFace[]{NORTH, SOUTH, EAST, WEST};
|
||||
public static final BlockFace[] HORIZONTAL = {NORTH, SOUTH, EAST, WEST};
|
||||
|
||||
private static final Map<BlockFace, BlockFace> opposites = new HashMap<>();
|
||||
private static final Map<BlockFace, BlockFace> opposites = new EnumMap<>(BlockFace.class);
|
||||
|
||||
static {
|
||||
opposites.put(BlockFace.NORTH, BlockFace.SOUTH);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public final class GlobalPosition extends Position {
|
||||
private final String dimension;
|
||||
|
||||
public GlobalPosition(final String dimension, final int x, final int y, final int z) {
|
||||
super(x, y, z);
|
||||
this.dimension = dimension;
|
||||
}
|
||||
|
||||
public String dimension() {
|
||||
return dimension;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final GlobalPosition position = (GlobalPosition) o;
|
||||
if (x != position.x) return false;
|
||||
if (y != position.y) return false;
|
||||
if (z != position.z) return false;
|
||||
return dimension.equals(position.dimension);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = dimension.hashCode();
|
||||
result = 31 * result + x;
|
||||
result = 31 * result + y;
|
||||
result = 31 * result + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GlobalPosition{" +
|
||||
"dimension='" + dimension + '\'' +
|
||||
", x=" + x +
|
||||
", y=" + y +
|
||||
", z=" + z +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class PlayerMessageSignature {
|
||||
private final UUID uuid;
|
||||
private final byte[] signatureBytes;
|
||||
|
||||
public PlayerMessageSignature(final UUID uuid, final byte[] signatureBytes) {
|
||||
this.uuid = uuid;
|
||||
this.signatureBytes = signatureBytes;
|
||||
}
|
||||
|
||||
public UUID uuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public byte[] signatureBytes() {
|
||||
return signatureBytes;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,9 +23,9 @@
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public class Position {
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
protected final int x;
|
||||
protected final int y;
|
||||
protected final int z;
|
||||
|
||||
public Position(int x, int y, int z) {
|
||||
this.x = x;
|
||||
@@ -33,7 +33,7 @@ public class Position {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
// @Deprecated/*(forRemoval=true)*/ Just leave this unchecked
|
||||
public Position(int x, short y, int z) {
|
||||
this(x, (int) y, z);
|
||||
}
|
||||
@@ -59,6 +59,10 @@ public class Position {
|
||||
return z;
|
||||
}
|
||||
|
||||
public GlobalPosition withDimension(String dimension) {
|
||||
return new GlobalPosition(dimension, x, y, z);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getX() {
|
||||
return x;
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public class Position3d {
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
|
||||
public Position3d(final double x, final double y, final double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public double x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double z() {
|
||||
return z;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public final class ProfileKey {
|
||||
private final long expiresAt;
|
||||
private final byte[] publicKey;
|
||||
private final byte[] keySignature;
|
||||
|
||||
public ProfileKey(final long expiresAt, final byte[] publicKey, final byte[] keySignature) {
|
||||
this.expiresAt = expiresAt;
|
||||
this.publicKey = publicKey;
|
||||
this.keySignature = keySignature;
|
||||
}
|
||||
|
||||
public long expiresAt() {
|
||||
return expiresAt;
|
||||
}
|
||||
|
||||
public byte[] publicKey() {
|
||||
return publicKey;
|
||||
}
|
||||
|
||||
public byte[] keySignature() {
|
||||
return keySignature;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public final class Quaternion {
|
||||
private final float x;
|
||||
private final float y;
|
||||
private final float z;
|
||||
private final float w;
|
||||
|
||||
public Quaternion(final float x, final float y, final float z, final float w) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
public float x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public float y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public float z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public float w() {
|
||||
return w;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,10 +22,9 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum RegistryType {
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,7 +26,7 @@ public final class TagData {
|
||||
private final String identifier;
|
||||
private final int[] entries;
|
||||
|
||||
public TagData(String identifier, int[] entries) {
|
||||
public TagData(final String identifier, final int[] entries) {
|
||||
this.identifier = identifier;
|
||||
this.entries = entries;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public final class Vector3f {
|
||||
private final float x;
|
||||
private final float y;
|
||||
private final float z;
|
||||
|
||||
public Vector3f(final float x, final float y, final float z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public float x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public float y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public float z() {
|
||||
return z;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+7
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -27,6 +27,10 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface BlockEntity {
|
||||
|
||||
static byte pack(int sectionX, int sectionZ) {
|
||||
return (byte) (((sectionX) & 15) << 4 | (sectionZ & 15));
|
||||
}
|
||||
|
||||
default byte sectionX() {
|
||||
return (byte) ((packedXZ() >> 4) & 15);
|
||||
}
|
||||
@@ -42,4 +46,6 @@ public interface BlockEntity {
|
||||
int typeId();
|
||||
|
||||
@Nullable CompoundTag tag();
|
||||
|
||||
BlockEntity withTypeId(int typeId);
|
||||
}
|
||||
+6
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -56,4 +56,9 @@ public final class BlockEntityImpl implements BlockEntity {
|
||||
public CompoundTag tag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity withTypeId(int typeId) {
|
||||
return new BlockEntityImpl(packedXZ, y, typeId, tag);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,10 +24,9 @@ package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
//TODO Move methods from distinctly different versions to different objects/interfaces
|
||||
public class BaseChunk implements Chunk {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,10 +24,9 @@ package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
// TODO specialized sub interfaces
|
||||
public interface Chunk {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,10 +24,9 @@ package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class Chunk1_18 implements Chunk {
|
||||
protected final int x;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -40,6 +40,18 @@ public interface ChunkSection {
|
||||
return y << 8 | z << 4 | x;
|
||||
}
|
||||
|
||||
static int xFromIndex(int idx) {
|
||||
return idx & 0xF;
|
||||
}
|
||||
|
||||
static int yFromIndex(int idx) {
|
||||
return idx >> 8 & 0xF;
|
||||
}
|
||||
|
||||
static int zFromIndex(int idx) {
|
||||
return idx >> 4 & 0xF;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getFlatBlock(int idx) {
|
||||
return palette(PaletteType.BLOCKS).idAt(idx);
|
||||
|
||||
+2
-3
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,9 +22,8 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class ChunkSectionImpl implements ChunkSection {
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+11
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,7 +23,6 @@
|
||||
package com.viaversion.viaversion.api.minecraft.entities;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -170,6 +169,16 @@ public class Entity1_10Types {
|
||||
public EntityType getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ObjectType implements com.viaversion.viaversion.api.minecraft.entities.ObjectType {
|
||||
|
||||
+11
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,7 +23,6 @@
|
||||
package com.viaversion.viaversion.api.minecraft.entities;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -187,6 +186,16 @@ public class Entity1_11Types {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
TYPES.put(type.id, type);
|
||||
|
||||
+11
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,7 +24,6 @@
|
||||
package com.viaversion.viaversion.api.minecraft.entities;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -191,6 +190,16 @@ public class Entity1_12Types {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
TYPES.put(type.id, type);
|
||||
|
||||
+11
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,7 +23,6 @@
|
||||
package com.viaversion.viaversion.api.minecraft.entities;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -240,6 +239,16 @@ public class Entity1_13Types {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
TYPES.put(type.id, type);
|
||||
|
||||
+11
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -224,6 +224,16 @@ public enum Entity1_14Types implements EntityType {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
static {
|
||||
TYPES = EntityTypeUtil.toOrderedArray(values());
|
||||
}
|
||||
|
||||
+11
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -226,6 +226,16 @@ public enum Entity1_15Types implements EntityType {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
static {
|
||||
TYPES = EntityTypeUtil.toOrderedArray(values());
|
||||
}
|
||||
|
||||
+11
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -231,6 +231,16 @@ public enum Entity1_16Types implements EntityType {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
static {
|
||||
TYPES = EntityTypeUtil.toOrderedArray(values());
|
||||
}
|
||||
|
||||
+11
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -235,6 +235,16 @@ public enum Entity1_16_2Types implements EntityType {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
static {
|
||||
TYPES = EntityTypeUtil.toOrderedArray(values());
|
||||
}
|
||||
|
||||
+11
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -240,6 +240,16 @@ public enum Entity1_17Types implements EntityType {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
static {
|
||||
TYPES = EntityTypeUtil.toOrderedArray(values());
|
||||
}
|
||||
|
||||
+273
@@ -0,0 +1,273 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.entities;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.util.EntityTypeUtil;
|
||||
import java.util.Locale;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum Entity1_19Types implements EntityType {
|
||||
|
||||
ENTITY(null, null),
|
||||
|
||||
AREA_EFFECT_CLOUD(ENTITY),
|
||||
END_CRYSTAL(ENTITY),
|
||||
EVOKER_FANGS(ENTITY),
|
||||
EXPERIENCE_ORB(ENTITY),
|
||||
EYE_OF_ENDER(ENTITY),
|
||||
FALLING_BLOCK(ENTITY),
|
||||
FIREWORK_ROCKET(ENTITY),
|
||||
ITEM(ENTITY),
|
||||
LLAMA_SPIT(ENTITY),
|
||||
TNT(ENTITY),
|
||||
SHULKER_BULLET(ENTITY),
|
||||
FISHING_BOBBER(ENTITY),
|
||||
|
||||
LIVINGENTITY(ENTITY, null),
|
||||
ARMOR_STAND(LIVINGENTITY),
|
||||
MARKER(ENTITY),
|
||||
PLAYER(LIVINGENTITY),
|
||||
|
||||
ABSTRACT_INSENTIENT(LIVINGENTITY, null),
|
||||
ENDER_DRAGON(ABSTRACT_INSENTIENT),
|
||||
|
||||
BEE(ABSTRACT_INSENTIENT),
|
||||
|
||||
ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null),
|
||||
|
||||
ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null),
|
||||
VILLAGER(ABSTRACT_AGEABLE),
|
||||
WANDERING_TRADER(ABSTRACT_AGEABLE),
|
||||
|
||||
// Animals
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
|
||||
AXOLOTL(ABSTRACT_ANIMAL),
|
||||
DOLPHIN(ABSTRACT_INSENTIENT),
|
||||
CHICKEN(ABSTRACT_ANIMAL),
|
||||
COW(ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(COW),
|
||||
PANDA(ABSTRACT_INSENTIENT),
|
||||
PIG(ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(ABSTRACT_ANIMAL),
|
||||
RABBIT(ABSTRACT_ANIMAL),
|
||||
SHEEP(ABSTRACT_ANIMAL),
|
||||
TURTLE(ABSTRACT_ANIMAL),
|
||||
FOX(ABSTRACT_ANIMAL),
|
||||
FROG(ABSTRACT_ANIMAL),
|
||||
GOAT(ABSTRACT_ANIMAL),
|
||||
|
||||
ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
OCELOT(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
WOLF(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_PARROT(ABSTRACT_TAMEABLE_ANIMAL, null),
|
||||
PARROT(ABSTRACT_PARROT),
|
||||
|
||||
// Horses
|
||||
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
|
||||
CHESTED_HORSE(ABSTRACT_HORSE, null),
|
||||
DONKEY(CHESTED_HORSE),
|
||||
MULE(CHESTED_HORSE),
|
||||
LLAMA(CHESTED_HORSE),
|
||||
TRADER_LLAMA(CHESTED_HORSE),
|
||||
HORSE(ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(ABSTRACT_HORSE),
|
||||
|
||||
// Golem
|
||||
ABSTRACT_GOLEM(ABSTRACT_CREATURE, null),
|
||||
SNOW_GOLEM(ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(ABSTRACT_GOLEM),
|
||||
SHULKER(ABSTRACT_GOLEM),
|
||||
|
||||
// Fish
|
||||
ABSTRACT_FISHES(ABSTRACT_CREATURE, null),
|
||||
COD(ABSTRACT_FISHES),
|
||||
PUFFERFISH(ABSTRACT_FISHES),
|
||||
SALMON(ABSTRACT_FISHES),
|
||||
TROPICAL_FISH(ABSTRACT_FISHES),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(ABSTRACT_CREATURE, null),
|
||||
BLAZE(ABSTRACT_MONSTER),
|
||||
CREEPER(ABSTRACT_MONSTER),
|
||||
ENDERMITE(ABSTRACT_MONSTER),
|
||||
ENDERMAN(ABSTRACT_MONSTER),
|
||||
GIANT(ABSTRACT_MONSTER),
|
||||
SILVERFISH(ABSTRACT_MONSTER),
|
||||
VEX(ABSTRACT_MONSTER),
|
||||
WITCH(ABSTRACT_MONSTER),
|
||||
WITHER(ABSTRACT_MONSTER),
|
||||
RAVAGER(ABSTRACT_MONSTER),
|
||||
|
||||
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
|
||||
|
||||
PIGLIN(ABSTRACT_PIGLIN),
|
||||
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
|
||||
|
||||
HOGLIN(ABSTRACT_ANIMAL),
|
||||
STRIDER(ABSTRACT_ANIMAL),
|
||||
TADPOLE(ABSTRACT_FISHES),
|
||||
ZOGLIN(ABSTRACT_MONSTER),
|
||||
WARDEN(ABSTRACT_MONSTER),
|
||||
|
||||
// Illagers
|
||||
ABSTRACT_ILLAGER_BASE(ABSTRACT_MONSTER, null),
|
||||
ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null),
|
||||
EVOKER(ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
VINDICATOR(ABSTRACT_ILLAGER_BASE),
|
||||
PILLAGER(ABSTRACT_ILLAGER_BASE),
|
||||
|
||||
// Skeletons
|
||||
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
|
||||
SKELETON(ABSTRACT_SKELETON),
|
||||
STRAY(ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(ABSTRACT_SKELETON),
|
||||
|
||||
// Guardians
|
||||
GUARDIAN(ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(GUARDIAN),
|
||||
|
||||
// Spiders
|
||||
SPIDER(ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(SPIDER),
|
||||
|
||||
// Zombies
|
||||
ZOMBIE(ABSTRACT_MONSTER),
|
||||
DROWNED(ZOMBIE),
|
||||
HUSK(ZOMBIE),
|
||||
ZOMBIFIED_PIGLIN(ZOMBIE),
|
||||
ZOMBIE_VILLAGER(ZOMBIE),
|
||||
|
||||
// Flying entities
|
||||
ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null),
|
||||
GHAST(ABSTRACT_FLYING),
|
||||
PHANTOM(ABSTRACT_FLYING),
|
||||
|
||||
ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null),
|
||||
BAT(ABSTRACT_AMBIENT),
|
||||
ALLAY(ABSTRACT_CREATURE),
|
||||
|
||||
ABSTRACT_WATERMOB(ABSTRACT_INSENTIENT, null),
|
||||
SQUID(ABSTRACT_WATERMOB),
|
||||
GLOW_SQUID(SQUID),
|
||||
|
||||
// Slimes
|
||||
SLIME(ABSTRACT_INSENTIENT),
|
||||
MAGMA_CUBE(SLIME),
|
||||
|
||||
// Hangable objects
|
||||
ABSTRACT_HANGING(ENTITY, null),
|
||||
LEASH_KNOT(ABSTRACT_HANGING),
|
||||
ITEM_FRAME(ABSTRACT_HANGING),
|
||||
GLOW_ITEM_FRAME(ITEM_FRAME),
|
||||
PAINTING(ABSTRACT_HANGING),
|
||||
|
||||
ABSTRACT_LIGHTNING(ENTITY, null),
|
||||
LIGHTNING_BOLT(ABSTRACT_LIGHTNING),
|
||||
|
||||
// Arrows
|
||||
ABSTRACT_ARROW(ENTITY, null),
|
||||
ARROW(ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(ABSTRACT_ARROW),
|
||||
TRIDENT(ABSTRACT_ARROW),
|
||||
|
||||
// Fireballs
|
||||
ABSTRACT_FIREBALL(ENTITY, null),
|
||||
DRAGON_FIREBALL(ABSTRACT_FIREBALL),
|
||||
FIREBALL(ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(ABSTRACT_FIREBALL),
|
||||
WITHER_SKULL(ABSTRACT_FIREBALL),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE_ABSTRACT(ENTITY, null),
|
||||
SNOWBALL(PROJECTILE_ABSTRACT),
|
||||
ENDER_PEARL(PROJECTILE_ABSTRACT),
|
||||
EGG(PROJECTILE_ABSTRACT),
|
||||
POTION(PROJECTILE_ABSTRACT),
|
||||
EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT),
|
||||
|
||||
// Vehicles
|
||||
MINECART_ABSTRACT(ENTITY, null),
|
||||
CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null),
|
||||
CHEST_MINECART(CHESTED_MINECART_ABSTRACT),
|
||||
HOPPER_MINECART(CHESTED_MINECART_ABSTRACT),
|
||||
MINECART(MINECART_ABSTRACT),
|
||||
FURNACE_MINECART(MINECART_ABSTRACT),
|
||||
COMMAND_BLOCK_MINECART(MINECART_ABSTRACT),
|
||||
TNT_MINECART(MINECART_ABSTRACT),
|
||||
SPAWNER_MINECART(MINECART_ABSTRACT),
|
||||
BOAT(ENTITY),
|
||||
CHEST_BOAT(BOAT);
|
||||
|
||||
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
|
||||
private final EntityType parent;
|
||||
private final String identifier;
|
||||
private int id = -1;
|
||||
|
||||
Entity1_19Types(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
Entity1_19Types(final EntityType parent, @Nullable final String identifier) {
|
||||
this.parent = parent;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
if (id == -1) {
|
||||
throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")");
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type");
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable EntityType getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return identifier == null;
|
||||
}
|
||||
|
||||
public static EntityType getTypeFromId(final int typeId) {
|
||||
return EntityTypeUtil.getTypeFromId(TYPES, typeId, ENTITY);
|
||||
}
|
||||
|
||||
public static void initialize(final Protocol<?, ?, ?, ?> protocol) {
|
||||
EntityTypeUtil.initialize(values(), TYPES, protocol, (type, id) -> type.id = id);
|
||||
}
|
||||
}
|
||||
+274
@@ -0,0 +1,274 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.entities;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.util.EntityTypeUtil;
|
||||
import java.util.Locale;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum Entity1_19_3Types implements EntityType {
|
||||
|
||||
ENTITY(null, null),
|
||||
|
||||
AREA_EFFECT_CLOUD(ENTITY),
|
||||
END_CRYSTAL(ENTITY),
|
||||
EVOKER_FANGS(ENTITY),
|
||||
EXPERIENCE_ORB(ENTITY),
|
||||
EYE_OF_ENDER(ENTITY),
|
||||
FALLING_BLOCK(ENTITY),
|
||||
FIREWORK_ROCKET(ENTITY),
|
||||
ITEM(ENTITY),
|
||||
LLAMA_SPIT(ENTITY),
|
||||
TNT(ENTITY),
|
||||
SHULKER_BULLET(ENTITY),
|
||||
FISHING_BOBBER(ENTITY),
|
||||
|
||||
LIVINGENTITY(ENTITY, null),
|
||||
ARMOR_STAND(LIVINGENTITY),
|
||||
MARKER(ENTITY),
|
||||
PLAYER(LIVINGENTITY),
|
||||
|
||||
ABSTRACT_INSENTIENT(LIVINGENTITY, null),
|
||||
ENDER_DRAGON(ABSTRACT_INSENTIENT),
|
||||
|
||||
BEE(ABSTRACT_INSENTIENT),
|
||||
|
||||
ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null),
|
||||
|
||||
ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null),
|
||||
VILLAGER(ABSTRACT_AGEABLE),
|
||||
WANDERING_TRADER(ABSTRACT_AGEABLE),
|
||||
|
||||
// Animals
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
|
||||
AXOLOTL(ABSTRACT_ANIMAL),
|
||||
DOLPHIN(ABSTRACT_INSENTIENT),
|
||||
CHICKEN(ABSTRACT_ANIMAL),
|
||||
COW(ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(COW),
|
||||
PANDA(ABSTRACT_INSENTIENT),
|
||||
PIG(ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(ABSTRACT_ANIMAL),
|
||||
RABBIT(ABSTRACT_ANIMAL),
|
||||
SHEEP(ABSTRACT_ANIMAL),
|
||||
TURTLE(ABSTRACT_ANIMAL),
|
||||
FOX(ABSTRACT_ANIMAL),
|
||||
FROG(ABSTRACT_ANIMAL),
|
||||
GOAT(ABSTRACT_ANIMAL),
|
||||
|
||||
ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
OCELOT(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
WOLF(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_PARROT(ABSTRACT_TAMEABLE_ANIMAL, null),
|
||||
PARROT(ABSTRACT_PARROT),
|
||||
|
||||
// Horses
|
||||
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
|
||||
CHESTED_HORSE(ABSTRACT_HORSE, null),
|
||||
DONKEY(CHESTED_HORSE),
|
||||
MULE(CHESTED_HORSE),
|
||||
LLAMA(CHESTED_HORSE),
|
||||
TRADER_LLAMA(CHESTED_HORSE),
|
||||
HORSE(ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(ABSTRACT_HORSE),
|
||||
CAMEL(ABSTRACT_HORSE),
|
||||
|
||||
// Golem
|
||||
ABSTRACT_GOLEM(ABSTRACT_CREATURE, null),
|
||||
SNOW_GOLEM(ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(ABSTRACT_GOLEM),
|
||||
SHULKER(ABSTRACT_GOLEM),
|
||||
|
||||
// Fish
|
||||
ABSTRACT_FISHES(ABSTRACT_CREATURE, null),
|
||||
COD(ABSTRACT_FISHES),
|
||||
PUFFERFISH(ABSTRACT_FISHES),
|
||||
SALMON(ABSTRACT_FISHES),
|
||||
TROPICAL_FISH(ABSTRACT_FISHES),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(ABSTRACT_CREATURE, null),
|
||||
BLAZE(ABSTRACT_MONSTER),
|
||||
CREEPER(ABSTRACT_MONSTER),
|
||||
ENDERMITE(ABSTRACT_MONSTER),
|
||||
ENDERMAN(ABSTRACT_MONSTER),
|
||||
GIANT(ABSTRACT_MONSTER),
|
||||
SILVERFISH(ABSTRACT_MONSTER),
|
||||
VEX(ABSTRACT_MONSTER),
|
||||
WITCH(ABSTRACT_MONSTER),
|
||||
WITHER(ABSTRACT_MONSTER),
|
||||
RAVAGER(ABSTRACT_MONSTER),
|
||||
|
||||
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
|
||||
|
||||
PIGLIN(ABSTRACT_PIGLIN),
|
||||
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
|
||||
|
||||
HOGLIN(ABSTRACT_ANIMAL),
|
||||
STRIDER(ABSTRACT_ANIMAL),
|
||||
TADPOLE(ABSTRACT_FISHES),
|
||||
ZOGLIN(ABSTRACT_MONSTER),
|
||||
WARDEN(ABSTRACT_MONSTER),
|
||||
|
||||
// Illagers
|
||||
ABSTRACT_ILLAGER_BASE(ABSTRACT_MONSTER, null),
|
||||
ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null),
|
||||
EVOKER(ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
VINDICATOR(ABSTRACT_ILLAGER_BASE),
|
||||
PILLAGER(ABSTRACT_ILLAGER_BASE),
|
||||
|
||||
// Skeletons
|
||||
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
|
||||
SKELETON(ABSTRACT_SKELETON),
|
||||
STRAY(ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(ABSTRACT_SKELETON),
|
||||
|
||||
// Guardians
|
||||
GUARDIAN(ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(GUARDIAN),
|
||||
|
||||
// Spiders
|
||||
SPIDER(ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(SPIDER),
|
||||
|
||||
// Zombies
|
||||
ZOMBIE(ABSTRACT_MONSTER),
|
||||
DROWNED(ZOMBIE),
|
||||
HUSK(ZOMBIE),
|
||||
ZOMBIFIED_PIGLIN(ZOMBIE),
|
||||
ZOMBIE_VILLAGER(ZOMBIE),
|
||||
|
||||
// Flying entities
|
||||
ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null),
|
||||
GHAST(ABSTRACT_FLYING),
|
||||
PHANTOM(ABSTRACT_FLYING),
|
||||
|
||||
ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null),
|
||||
BAT(ABSTRACT_AMBIENT),
|
||||
ALLAY(ABSTRACT_CREATURE),
|
||||
|
||||
ABSTRACT_WATERMOB(ABSTRACT_INSENTIENT, null),
|
||||
SQUID(ABSTRACT_WATERMOB),
|
||||
GLOW_SQUID(SQUID),
|
||||
|
||||
// Slimes
|
||||
SLIME(ABSTRACT_INSENTIENT),
|
||||
MAGMA_CUBE(SLIME),
|
||||
|
||||
// Hangable objects
|
||||
ABSTRACT_HANGING(ENTITY, null),
|
||||
LEASH_KNOT(ABSTRACT_HANGING),
|
||||
ITEM_FRAME(ABSTRACT_HANGING),
|
||||
GLOW_ITEM_FRAME(ITEM_FRAME),
|
||||
PAINTING(ABSTRACT_HANGING),
|
||||
|
||||
ABSTRACT_LIGHTNING(ENTITY, null),
|
||||
LIGHTNING_BOLT(ABSTRACT_LIGHTNING),
|
||||
|
||||
// Arrows
|
||||
ABSTRACT_ARROW(ENTITY, null),
|
||||
ARROW(ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(ABSTRACT_ARROW),
|
||||
TRIDENT(ABSTRACT_ARROW),
|
||||
|
||||
// Fireballs
|
||||
ABSTRACT_FIREBALL(ENTITY, null),
|
||||
DRAGON_FIREBALL(ABSTRACT_FIREBALL),
|
||||
FIREBALL(ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(ABSTRACT_FIREBALL),
|
||||
WITHER_SKULL(ABSTRACT_FIREBALL),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE_ABSTRACT(ENTITY, null),
|
||||
SNOWBALL(PROJECTILE_ABSTRACT),
|
||||
ENDER_PEARL(PROJECTILE_ABSTRACT),
|
||||
EGG(PROJECTILE_ABSTRACT),
|
||||
POTION(PROJECTILE_ABSTRACT),
|
||||
EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT),
|
||||
|
||||
// Vehicles
|
||||
MINECART_ABSTRACT(ENTITY, null),
|
||||
CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null),
|
||||
CHEST_MINECART(CHESTED_MINECART_ABSTRACT),
|
||||
HOPPER_MINECART(CHESTED_MINECART_ABSTRACT),
|
||||
MINECART(MINECART_ABSTRACT),
|
||||
FURNACE_MINECART(MINECART_ABSTRACT),
|
||||
COMMAND_BLOCK_MINECART(MINECART_ABSTRACT),
|
||||
TNT_MINECART(MINECART_ABSTRACT),
|
||||
SPAWNER_MINECART(MINECART_ABSTRACT),
|
||||
BOAT(ENTITY),
|
||||
CHEST_BOAT(BOAT);
|
||||
|
||||
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
|
||||
private final EntityType parent;
|
||||
private final String identifier;
|
||||
private int id = -1;
|
||||
|
||||
Entity1_19_3Types(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
Entity1_19_3Types(final EntityType parent, @Nullable final String identifier) {
|
||||
this.parent = parent;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
if (id == -1) {
|
||||
throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")");
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type");
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable EntityType getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return identifier == null;
|
||||
}
|
||||
|
||||
public static EntityType getTypeFromId(final int typeId) {
|
||||
return EntityTypeUtil.getTypeFromId(TYPES, typeId, ENTITY);
|
||||
}
|
||||
|
||||
public static void initialize(final Protocol<?, ?, ?, ?> protocol) {
|
||||
EntityTypeUtil.initialize(values(), TYPES, protocol, (type, id) -> type.id = id);
|
||||
}
|
||||
}
|
||||
+281
@@ -0,0 +1,281 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.entities;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.util.EntityTypeUtil;
|
||||
import java.util.Locale;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum Entity1_19_4Types implements EntityType {
|
||||
|
||||
ENTITY(null, null),
|
||||
|
||||
AREA_EFFECT_CLOUD(ENTITY),
|
||||
END_CRYSTAL(ENTITY),
|
||||
EVOKER_FANGS(ENTITY),
|
||||
EXPERIENCE_ORB(ENTITY),
|
||||
EYE_OF_ENDER(ENTITY),
|
||||
FALLING_BLOCK(ENTITY),
|
||||
FIREWORK_ROCKET(ENTITY),
|
||||
ITEM(ENTITY),
|
||||
LLAMA_SPIT(ENTITY),
|
||||
TNT(ENTITY),
|
||||
SHULKER_BULLET(ENTITY),
|
||||
FISHING_BOBBER(ENTITY),
|
||||
|
||||
LIVINGENTITY(ENTITY, null),
|
||||
ARMOR_STAND(LIVINGENTITY),
|
||||
MARKER(ENTITY),
|
||||
PLAYER(LIVINGENTITY),
|
||||
|
||||
DISPLAY(ENTITY, null),
|
||||
BLOCK_DISPLAY(DISPLAY),
|
||||
ITEM_DISPLAY(DISPLAY),
|
||||
TEXT_DISPLAY(DISPLAY),
|
||||
INTERACTION(ENTITY),
|
||||
|
||||
ABSTRACT_INSENTIENT(LIVINGENTITY, null),
|
||||
ENDER_DRAGON(ABSTRACT_INSENTIENT),
|
||||
|
||||
BEE(ABSTRACT_INSENTIENT),
|
||||
|
||||
ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null),
|
||||
|
||||
ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null),
|
||||
VILLAGER(ABSTRACT_AGEABLE),
|
||||
WANDERING_TRADER(ABSTRACT_AGEABLE),
|
||||
|
||||
// Animals
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
|
||||
AXOLOTL(ABSTRACT_ANIMAL),
|
||||
DOLPHIN(ABSTRACT_INSENTIENT),
|
||||
CHICKEN(ABSTRACT_ANIMAL),
|
||||
COW(ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(COW),
|
||||
PANDA(ABSTRACT_INSENTIENT),
|
||||
PIG(ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(ABSTRACT_ANIMAL),
|
||||
RABBIT(ABSTRACT_ANIMAL),
|
||||
SHEEP(ABSTRACT_ANIMAL),
|
||||
TURTLE(ABSTRACT_ANIMAL),
|
||||
FOX(ABSTRACT_ANIMAL),
|
||||
FROG(ABSTRACT_ANIMAL),
|
||||
GOAT(ABSTRACT_ANIMAL),
|
||||
SNIFFER(ABSTRACT_ANIMAL),
|
||||
|
||||
ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
OCELOT(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
WOLF(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_PARROT(ABSTRACT_TAMEABLE_ANIMAL, null),
|
||||
PARROT(ABSTRACT_PARROT),
|
||||
|
||||
// Horses
|
||||
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
|
||||
CHESTED_HORSE(ABSTRACT_HORSE, null),
|
||||
DONKEY(CHESTED_HORSE),
|
||||
MULE(CHESTED_HORSE),
|
||||
LLAMA(CHESTED_HORSE),
|
||||
TRADER_LLAMA(CHESTED_HORSE),
|
||||
HORSE(ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(ABSTRACT_HORSE),
|
||||
CAMEL(ABSTRACT_HORSE),
|
||||
|
||||
// Golem
|
||||
ABSTRACT_GOLEM(ABSTRACT_CREATURE, null),
|
||||
SNOW_GOLEM(ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(ABSTRACT_GOLEM),
|
||||
SHULKER(ABSTRACT_GOLEM),
|
||||
|
||||
// Fish
|
||||
ABSTRACT_FISHES(ABSTRACT_CREATURE, null),
|
||||
COD(ABSTRACT_FISHES),
|
||||
PUFFERFISH(ABSTRACT_FISHES),
|
||||
SALMON(ABSTRACT_FISHES),
|
||||
TROPICAL_FISH(ABSTRACT_FISHES),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(ABSTRACT_CREATURE, null),
|
||||
BLAZE(ABSTRACT_MONSTER),
|
||||
CREEPER(ABSTRACT_MONSTER),
|
||||
ENDERMITE(ABSTRACT_MONSTER),
|
||||
ENDERMAN(ABSTRACT_MONSTER),
|
||||
GIANT(ABSTRACT_MONSTER),
|
||||
SILVERFISH(ABSTRACT_MONSTER),
|
||||
VEX(ABSTRACT_MONSTER),
|
||||
WITCH(ABSTRACT_MONSTER),
|
||||
WITHER(ABSTRACT_MONSTER),
|
||||
RAVAGER(ABSTRACT_MONSTER),
|
||||
|
||||
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
|
||||
|
||||
PIGLIN(ABSTRACT_PIGLIN),
|
||||
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
|
||||
|
||||
HOGLIN(ABSTRACT_ANIMAL),
|
||||
STRIDER(ABSTRACT_ANIMAL),
|
||||
TADPOLE(ABSTRACT_FISHES),
|
||||
ZOGLIN(ABSTRACT_MONSTER),
|
||||
WARDEN(ABSTRACT_MONSTER),
|
||||
|
||||
// Illagers
|
||||
ABSTRACT_ILLAGER_BASE(ABSTRACT_MONSTER, null),
|
||||
ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null),
|
||||
EVOKER(ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
VINDICATOR(ABSTRACT_ILLAGER_BASE),
|
||||
PILLAGER(ABSTRACT_ILLAGER_BASE),
|
||||
|
||||
// Skeletons
|
||||
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
|
||||
SKELETON(ABSTRACT_SKELETON),
|
||||
STRAY(ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(ABSTRACT_SKELETON),
|
||||
|
||||
// Guardians
|
||||
GUARDIAN(ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(GUARDIAN),
|
||||
|
||||
// Spiders
|
||||
SPIDER(ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(SPIDER),
|
||||
|
||||
// Zombies
|
||||
ZOMBIE(ABSTRACT_MONSTER),
|
||||
DROWNED(ZOMBIE),
|
||||
HUSK(ZOMBIE),
|
||||
ZOMBIFIED_PIGLIN(ZOMBIE),
|
||||
ZOMBIE_VILLAGER(ZOMBIE),
|
||||
|
||||
// Flying entities
|
||||
ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null),
|
||||
GHAST(ABSTRACT_FLYING),
|
||||
PHANTOM(ABSTRACT_FLYING),
|
||||
|
||||
ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null),
|
||||
BAT(ABSTRACT_AMBIENT),
|
||||
ALLAY(ABSTRACT_CREATURE),
|
||||
|
||||
ABSTRACT_WATERMOB(ABSTRACT_INSENTIENT, null),
|
||||
SQUID(ABSTRACT_WATERMOB),
|
||||
GLOW_SQUID(SQUID),
|
||||
|
||||
// Slimes
|
||||
SLIME(ABSTRACT_INSENTIENT),
|
||||
MAGMA_CUBE(SLIME),
|
||||
|
||||
// Hangable objects
|
||||
ABSTRACT_HANGING(ENTITY, null),
|
||||
LEASH_KNOT(ABSTRACT_HANGING),
|
||||
ITEM_FRAME(ABSTRACT_HANGING),
|
||||
GLOW_ITEM_FRAME(ITEM_FRAME),
|
||||
PAINTING(ABSTRACT_HANGING),
|
||||
|
||||
ABSTRACT_LIGHTNING(ENTITY, null),
|
||||
LIGHTNING_BOLT(ABSTRACT_LIGHTNING),
|
||||
|
||||
// Arrows
|
||||
ABSTRACT_ARROW(ENTITY, null),
|
||||
ARROW(ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(ABSTRACT_ARROW),
|
||||
TRIDENT(ABSTRACT_ARROW),
|
||||
|
||||
// Fireballs
|
||||
ABSTRACT_FIREBALL(ENTITY, null),
|
||||
DRAGON_FIREBALL(ABSTRACT_FIREBALL),
|
||||
FIREBALL(ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(ABSTRACT_FIREBALL),
|
||||
WITHER_SKULL(ABSTRACT_FIREBALL),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE_ABSTRACT(ENTITY, null),
|
||||
SNOWBALL(PROJECTILE_ABSTRACT),
|
||||
ENDER_PEARL(PROJECTILE_ABSTRACT),
|
||||
EGG(PROJECTILE_ABSTRACT),
|
||||
POTION(PROJECTILE_ABSTRACT),
|
||||
EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT),
|
||||
|
||||
// Vehicles
|
||||
MINECART_ABSTRACT(ENTITY, null),
|
||||
CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null),
|
||||
CHEST_MINECART(CHESTED_MINECART_ABSTRACT),
|
||||
HOPPER_MINECART(CHESTED_MINECART_ABSTRACT),
|
||||
MINECART(MINECART_ABSTRACT),
|
||||
FURNACE_MINECART(MINECART_ABSTRACT),
|
||||
COMMAND_BLOCK_MINECART(MINECART_ABSTRACT),
|
||||
TNT_MINECART(MINECART_ABSTRACT),
|
||||
SPAWNER_MINECART(MINECART_ABSTRACT),
|
||||
BOAT(ENTITY),
|
||||
CHEST_BOAT(BOAT);
|
||||
|
||||
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
|
||||
private final EntityType parent;
|
||||
private final String identifier;
|
||||
private int id = -1;
|
||||
|
||||
Entity1_19_4Types(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
Entity1_19_4Types(final EntityType parent, @Nullable final String identifier) {
|
||||
this.parent = parent;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
if (id == -1) {
|
||||
throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")");
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type");
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable EntityType getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return identifier == null;
|
||||
}
|
||||
|
||||
public static EntityType getTypeFromId(final int typeId) {
|
||||
return EntityTypeUtil.getTypeFromId(TYPES, typeId, ENTITY);
|
||||
}
|
||||
|
||||
public static void initialize(final Protocol<?, ?, ?, ?> protocol) {
|
||||
EntityTypeUtil.initialize(values(), TYPES, protocol, (type, id) -> type.id = id);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -30,6 +30,7 @@ public interface EntityType {
|
||||
* Returns the entity id.
|
||||
*
|
||||
* @return entity id
|
||||
* @throws IllegalStateException if ids have not been loaded yet
|
||||
*/
|
||||
int getId();
|
||||
|
||||
@@ -47,6 +48,22 @@ public interface EntityType {
|
||||
*/
|
||||
String name();
|
||||
|
||||
/**
|
||||
* Returns the entity's Vanilla identifier.
|
||||
*
|
||||
* @return entity identifier
|
||||
* @throws IllegalArgumentException if {@link #isAbstractType()} returns true
|
||||
*/
|
||||
String identifier();
|
||||
|
||||
/**
|
||||
* Returns whether the type does not represent an actual entity, e.g. animal or monster.
|
||||
*
|
||||
* @return whether the type does not represent an actual entity
|
||||
*/
|
||||
boolean isAbstractType();
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default boolean is(EntityType... types) {
|
||||
for (EntityType type : types) {
|
||||
if (this == type) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,9 +24,8 @@ package com.viaversion.viaversion.api.minecraft.item;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class DataItem implements Item {
|
||||
@SerializedName(value = "identifier", alternate = "id")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -63,6 +63,14 @@ public interface MetaType {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MetaType{" +
|
||||
"typeId=" + typeId +
|
||||
", type=" + type +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,9 +23,8 @@
|
||||
package com.viaversion.viaversion.api.minecraft.metadata;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class Metadata {
|
||||
private int id;
|
||||
|
||||
Loaded 100 of 810 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user