Compare commits
363
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0dd7dfe2f3 | ||
|
|
b77d0fedd9 | ||
|
|
c07adfddb2 | ||
|
|
1e244a126d | ||
|
|
842cb8dac5 | ||
|
|
5053d739c0 | ||
|
|
d43ad37663 | ||
|
|
bb48dc90f9 | ||
|
|
1ea27f1077 | ||
|
|
3f72e9ea47 | ||
|
|
8a826b88fb | ||
|
|
82452dbdfe | ||
|
|
e439d040a7 | ||
|
|
2f41d09e23 | ||
|
|
0f73304a1d | ||
|
|
2dad770d67 | ||
|
|
2a088c08ed | ||
|
|
d4034792c4 | ||
|
|
7bdcf9a456 | ||
|
|
a48c3a6ec2 | ||
|
|
5245a7ef2e | ||
|
|
03e8eec12e | ||
|
|
76abe4432f | ||
|
|
af393c564f | ||
|
|
d8aa3c4b39 | ||
|
|
d9446eed07 | ||
|
|
3f7d286606 | ||
|
|
869755ec4a | ||
|
|
e26f63c703 | ||
|
|
792f52e637 | ||
|
|
e886aca8be | ||
|
|
94e853e5cf | ||
|
|
9b1c97919c | ||
|
|
01589b3c49 | ||
|
|
c5756fe45c | ||
|
|
9547cf160d | ||
|
|
659bee771b | ||
|
|
d5ccb17951 | ||
|
|
47f5617f83 | ||
|
|
052fb6e366 | ||
|
|
7d9c6fea69 | ||
|
|
f92d241028 | ||
|
|
0427aec4ab | ||
|
|
5a1a22a007 | ||
|
|
91f31b578f | ||
|
|
1399c901d2 | ||
|
|
b3d02491c6 | ||
|
|
1d0b6cc5c4 | ||
|
|
04b31d70b2 | ||
|
|
0fc0259d8c | ||
|
|
9fd40395eb | ||
|
|
75d86851ce | ||
|
|
b3f0c3e9a7 | ||
|
|
d6b5b5dc3e | ||
|
|
fcfea24b36 | ||
|
|
9149f12809 | ||
|
|
73c58518ad | ||
|
|
c9dfc739a2 | ||
|
|
bd4df2813d | ||
|
|
d47b5be7f3 | ||
|
|
0142e3aea7 | ||
|
|
d0fecb8951 | ||
|
|
5286efde15 | ||
|
|
ca25e62d2d | ||
|
|
501f65e216 | ||
|
|
e965e97139 | ||
|
|
75db1a7cdf | ||
|
|
2d41eb52a6 | ||
|
|
7e268a6f87 | ||
|
|
113bf1e275 | ||
|
|
2aec3ce6d1 | ||
|
|
f60e31ac78 | ||
|
|
8c4ff7ebfc | ||
|
|
4c7729e602 | ||
|
|
3dfc3bb15b | ||
|
|
69b33dc2d2 | ||
|
|
c24169c410 | ||
|
|
31211c2214 | ||
|
|
cb5fc9fb08 | ||
|
|
a8d7ab62e3 | ||
|
|
71313b4753 | ||
|
|
994bc8eefc | ||
|
|
7d35826637 | ||
|
|
4f40372392 | ||
|
|
e993be751c | ||
|
|
f1b92fea8d | ||
|
|
fc9d5b6d9d | ||
|
|
9549a18cec | ||
|
|
d691096ce1 | ||
|
|
73ed425bf7 | ||
|
|
cdc9c3ae95 | ||
|
|
c113e19d41 | ||
|
|
d3af70d76c | ||
|
|
c00bc6b667 | ||
|
|
fa3c933b2f | ||
|
|
07bb0269c3 | ||
|
|
57c0d83608 | ||
|
|
4854b131b8 | ||
|
|
1864b66e42 | ||
|
|
8aa6769193 | ||
|
|
5f90bcbbaf | ||
|
|
d068822143 | ||
|
|
a77e328dfe | ||
|
|
9c84e0dbe9 | ||
|
|
66e0453398 | ||
|
|
7ec6888a30 | ||
|
|
c9733948b3 | ||
|
|
798b70cbe6 | ||
|
|
1f43ff571d | ||
|
|
d28e7cd652 | ||
|
|
f20d99fcef | ||
|
|
a1c182f291 | ||
|
|
8e63fd635b | ||
|
|
676e62c71f | ||
|
|
f422e03348 | ||
|
|
fdf735420f | ||
|
|
b13fbbe175 | ||
|
|
9dd3348510 | ||
|
|
0e97af29b4 | ||
|
|
3dfcd6b9b9 | ||
|
|
8df0c0ae2e | ||
|
|
d2ca6a82be | ||
|
|
9654a613cd | ||
|
|
c5e6fa7d0c | ||
|
|
b78f9d350b | ||
|
|
ebbe1b6da2 | ||
|
|
3aed7cb949 | ||
|
|
e2f3dc7572 | ||
|
|
f2b9c42590 | ||
|
|
9894671274 | ||
|
|
71ab15b331 | ||
|
|
34bc5b9d36 | ||
|
|
d80fd46c2f | ||
|
|
b47446d9f7 | ||
|
|
dcf741a2ba | ||
|
|
a4adef3cec | ||
|
|
f525ad98e7 | ||
|
|
bc0b4470f6 | ||
|
|
d3d6d4f1cd | ||
|
|
5069b26c2f | ||
|
|
079671060c | ||
|
|
89cd8aec1d | ||
|
|
7ac7ea485f | ||
|
|
5e4f25efeb | ||
|
|
a152993ffd | ||
|
|
73daac471c | ||
|
|
f4e9225f85 | ||
|
|
1ed22327f6 | ||
|
|
ce2ad7d5eb | ||
|
|
d7e66260de | ||
|
|
dc6d581123 | ||
|
|
bd3f1206e6 | ||
|
|
b9e92e5c1f | ||
|
|
0acaed7c7a | ||
|
|
3055a4277d | ||
|
|
bcbe69d24c | ||
|
|
33cc21d6e6 | ||
|
|
949b3d712e | ||
|
|
216dcb2931 | ||
|
|
bff1536529 | ||
|
|
b221e47eb7 | ||
|
|
fb434a79bd | ||
|
|
1be0605f51 | ||
|
|
c75b4d8ef5 | ||
|
|
e08c263ced | ||
|
|
1bb85b11e9 | ||
|
|
128e191132 | ||
|
|
3520f99d5a | ||
|
|
7825a1e460 | ||
|
|
bfde4b953c | ||
|
|
57b37457d6 | ||
|
|
f7aa1a516e | ||
|
|
b1468ac6d0 | ||
|
|
27b5fdb4ff | ||
|
|
a99273db2e | ||
|
|
64f911ed4a | ||
|
|
4302dd61aa | ||
|
|
98c5d38d0c | ||
|
|
033d5ae49a | ||
|
|
8cf9114403 | ||
|
|
bd8e469216 | ||
|
|
57d7fd59cc | ||
|
|
8fe0681778 | ||
|
|
ea5cf3e594 | ||
|
|
13eec3c2ea | ||
|
|
31ccd2ab9b | ||
|
|
2be190d152 | ||
|
|
4e25549682 | ||
|
|
287678c12a | ||
|
|
4343aa17fc | ||
|
|
970986bc59 | ||
|
|
2586788bf6 | ||
|
|
0c2c8400ae | ||
|
|
ba4404fad6 | ||
|
|
6f53c069ea | ||
|
|
99f29e2597 | ||
|
|
7932b79080 | ||
|
|
4b780b92ee | ||
|
|
d04aaeb926 | ||
|
|
9f1ee27afc | ||
|
|
5f685884ff | ||
|
|
ba2e50cc88 | ||
|
|
7b28683b6a | ||
|
|
510747a7cd | ||
|
|
8c5752bb4c | ||
|
|
33e2a1fc13 | ||
|
|
dbe8a389ce | ||
|
|
83223c1520 | ||
|
|
935077222e | ||
|
|
8961660846 | ||
|
|
1fe23e4aeb | ||
|
|
06394c1f74 | ||
|
|
68c2af2795 | ||
|
|
35a00d0b95 | ||
|
|
c2489c7a4c | ||
|
|
c743c20334 | ||
|
|
228689f181 | ||
|
|
67e6e1a2e3 | ||
|
|
a2c1c52f51 | ||
|
|
fd4db24d44 | ||
|
|
0b7fdd4c69 | ||
|
|
4849ca0745 | ||
|
|
60b782455d | ||
|
|
3fef71db2e | ||
|
|
9ca02680c8 | ||
|
|
5899886b42 | ||
|
|
c2567115d8 | ||
|
|
4255876c22 | ||
|
|
57a589924d | ||
|
|
936dcafc11 | ||
|
|
b6489b8343 | ||
|
|
bf11a0a7de | ||
|
|
7d41706026 | ||
|
|
93f081dd84 | ||
|
|
3f82b150d2 | ||
|
|
7a96498f6d | ||
|
|
817febe605 | ||
|
|
bb4a8b73e0 | ||
|
|
8d3492ba30 | ||
|
|
658364b643 | ||
|
|
666b204ebb | ||
|
|
bfab9b0c11 | ||
|
|
121f107ff3 | ||
|
|
426bd9aa99 | ||
|
|
7a66bb8e1c | ||
|
|
329abcac7d | ||
|
|
0961de898d | ||
|
|
b4ee564aa2 | ||
|
|
73178b504e | ||
|
|
d0cc531386 | ||
|
|
617ef10667 | ||
|
|
5569caf610 | ||
|
|
868a5bd24e | ||
|
|
b113a82710 | ||
|
|
3ee4c8ed63 | ||
|
|
cd65925d6b | ||
|
|
307414eb51 | ||
|
|
51745cb2ef | ||
|
|
f44782d21d | ||
|
|
7556f7b8fa | ||
|
|
abd58399cd | ||
|
|
0a2fd8f296 | ||
|
|
f2c816df72 | ||
|
|
098f7ff3c2 | ||
|
|
18f04bf8ea | ||
|
|
feefe6f278 | ||
|
|
4074231a57 | ||
|
|
13efe47a5c | ||
|
|
b07cf03dc1 | ||
|
|
0a921d9bdc | ||
|
|
7b0c2fb51a | ||
|
|
b426302e76 | ||
|
|
3442cda8ce | ||
|
|
55a0a70264 | ||
|
|
a9bfda4568 | ||
|
|
93990c8baa | ||
|
|
f868dfa125 | ||
|
|
386495e168 | ||
|
|
cad78ea68f | ||
|
|
908823c612 | ||
|
|
2d03110f08 | ||
|
|
92878a39ef | ||
|
|
aa0423c6e2 | ||
|
|
39180e22b8 | ||
|
|
f68aed464d | ||
|
|
6ffa24b50b | ||
|
|
e51d7b3fdb | ||
|
|
01bb8dedda | ||
|
|
6cdca97d35 | ||
|
|
4cf271af81 | ||
|
|
aa262bb0a5 | ||
|
|
2480eb6a7f | ||
|
|
56b82b049a | ||
|
|
3c0930c62f | ||
|
|
26a8e5fef1 | ||
|
|
caa6519780 | ||
|
|
1e35c2713f | ||
|
|
cd5d88c34f | ||
|
|
7640342165 | ||
|
|
4e1d4a75b2 | ||
|
|
343b403cf1 | ||
|
|
78aecbddf8 | ||
|
|
48241ba841 | ||
|
|
a8fbb000eb | ||
|
|
ff25cbd6eb | ||
|
|
e2a7e10312 | ||
|
|
c7baa27fd0 | ||
|
|
35578372a1 | ||
|
|
293427c172 | ||
|
|
08d8ccf6ca | ||
|
|
35ceee1a47 | ||
|
|
dccda57fc0 | ||
|
|
5c21f60ef7 | ||
|
|
c124c1c809 | ||
|
|
302716054d | ||
|
|
46a5bb16d7 | ||
|
|
f3f7ea7987 | ||
|
|
e62c4a3f9e | ||
|
|
d58c80cd2f | ||
|
|
7a6c51331b | ||
|
|
564286d742 | ||
|
|
dcc0642af9 | ||
|
|
e449599ae7 | ||
|
|
621c02f974 | ||
|
|
22bd350e35 | ||
|
|
a8dc5f0f07 | ||
|
|
d76edced04 | ||
|
|
e0f32d9f2f | ||
|
|
4a8bd2cca2 | ||
|
|
0fcb764652 | ||
|
|
46e322b2f3 | ||
|
|
e020c616c9 | ||
|
|
da87241549 | ||
|
|
6473b608f6 | ||
|
|
a5bd8abe93 | ||
|
|
c8d339ab30 | ||
|
|
8000561ae9 | ||
|
|
1dafa7d273 | ||
|
|
ce8fab7c44 | ||
|
|
37561705ed | ||
|
|
00176c4a0c | ||
|
|
7b8a33cc78 | ||
|
|
ceae2c2094 | ||
|
|
52b9db5029 | ||
|
|
27af372f79 | ||
|
|
c4e50efa90 | ||
|
|
fa1ae5b9c9 | ||
|
|
8f6784e0e2 | ||
|
|
5d5c98acc6 | ||
|
|
0946c72bdc | ||
|
|
05470c5f1b | ||
|
|
34bd15dec7 | ||
|
|
abb05ce902 | ||
|
|
fe0fbc7081 | ||
|
|
00b8d22cf6 | ||
|
|
d62284e9cd | ||
|
|
3904ed4fd7 | ||
|
|
64c436c2e1 | ||
|
|
84b093a997 | ||
|
|
794f401bd0 | ||
|
|
dc732fac6f | ||
|
|
2f8114abb1 | ||
|
|
90781c9d27 |
No files matched your search
+5
-2
@@ -8,6 +8,9 @@ tab_width = 4
|
||||
[*.java]
|
||||
ij_java_class_count_to_use_import_on_demand = 999999
|
||||
ij_java_names_count_to_use_import_on_demand = 999999
|
||||
ij_java_imports_layout = *,|,$*
|
||||
ij_java_imports_layout = *, |, $*
|
||||
ij_java_generate_final_locals = true
|
||||
ij_java_generate_final_parameters = true
|
||||
ij_java_generate_final_parameters = true
|
||||
|
||||
[{*.json,*.yml}]
|
||||
indent_size = 2
|
||||
@@ -71,9 +71,9 @@ body:
|
||||
attributes:
|
||||
label: Additional Server Info
|
||||
description: |
|
||||
Do you use a proxy (e.g. BungeeCord)? What software do you use and what plugins?
|
||||
Do you use a proxy (e.g. Velocity)? What software do you use and what plugins?
|
||||
placeholder: |
|
||||
Example: "I also use BungeeCord with the following plugins: x, y, z"
|
||||
Example: "I also use Velocity with the following plugins: x, y, z"
|
||||
validations:
|
||||
required: false
|
||||
|
||||
@@ -82,7 +82,7 @@ body:
|
||||
label: Checklist
|
||||
description: Make sure you have followed each of the steps outlined here.
|
||||
options:
|
||||
- label: Via plugins are only running on **EITHER** the backend servers (e.g. Paper) **OR** the proxy (e.g. BungeeCord), **not on both**.
|
||||
- label: Via plugins are only running on **EITHER** the backend servers (e.g. Paper) **OR** the proxy (e.g. Velocity), **not on both**.
|
||||
required: true
|
||||
- label: I have included a ViaVersion dump.
|
||||
required: true
|
||||
|
||||
@@ -13,7 +13,7 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
uses: gradle/actions/wrapper-validation@v3
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
|
||||
@@ -13,7 +13,7 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
uses: gradle/actions/wrapper-validation@v3
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
**Allows the connection of higher client versions to lower server versions -
|
||||
it works on any platform you can think of.**
|
||||
|
||||
The base ViaVersion jar runs on Paper, Velocity, Bungee, and Sponge. We also have projects integrating ViaVersion to run
|
||||
on Fabric, Forge, or as a standalone proxy to join from basically any client version on any server version from the
|
||||
past decade. **See [HERE](https://github.com/ViaVersion) for an overview of the different Via\* projects.**
|
||||
The base ViaVersion jar runs on Paper and Velocity. We also have projects integrating ViaVersion to run
|
||||
on Fabric, Forge, Bungee, Sponge, or as a standalone proxy to join from basically any client version on
|
||||
any server version from the past decade. **See [HERE](https://github.com/ViaVersion) for an overview of the different Via\* projects.**
|
||||
|
||||
Supported Versions:
|
||||
|
||||
@@ -47,7 +47,7 @@ ViaVersion as a Dependency
|
||||
<dependency>
|
||||
<groupId>com.viaversion</groupId>
|
||||
<artifactId>viaversion-api</artifactId>
|
||||
<version>[4.0.0,5.0.0)</version>
|
||||
<version>[5.0.0,6.0.0)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
```
|
||||
@@ -73,6 +73,8 @@ Building
|
||||
After cloning this repository, build the project with Gradle by running `./gradlew build` and take the created jar out
|
||||
of the `build/libs` directory.
|
||||
|
||||
You need JDK 17 or newer to build ViaVersion.
|
||||
|
||||
|
||||
Mapping Files
|
||||
--------------
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
dependencies {
|
||||
compileOnly(projects.viaversionApi)
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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 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;
|
||||
|
||||
/**
|
||||
* @deprecated may be removed at some point, use {@link com.viaversion.viaversion.api.Via}
|
||||
*/
|
||||
@Deprecated
|
||||
public class Via<T> implements ViaAPI<T> {
|
||||
|
||||
private static final ViaAPI INSTANCE = new Via();
|
||||
|
||||
private Via() {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static ViaAPI getAPI() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerVersion(T player) {
|
||||
return com.viaversion.viaversion.api.Via.getAPI().getPlayerVersion(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerVersion(UUID uuid) {
|
||||
return com.viaversion.viaversion.api.Via.getAPI().getPlayerVersion(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInjected(UUID playerUUID) {
|
||||
return com.viaversion.viaversion.api.Via.getAPI().isInjected(playerUUID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return com.viaversion.viaversion.api.Via.getAPI().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRawPacket(T player, ByteBuf packet) {
|
||||
com.viaversion.viaversion.api.Via.getAPI().sendRawPacket(player, packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRawPacket(UUID uuid, ByteBuf packet) {
|
||||
com.viaversion.viaversion.api.Via.getAPI().sendRawPacket(uuid, packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossBar createBossBar(String title, BossColor color, BossStyle style) {
|
||||
return new BossBar(com.viaversion.viaversion.api.Via.getAPI().legacyAPI().createLegacyBossBar(title,
|
||||
com.viaversion.viaversion.api.legacy.bossbar.BossColor.values()[color.ordinal()],
|
||||
com.viaversion.viaversion.api.legacy.bossbar.BossStyle.values()[style.ordinal()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossBar createBossBar(String title, float health, BossColor color, BossStyle style) {
|
||||
return new BossBar(com.viaversion.viaversion.api.Via.getAPI().legacyAPI().createLegacyBossBar(title, health,
|
||||
com.viaversion.viaversion.api.legacy.bossbar.BossColor.values()[color.ordinal()],
|
||||
com.viaversion.viaversion.api.legacy.bossbar.BossStyle.values()[style.ordinal()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedSet<Integer> getSupportedVersions() {
|
||||
return com.viaversion.viaversion.api.Via.getAPI().getSupportedVersions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedSet<Integer> getFullSupportedVersions() {
|
||||
return com.viaversion.viaversion.api.Via.getAPI().getFullSupportedVersions();
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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 us.myles.ViaVersion.api.boss;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@Deprecated
|
||||
public class BossBar<T> {
|
||||
|
||||
private final com.viaversion.viaversion.api.legacy.bossbar.BossBar bossBar;
|
||||
|
||||
public BossBar(com.viaversion.viaversion.api.legacy.bossbar.BossBar bossBar) {
|
||||
this.bossBar = bossBar;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return bossBar.getTitle();
|
||||
}
|
||||
|
||||
public BossBar setTitle(String title) {
|
||||
bossBar.setTitle(title);
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getHealth() {
|
||||
return bossBar.getHealth();
|
||||
}
|
||||
|
||||
public BossBar setHealth(float health) {
|
||||
bossBar.setHealth(health);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BossColor getColor() {
|
||||
return BossColor.values()[bossBar.getColor().ordinal()];
|
||||
}
|
||||
|
||||
public BossBar setColor(BossColor color) {
|
||||
bossBar.setColor(com.viaversion.viaversion.api.legacy.bossbar.BossColor.values()[color.ordinal()]);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BossStyle getStyle() {
|
||||
return BossStyle.values()[bossBar.getStyle().ordinal()];
|
||||
}
|
||||
|
||||
public BossBar setStyle(BossStyle style) {
|
||||
bossBar.setStyle(com.viaversion.viaversion.api.legacy.bossbar.BossStyle.values()[style.ordinal()]);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public BossBar addPlayer(T player) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public BossBar addPlayer(UUID player) {
|
||||
bossBar.addPlayer(player);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public BossBar addPlayers(T... players) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public BossBar removePlayer(T player) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public BossBar removePlayer(UUID uuid) {
|
||||
bossBar.removePlayer(uuid);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BossBar addFlag(BossFlag flag) {
|
||||
bossBar.addFlag(com.viaversion.viaversion.api.legacy.bossbar.BossFlag.values()[flag.ordinal()]);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BossBar removeFlag(BossFlag flag) {
|
||||
bossBar.removeFlag(com.viaversion.viaversion.api.legacy.bossbar.BossFlag.values()[flag.ordinal()]);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasFlag(BossFlag flag) {
|
||||
return bossBar.hasFlag(com.viaversion.viaversion.api.legacy.bossbar.BossFlag.values()[flag.ordinal()]);
|
||||
}
|
||||
|
||||
public Set<UUID> getPlayers() {
|
||||
return bossBar.getPlayers();
|
||||
}
|
||||
|
||||
public BossBar show() {
|
||||
bossBar.show();
|
||||
return this;
|
||||
}
|
||||
|
||||
public BossBar hide() {
|
||||
bossBar.hide();
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return bossBar.isVisible();
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
return bossBar.getId();
|
||||
}
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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 us.myles.ViaVersion.api.protocol;
|
||||
|
||||
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 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}
|
||||
*/
|
||||
@Deprecated
|
||||
public class ProtocolVersion {
|
||||
private static final Int2ObjectMap<ProtocolVersion> versions = new Int2ObjectOpenHashMap<>();
|
||||
private static final List<ProtocolVersion> versionList = new ArrayList<>();
|
||||
|
||||
public static final ProtocolVersion v1_4_6 = register(51, "1.4.6/7", new VersionRange("1.4", 6, 7));
|
||||
public static final ProtocolVersion v1_5_1 = register(60, "1.5.1");
|
||||
public static final ProtocolVersion v1_5_2 = register(61, "1.5.2");
|
||||
public static final ProtocolVersion v_1_6_1 = register(73, "1.6.1");
|
||||
public static final ProtocolVersion v_1_6_2 = register(74, "1.6.2");
|
||||
public static final ProtocolVersion v_1_6_3 = register(77, "1.6.3");
|
||||
public static final ProtocolVersion v_1_6_4 = register(78, "1.6.4");
|
||||
public static final ProtocolVersion v1_7_1 = register(4, "1.7-1.7.5", new VersionRange("1.7", 0, 5));
|
||||
public static final ProtocolVersion v1_7_6 = register(5, "1.7.6-1.7.10", new VersionRange("1.7", 6, 10));
|
||||
public static final ProtocolVersion v1_8 = register(47, "1.8.x");
|
||||
public static final ProtocolVersion v1_9 = register(107, "1.9");
|
||||
public static final ProtocolVersion v1_9_1 = register(108, "1.9.1");
|
||||
public static final ProtocolVersion v1_9_2 = register(109, "1.9.2");
|
||||
public static final ProtocolVersion v1_9_3 = register(110, "1.9.3/4", new VersionRange("1.9", 3, 4));
|
||||
public static final ProtocolVersion v1_10 = register(210, "1.10.x");
|
||||
public static final ProtocolVersion v1_11 = register(315, "1.11");
|
||||
public static final ProtocolVersion v1_11_1 = register(316, "1.11.1/2", new VersionRange("1.11", 1, 2));
|
||||
public static final ProtocolVersion v1_12 = register(335, "1.12");
|
||||
public static final ProtocolVersion v1_12_1 = register(338, "1.12.1");
|
||||
public static final ProtocolVersion v1_12_2 = register(340, "1.12.2");
|
||||
public static final ProtocolVersion v1_13 = register(393, "1.13");
|
||||
public static final ProtocolVersion v1_13_1 = register(401, "1.13.1");
|
||||
public static final ProtocolVersion v1_13_2 = register(404, "1.13.2");
|
||||
public static final ProtocolVersion v1_14 = register(477, "1.14");
|
||||
public static final ProtocolVersion v1_14_1 = register(480, "1.14.1");
|
||||
public static final ProtocolVersion v1_14_2 = register(485, "1.14.2");
|
||||
public static final ProtocolVersion v1_14_3 = register(490, "1.14.3");
|
||||
public static final ProtocolVersion v1_14_4 = register(498, "1.14.4");
|
||||
public static final ProtocolVersion v1_15 = register(573, "1.15");
|
||||
public static final ProtocolVersion v1_15_1 = register(575, "1.15.1");
|
||||
public static final ProtocolVersion v1_15_2 = register(578, "1.15.2");
|
||||
public static final ProtocolVersion v1_16 = register(735, "1.16");
|
||||
public static final ProtocolVersion v1_16_1 = register(736, "1.16.1");
|
||||
public static final ProtocolVersion v1_16_2 = register(751, "1.16.2");
|
||||
public static final ProtocolVersion v1_16_3 = register(753, "1.16.3");
|
||||
public static final ProtocolVersion v1_16_4 = register(754, "1.16.4/5", new VersionRange("1.16", 4, 5));
|
||||
public static final ProtocolVersion v1_17 = register(755, "1.17");
|
||||
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/2", new VersionRange("1.19", 1, 2));
|
||||
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/1.20.1", new VersionRange("1.20", 0, 1));
|
||||
public static final ProtocolVersion v1_20_2 = register(764, "1.20.2");
|
||||
public static final ProtocolVersion v1_20_3 = register(765, "1.20.3");
|
||||
public static final ProtocolVersion unknown = register(-1, "UNKNOWN");
|
||||
|
||||
public static ProtocolVersion register(int version, String name) {
|
||||
return register(version, -1, name);
|
||||
}
|
||||
|
||||
public static ProtocolVersion register(int version, int snapshotVersion, String name) {
|
||||
return register(version, snapshotVersion, name, null);
|
||||
}
|
||||
|
||||
public static ProtocolVersion register(int version, String name, @Nullable VersionRange versionRange) {
|
||||
return register(version, -1, name, versionRange);
|
||||
}
|
||||
|
||||
public static ProtocolVersion register(int version, int snapshotVersion, String name, @Nullable VersionRange versionRange) {
|
||||
ProtocolVersion protocol = new ProtocolVersion(version, snapshotVersion, name, versionRange);
|
||||
versionList.add(protocol);
|
||||
versions.put(protocol.getVersion(), protocol);
|
||||
if (protocol.isSnapshot()) {
|
||||
versions.put(protocol.getFullSnapshotVersion(), protocol);
|
||||
}
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public static boolean isRegistered(int id) {
|
||||
return versions.containsKey(id);
|
||||
}
|
||||
|
||||
public static @NonNull ProtocolVersion getProtocol(int id) {
|
||||
ProtocolVersion protocolVersion = versions.get(id);
|
||||
if (protocolVersion != null) {
|
||||
return protocolVersion;
|
||||
} else {
|
||||
return new ProtocolVersion(id, "Unknown (" + id + ")");
|
||||
}
|
||||
}
|
||||
|
||||
public static int getIndex(ProtocolVersion version) {
|
||||
return versionList.indexOf(version);
|
||||
}
|
||||
|
||||
public static List<ProtocolVersion> getProtocols() {
|
||||
return Collections.unmodifiableList(new ArrayList<>(versions.values()));
|
||||
}
|
||||
|
||||
public static @Nullable ProtocolVersion getClosest(String protocol) {
|
||||
for (ProtocolVersion version : versions.values()) {
|
||||
String name = version.getName();
|
||||
if (name.equals(protocol)) {
|
||||
return version;
|
||||
}
|
||||
|
||||
if (version.isVersionWildcard()) {
|
||||
// Test against the major version with and without a minor version
|
||||
String majorVersion = name.substring(0, name.length() - 2);
|
||||
if (majorVersion.equals(protocol) || (protocol.startsWith(name.substring(0, name.length() - 1)))) {
|
||||
return version;
|
||||
}
|
||||
} else if (version.isRange()) {
|
||||
if (version.getIncludedVersions().contains(protocol)) {
|
||||
return version;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private final int version;
|
||||
private final int snapshotVersion;
|
||||
private final String name;
|
||||
private final boolean versionWildcard;
|
||||
private final Set<String> includedVersions;
|
||||
|
||||
public ProtocolVersion(int version, String name) {
|
||||
this(version, -1, name, null);
|
||||
}
|
||||
|
||||
public ProtocolVersion(int version, int snapshotVersion, String name, @Nullable VersionRange versionRange) {
|
||||
this.version = version;
|
||||
this.snapshotVersion = snapshotVersion;
|
||||
this.name = name;
|
||||
this.versionWildcard = name.endsWith(".x");
|
||||
|
||||
Preconditions.checkArgument(!versionWildcard || versionRange == null, "A version cannot be a wildcard and a range at the same time!");
|
||||
if (versionRange != null) {
|
||||
includedVersions = new LinkedHashSet<>();
|
||||
for (int i = versionRange.rangeFrom(); i <= versionRange.rangeTo(); i++) {
|
||||
if (i == 0) {
|
||||
includedVersions.add(versionRange.baseVersion()); // Keep both the base version and with ".0" appended
|
||||
}
|
||||
|
||||
includedVersions.add(versionRange.baseVersion() + "." + i);
|
||||
}
|
||||
} else {
|
||||
includedVersions = Collections.singleton(name);
|
||||
}
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public int getSnapshotVersion() {
|
||||
Preconditions.checkArgument(isSnapshot());
|
||||
return snapshotVersion;
|
||||
}
|
||||
|
||||
public int getFullSnapshotVersion() {
|
||||
Preconditions.checkArgument(isSnapshot());
|
||||
return (1 << 30) | snapshotVersion; // Bit indicating snapshot versions
|
||||
}
|
||||
|
||||
public int getOriginalVersion() {
|
||||
return snapshotVersion == -1 ? version : ((1 << 30) | snapshotVersion);
|
||||
}
|
||||
|
||||
public boolean isKnown() {
|
||||
return version != -1;
|
||||
}
|
||||
|
||||
public boolean isRange() {
|
||||
return includedVersions.size() != 1;
|
||||
}
|
||||
|
||||
public Set<String> getIncludedVersions() {
|
||||
return Collections.unmodifiableSet(includedVersions);
|
||||
}
|
||||
|
||||
public boolean isVersionWildcard() {
|
||||
return versionWildcard;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isSnapshot() {
|
||||
return snapshotVersion != -1;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ProtocolVersion that = (ProtocolVersion) o;
|
||||
return version == that.version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s (%d)", this.name, this.version);
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,9 @@ sourceSets {
|
||||
|
||||
dependencies {
|
||||
api(libs.fastutil)
|
||||
api(libs.flare)
|
||||
api(libs.flareFastutil)
|
||||
api(libs.vianbt)
|
||||
api(libs.vianbt) {
|
||||
exclude("it.unimi.dsi", "fastutil")
|
||||
}
|
||||
api(libs.gson)
|
||||
implementation(rootProject.libs.text) {
|
||||
exclude("com.google.code.gson", "gson")
|
||||
@@ -34,5 +34,3 @@ dependencies {
|
||||
java {
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
publishShadowJar()
|
||||
@@ -27,10 +27,13 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.legacy.LegacyViaAPI;
|
||||
import com.viaversion.viaversion.api.platform.ViaPlatform;
|
||||
import com.viaversion.viaversion.api.protocol.ProtocolManager;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.protocol.version.ServerProtocolVersion;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
@@ -53,7 +56,7 @@ public interface ViaAPI<T> {
|
||||
* @since 4.0.2
|
||||
*/
|
||||
default int majorVersion() {
|
||||
return 4;
|
||||
return 5;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +66,7 @@ public interface ViaAPI<T> {
|
||||
* @return API version incremented with meaningful API changes
|
||||
*/
|
||||
default int apiVersion() {
|
||||
return 23;
|
||||
return 26;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,12 +78,21 @@ public interface ViaAPI<T> {
|
||||
|
||||
/**
|
||||
* Returns the protocol version of a player.
|
||||
* This will also retrieve the version from ProtocolSupport if it's being used.
|
||||
*
|
||||
* @param player the platform's player object, e.g. Bukkit this is Player
|
||||
* @return protocol version, for example (47=1.8-1.8.8, 107=1.9, 108=1.9.1), or -1 if no longer connected
|
||||
*/
|
||||
int getPlayerVersion(T player);
|
||||
default int getPlayerVersion(T player) {
|
||||
return getPlayerProtocolVersion(player).getVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the protocol version of a player.
|
||||
*
|
||||
* @param player the platform's player object, e.g. Bukkit this is Player
|
||||
* @return the protocol version object (see {@link ProtocolVersion}), or ProtocolVersion.unknown if not connected
|
||||
*/
|
||||
ProtocolVersion getPlayerProtocolVersion(T player);
|
||||
|
||||
/**
|
||||
* Returns the protocol version of a player.
|
||||
@@ -88,7 +100,18 @@ public interface ViaAPI<T> {
|
||||
* @param uuid UUID of a player
|
||||
* @return protocol version, for example (47=1.8-1.8.8, 107=1.9, 108=1.9.1), or -1 if not connected
|
||||
*/
|
||||
int getPlayerVersion(UUID uuid);
|
||||
default int getPlayerVersion(UUID uuid) {
|
||||
return getPlayerProtocolVersion(uuid).getVersion();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the protocol version of a player.
|
||||
*
|
||||
* @param uuid UUID of a player
|
||||
* @return the protocol version object (see {@link ProtocolVersion}), or ProtocolVersion.unknown if not connected
|
||||
*/
|
||||
ProtocolVersion getPlayerProtocolVersion(UUID uuid);
|
||||
|
||||
/**
|
||||
* Returns whether Via injected into this player connection.
|
||||
@@ -131,6 +154,16 @@ public interface ViaAPI<T> {
|
||||
*/
|
||||
void sendRawPacket(UUID uuid, ByteBuf packet);
|
||||
|
||||
@Deprecated
|
||||
default SortedSet<Integer> getSupportedVersions() {
|
||||
return getSupportedProtocolVersions().stream().map(ProtocolVersion::getVersion).collect(Collectors.toCollection(TreeSet::new));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
default SortedSet<Integer> getFullSupportedVersions() {
|
||||
return getFullSupportedProtocolVersions().stream().map(ProtocolVersion::getVersion).collect(Collectors.toCollection(TreeSet::new));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the supported protocol versions.
|
||||
* This method removes any blocked protocol versions.
|
||||
@@ -138,14 +171,15 @@ public interface ViaAPI<T> {
|
||||
* @return a sorted set of protocol versions
|
||||
* @see #getFullSupportedVersions() for a full list
|
||||
*/
|
||||
SortedSet<Integer> getSupportedVersions();
|
||||
SortedSet<ProtocolVersion> getSupportedProtocolVersions();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the supported protocol versions, including blocked protocols.
|
||||
*
|
||||
* @return a sorted set of protocol versions
|
||||
*/
|
||||
SortedSet<Integer> getFullSupportedVersions();
|
||||
SortedSet<ProtocolVersion> getFullSupportedProtocolVersions();
|
||||
|
||||
/**
|
||||
* Returns legacy api only applicable on/to legacy versions.
|
||||
|
||||
@@ -26,21 +26,21 @@ import com.viaversion.viaversion.util.ChatColorUtil;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ViaSubCommand {
|
||||
public interface ViaSubCommand {
|
||||
|
||||
/**
|
||||
* Subcommand name
|
||||
*
|
||||
* @return The commands name
|
||||
*/
|
||||
public abstract String name();
|
||||
String name();
|
||||
|
||||
/**
|
||||
* subcommand description, this'll show in /viaversion list
|
||||
*
|
||||
* @return The commands description
|
||||
*/
|
||||
public abstract String description();
|
||||
String description();
|
||||
|
||||
/**
|
||||
* Usage example:
|
||||
@@ -48,7 +48,7 @@ public abstract class ViaSubCommand {
|
||||
*
|
||||
* @return The commands usage
|
||||
*/
|
||||
public String usage() {
|
||||
default String usage() {
|
||||
return name();
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public abstract class ViaSubCommand {
|
||||
*
|
||||
* @return The permission required to use the commands
|
||||
*/
|
||||
public String permission() {
|
||||
default String permission() {
|
||||
return "viaversion.admin." + name();
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public abstract class ViaSubCommand {
|
||||
* @param args Arguments
|
||||
* @return commands executed succesfully if false, show usage
|
||||
*/
|
||||
public abstract boolean execute(ViaCommandSender sender, String[] args);
|
||||
boolean execute(ViaCommandSender sender, String[] args);
|
||||
|
||||
/**
|
||||
* Yay, possibility to implement tab-completion
|
||||
@@ -77,7 +77,7 @@ public abstract class ViaSubCommand {
|
||||
* @param args args
|
||||
* @return tab complete possibilities
|
||||
*/
|
||||
public List<String> onTabComplete(ViaCommandSender sender, String[] args) {
|
||||
default List<String> onTabComplete(ViaCommandSender sender, String[] args) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public abstract class ViaSubCommand {
|
||||
* @param s string to replace
|
||||
* @return output String
|
||||
*/
|
||||
public static String color(String s) {
|
||||
static String color(String s) {
|
||||
return ChatColorUtil.translateAlternateColorCodes(s);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public abstract class ViaSubCommand {
|
||||
* @param message message
|
||||
* @param args objects to replace
|
||||
*/
|
||||
public static void sendMessage(ViaCommandSender sender, String message, Object... args) {
|
||||
default void sendMessage(ViaCommandSender sender, String message, Object... args) {
|
||||
sender.sendMessage(color(args == null ? message : String.format(message, args)));
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public interface ViaVersionCommand {
|
||||
* Register your own subcommand inside ViaVersion
|
||||
*
|
||||
* @param command Your own SubCommand instance to handle it.
|
||||
* @throws Exception throws an exception when the subcommand already exists or if it's not valid, example: spacee
|
||||
* @throws IllegalArgumentException throws an exception when the subcommand already exists or if it's not valid, example: spacee
|
||||
*/
|
||||
void registerSubCommand(ViaSubCommand command);
|
||||
|
||||
|
||||
+21
-20
@@ -27,8 +27,6 @@ import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.WorldIdentifiers;
|
||||
import com.viaversion.viaversion.api.protocol.version.BlockedProtocolVersions;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface ViaVersionConfig extends Config {
|
||||
|
||||
@@ -235,13 +233,6 @@ public interface ViaVersionConfig extends Config {
|
||||
*/
|
||||
boolean isChunkBorderFix();
|
||||
|
||||
/**
|
||||
* Force json transform
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean isForceJsonTransform();
|
||||
|
||||
/**
|
||||
* Should we fix nbt array's in json chat messages for 1.12 clients
|
||||
*
|
||||
@@ -272,17 +263,6 @@ public interface ViaVersionConfig extends Config {
|
||||
*/
|
||||
BlockedProtocolVersions blockedProtocolVersions();
|
||||
|
||||
/**
|
||||
* Get the blocked protocols
|
||||
*
|
||||
* @return An Integer list
|
||||
* @deprecated use {@link #blockedProtocolVersions()}
|
||||
*/
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default IntSet getBlockedProtocols() {
|
||||
return blockedProtocolVersions().singleBlockedVersions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the custom disconnect message
|
||||
*
|
||||
@@ -463,4 +443,25 @@ public interface ViaVersionConfig extends Config {
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean isArmorToggleFix();
|
||||
|
||||
/**
|
||||
* If disabled, tamed cats will be displayed as ocelots to 1.14+ clients on 1.13 servers. Otherwise, ocelots (tamed and untamed) will be displayed as cats.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean translateOcelotToCat();
|
||||
|
||||
/**
|
||||
* Returns the value of the "enforce secure chat" setting sent to 1.19+ clients on join.
|
||||
*
|
||||
* @return the value sent to 1.19+ clients on join
|
||||
*/
|
||||
boolean enforceSecureChat();
|
||||
|
||||
/**
|
||||
* Handles items with invalid count values (higher than max stack size) on 1.20.3 servers.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean handleInvalidItemCount();
|
||||
}
|
||||
@@ -54,7 +54,6 @@ public interface ConnectionManager {
|
||||
* Returns the frontend UserConnection from the player connected to this proxy server
|
||||
* Returns null when there isn't a server or connection was not found
|
||||
* When ViaVersion is reloaded, this method may not return some players.
|
||||
* May not return ProtocolSupport players.
|
||||
* <p>
|
||||
* Note that connections are removed as soon as their channel is closed,
|
||||
* so avoid using this method during player quits for example.
|
||||
@@ -67,7 +66,6 @@ public interface ConnectionManager {
|
||||
* Returns the UUID from the frontend connection to this proxy server
|
||||
* Returns null when there isn't a server or this connection isn't frontend, or it doesn't have an id
|
||||
* When ViaVersion is reloaded, this method may not return some players.
|
||||
* May not return ProtocolSupport players.
|
||||
* <p>
|
||||
* Note that connections are removed as soon as their channel is closed,
|
||||
* so avoid using this method during player quits for example.
|
||||
@@ -81,7 +79,6 @@ public interface ConnectionManager {
|
||||
* May contain duplicated UUIDs on multiple ProtocolInfo.
|
||||
* May contain frontend, backend and/or client-sided connections.
|
||||
* When ViaVersion is reloaded, this method may not return some players.
|
||||
* May not contain ProtocolSupport players.
|
||||
*
|
||||
* @return connected UserConnections
|
||||
*/
|
||||
@@ -91,7 +88,6 @@ public interface ConnectionManager {
|
||||
* Returns a map containing the UUIDs and frontend UserConnections from players connected to this proxy server
|
||||
* Returns empty list when there isn't a server
|
||||
* When ViaVersion is reloaded, this method may not return some players.
|
||||
* May not contain ProtocolSupport players.
|
||||
*
|
||||
* @return map containing the UUIDs and frontend UserConnections from players connected to this proxy server
|
||||
*/
|
||||
|
||||
@@ -25,22 +25,12 @@ package com.viaversion.viaversion.api.connection;
|
||||
import com.viaversion.viaversion.api.protocol.ProtocolPipeline;
|
||||
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface ProtocolInfo {
|
||||
|
||||
/**
|
||||
* Returns the protocol state the user is currently in.
|
||||
*
|
||||
* @return protocol state
|
||||
* @deprecated server and client can be in different states, use {@link #getClientState()} or {@link #getServerState()}
|
||||
*/
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default State getState() {
|
||||
return this.getServerState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the protocol state the client is currently in.
|
||||
*
|
||||
@@ -93,24 +83,36 @@ public interface ProtocolInfo {
|
||||
void setServerState(State serverState);
|
||||
|
||||
/**
|
||||
* Returns the user's protocol version, or -1 if not set.
|
||||
* Returns the user's protocol version, or null if not set.
|
||||
* This is set during the {@link State#HANDSHAKE} state.
|
||||
*
|
||||
* @return protocol version, or -1 if not set
|
||||
* @return protocol version, may be unknown
|
||||
* @see ProtocolVersion#isKnown()
|
||||
*/
|
||||
int getProtocolVersion();
|
||||
ProtocolVersion protocolVersion();
|
||||
|
||||
void setProtocolVersion(int protocolVersion);
|
||||
void setProtocolVersion(ProtocolVersion protocolVersion);
|
||||
|
||||
/**
|
||||
* Returns the server protocol version the user is connected to, or -1 if not set.
|
||||
* Returns the server protocol version the user is connected to.
|
||||
* This is set during the {@link State#HANDSHAKE} state.
|
||||
*
|
||||
* @return server protocol version, or -1 if not set
|
||||
* @return the server protocol version the user is connected to, may be unknown
|
||||
* @see ProtocolVersion#isKnown()
|
||||
*/
|
||||
int getServerProtocolVersion();
|
||||
ProtocolVersion serverProtocolVersion();
|
||||
|
||||
void setServerProtocolVersion(int serverProtocolVersion);
|
||||
void setServerProtocolVersion(ProtocolVersion protocolVersion);
|
||||
|
||||
@Deprecated
|
||||
default int getProtocolVersion() {
|
||||
return protocolVersion() != null ? protocolVersion().getVersion() : -1;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
default int getServerProtocolVersion() {
|
||||
return serverProtocolVersion() != null ? serverProtocolVersion().getVersion() : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the username associated with this connection.
|
||||
@@ -140,12 +142,4 @@ public interface ProtocolInfo {
|
||||
ProtocolPipeline getPipeline();
|
||||
|
||||
void setPipeline(ProtocolPipeline pipeline);
|
||||
|
||||
/**
|
||||
* Returns the user connection this info represents.
|
||||
*
|
||||
* @return user connection
|
||||
*/
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
UserConnection getUser();
|
||||
}
|
||||
}
|
||||
@@ -27,11 +27,11 @@ import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketTracker;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.exception.CancelException;
|
||||
import com.viaversion.viaversion.exception.InformativeException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.handler.codec.CodecException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@@ -205,11 +205,10 @@ public interface UserConnection {
|
||||
*
|
||||
* @param buf ByteBuf with packet id and packet contents
|
||||
* @param cancelSupplier function called with original CancelException for generating the Exception when the packet is cancelled
|
||||
* @throws CancelException if the packet should be cancelled
|
||||
* @throws CodecException if the packet should be cancelled (by netty)
|
||||
* @throws InformativeException if packet transforming failed
|
||||
* @throws Exception if any other processing outside of transforming fails
|
||||
*/
|
||||
void transformClientbound(ByteBuf buf, Function<Throwable, Exception> cancelSupplier) throws Exception;
|
||||
void transformClientbound(ByteBuf buf, Function<Throwable, CodecException> cancelSupplier) throws InformativeException;
|
||||
|
||||
/**
|
||||
* Transforms the serverbound packet contained in ByteBuf.
|
||||
@@ -217,11 +216,10 @@ public interface UserConnection {
|
||||
* @param buf ByteBuf with packet id and packet contents
|
||||
* @param cancelSupplier Function called with original CancelException for generating the Exception used when
|
||||
* packet is cancelled
|
||||
* @throws CancelException if the packet should be cancelled
|
||||
* @throws CodecException if the packet should be cancelled (by netty)
|
||||
* @throws InformativeException if packet transforming failed
|
||||
* @throws Exception if any other processing outside of transforming fails
|
||||
*/
|
||||
void transformServerbound(ByteBuf buf, Function<Throwable, Exception> cancelSupplier) throws Exception;
|
||||
void transformServerbound(ByteBuf buf, Function<Throwable, CodecException> cancelSupplier) throws InformativeException;
|
||||
|
||||
/**
|
||||
* Transforms the packet depending on whether the connection is clientside or not.
|
||||
@@ -229,7 +227,7 @@ public interface UserConnection {
|
||||
* @see #transformClientbound(ByteBuf, Function)
|
||||
* @see #transformServerbound(ByteBuf, Function)
|
||||
*/
|
||||
default void transformOutgoing(ByteBuf buf, Function<Throwable, Exception> cancelSupplier) throws Exception {
|
||||
default void transformOutgoing(ByteBuf buf, Function<Throwable, CodecException> cancelSupplier) throws InformativeException {
|
||||
if (isClientSide()) {
|
||||
transformServerbound(buf, cancelSupplier);
|
||||
} else {
|
||||
@@ -243,7 +241,7 @@ public interface UserConnection {
|
||||
* @see #transformClientbound(ByteBuf, Function)
|
||||
* @see #transformServerbound(ByteBuf, Function)
|
||||
*/
|
||||
default void transformIncoming(ByteBuf buf, Function<Throwable, Exception> cancelSupplier) throws Exception {
|
||||
default void transformIncoming(ByteBuf buf, Function<Throwable, CodecException> cancelSupplier) throws InformativeException {
|
||||
if (isClientSide()) {
|
||||
transformClientbound(buf, cancelSupplier);
|
||||
} else {
|
||||
@@ -315,20 +313,6 @@ public interface UserConnection {
|
||||
*/
|
||||
boolean shouldApplyBlockProtocol();
|
||||
|
||||
/**
|
||||
* Returns whether the packet limiter applies to this user.
|
||||
*
|
||||
* @return whether the packet limiter applies to this user
|
||||
*/
|
||||
boolean isPacketLimiterEnabled();
|
||||
|
||||
/**
|
||||
* Sets the status of the packet limiter.
|
||||
*
|
||||
* @param packetLimiterEnabled whether the packet limiter should be enabled
|
||||
*/
|
||||
void setPacketLimiterEnabled(boolean packetLimiterEnabled);
|
||||
|
||||
/**
|
||||
* Returns a newly generated uuid that will let a packet be passed through without
|
||||
* transformig its contents if used together with {@link PacketWrapper#PASSTHROUGH_ID}.
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
/**
|
||||
* Mappings containing the full string identifier mappings.
|
||||
*/
|
||||
public interface FullMappings extends Mappings {
|
||||
public interface FullMappings extends BiMappings {
|
||||
|
||||
/**
|
||||
* Returns the unmapped integer id for the given identifier, or -1 if not found.
|
||||
@@ -49,17 +49,17 @@ public interface FullMappings extends Mappings {
|
||||
* Returns the unmapped string identifier for the given mapped id.
|
||||
*
|
||||
* @param id unmapped id
|
||||
* @return unmapped string identifier
|
||||
* @return unmapped string identifier, or null if out of bounds
|
||||
*/
|
||||
String identifier(int id);
|
||||
@Nullable String identifier(int id);
|
||||
|
||||
/**
|
||||
* Returns the mapped string identifier for the given mapped id.
|
||||
*
|
||||
* @param mappedId mapped id
|
||||
* @return mapped string identifier
|
||||
* @return mapped string identifier, or null if out of bounds
|
||||
*/
|
||||
String mappedIdentifier(int mappedId);
|
||||
@Nullable String mappedIdentifier(int mappedId);
|
||||
|
||||
/**
|
||||
* Returns the mapped string identifier for the given unmapped identifier.
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
@@ -37,6 +38,7 @@ public class FullMappingsBase implements FullMappings {
|
||||
private final Mappings mappings;
|
||||
|
||||
public FullMappingsBase(final List<String> unmappedIdentifiers, final List<String> mappedIdentifiers, final Mappings mappings) {
|
||||
Preconditions.checkNotNull(mappings, "Mappings cannot be null");
|
||||
this.mappings = mappings;
|
||||
this.stringToId = toInverseMap(unmappedIdentifiers);
|
||||
this.mappedStringToId = toInverseMap(mappedIdentifiers);
|
||||
@@ -52,6 +54,15 @@ public class FullMappingsBase implements FullMappings {
|
||||
this.mappings = mappings;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id(final String identifier) {
|
||||
return stringToId.getInt(Key.stripMinecraftNamespace(identifier));
|
||||
@@ -64,12 +75,20 @@ public class FullMappingsBase implements FullMappings {
|
||||
|
||||
@Override
|
||||
public String identifier(final int id) {
|
||||
if (id < 0 || id >= idToString.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String identifier = idToString[id];
|
||||
return Key.namespaced(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String mappedIdentifier(final int mappedId) {
|
||||
if (mappedId < 0 || mappedId >= mappedIdToString.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String identifier = mappedIdToString[mappedId];
|
||||
return Key.namespaced(identifier);
|
||||
}
|
||||
@@ -109,13 +128,4 @@ public class FullMappingsBase implements FullMappings {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -22,15 +22,7 @@
|
||||
*/
|
||||
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;
|
||||
}
|
||||
public record IdentityMappings(int size, int mappedSize) implements Mappings {
|
||||
|
||||
@Override
|
||||
public int getNewId(final int id) {
|
||||
@@ -42,16 +34,6 @@ public class IdentityMappings implements Mappings {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mappedSize() {
|
||||
return mappedSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mappings inverse() {
|
||||
return new IdentityMappings(mappedSize, size);
|
||||
|
||||
@@ -79,6 +79,8 @@ public interface MappingData {
|
||||
*/
|
||||
int getNewParticleId(int id);
|
||||
|
||||
int getNewAttributeId(int id);
|
||||
|
||||
/**
|
||||
* Returns a list of tags to send if present.
|
||||
*
|
||||
@@ -87,8 +89,21 @@ public interface MappingData {
|
||||
*/
|
||||
@Nullable List<TagData> getTags(RegistryType type);
|
||||
|
||||
/**
|
||||
* Returns item mappings.
|
||||
*
|
||||
* @return item mappings
|
||||
*/
|
||||
@Nullable BiMappings getItemMappings();
|
||||
|
||||
/**
|
||||
* Returns item mappings if they also have identifier data present.
|
||||
*
|
||||
* @return item mappings if they also have identifier data present
|
||||
* @see #getItemMappings()
|
||||
*/
|
||||
@Nullable FullMappings getFullItemMappings();
|
||||
|
||||
@Nullable ParticleMappings getParticleMappings();
|
||||
|
||||
@Nullable Mappings getBlockMappings();
|
||||
@@ -105,9 +120,15 @@ public interface MappingData {
|
||||
|
||||
@Nullable Mappings getEnchantmentMappings();
|
||||
|
||||
@Nullable Mappings getAttributeMappings();
|
||||
|
||||
@Nullable Mappings getPaintingMappings();
|
||||
|
||||
@Nullable FullMappings getEntityMappings();
|
||||
|
||||
@Nullable FullMappings getArgumentTypeMappings();
|
||||
|
||||
@Nullable Mappings getPaintingMappings();
|
||||
@Nullable FullMappings getRecipeSerializerMappings();
|
||||
|
||||
@Nullable FullMappings getDataComponentSerializerMappings();
|
||||
}
|
||||
@@ -22,10 +22,9 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
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.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.IntArrayTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.TagData;
|
||||
@@ -34,7 +33,6 @@ 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 {
|
||||
@@ -44,6 +42,8 @@ public class MappingDataBase implements MappingData {
|
||||
protected BiMappings itemMappings;
|
||||
protected FullMappings argumentTypeMappings;
|
||||
protected FullMappings entityMappings;
|
||||
protected FullMappings recipeSerializerMappings;
|
||||
protected FullMappings itemDataSerializerMappings;
|
||||
protected ParticleMappings particleMappings;
|
||||
protected Mappings blockMappings;
|
||||
protected Mappings blockStateMappings;
|
||||
@@ -53,6 +53,7 @@ public class MappingDataBase implements MappingData {
|
||||
protected Mappings enchantmentMappings;
|
||||
protected Mappings paintingMappings;
|
||||
protected Mappings menuMappings;
|
||||
protected Mappings attributeMappings;
|
||||
protected Map<RegistryType, List<TagData>> tags;
|
||||
|
||||
public MappingDataBase(final String unmappedVersion, final String mappedVersion) {
|
||||
@@ -66,7 +67,7 @@ public class MappingDataBase implements MappingData {
|
||||
getLogger().info("Loading " + unmappedVersion + " -> " + mappedVersion + " mappings...");
|
||||
}
|
||||
|
||||
final CompoundTag data = readNBTFile("mappings-" + unmappedVersion + "to" + mappedVersion + ".nbt");
|
||||
final CompoundTag data = readMappingsFile("mappings-" + unmappedVersion + "to" + mappedVersion + ".nbt");
|
||||
blockMappings = loadMappings(data, "blocks");
|
||||
blockStateMappings = loadMappings(data, "blockstates");
|
||||
blockEntityMappings = loadMappings(data, "blockentities");
|
||||
@@ -75,48 +76,76 @@ public class MappingDataBase implements MappingData {
|
||||
menuMappings = loadMappings(data, "menus");
|
||||
enchantmentMappings = loadMappings(data, "enchantments");
|
||||
paintingMappings = loadMappings(data, "paintings");
|
||||
itemMappings = loadBiMappings(data, "items");
|
||||
attributeMappings = loadMappings(data, "attributes");
|
||||
|
||||
final CompoundTag unmappedIdentifierData = MappingDataLoader.loadNBT("identifiers-" + unmappedVersion + ".nbt", true);
|
||||
final CompoundTag mappedIdentifierData = MappingDataLoader.loadNBT("identifiers-" + mappedVersion + ".nbt", true);
|
||||
|
||||
final CompoundTag unmappedIdentifierData = readUnmappedIdentifiersFile("identifiers-" + unmappedVersion + ".nbt");
|
||||
final CompoundTag mappedIdentifierData = readMappedIdentifiersFile("identifiers-" + mappedVersion + ".nbt");
|
||||
if (unmappedIdentifierData != null && mappedIdentifierData != null) {
|
||||
itemMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "items");
|
||||
entityMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "entities");
|
||||
argumentTypeMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "argumenttypes");
|
||||
recipeSerializerMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "recipe_serializers");
|
||||
itemDataSerializerMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "data_component_type");
|
||||
|
||||
final ListTag unmappedParticles = unmappedIdentifierData.get("particles");
|
||||
final ListTag mappedParticles = mappedIdentifierData.get("particles");
|
||||
final List<String> unmappedParticles = identifiersFromGlobalIds(unmappedIdentifierData, "particles");
|
||||
final List<String> mappedParticles = identifiersFromGlobalIds(mappedIdentifierData, "particles");
|
||||
if (unmappedParticles != null && mappedParticles != null) {
|
||||
Mappings particleMappings = loadMappings(data, "particles");
|
||||
if (particleMappings == null) {
|
||||
particleMappings = new IdentityMappings(unmappedParticles.size(), mappedParticles.size());
|
||||
}
|
||||
|
||||
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);
|
||||
this.particleMappings = new ParticleMappings(unmappedParticles, mappedParticles, particleMappings);
|
||||
}
|
||||
} else {
|
||||
// Might not have identifiers in older versions
|
||||
itemMappings = loadBiMappings(data, "items");
|
||||
}
|
||||
|
||||
final CompoundTag tagsTag = data.get("tags");
|
||||
final CompoundTag tagsTag = data.getCompoundTag("tags");
|
||||
if (tagsTag != null) {
|
||||
this.tags = new EnumMap<>(RegistryType.class);
|
||||
loadTags(RegistryType.ITEM, tagsTag);
|
||||
loadTags(RegistryType.BLOCK, tagsTag);
|
||||
loadTags(RegistryType.ENTITY, tagsTag);
|
||||
}
|
||||
|
||||
loadExtras(data);
|
||||
}
|
||||
|
||||
protected @Nullable CompoundTag readNBTFile(final String name) {
|
||||
return MappingDataLoader.loadNBT(name);
|
||||
protected @Nullable List<String> identifiersFromGlobalIds(final CompoundTag mappingsTag, final String key) {
|
||||
return MappingDataLoader.INSTANCE.identifiersFromGlobalIds(mappingsTag, key);
|
||||
}
|
||||
|
||||
protected @Nullable CompoundTag readMappingsFile(final String name) {
|
||||
return MappingDataLoader.INSTANCE.loadNBT(name);
|
||||
}
|
||||
|
||||
protected @Nullable CompoundTag readUnmappedIdentifiersFile(final String name) {
|
||||
return MappingDataLoader.INSTANCE.loadNBT(name, true);
|
||||
}
|
||||
|
||||
protected @Nullable CompoundTag readMappedIdentifiersFile(final String name) {
|
||||
return MappingDataLoader.INSTANCE.loadNBT(name, true);
|
||||
}
|
||||
|
||||
protected @Nullable Mappings loadMappings(final CompoundTag data, final String key) {
|
||||
return MappingDataLoader.loadMappings(data, key);
|
||||
return MappingDataLoader.INSTANCE.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 FullMappings loadFullMappings(final CompoundTag data, final CompoundTag unmappedIdentifiersTag, final CompoundTag mappedIdentifiersTag, final String key) {
|
||||
if (!unmappedIdentifiersTag.contains(key) || !mappedIdentifiersTag.contains(key)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final List<String> unmappedIdentifiers = identifiersFromGlobalIds(unmappedIdentifiersTag, key);
|
||||
final List<String> mappedIdentifiers = identifiersFromGlobalIds(mappedIdentifiersTag, key);
|
||||
Mappings mappings = loadBiMappings(data, key); // Load as bi-mappings to keep the inverse cached
|
||||
if (mappings == null) {
|
||||
mappings = new IdentityMappings(unmappedIdentifiers.size(), mappedIdentifiers.size());
|
||||
}
|
||||
|
||||
return new FullMappingsBase(unmappedIdentifiers, mappedIdentifiers, mappings);
|
||||
}
|
||||
|
||||
protected @Nullable BiMappings loadBiMappings(final CompoundTag data, final String key) {
|
||||
@@ -125,7 +154,7 @@ public class MappingDataBase implements MappingData {
|
||||
}
|
||||
|
||||
private void loadTags(final RegistryType type, final CompoundTag data) {
|
||||
final CompoundTag tag = data.get(type.resourceLocation());
|
||||
final CompoundTag tag = data.getCompoundTag(type.resourceLocation());
|
||||
if (tag == null) {
|
||||
return;
|
||||
}
|
||||
@@ -164,6 +193,11 @@ public class MappingDataBase implements MappingData {
|
||||
return checkValidity(id, particleMappings.getNewId(id), "particles");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewAttributeId(final int id) {
|
||||
return checkValidity(id, attributeMappings.getNewId(id), "attributes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<TagData> getTags(final RegistryType type) {
|
||||
return tags != null ? tags.get(type) : null;
|
||||
@@ -174,6 +208,14 @@ public class MappingDataBase implements MappingData {
|
||||
return itemMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FullMappings getFullItemMappings() {
|
||||
if (itemMappings instanceof FullMappings) {
|
||||
return (FullMappings) itemMappings;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ParticleMappings getParticleMappings() {
|
||||
return particleMappings;
|
||||
@@ -214,6 +256,11 @@ public class MappingDataBase implements MappingData {
|
||||
return enchantmentMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Mappings getAttributeMappings() {
|
||||
return attributeMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FullMappings getEntityMappings() {
|
||||
return entityMappings;
|
||||
@@ -224,11 +271,21 @@ public class MappingDataBase implements MappingData {
|
||||
return argumentTypeMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FullMappings getDataComponentSerializerMappings() {
|
||||
return itemDataSerializerMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Mappings getPaintingMappings() {
|
||||
return paintingMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FullMappings getRecipeSerializerMappings() {
|
||||
return recipeSerializerMappings;
|
||||
}
|
||||
|
||||
protected Logger getLogger() {
|
||||
return Via.getPlatform().getLogger();
|
||||
}
|
||||
@@ -253,4 +310,4 @@ public class MappingDataBase implements MappingData {
|
||||
|
||||
protected void loadExtras(final CompoundTag data) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,46 +22,95 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
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.github.steveice10.opennbt.tag.io.NBTIO;
|
||||
import com.github.steveice10.opennbt.tag.io.TagReader;
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonIOException;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.viaversion.nbt.io.NBTIO;
|
||||
import com.viaversion.nbt.io.TagReader;
|
||||
import com.viaversion.nbt.tag.ByteTag;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.IntArrayTag;
|
||||
import com.viaversion.nbt.tag.IntTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.util.GsonUtil;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.logging.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class MappingDataLoader {
|
||||
public class MappingDataLoader {
|
||||
|
||||
private static final Map<String, CompoundTag> MAPPINGS_CACHE = new HashMap<>();
|
||||
private static final TagReader<CompoundTag> MAPPINGS_READER = NBTIO.reader(CompoundTag.class).named();
|
||||
public static final MappingDataLoader INSTANCE = new MappingDataLoader(MappingDataLoader.class, "assets/viaversion/data/");
|
||||
public static final TagReader<CompoundTag> MAPPINGS_READER = NBTIO.reader(CompoundTag.class).named();
|
||||
private static final Map<String, String[]> GLOBAL_IDENTIFIER_INDEXES = new HashMap<>();
|
||||
private static final 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 boolean cacheValid = true;
|
||||
|
||||
public static void clearCache() {
|
||||
MAPPINGS_CACHE.clear();
|
||||
private final Map<String, CompoundTag> mappingsCache = new HashMap<>();
|
||||
private final Class<?> dataLoaderClass;
|
||||
private final String dataPath;
|
||||
private boolean cacheValid = true;
|
||||
|
||||
public MappingDataLoader(final Class<?> dataLoaderClass, final String dataPath) {
|
||||
this.dataLoaderClass = dataLoaderClass;
|
||||
this.dataPath = dataPath;
|
||||
}
|
||||
|
||||
public static void loadGlobalIdentifiers() {
|
||||
// Load in a file with all the identifiers we need, so that we don't need to duplicate them
|
||||
// for every single new version with only a couple of changes in them.
|
||||
final CompoundTag globalIdentifiers = INSTANCE.loadNBT("identifier-table.nbt");
|
||||
for (final Map.Entry<String, Tag> entry : globalIdentifiers.entrySet()) {
|
||||
//noinspection unchecked
|
||||
final ListTag<StringTag> value = (ListTag<StringTag>) entry.getValue();
|
||||
final String[] array = new String[value.size()];
|
||||
for (int i = 0, size = value.size(); i < size; i++) {
|
||||
array[i] = value.get(i).getValue();
|
||||
}
|
||||
GLOBAL_IDENTIFIER_INDEXES.put(entry.getKey(), array);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the global id of the identifier in the registry.
|
||||
*
|
||||
* @param registry registry key
|
||||
* @param globalId global id
|
||||
* @return identifier
|
||||
* @throws IllegalArgumentException if the registry key is invalid
|
||||
*/
|
||||
public @Nullable String identifierFromGlobalId(final String registry, final int globalId) {
|
||||
final String[] array = GLOBAL_IDENTIFIER_INDEXES.get(registry);
|
||||
if (array == null) {
|
||||
throw new IllegalArgumentException("Unknown global identifier key: " + registry);
|
||||
}
|
||||
if (globalId < 0 || globalId >= array.length) {
|
||||
throw new IllegalArgumentException("Unknown global identifier index: " + globalId);
|
||||
}
|
||||
return array[globalId];
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
mappingsCache.clear();
|
||||
cacheValid = false;
|
||||
}
|
||||
|
||||
@@ -70,8 +119,8 @@ public final class MappingDataLoader {
|
||||
*
|
||||
* @return loaded json object, or null if not found or invalid
|
||||
*/
|
||||
public static @Nullable JsonObject loadFromDataDir(final String name) {
|
||||
final File file = new File(Via.getPlatform().getDataFolder(), name);
|
||||
public @Nullable JsonObject loadFromDataDir(final String name) {
|
||||
final File file = new File(getDataFolder(), name);
|
||||
if (!file.exists()) {
|
||||
return loadData(name);
|
||||
}
|
||||
@@ -81,7 +130,7 @@ public final class MappingDataLoader {
|
||||
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
|
||||
} 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!");
|
||||
getLogger().warning(name + " is badly formatted!");
|
||||
throw new RuntimeException(e);
|
||||
} catch (final IOException | JsonIOException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -93,7 +142,7 @@ public final class MappingDataLoader {
|
||||
*
|
||||
* @return loaded json object from bundled resources if present
|
||||
*/
|
||||
public static @Nullable JsonObject loadData(final String name) {
|
||||
public @Nullable JsonObject loadData(final String name) {
|
||||
final InputStream stream = getResource(name);
|
||||
if (stream == null) {
|
||||
return null;
|
||||
@@ -106,12 +155,12 @@ public final class MappingDataLoader {
|
||||
}
|
||||
}
|
||||
|
||||
public static @Nullable CompoundTag loadNBT(final String name, final boolean cache) {
|
||||
public @Nullable CompoundTag loadNBT(final String name, final boolean cache) {
|
||||
if (!cacheValid) {
|
||||
return loadNBTFromFile(name);
|
||||
}
|
||||
|
||||
CompoundTag data = MAPPINGS_CACHE.get(name);
|
||||
CompoundTag data = mappingsCache.get(name);
|
||||
if (data != null) {
|
||||
return data;
|
||||
}
|
||||
@@ -119,29 +168,29 @@ public final class MappingDataLoader {
|
||||
data = loadNBTFromFile(name);
|
||||
|
||||
if (cache && data != null) {
|
||||
MAPPINGS_CACHE.put(name, data);
|
||||
mappingsCache.put(name, data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public static @Nullable CompoundTag loadNBT(final String name) {
|
||||
public @Nullable CompoundTag loadNBT(final String name) {
|
||||
return loadNBT(name, false);
|
||||
}
|
||||
|
||||
public static @Nullable CompoundTag loadNBTFromFile(final String name) {
|
||||
public @Nullable CompoundTag loadNBTFromFile(final String name) {
|
||||
final InputStream resource = getResource(name);
|
||||
if (resource == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try (final InputStream stream = resource) {
|
||||
try (final InputStream stream = new BufferedInputStream(resource)) {
|
||||
return MAPPINGS_READER.read(stream);
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static @Nullable Mappings loadMappings(final CompoundTag mappingsTag, final String key) {
|
||||
public @Nullable Mappings loadMappings(final CompoundTag mappingsTag, final String key) {
|
||||
return loadMappings(mappingsTag, key, size -> {
|
||||
final int[] array = new int[size];
|
||||
Arrays.fill(array, -1);
|
||||
@@ -150,29 +199,29 @@ public final class MappingDataLoader {
|
||||
}
|
||||
|
||||
@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
|
||||
public <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);
|
||||
final CompoundTag tag = mappingsTag.getCompoundTag(key);
|
||||
if (tag == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final ByteTag serializationStragetyTag = tag.get("id");
|
||||
final IntTag mappedSizeTag = tag.get("mappedSize");
|
||||
final ByteTag serializationStragetyTag = tag.getUnchecked("id");
|
||||
final IntTag mappedSizeTag = tag.getUnchecked("mappedSize");
|
||||
final byte strategy = serializationStragetyTag.asByte();
|
||||
final V mappings;
|
||||
if (strategy == DIRECT_ID) {
|
||||
final IntArrayTag valuesTag = tag.get("val");
|
||||
final IntArrayTag valuesTag = tag.getIntArrayTag("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 IntArrayTag shiftsAtTag = tag.getIntArrayTag("at");
|
||||
final IntArrayTag shiftsTag = tag.getIntArrayTag("to");
|
||||
final IntTag sizeTag = tag.getUnchecked("size");
|
||||
final int[] shiftsAt = shiftsAtTag.getValue();
|
||||
final int[] shiftsTo = shiftsTag.getValue();
|
||||
final int size = sizeTag.asInt();
|
||||
@@ -196,9 +245,9 @@ public final class MappingDataLoader {
|
||||
}
|
||||
}
|
||||
} else if (strategy == CHANGES_ID) {
|
||||
final IntArrayTag changesAtTag = tag.get("at");
|
||||
final IntArrayTag valuesTag = tag.get("val");
|
||||
final IntTag sizeTag = tag.get("size");
|
||||
final IntArrayTag changesAtTag = tag.getIntArrayTag("at");
|
||||
final IntArrayTag valuesTag = tag.getIntArrayTag("val");
|
||||
final IntTag sizeTag = tag.getUnchecked("size");
|
||||
final boolean fillBetween = tag.get("nofill") == null;
|
||||
final int[] changesAt = changesAtTag.getValue();
|
||||
final int[] values = valuesTag.getValue();
|
||||
@@ -218,7 +267,7 @@ public final class MappingDataLoader {
|
||||
addConsumer.addTo(mappings, id, values[i]);
|
||||
}
|
||||
} else if (strategy == IDENTITY_ID) {
|
||||
final IntTag sizeTag = tag.get("size");
|
||||
final IntTag sizeTag = tag.getUnchecked("size");
|
||||
return new IdentityMappings(sizeTag.asInt(), mappedSizeTag.asInt());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown serialization strategy: " + strategy);
|
||||
@@ -226,23 +275,17 @@ public final class MappingDataLoader {
|
||||
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) {
|
||||
public @Nullable List<String> identifiersFromGlobalIds(final CompoundTag mappingsTag, final String key) {
|
||||
final Mappings mappings = loadMappings(mappingsTag, key);
|
||||
if (mappings == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Mappings mappings = loadMappings(mappingsTag, key);
|
||||
if (mappings == null) {
|
||||
mappings = new IdentityMappings(unmappedElements.size(), mappedElements.size());
|
||||
final List<String> identifiers = new ArrayList<>(mappings.size());
|
||||
for (int i = 0; i < mappings.size(); i++) {
|
||||
identifiers.add(identifierFromGlobalId(key, mappings.getNewId(i)));
|
||||
}
|
||||
|
||||
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
|
||||
);
|
||||
return identifiers;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,7 +294,7 @@ public final class MappingDataLoader {
|
||||
* @param object json object
|
||||
* @return map with indexes hashed by their id value
|
||||
*/
|
||||
public static Object2IntMap<String> indexedObjectToMap(final JsonObject object) {
|
||||
public Object2IntMap<String> indexedObjectToMap(final JsonObject object) {
|
||||
final Object2IntMap<String> map = new Object2IntOpenHashMap<>(object.size(), .99F);
|
||||
map.defaultReturnValue(-1);
|
||||
for (final Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
@@ -266,7 +309,7 @@ public final class MappingDataLoader {
|
||||
* @param array json array
|
||||
* @return map with indexes hashed by their id value
|
||||
*/
|
||||
public static Object2IntMap<String> arrayToMap(final JsonArray array) {
|
||||
public 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++) {
|
||||
@@ -275,8 +318,16 @@ public final class MappingDataLoader {
|
||||
return map;
|
||||
}
|
||||
|
||||
public static @Nullable InputStream getResource(final String name) {
|
||||
return MappingDataLoader.class.getClassLoader().getResourceAsStream("assets/viaversion/data/" + name);
|
||||
public Logger getLogger() {
|
||||
return Via.getPlatform().getLogger();
|
||||
}
|
||||
|
||||
public File getDataFolder() {
|
||||
return Via.getPlatform().getDataFolder();
|
||||
}
|
||||
|
||||
public @Nullable InputStream getResource(final String name) {
|
||||
return dataLoaderClass.getClassLoader().getResourceAsStream(dataPath + name);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
|
||||
@@ -84,10 +84,4 @@ public interface Mappings {
|
||||
* @return mappings with keys and values swapped
|
||||
*/
|
||||
Mappings inverse();
|
||||
|
||||
@FunctionalInterface
|
||||
interface MappingsSupplier<T extends Mappings> {
|
||||
|
||||
T supply(int[] mappings, int mappedIds);
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ public class ParticleMappings extends FullMappingsBase {
|
||||
addBlockParticle("block");
|
||||
addBlockParticle("falling_dust");
|
||||
addBlockParticle("block_marker");
|
||||
addBlockParticle("dust_pillar");
|
||||
addItemParticle("item");
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ package com.viaversion.viaversion.api.data.entity;
|
||||
|
||||
public interface DimensionData {
|
||||
|
||||
int id();
|
||||
|
||||
int minY();
|
||||
|
||||
int height();
|
||||
|
||||
@@ -34,6 +34,7 @@ public interface EntityTracker {
|
||||
*
|
||||
* @return user connection
|
||||
*/
|
||||
@Deprecated
|
||||
UserConnection user();
|
||||
|
||||
/**
|
||||
@@ -165,6 +166,8 @@ public interface EntityTracker {
|
||||
|
||||
@Nullable DimensionData dimensionData(String dimension);
|
||||
|
||||
@Nullable DimensionData dimensionData(int dimensionId);
|
||||
|
||||
void setDimensions(Map<String, DimensionData> dimensions);
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,11 +48,11 @@ public interface TrackedEntity {
|
||||
boolean hasData();
|
||||
|
||||
/**
|
||||
* Returns whether metadata has already been sent at least once for this entity.
|
||||
* Returns whether entity data has already been sent at least once for this entity.
|
||||
*
|
||||
* @return whether metadata has already been sent at least once for this entity
|
||||
* @return whether entity data has already been sent at least once for this entity
|
||||
*/
|
||||
boolean hasSentMetadata();
|
||||
boolean hasSentEntityData();
|
||||
|
||||
void sentMetadata(boolean sentMetadata);
|
||||
void sentEntityData(boolean sentEntityData);
|
||||
}
|
||||
@@ -29,7 +29,6 @@ import com.viaversion.viaversion.api.protocol.packet.PacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Beta
|
||||
public interface DebugHandler {
|
||||
|
||||
/**
|
||||
@@ -51,6 +50,7 @@ public interface DebugHandler {
|
||||
*
|
||||
* @param packetTypeName packet type name
|
||||
*/
|
||||
@Beta
|
||||
void addPacketTypeNameToLog(String packetTypeName);
|
||||
|
||||
/**
|
||||
@@ -59,6 +59,7 @@ public interface DebugHandler {
|
||||
*
|
||||
* @param packetType packet type
|
||||
*/
|
||||
@Beta
|
||||
void addPacketTypeToLog(PacketType packetType);
|
||||
|
||||
/**
|
||||
@@ -66,11 +67,13 @@ public interface DebugHandler {
|
||||
*
|
||||
* @param packetTypeName packet type name
|
||||
*/
|
||||
@Beta
|
||||
boolean removePacketTypeNameToLog(String packetTypeName);
|
||||
|
||||
/**
|
||||
* Resets packet type filters.
|
||||
*/
|
||||
@Beta
|
||||
void clearPacketTypesToLog();
|
||||
|
||||
/**
|
||||
@@ -79,6 +82,7 @@ public interface DebugHandler {
|
||||
*
|
||||
* @return whether packets should be logged after being transformed
|
||||
*/
|
||||
@Beta
|
||||
boolean logPostPacketTransform();
|
||||
|
||||
/**
|
||||
@@ -86,6 +90,7 @@ public interface DebugHandler {
|
||||
*
|
||||
* @param logPostPacketTransform whether packets should be logged after being transformed
|
||||
*/
|
||||
@Beta
|
||||
void setLogPostPacketTransform(boolean logPostPacketTransform);
|
||||
|
||||
/**
|
||||
@@ -98,6 +103,7 @@ public interface DebugHandler {
|
||||
*/
|
||||
boolean shouldLog(PacketWrapper wrapper, Direction direction);
|
||||
|
||||
@Beta
|
||||
default void enableAndLogIds(final PacketType... packetTypes) {
|
||||
setEnabled(true);
|
||||
for (final PacketType packetType : packetTypes) {
|
||||
|
||||
@@ -34,7 +34,6 @@ public enum BlockFace {
|
||||
BOTTOM((byte) 0, (byte) -1, (byte) 0, EnumAxis.Y);
|
||||
|
||||
public static final BlockFace[] HORIZONTAL = {NORTH, SOUTH, EAST, WEST};
|
||||
|
||||
private static final Map<BlockFace, BlockFace> opposites = new EnumMap<>(BlockFace.class);
|
||||
|
||||
static {
|
||||
@@ -78,26 +77,6 @@ public enum BlockFace {
|
||||
return axis;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public byte getModX() {
|
||||
return modX;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public byte getModY() {
|
||||
return modY;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public byte getModZ() {
|
||||
return modZ;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public EnumAxis getAxis() {
|
||||
return axis;
|
||||
}
|
||||
|
||||
public enum EnumAxis {
|
||||
X, Y, Z
|
||||
}
|
||||
|
||||
+12
-37
@@ -22,29 +22,19 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public class Position {
|
||||
public class BlockPosition {
|
||||
protected final int x;
|
||||
protected final int y;
|
||||
protected final int z;
|
||||
|
||||
public Position(int x, int y, int z) {
|
||||
public BlockPosition(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
// @Deprecated/*(forRemoval=true)*/ Just leave this unchecked
|
||||
public Position(int x, short y, int z) {
|
||||
this(x, (int) y, z);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public Position(Position toCopy) {
|
||||
this(toCopy.x(), toCopy.y(), toCopy.z());
|
||||
}
|
||||
|
||||
public Position getRelative(BlockFace face) {
|
||||
return new Position(x + face.modX(), (short) (y + face.modY()), z + face.modZ());
|
||||
public BlockPosition getRelative(BlockFace face) {
|
||||
return new BlockPosition(x + face.modX(), y + face.modY(), z + face.modZ());
|
||||
}
|
||||
|
||||
public int x() {
|
||||
@@ -59,30 +49,15 @@ 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;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getZ() {
|
||||
return z;
|
||||
public GlobalBlockPosition withDimension(String dimension) {
|
||||
return new GlobalBlockPosition(dimension, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Position position = (Position) o;
|
||||
BlockPosition position = (BlockPosition) o;
|
||||
if (x != position.x) return false;
|
||||
if (y != position.y) return false;
|
||||
return z == position.z;
|
||||
@@ -98,10 +73,10 @@ public class Position {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Position{" +
|
||||
"x=" + x +
|
||||
", y=" + y +
|
||||
", z=" + z +
|
||||
'}';
|
||||
return "BlockPosition{" +
|
||||
"x=" + x +
|
||||
", y=" + y +
|
||||
", z=" + z +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -20,7 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.metadata;
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -82,8 +82,8 @@ public final class ChunkPosition {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChunkPosition{" +
|
||||
"chunkX=" + chunkX +
|
||||
", chunkZ=" + chunkZ +
|
||||
'}';
|
||||
"chunkX=" + chunkX +
|
||||
", chunkZ=" + chunkZ +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -38,20 +38,11 @@ public enum Environment {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public static Environment getEnvironmentById(int id) {
|
||||
switch (id) {
|
||||
default:
|
||||
case -1:
|
||||
return NETHER;
|
||||
case 0:
|
||||
return NORMAL;
|
||||
case 1:
|
||||
return END;
|
||||
}
|
||||
return switch (id) {
|
||||
case 0 -> NORMAL;
|
||||
case 1 -> END;
|
||||
default -> NETHER; // -1 implicitly
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -22,41 +22,5 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public class EulerAngle {
|
||||
private final float x;
|
||||
private final float y;
|
||||
private final float z;
|
||||
|
||||
public EulerAngle(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;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public float getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public float getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public float getZ() {
|
||||
return z;
|
||||
}
|
||||
public record EulerAngle(float x, float y, float z) {
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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 enum GameMode {
|
||||
|
||||
SURVIVAL("Survival Mode"),
|
||||
CREATIVE("Creative Mode"),
|
||||
ADVENTURE("Adventure Mode"),
|
||||
SPECTATOR("Spectator Mode");
|
||||
|
||||
private final String text;
|
||||
|
||||
GameMode(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public String text() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public static GameMode getById(int id) {
|
||||
return switch (id) {
|
||||
case 0 -> SURVIVAL;
|
||||
case 1 -> CREATIVE;
|
||||
case 2 -> ADVENTURE;
|
||||
case 3 -> SPECTATOR;
|
||||
default -> throw new IllegalArgumentException("Unknown gamemode id: " + id);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public record GameProfile(@Nullable String name, @Nullable UUID id, Property[] properties) {
|
||||
|
||||
public record Property(String name, String value, @Nullable String signature) {
|
||||
}
|
||||
}
|
||||
+9
-9
@@ -22,10 +22,10 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public final class GlobalPosition extends Position {
|
||||
public final class GlobalBlockPosition extends BlockPosition {
|
||||
private final String dimension;
|
||||
|
||||
public GlobalPosition(final String dimension, final int x, final int y, final int z) {
|
||||
public GlobalBlockPosition(final String dimension, final int x, final int y, final int z) {
|
||||
super(x, y, z);
|
||||
this.dimension = dimension;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public final class GlobalPosition extends Position {
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final GlobalPosition position = (GlobalPosition) o;
|
||||
final GlobalBlockPosition position = (GlobalBlockPosition) o;
|
||||
if (x != position.x) return false;
|
||||
if (y != position.y) return false;
|
||||
if (z != position.z) return false;
|
||||
@@ -56,11 +56,11 @@ public final class GlobalPosition extends Position {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GlobalPosition{" +
|
||||
"dimension='" + dimension + '\'' +
|
||||
", x=" + x +
|
||||
", y=" + y +
|
||||
", z=" + z +
|
||||
'}';
|
||||
return "GlobalBlockPosition{" +
|
||||
"dimension='" + dimension + '\'' +
|
||||
", x=" + x +
|
||||
", y=" + y +
|
||||
", z=" + z +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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 interface Holder<T> {
|
||||
|
||||
/**
|
||||
* Returns an indirect id holder.
|
||||
*
|
||||
* @param id the id
|
||||
* @param <T> the type of the value
|
||||
* @return a new holder with the given id
|
||||
* @throws IllegalArgumentException if the id is negative
|
||||
*/
|
||||
static <T> Holder<T> of(final int id) {
|
||||
return new HolderImpl<>(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a direct value holder.
|
||||
*
|
||||
* @param value the value
|
||||
* @param <T> the type of the value
|
||||
* @return a new direct holder
|
||||
*/
|
||||
static <T> Holder<T> of(final T value) {
|
||||
return new HolderImpl<>(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this holder is backed by a direct value.
|
||||
*
|
||||
* @return true if the holder is direct
|
||||
* @see #hasId()
|
||||
*/
|
||||
boolean isDirect();
|
||||
|
||||
/**
|
||||
* Returns true if this holder has an id.
|
||||
*
|
||||
* @return true if this holder has an id
|
||||
* @see #isDirect()
|
||||
*/
|
||||
boolean hasId();
|
||||
|
||||
/**
|
||||
* Returns the value of this holder.
|
||||
*
|
||||
* @return the value of this holder
|
||||
* @throws IllegalArgumentException if this holder is not direct
|
||||
* @see #isDirect()
|
||||
*/
|
||||
T value();
|
||||
|
||||
/**
|
||||
* Returns the id of this holder, or -1 if this holder is direct.
|
||||
*
|
||||
* @return the id of this holder, or -1 if this holder is direct
|
||||
* @see #hasId()
|
||||
*/
|
||||
int id();
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
final class HolderImpl<T> implements Holder<T> {
|
||||
|
||||
private final T value;
|
||||
private final int id;
|
||||
|
||||
HolderImpl(final int id) {
|
||||
Preconditions.checkArgument(id >= 0, "id cannot be negative");
|
||||
this.value = null;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
HolderImpl(final T value) {
|
||||
this.value = value;
|
||||
this.id = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirect() {
|
||||
return id == -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasId() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T value() {
|
||||
Preconditions.checkArgument(isDirect(), "Holder is not direct");
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "HolderImpl{" +
|
||||
"value=" + value +
|
||||
", id=" + id +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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;
|
||||
|
||||
/**
|
||||
* Set of ids that either holds a string tag key or an array of ids.
|
||||
*/
|
||||
public interface HolderSet {
|
||||
|
||||
/**
|
||||
* Creates a new holder set for the given tag.
|
||||
*
|
||||
* @param tagKey the tag key
|
||||
* @return a new holder set
|
||||
*/
|
||||
static HolderSet of(final String tagKey) {
|
||||
return new HolderSetImpl(tagKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new holder set for the given ids.
|
||||
*
|
||||
* @param ids the direct ids
|
||||
* @return a new holder set
|
||||
*/
|
||||
static HolderSet of(final int[] ids) {
|
||||
return new HolderSetImpl(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tag key.
|
||||
*
|
||||
* @return the tag key
|
||||
* @see #hasTagKey()
|
||||
*/
|
||||
String tagKey();
|
||||
|
||||
/**
|
||||
* Returns whether this holder set has a tag key.
|
||||
*
|
||||
* @return true if this holder set has a tag key, false if it has direct ids
|
||||
*/
|
||||
boolean hasTagKey();
|
||||
|
||||
/**
|
||||
* Gets the direct ids.
|
||||
*
|
||||
* @return direct ids
|
||||
* @see #hasIds()
|
||||
*/
|
||||
int[] ids();
|
||||
|
||||
/**
|
||||
* Returns whether this holder set has direct ids.
|
||||
*
|
||||
* @return true if this holder set has direct ids, false if it has a tag key
|
||||
*/
|
||||
boolean hasIds();
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.util.EitherImpl;
|
||||
|
||||
final class HolderSetImpl extends EitherImpl<String, int[]> implements HolderSet {
|
||||
|
||||
HolderSetImpl(final String tagKey) {
|
||||
super(tagKey, null);
|
||||
}
|
||||
|
||||
HolderSetImpl(final int[] ids) {
|
||||
super(null, ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tagKey() {
|
||||
return left();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTagKey() {
|
||||
return isLeft();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] ids() {
|
||||
return right();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasIds() {
|
||||
return isRight();
|
||||
}
|
||||
}
|
||||
@@ -24,11 +24,12 @@ package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.util.IdHolder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class Particle {
|
||||
public final class Particle implements IdHolder {
|
||||
private final List<ParticleData<?>> arguments = new ArrayList<>(4);
|
||||
private int id;
|
||||
|
||||
@@ -36,7 +37,8 @@ public final class Particle {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
@Override
|
||||
public int id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -66,6 +68,18 @@ public final class Particle {
|
||||
arguments.add(index, new ParticleData<>(type, value));
|
||||
}
|
||||
|
||||
public <T> void set(final int index, final Type<T> type, final T value) {
|
||||
arguments.set(index, new ParticleData<>(type, value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Particle{" +
|
||||
"arguments=" + arguments +
|
||||
", id=" + id +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static final class ParticleData<T> {
|
||||
private final Type<T> type;
|
||||
private T value;
|
||||
@@ -87,7 +101,7 @@ public final class Particle {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void write(final ByteBuf buf) throws Exception {
|
||||
public void write(final ByteBuf buf) {
|
||||
type.write(buf, value);
|
||||
}
|
||||
|
||||
@@ -98,9 +112,9 @@ public final class Particle {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ParticleData{" +
|
||||
"type=" + type +
|
||||
", value=" + value +
|
||||
'}';
|
||||
"type=" + type +
|
||||
", value=" + value +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-16
@@ -24,20 +24,5 @@ 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;
|
||||
}
|
||||
public record PlayerMessageSignature(UUID uuid, byte[] signatureBytes) {
|
||||
}
|
||||
@@ -22,26 +22,5 @@
|
||||
*/
|
||||
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;
|
||||
}
|
||||
public record ProfileKey(long expiresAt, byte[] publicKey, byte[] keySignature) {
|
||||
}
|
||||
@@ -22,42 +22,5 @@
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Quaternion{" +
|
||||
"x=" + x +
|
||||
", y=" + y +
|
||||
", z=" + z +
|
||||
", w=" + w +
|
||||
'}';
|
||||
}
|
||||
public record Quaternion(float x, float y, float z, float w) {
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public record RegistryEntry(String key, @Nullable Tag tag) {
|
||||
|
||||
public RegistryEntry withKey(final String key) {
|
||||
return new RegistryEntry(key, tag != null ? tag.copy() : null);
|
||||
}
|
||||
}
|
||||
+5
-16
@@ -20,24 +20,13 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package us.myles.ViaVersion.api.boss;
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
@Deprecated
|
||||
public enum BossStyle {
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
SOLID(0),
|
||||
SEGMENTED_6(1),
|
||||
SEGMENTED_10(2),
|
||||
SEGMENTED_12(3),
|
||||
SEGMENTED_20(4);
|
||||
public record SoundEvent(String identifier, @Nullable Float fixedRange) {
|
||||
|
||||
private final int id;
|
||||
|
||||
BossStyle(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
public SoundEvent withIdentifier(final String identifier) {
|
||||
return new SoundEvent(identifier, this.fixedRange);
|
||||
}
|
||||
}
|
||||
@@ -22,20 +22,23 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public final class TagData {
|
||||
private final String identifier;
|
||||
private final int[] entries;
|
||||
import java.util.Arrays;
|
||||
|
||||
public TagData(final String identifier, final int[] entries) {
|
||||
this.identifier = identifier;
|
||||
this.entries = entries;
|
||||
public record TagData(String identifier, int[] entries) {
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final TagData tagData = (TagData) o;
|
||||
if (!identifier.equals(tagData.identifier)) return false;
|
||||
return Arrays.equals(entries, tagData.entries);
|
||||
}
|
||||
|
||||
public String identifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public int[] entries() {
|
||||
return entries;
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = identifier.hashCode();
|
||||
result = 31 * result + Arrays.hashCode(entries);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -22,56 +22,5 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public class Vector {
|
||||
private int blockX;
|
||||
private int blockY;
|
||||
private int blockZ;
|
||||
|
||||
public Vector(int blockX, int blockY, int blockZ) {
|
||||
this.blockX = blockX;
|
||||
this.blockY = blockY;
|
||||
this.blockZ = blockZ;
|
||||
}
|
||||
|
||||
public int blockX() {
|
||||
return blockX;
|
||||
}
|
||||
|
||||
public int blockY() {
|
||||
return blockY;
|
||||
}
|
||||
|
||||
public int blockZ() {
|
||||
return blockZ;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getBlockX() {
|
||||
return blockX;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getBlockY() {
|
||||
return blockY;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getBlockZ() {
|
||||
return blockZ;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public void setBlockX(int blockX) {
|
||||
this.blockX = blockX;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public void setBlockY(int blockY) {
|
||||
this.blockY = blockY;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public void setBlockZ(int blockZ) {
|
||||
this.blockZ = blockZ;
|
||||
}
|
||||
public record Vector(int blockX, int blockY, int blockZ) {
|
||||
}
|
||||
@@ -22,26 +22,5 @@
|
||||
*/
|
||||
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;
|
||||
}
|
||||
public record Vector3f(float x, float y, float z) {
|
||||
}
|
||||
@@ -22,41 +22,5 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public class VillagerData {
|
||||
private final int type;
|
||||
private final int profession;
|
||||
private final int level;
|
||||
|
||||
public VillagerData(final int type, final int profession, final int level) {
|
||||
this.type = type;
|
||||
this.profession = profession;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int type() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int profession() {
|
||||
return profession;
|
||||
}
|
||||
|
||||
public int level() {
|
||||
return level;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getProfession() {
|
||||
return profession;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
public record VillagerData(int type, int profession, int level) {
|
||||
}
|
||||
@@ -24,34 +24,12 @@ package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class WorldIdentifiers implements StorableObject {
|
||||
public record WorldIdentifiers(String overworld, String nether, String end) implements StorableObject {
|
||||
public static final String OVERWORLD_DEFAULT = "minecraft:overworld";
|
||||
public static final String NETHER_DEFAULT = "minecraft:the_nether";
|
||||
public static final String END_DEFAULT = "minecraft:the_end";
|
||||
|
||||
private final String overworld;
|
||||
private final String nether;
|
||||
private final String end;
|
||||
|
||||
public WorldIdentifiers(String overworld) {
|
||||
this(overworld, NETHER_DEFAULT, END_DEFAULT);
|
||||
}
|
||||
|
||||
public WorldIdentifiers(String overworld, String nether, String end) {
|
||||
this.overworld = overworld;
|
||||
this.nether = nether;
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
public String overworld() {
|
||||
return this.overworld;
|
||||
}
|
||||
|
||||
public String nether() {
|
||||
return this.nether;
|
||||
}
|
||||
|
||||
public String end() {
|
||||
return this.end;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.blockentity;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface BlockEntity {
|
||||
|
||||
+2
-33
@@ -22,40 +22,9 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.blockentity;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
|
||||
public final class BlockEntityImpl implements BlockEntity {
|
||||
private final byte packedXZ;
|
||||
private final short y;
|
||||
private final int typeId;
|
||||
private final CompoundTag tag;
|
||||
|
||||
public BlockEntityImpl(final byte packedXZ, final short y, final int typeId, final CompoundTag tag) {
|
||||
this.packedXZ = packedXZ;
|
||||
this.y = y;
|
||||
this.typeId = typeId;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte packedXZ() {
|
||||
return packedXZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int typeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag tag() {
|
||||
return tag;
|
||||
}
|
||||
public record BlockEntityImpl(byte packedXZ, short y, int typeId, CompoundTag tag) implements BlockEntity {
|
||||
|
||||
@Override
|
||||
public BlockEntity withTypeId(int typeId) {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -52,86 +52,6 @@ public interface ChunkSection {
|
||||
return idx >> 4 & 0xF;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getFlatBlock(int idx) {
|
||||
return palette(PaletteType.BLOCKS).idAt(idx);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getFlatBlock(int x, int y, int z) {
|
||||
return getFlatBlock(index(x, y, z));
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void setFlatBlock(int idx, int id) {
|
||||
palette(PaletteType.BLOCKS).setIdAt(idx, id);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void setFlatBlock(int x, int y, int z, int id) {
|
||||
setFlatBlock(index(x, y, z), id);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getBlockWithoutData(int x, int y, int z) {
|
||||
return getFlatBlock(x, y, z) >> 4;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getBlockData(int x, int y, int z) {
|
||||
return getFlatBlock(x, y, z) & 0xF;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void setBlockWithData(int x, int y, int z, int type, int data) {
|
||||
setFlatBlock(index(x, y, z), type << 4 | (data & 0xF));
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void setBlockWithData(int idx, int type, int data) {
|
||||
setFlatBlock(idx, type << 4 | (data & 0xF));
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void setPaletteIndex(int idx, int index) {
|
||||
palette(PaletteType.BLOCKS).setPaletteIndexAt(idx, index);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getPaletteIndex(int idx) {
|
||||
return palette(PaletteType.BLOCKS).paletteIndexAt(idx);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getPaletteSize() {
|
||||
return palette(PaletteType.BLOCKS).size();
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getPaletteEntry(int index) {
|
||||
return palette(PaletteType.BLOCKS).idByIndex(index);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void setPaletteEntry(int index, int id) {
|
||||
palette(PaletteType.BLOCKS).setIdByIndex(index, id);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void replacePaletteEntry(int oldId, int newId) {
|
||||
palette(PaletteType.BLOCKS).replaceId(oldId, newId);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void addPaletteEntry(int id) {
|
||||
palette(PaletteType.BLOCKS).addId(id);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void clearPalette() {
|
||||
palette(PaletteType.BLOCKS).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of non-air blocks in this section.
|
||||
*
|
||||
|
||||
@@ -137,6 +137,7 @@ public final class DataPaletteImpl implements DataPalette {
|
||||
|
||||
interface ChunkData {
|
||||
int get(int idx);
|
||||
|
||||
void set(int idx, int val);
|
||||
}
|
||||
|
||||
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.data;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
final class EmptyStructuredData<T> implements StructuredData<T> {
|
||||
|
||||
private final StructuredDataKey<T> key;
|
||||
private int id;
|
||||
|
||||
EmptyStructuredData(final StructuredDataKey<T> key, final int id) {
|
||||
this.key = key;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final T value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final ByteBuf buffer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(final int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructuredDataKey<T> key() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T value() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final EmptyStructuredData<?> that = (EmptyStructuredData<?>) o;
|
||||
if (id != that.id) return false;
|
||||
return key.equals(that.key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = key.hashCode();
|
||||
result = 31 * result + id;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EmptyStructuredData{" +
|
||||
"key=" + key +
|
||||
", id=" + id +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.data;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Objects;
|
||||
|
||||
final class FilledStructuredData<T> implements StructuredData<T> {
|
||||
|
||||
private final StructuredDataKey<T> key;
|
||||
private T value;
|
||||
private int id;
|
||||
|
||||
FilledStructuredData(final StructuredDataKey<T> key, final T value, final int id) {
|
||||
Preconditions.checkNotNull(key);
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final ByteBuf buffer) {
|
||||
key.type().write(buffer, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(final int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructuredDataKey<T> key() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final FilledStructuredData<?> that = (FilledStructuredData<?>) o;
|
||||
if (id != that.id) return false;
|
||||
if (!key.equals(that.key)) return false;
|
||||
return Objects.equals(value, that.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = key.hashCode();
|
||||
result = 31 * result + (value != null ? value.hashCode() : 0);
|
||||
result = 31 * result + id;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FilledStructuredData{" +
|
||||
"key=" + key +
|
||||
", value=" + value +
|
||||
", id=" + id +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.data;
|
||||
|
||||
import com.viaversion.viaversion.util.IdHolder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface StructuredData<T> extends IdHolder {
|
||||
|
||||
/**
|
||||
* Returns filled structured data, equivalent to an Optional with a value in vanilla.
|
||||
*
|
||||
* @param key serializer key
|
||||
* @param value value
|
||||
* @param id serializer id
|
||||
* @param <T> serializer type
|
||||
* @return filled structured data
|
||||
*/
|
||||
static <T> StructuredData<T> of(final StructuredDataKey<T> key, final T value, final int id) {
|
||||
return new FilledStructuredData<>(key, value, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns empty structured data, equivalent to an empty Optional in vanilla.
|
||||
*
|
||||
* @param key serializer key
|
||||
* @param id serializer id
|
||||
* @return empty structured data
|
||||
*/
|
||||
static <T> StructuredData<T> empty(final StructuredDataKey<T> key, final int id) {
|
||||
return new EmptyStructuredData<>(key, id);
|
||||
}
|
||||
|
||||
void setValue(final T value);
|
||||
|
||||
void write(final ByteBuf buffer);
|
||||
|
||||
void setId(final int id);
|
||||
|
||||
StructuredDataKey<T> key();
|
||||
|
||||
@Nullable T value();
|
||||
|
||||
/**
|
||||
* Returns whether the structured data is present. Even if true, the value may be null.
|
||||
*
|
||||
* @return true if the structured data is present
|
||||
*/
|
||||
default boolean isPresent() {
|
||||
return !isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the structured data is empty. Not to be confused with a null value.
|
||||
*
|
||||
* @return true if the structured data is empty
|
||||
*/
|
||||
boolean isEmpty();
|
||||
}
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.data;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.data.FullMappings;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.util.Unit;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class StructuredDataContainer {
|
||||
|
||||
private final Map<StructuredDataKey<?>, StructuredData<?>> data;
|
||||
private FullMappings lookup;
|
||||
private boolean mappedNames;
|
||||
|
||||
public StructuredDataContainer(final Map<StructuredDataKey<?>, StructuredData<?>> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public StructuredDataContainer(final StructuredData<?>[] dataArray) {
|
||||
this(new Reference2ObjectOpenHashMap<>(dataArray.length));
|
||||
for (final StructuredData<?> data : dataArray) {
|
||||
this.data.put(data.key(), data);
|
||||
}
|
||||
}
|
||||
|
||||
public StructuredDataContainer() {
|
||||
this(new Reference2ObjectOpenHashMap<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns structured data by id if present.
|
||||
*
|
||||
* @param key serializer id
|
||||
* @param <T> data type
|
||||
* @return structured data
|
||||
*/
|
||||
public @Nullable <T> StructuredData<T> get(final StructuredDataKey<T> key) {
|
||||
//noinspection unchecked
|
||||
return (StructuredData<T>) this.data.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns structured data by id if not empty.
|
||||
*
|
||||
* @param key serializer id
|
||||
* @param <T> data type
|
||||
* @return structured data if not empty
|
||||
*/
|
||||
public @Nullable <T> StructuredData<T> getNonEmpty(final StructuredDataKey<T> key) {
|
||||
//noinspection unchecked
|
||||
final StructuredData<T> data = (StructuredData<T>) this.data.get(key);
|
||||
return data != null && data.isPresent() ? data : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns structured data by id if not empty, or creates it.
|
||||
*
|
||||
* @param key serializer id
|
||||
* @param mappingFunction function to create structured data if not present
|
||||
* @param <T> data type
|
||||
* @return structured data if not empty
|
||||
*/
|
||||
public <T> StructuredData<T> computeIfAbsent(final StructuredDataKey<T> key, final Function<StructuredDataKey<T>, T> mappingFunction) {
|
||||
final StructuredData<T> data = this.getNonEmpty(key);
|
||||
if (data != null) {
|
||||
return data;
|
||||
}
|
||||
|
||||
final int id = serializerId(key);
|
||||
final StructuredData<T> empty = StructuredData.of(key, mappingFunction.apply(key), id);
|
||||
this.data.put(key, empty);
|
||||
return empty;
|
||||
}
|
||||
|
||||
public <T> void set(final StructuredDataKey<T> key, final T value) {
|
||||
final int id = serializerId(key);
|
||||
if (id != -1) {
|
||||
this.data.put(key, StructuredData.of(key, value, id));
|
||||
}
|
||||
}
|
||||
|
||||
public void set(final StructuredDataKey<Unit> key) {
|
||||
this.set(key, Unit.INSTANCE);
|
||||
}
|
||||
|
||||
public void addEmpty(final StructuredDataKey<?> key) {
|
||||
// Empty optional to override the Minecraft default
|
||||
this.data.put(key, StructuredData.empty(key, serializerId(key)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes and returns structured data by the given key.
|
||||
*
|
||||
* @param key serializer key
|
||||
* @param <T> data type
|
||||
* @return removed structured data
|
||||
*/
|
||||
public @Nullable <T> StructuredData<T> remove(final StructuredDataKey<T> key) {
|
||||
final StructuredData<?> data = this.data.remove(key);
|
||||
//noinspection unchecked
|
||||
return data != null ? (StructuredData<T>) data : null;
|
||||
}
|
||||
|
||||
public boolean contains(final StructuredDataKey<?> key) {
|
||||
return this.data.containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the lookup for serializer ids. Required to call most of the other methods.
|
||||
*
|
||||
* @param protocol protocol to retreive the id of the serializer from
|
||||
* @param mappedNames if the names are mapped (true if structures from the mapped version are added, false for the unmapped version)
|
||||
*/
|
||||
public void setIdLookup(final Protocol<?, ?, ?, ?> protocol, final boolean mappedNames) {
|
||||
this.lookup = protocol.getMappingData().getDataComponentSerializerMappings();
|
||||
Preconditions.checkNotNull(this.lookup, "Data component serializer mappings are null");
|
||||
this.mappedNames = mappedNames;
|
||||
}
|
||||
|
||||
public StructuredDataContainer copy() {
|
||||
final StructuredDataContainer copy = new StructuredDataContainer(new Reference2ObjectOpenHashMap<>(data));
|
||||
copy.lookup = this.lookup;
|
||||
return copy;
|
||||
}
|
||||
|
||||
private int serializerId(final StructuredDataKey<?> key) {
|
||||
final int id = mappedNames ? lookup.mappedId(key.identifier()) : lookup.id(key.identifier());
|
||||
if (id == -1) {
|
||||
Via.getPlatform().getLogger().severe("Could not find item data serializer for type " + key);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public Map<StructuredDataKey<?>, StructuredData<?>> data() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StructuredDataContainer{" +
|
||||
"data=" + data +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.data;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.api.minecraft.GameProfile;
|
||||
import com.viaversion.viaversion.api.minecraft.Holder;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.AdventureModePredicate;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.ArmorTrim;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.BannerPatternLayer;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.Bee;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.BlockStateProperties;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.DyedColor;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.Enchantments;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.FilterableString;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.FireworkExplosion;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.Fireworks;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.FoodProperties;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.Instrument;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.LodestoneTracker;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.PotDecorations;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.PotionContents;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.SuspiciousStewEffect;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.ToolProperties;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.Unbreakable;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.WrittenBook;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
|
||||
import com.viaversion.viaversion.util.Unit;
|
||||
|
||||
public record StructuredDataKey<T>(String identifier, Type<T> type) {
|
||||
|
||||
public static final StructuredDataKey<CompoundTag> CUSTOM_DATA = new StructuredDataKey<>("custom_data", Types.COMPOUND_TAG);
|
||||
public static final StructuredDataKey<Integer> MAX_STACK_SIZE = new StructuredDataKey<>("max_stack_size", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> MAX_DAMAGE = new StructuredDataKey<>("max_damage", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Integer> DAMAGE = new StructuredDataKey<>("damage", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Unbreakable> UNBREAKABLE = new StructuredDataKey<>("unbreakable", Unbreakable.TYPE);
|
||||
public static final StructuredDataKey<Tag> CUSTOM_NAME = new StructuredDataKey<>("custom_name", Types.TAG);
|
||||
public static final StructuredDataKey<Tag> ITEM_NAME = new StructuredDataKey<>("item_name", Types.TAG);
|
||||
public static final StructuredDataKey<Tag[]> LORE = new StructuredDataKey<>("lore", Types.TAG_ARRAY);
|
||||
public static final StructuredDataKey<Integer> RARITY = new StructuredDataKey<>("rarity", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Enchantments> ENCHANTMENTS = new StructuredDataKey<>("enchantments", Enchantments.TYPE);
|
||||
public static final StructuredDataKey<AdventureModePredicate> CAN_PLACE_ON = new StructuredDataKey<>("can_place_on", AdventureModePredicate.TYPE);
|
||||
public static final StructuredDataKey<AdventureModePredicate> CAN_BREAK = new StructuredDataKey<>("can_break", AdventureModePredicate.TYPE);
|
||||
public static final StructuredDataKey<AttributeModifiers> ATTRIBUTE_MODIFIERS = new StructuredDataKey<>("attribute_modifiers", AttributeModifiers.TYPE);
|
||||
public static final StructuredDataKey<Integer> CUSTOM_MODEL_DATA = new StructuredDataKey<>("custom_model_data", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Unit> HIDE_ADDITIONAL_TOOLTIP = new StructuredDataKey<>("hide_additional_tooltip", Types.EMPTY);
|
||||
public static final StructuredDataKey<Unit> HIDE_TOOLTIP = new StructuredDataKey<>("hide_tooltip", Types.EMPTY);
|
||||
public static final StructuredDataKey<Integer> REPAIR_COST = new StructuredDataKey<>("repair_cost", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Unit> CREATIVE_SLOT_LOCK = new StructuredDataKey<>("creative_slot_lock", Types.EMPTY);
|
||||
public static final StructuredDataKey<Boolean> ENCHANTMENT_GLINT_OVERRIDE = new StructuredDataKey<>("enchantment_glint_override", Types.BOOLEAN);
|
||||
public static final StructuredDataKey<Tag> INTANGIBLE_PROJECTILE = new StructuredDataKey<>("intangible_projectile", Types.TAG); // Doesn't actually hold data
|
||||
public static final StructuredDataKey<FoodProperties> FOOD = new StructuredDataKey<>("food", FoodProperties.TYPE);
|
||||
public static final StructuredDataKey<Unit> FIRE_RESISTANT = new StructuredDataKey<>("fire_resistant", Types.EMPTY);
|
||||
public static final StructuredDataKey<ToolProperties> TOOL = new StructuredDataKey<>("tool", ToolProperties.TYPE);
|
||||
public static final StructuredDataKey<Enchantments> STORED_ENCHANTMENTS = new StructuredDataKey<>("stored_enchantments", Enchantments.TYPE);
|
||||
public static final StructuredDataKey<DyedColor> DYED_COLOR = new StructuredDataKey<>("dyed_color", DyedColor.TYPE);
|
||||
public static final StructuredDataKey<Integer> MAP_COLOR = new StructuredDataKey<>("map_color", Types.INT);
|
||||
public static final StructuredDataKey<Integer> MAP_ID = new StructuredDataKey<>("map_id", Types.VAR_INT);
|
||||
public static final StructuredDataKey<CompoundTag> MAP_DECORATIONS = new StructuredDataKey<>("map_decorations", Types.COMPOUND_TAG);
|
||||
public static final StructuredDataKey<Integer> MAP_POST_PROCESSING = new StructuredDataKey<>("map_post_processing", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Item[]> CHARGED_PROJECTILES = new StructuredDataKey<>("charged_projectiles", Types1_20_5.ITEM_ARRAY);
|
||||
public static final StructuredDataKey<Item[]> BUNDLE_CONTENTS = new StructuredDataKey<>("bundle_contents", Types1_20_5.ITEM_ARRAY);
|
||||
public static final StructuredDataKey<PotionContents> POTION_CONTENTS = new StructuredDataKey<>("potion_contents", PotionContents.TYPE);
|
||||
public static final StructuredDataKey<SuspiciousStewEffect[]> SUSPICIOUS_STEW_EFFECTS = new StructuredDataKey<>("suspicious_stew_effects", SuspiciousStewEffect.ARRAY_TYPE);
|
||||
public static final StructuredDataKey<FilterableString[]> WRITABLE_BOOK_CONTENT = new StructuredDataKey<>("writable_book_content", FilterableString.ARRAY_TYPE);
|
||||
public static final StructuredDataKey<WrittenBook> WRITTEN_BOOK_CONTENT = new StructuredDataKey<>("written_book_content", WrittenBook.TYPE);
|
||||
public static final StructuredDataKey<ArmorTrim> TRIM = new StructuredDataKey<>("trim", ArmorTrim.TYPE);
|
||||
public static final StructuredDataKey<CompoundTag> DEBUG_STICK_STATE = new StructuredDataKey<>("debug_stick_state", Types.COMPOUND_TAG);
|
||||
public static final StructuredDataKey<CompoundTag> ENTITY_DATA = new StructuredDataKey<>("entity_data", Types.COMPOUND_TAG);
|
||||
public static final StructuredDataKey<CompoundTag> BUCKET_ENTITY_DATA = new StructuredDataKey<>("bucket_entity_data", Types.COMPOUND_TAG);
|
||||
public static final StructuredDataKey<CompoundTag> BLOCK_ENTITY_DATA = new StructuredDataKey<>("block_entity_data", Types.COMPOUND_TAG);
|
||||
public static final StructuredDataKey<Holder<Instrument>> INSTRUMENT = new StructuredDataKey<>("instrument", Instrument.TYPE);
|
||||
public static final StructuredDataKey<Integer> OMINOUS_BOTTLE_AMPLIFIER = new StructuredDataKey<>("ominous_bottle_amplifier", Types.VAR_INT);
|
||||
public static final StructuredDataKey<Tag> RECIPES = new StructuredDataKey<>("recipes", Types.TAG);
|
||||
public static final StructuredDataKey<LodestoneTracker> LODESTONE_TRACKER = new StructuredDataKey<>("lodestone_tracker", LodestoneTracker.TYPE);
|
||||
public static final StructuredDataKey<FireworkExplosion> FIREWORK_EXPLOSION = new StructuredDataKey<>("firework_explosion", FireworkExplosion.TYPE);
|
||||
public static final StructuredDataKey<Fireworks> FIREWORKS = new StructuredDataKey<>("fireworks", Fireworks.TYPE);
|
||||
public static final StructuredDataKey<GameProfile> PROFILE = new StructuredDataKey<>("profile", Types.GAME_PROFILE);
|
||||
public static final StructuredDataKey<String> NOTE_BLOCK_SOUND = new StructuredDataKey<>("note_block_sound", Types.STRING);
|
||||
public static final StructuredDataKey<BannerPatternLayer[]> BANNER_PATTERNS = new StructuredDataKey<>("banner_patterns", BannerPatternLayer.ARRAY_TYPE);
|
||||
public static final StructuredDataKey<Integer> BASE_COLOR = new StructuredDataKey<>("base_color", Types.VAR_INT);
|
||||
public static final StructuredDataKey<PotDecorations> POT_DECORATIONS = new StructuredDataKey<>("pot_decorations", PotDecorations.TYPE);
|
||||
public static final StructuredDataKey<Item[]> CONTAINER = new StructuredDataKey<>("container", Types1_20_5.ITEM_ARRAY);
|
||||
public static final StructuredDataKey<BlockStateProperties> BLOCK_STATE = new StructuredDataKey<>("block_state", BlockStateProperties.TYPE);
|
||||
public static final StructuredDataKey<Bee[]> BEES = new StructuredDataKey<>("bees", Bee.ARRAY_TYPE);
|
||||
public static final StructuredDataKey<Tag> LOCK = new StructuredDataKey<>("lock", Types.TAG);
|
||||
public static final StructuredDataKey<CompoundTag> CONTAINER_LOOT = new StructuredDataKey<>("container_loot", Types.COMPOUND_TAG);
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StructuredDataKey{" +
|
||||
"identifier='" + identifier + '\'' +
|
||||
", type=" + type +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+152
-122
@@ -25,141 +25,160 @@ 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;
|
||||
|
||||
// 1.10 Entity / Object ids
|
||||
public class EntityTypes1_10 {
|
||||
|
||||
public static EntityType getTypeFromId(int typeID, boolean isObject) {
|
||||
Optional<EntityType> type;
|
||||
public static EntityType getTypeFromId(final int typeId, final boolean object) {
|
||||
EntityType type;
|
||||
|
||||
if (isObject)
|
||||
type = ObjectType.getPCEntity(typeID);
|
||||
else
|
||||
type = EntityType.findById(typeID);
|
||||
|
||||
if (!type.isPresent()) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.10 type id " + typeID + " isObject=" + isObject);
|
||||
if (object) {
|
||||
type = ObjectType.getEntityType(typeId);
|
||||
} else {
|
||||
type = EntityType.findById(typeId);
|
||||
}
|
||||
if (type == null) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.10 type id " + typeId + " objectType=" + object);
|
||||
return EntityType.ENTITY; // Fall back to the basic ENTITY
|
||||
}
|
||||
|
||||
return type.get();
|
||||
return type;
|
||||
}
|
||||
|
||||
public enum EntityType implements com.viaversion.viaversion.api.minecraft.entities.EntityType {
|
||||
ENTITY(-1),
|
||||
DROPPED_ITEM(1, ENTITY),
|
||||
|
||||
ENTITY,
|
||||
|
||||
AREA_EFFECT_CLOUD(3, ENTITY),
|
||||
END_CRYSTAL(200, ENTITY),
|
||||
EXPERIENCE_ORB(2, ENTITY),
|
||||
LEASH_HITCH(8, ENTITY), // Actually entity hanging but it doesn't make a lot of difference for metadata
|
||||
PAINTING(9, ENTITY), // Actually entity hanging but it doesn't make a lot of difference for metadata
|
||||
ARROW(10, ENTITY),
|
||||
SNOWBALL(11, ENTITY), // Actually EntityProjectile
|
||||
FIREBALL(12, ENTITY),
|
||||
SMALL_FIREBALL(13, ENTITY),
|
||||
ENDER_PEARL(14, ENTITY), // Actually EntityProjectile
|
||||
ENDER_SIGNAL(15, ENTITY),
|
||||
THROWN_EXP_BOTTLE(17, ENTITY),
|
||||
ITEM_FRAME(18, ENTITY), // Actually EntityHanging
|
||||
WITHER_SKULL(19, ENTITY),
|
||||
PRIMED_TNT(20, ENTITY),
|
||||
EYE_OF_ENDER(15, ENTITY),
|
||||
FALLING_BLOCK(21, ENTITY),
|
||||
FIREWORK(22, ENTITY),
|
||||
TIPPED_ARROW(23, ARROW),
|
||||
SPECTRAL_ARROW(24, ARROW),
|
||||
ITEM(1, ENTITY),
|
||||
TNT(20, ENTITY),
|
||||
LIGHTNING_BOLT(ENTITY), // Needed for entity (un)tracking
|
||||
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY),
|
||||
LEASH_KNOT(8, HANGING_ENTITY),
|
||||
ITEM_FRAME(18, HANGING_ENTITY),
|
||||
PAINTING(9, HANGING_ENTITY),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE(ENTITY),
|
||||
FIREWORK_ROCKET(22, ENTITY),
|
||||
SHULKER_BULLET(25, ENTITY),
|
||||
DRAGON_FIREBALL(26, FIREBALL),
|
||||
SNOWBALL(11, PROJECTILE),
|
||||
ENDER_PEARL(14, PROJECTILE),
|
||||
EGG(7, PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(17, PROJECTILE),
|
||||
POTION(16, PROJECTILE),
|
||||
FISHING_HOOK(ENTITY),
|
||||
|
||||
ENTITY_LIVING(-1, ENTITY),
|
||||
ENTITY_INSENTIENT(-1, ENTITY_LIVING),
|
||||
ENTITY_AGEABLE(-1, ENTITY_INSENTIENT),
|
||||
ENTITY_TAMEABLE_ANIMAL(-1, ENTITY_AGEABLE),
|
||||
ENTITY_HUMAN(-1, ENTITY_LIVING),
|
||||
ABSTRACT_ARROW(ENTITY),
|
||||
ARROW(10, ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(24, ABSTRACT_ARROW),
|
||||
|
||||
ARMOR_STAND(30, ENTITY_LIVING),
|
||||
HURTING_PROJECTILE(ENTITY),
|
||||
DRAGON_FIREBALL(26, HURTING_PROJECTILE),
|
||||
FIREBALL(12, HURTING_PROJECTILE),
|
||||
SMALL_FIREBALL(13, HURTING_PROJECTILE),
|
||||
WITHER_SKULL(19, HURTING_PROJECTILE),
|
||||
|
||||
// Vehicles
|
||||
MINECART_ABSTRACT(-1, ENTITY),
|
||||
MINECART_COMMAND(40, MINECART_ABSTRACT),
|
||||
BOAT(41, ENTITY),
|
||||
MINECART_RIDEABLE(42, MINECART_ABSTRACT),
|
||||
MINECART_CHEST(43, MINECART_ABSTRACT),
|
||||
MINECART_FURNACE(44, MINECART_ABSTRACT),
|
||||
MINECART_TNT(45, MINECART_ABSTRACT),
|
||||
MINECART_HOPPER(46, MINECART_ABSTRACT),
|
||||
MINECART_MOB_SPAWNER(47, MINECART_ABSTRACT),
|
||||
|
||||
CREEPER(50, ENTITY_INSENTIENT),
|
||||
SKELETON(51, ENTITY_INSENTIENT),
|
||||
SPIDER(52, ENTITY_INSENTIENT),
|
||||
GIANT(53, ENTITY_INSENTIENT),
|
||||
ZOMBIE(54, ENTITY_INSENTIENT),
|
||||
SLIME(55, ENTITY_INSENTIENT),
|
||||
GHAST(56, ENTITY_INSENTIENT),
|
||||
PIG_ZOMBIE(57, ZOMBIE),
|
||||
ENDERMAN(58, ENTITY_INSENTIENT),
|
||||
CAVE_SPIDER(59, SPIDER),
|
||||
SILVERFISH(60, ENTITY_INSENTIENT),
|
||||
BLAZE(61, ENTITY_INSENTIENT),
|
||||
ABSTRACT_MINECART(ENTITY),
|
||||
MINECART(42, ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(44, ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(40, ABSTRACT_MINECART),
|
||||
TNT_MINECART(45, ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(47, ABSTRACT_MINECART),
|
||||
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART),
|
||||
CHEST_MINECART(43, ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(46, ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
LIVING_ENTITY_BASE(ENTITY),
|
||||
ARMOR_STAND(30, LIVING_ENTITY_BASE),
|
||||
PLAYER(LIVING_ENTITY_BASE), // Needed for entity (un)tracking
|
||||
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(48, LIVING_ENTITY_BASE),
|
||||
ENDER_DRAGON(63, LIVING_ENTITY),
|
||||
ABSTRACT_CREATURE(LIVING_ENTITY),
|
||||
SLIME(55, LIVING_ENTITY),
|
||||
MAGMA_CUBE(62, SLIME),
|
||||
ENDER_DRAGON(63, ENTITY_INSENTIENT),
|
||||
WITHER(64, ENTITY_INSENTIENT),
|
||||
BAT(65, ENTITY_INSENTIENT),
|
||||
WITCH(66, ENTITY_INSENTIENT),
|
||||
ENDERMITE(67, ENTITY_INSENTIENT),
|
||||
GUARDIAN(68, ENTITY_INSENTIENT),
|
||||
IRON_GOLEM(99, ENTITY_INSENTIENT), // moved up to avoid illegal forward references
|
||||
SHULKER(69, IRON_GOLEM),
|
||||
PIG(90, ENTITY_AGEABLE),
|
||||
SHEEP(91, ENTITY_AGEABLE),
|
||||
COW(92, ENTITY_AGEABLE),
|
||||
CHICKEN(93, ENTITY_AGEABLE),
|
||||
SQUID(94, ENTITY_INSENTIENT),
|
||||
WOLF(95, ENTITY_TAMEABLE_ANIMAL),
|
||||
MUSHROOM_COW(96, COW),
|
||||
SNOWMAN(97, IRON_GOLEM),
|
||||
OCELOT(98, ENTITY_TAMEABLE_ANIMAL),
|
||||
HORSE(100, ENTITY_AGEABLE),
|
||||
RABBIT(101, ENTITY_AGEABLE),
|
||||
POLAR_BEAR(102, ENTITY_AGEABLE),
|
||||
VILLAGER(120, ENTITY_AGEABLE),
|
||||
ENDER_CRYSTAL(200, ENTITY),
|
||||
SPLASH_POTION(-1, ENTITY),
|
||||
LINGERING_POTION(-1, SPLASH_POTION),
|
||||
AREA_EFFECT_CLOUD(-1, ENTITY),
|
||||
EGG(-1, ENTITY),
|
||||
FISHING_HOOK(-1, ENTITY),
|
||||
LIGHTNING(-1, ENTITY),
|
||||
WEATHER(-1, ENTITY),
|
||||
PLAYER(-1, ENTITY_HUMAN),
|
||||
COMPLEX_PART(-1, ENTITY);
|
||||
|
||||
// Flying entities
|
||||
FLYING_MOB(LIVING_ENTITY),
|
||||
GHAST(56, FLYING_MOB),
|
||||
|
||||
AMBIENT_CREATURE(LIVING_ENTITY),
|
||||
BAT(65, AMBIENT_CREATURE),
|
||||
|
||||
ABSTRACT_GOLEM(ABSTRACT_CREATURE),
|
||||
SNOW_GOLEM(97, ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(99, ABSTRACT_GOLEM),
|
||||
SHULKER(69, ABSTRACT_GOLEM),
|
||||
|
||||
WATER_ANIMAL(LIVING_ENTITY),
|
||||
SQUID(94, WATER_ANIMAL),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(ABSTRACT_CREATURE),
|
||||
VILLAGER(120, ABSTRACT_AGEABLE),
|
||||
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE),
|
||||
CHICKEN(93, ABSTRACT_ANIMAL),
|
||||
COW(92, ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(96, COW),
|
||||
PIG(90, ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(102, ABSTRACT_ANIMAL),
|
||||
RABBIT(101, ABSTRACT_ANIMAL),
|
||||
SHEEP(91, ABSTRACT_ANIMAL),
|
||||
HORSE(100, ABSTRACT_ANIMAL),
|
||||
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL),
|
||||
OCELOT(98, TAMABLE_ANIMAL),
|
||||
WOLF(95, TAMABLE_ANIMAL),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(49, ABSTRACT_CREATURE),
|
||||
BLAZE(61, ABSTRACT_MONSTER),
|
||||
CREEPER(50, ABSTRACT_MONSTER),
|
||||
ENDERMITE(67, ABSTRACT_MONSTER),
|
||||
ENDERMAN(58, ABSTRACT_MONSTER),
|
||||
GIANT(53, ABSTRACT_MONSTER),
|
||||
SILVERFISH(60, ABSTRACT_MONSTER),
|
||||
WITCH(66, ABSTRACT_MONSTER),
|
||||
WITHER(64, ABSTRACT_MONSTER),
|
||||
SKELETON(51, ABSTRACT_MONSTER),
|
||||
ZOMBIE(54, ABSTRACT_MONSTER),
|
||||
ZOMBIE_PIGMEN(57, ZOMBIE),
|
||||
|
||||
GUARDIAN(68, ABSTRACT_MONSTER),
|
||||
SPIDER(52, ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(59, SPIDER);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
|
||||
private final int id;
|
||||
private final EntityType parent;
|
||||
|
||||
EntityType(int id) {
|
||||
this.id = id;
|
||||
EntityType() {
|
||||
this.id = -1;
|
||||
this.parent = null;
|
||||
}
|
||||
|
||||
EntityType(EntityType parent) {
|
||||
this.id = -1;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
EntityType(int id, EntityType parent) {
|
||||
this.id = id;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
TYPES.put(type.id, type);
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<EntityType> findById(int id) {
|
||||
if (id == -1) // Check if this is called
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(TYPES.get(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
@@ -179,16 +198,29 @@ public class EntityTypes1_10 {
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
TYPES.put(type.id, type);
|
||||
}
|
||||
}
|
||||
|
||||
public static EntityType findById(final int id) {
|
||||
if (id == -1) {
|
||||
return null;
|
||||
}
|
||||
return TYPES.get(id);
|
||||
}
|
||||
}
|
||||
|
||||
public enum ObjectType implements com.viaversion.viaversion.api.minecraft.entities.ObjectType {
|
||||
BOAT(1, EntityType.BOAT),
|
||||
ITEM(2, EntityType.DROPPED_ITEM),
|
||||
ITEM(2, EntityType.ITEM),
|
||||
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
|
||||
MINECART(10, EntityType.MINECART_RIDEABLE),
|
||||
TNT_PRIMED(50, EntityType.PRIMED_TNT),
|
||||
ENDER_CRYSTAL(51, EntityType.ENDER_CRYSTAL),
|
||||
TIPPED_ARROW(60, EntityType.TIPPED_ARROW),
|
||||
MINECART(10, EntityType.MINECART), // There are multiple types, but we don't need them
|
||||
TNT_PRIMED(50, EntityType.TNT),
|
||||
ENDER_CRYSTAL(51, EntityType.END_CRYSTAL),
|
||||
TIPPED_ARROW(60, EntityType.ARROW),
|
||||
SNOWBALL(61, EntityType.SNOWBALL),
|
||||
EGG(62, EntityType.EGG),
|
||||
FIREBALL(63, EntityType.FIREBALL),
|
||||
@@ -198,11 +230,11 @@ public class EntityTypes1_10 {
|
||||
SHULKER_BULLET(67, EntityType.SHULKER_BULLET),
|
||||
FALLING_BLOCK(70, EntityType.FALLING_BLOCK),
|
||||
ITEM_FRAME(71, EntityType.ITEM_FRAME),
|
||||
ENDER_SIGNAL(72, EntityType.ENDER_SIGNAL),
|
||||
POTION(73, EntityType.SPLASH_POTION),
|
||||
THROWN_EXP_BOTTLE(75, EntityType.THROWN_EXP_BOTTLE),
|
||||
FIREWORK(76, EntityType.FIREWORK),
|
||||
LEASH(77, EntityType.LEASH_HITCH),
|
||||
EYE_OF_ENDER(72, EntityType.EYE_OF_ENDER),
|
||||
POTION(73, EntityType.POTION),
|
||||
EXPERIENCE_BOTTLE(75, EntityType.EXPERIENCE_BOTTLE),
|
||||
FIREWORK_ROCKET(76, EntityType.FIREWORK_ROCKET),
|
||||
LEASH(77, EntityType.LEASH_KNOT),
|
||||
ARMOR_STAND(78, EntityType.ARMOR_STAND),
|
||||
FISHIHNG_HOOK(90, EntityType.FISHING_HOOK),
|
||||
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
||||
@@ -234,18 +266,16 @@ public class EntityTypes1_10 {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static Optional<ObjectType> findById(int id) {
|
||||
if (id == -1)
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(TYPES.get(id));
|
||||
public static ObjectType findById(final int id) {
|
||||
if (id == -1) {
|
||||
return null;
|
||||
}
|
||||
return TYPES.get(id);
|
||||
}
|
||||
|
||||
public static Optional<EntityType> getPCEntity(int id) {
|
||||
Optional<ObjectType> output = findById(id);
|
||||
|
||||
if (!output.isPresent())
|
||||
return Optional.empty();
|
||||
return Optional.of(output.get().type);
|
||||
public static EntityType getEntityType(final int id) {
|
||||
final ObjectType objectType = findById(id);
|
||||
return objectType != null ? objectType.type : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+156
-129
@@ -25,152 +25,180 @@ 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;
|
||||
|
||||
// 1.11 Entity / Object ids
|
||||
public class EntityTypes1_11 {
|
||||
|
||||
public static EntityType getTypeFromId(int typeID, boolean isObject) {
|
||||
Optional<EntityType> type;
|
||||
public static EntityType getTypeFromId(final int typeId, final boolean object) {
|
||||
EntityType type;
|
||||
|
||||
if (isObject)
|
||||
type = ObjectType.getPCEntity(typeID);
|
||||
else
|
||||
type = EntityType.findById(typeID);
|
||||
|
||||
if (!type.isPresent()) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.11 type id " + typeID + " isObject=" + isObject);
|
||||
if (object) {
|
||||
type = ObjectType.getEntityType(typeId);
|
||||
} else {
|
||||
type = EntityType.findById(typeId);
|
||||
}
|
||||
if (type == null) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.11 type id " + typeId + " objectType=" + object);
|
||||
return EntityType.ENTITY; // Fall back to the basic ENTITY
|
||||
}
|
||||
|
||||
return type.get();
|
||||
return type;
|
||||
}
|
||||
|
||||
public enum EntityType implements com.viaversion.viaversion.api.minecraft.entities.EntityType {
|
||||
ENTITY(-1),
|
||||
DROPPED_ITEM(1, ENTITY),
|
||||
|
||||
ENTITY,
|
||||
|
||||
AREA_EFFECT_CLOUD(3, ENTITY),
|
||||
END_CRYSTAL(200, ENTITY),
|
||||
EVOKER_FANGS(33, ENTITY),
|
||||
EXPERIENCE_ORB(2, ENTITY),
|
||||
LEASH_HITCH(8, ENTITY), // Actually entity hanging but it doesn't make a lot of difference for metadata
|
||||
PAINTING(9, ENTITY), // Actually entity hanging but it doesn't make a lot of difference for metadata
|
||||
ARROW(10, ENTITY),
|
||||
SNOWBALL(11, ENTITY), // Actually EntityProjectile
|
||||
FIREBALL(12, ENTITY),
|
||||
SMALL_FIREBALL(13, ENTITY),
|
||||
ENDER_PEARL(14, ENTITY), // Actually EntityProjectile
|
||||
ENDER_SIGNAL(15, ENTITY),
|
||||
THROWN_EXP_BOTTLE(17, ENTITY),
|
||||
ITEM_FRAME(18, ENTITY), // Actually EntityHanging
|
||||
WITHER_SKULL(19, ENTITY),
|
||||
PRIMED_TNT(20, ENTITY),
|
||||
EYE_OF_ENDER(15, ENTITY),
|
||||
FALLING_BLOCK(21, ENTITY),
|
||||
FIREWORK(22, ENTITY),
|
||||
SPECTRAL_ARROW(24, ARROW),
|
||||
ITEM(1, ENTITY),
|
||||
TNT(20, ENTITY),
|
||||
LIGHTNING_BOLT(ENTITY), // Needed for entity (un)tracking
|
||||
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY),
|
||||
LEASH_KNOT(8, HANGING_ENTITY),
|
||||
ITEM_FRAME(18, HANGING_ENTITY),
|
||||
PAINTING(9, HANGING_ENTITY),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE(ENTITY),
|
||||
FIREWORK_ROCKET(22, ENTITY),
|
||||
LLAMA_SPIT(104, ENTITY),
|
||||
SHULKER_BULLET(25, ENTITY),
|
||||
DRAGON_FIREBALL(26, FIREBALL),
|
||||
EVOCATION_FANGS(33, ENTITY),
|
||||
SNOWBALL(11, PROJECTILE),
|
||||
ENDER_PEARL(14, PROJECTILE),
|
||||
EGG(7, PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(17, PROJECTILE),
|
||||
POTION(16, PROJECTILE),
|
||||
FISHING_HOOK(ENTITY),
|
||||
|
||||
ABSTRACT_ARROW(ENTITY),
|
||||
ARROW(10, ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(24, ABSTRACT_ARROW),
|
||||
|
||||
ENTITY_LIVING(-1, ENTITY),
|
||||
ENTITY_INSENTIENT(-1, ENTITY_LIVING),
|
||||
ENTITY_AGEABLE(-1, ENTITY_INSENTIENT),
|
||||
ENTITY_TAMEABLE_ANIMAL(-1, ENTITY_AGEABLE),
|
||||
ENTITY_HUMAN(-1, ENTITY_LIVING),
|
||||
|
||||
ARMOR_STAND(30, ENTITY_LIVING),
|
||||
EVOCATION_ILLAGER(34, ENTITY_INSENTIENT),
|
||||
VEX(35, ENTITY_INSENTIENT),
|
||||
VINDICATION_ILLAGER(36, ENTITY_INSENTIENT),
|
||||
HURTING_PROJECTILE(ENTITY),
|
||||
DRAGON_FIREBALL(26, HURTING_PROJECTILE),
|
||||
FIREBALL(12, HURTING_PROJECTILE),
|
||||
SMALL_FIREBALL(13, HURTING_PROJECTILE),
|
||||
WITHER_SKULL(19, HURTING_PROJECTILE),
|
||||
|
||||
// Vehicles
|
||||
MINECART_ABSTRACT(-1, ENTITY),
|
||||
MINECART_COMMAND(40, MINECART_ABSTRACT),
|
||||
BOAT(41, ENTITY),
|
||||
MINECART_RIDEABLE(42, MINECART_ABSTRACT),
|
||||
MINECART_CHEST(43, MINECART_ABSTRACT),
|
||||
MINECART_FURNACE(44, MINECART_ABSTRACT),
|
||||
MINECART_TNT(45, MINECART_ABSTRACT),
|
||||
MINECART_HOPPER(46, MINECART_ABSTRACT),
|
||||
MINECART_MOB_SPAWNER(47, MINECART_ABSTRACT),
|
||||
|
||||
CREEPER(50, ENTITY_INSENTIENT),
|
||||
ABSTRACT_MINECART(ENTITY),
|
||||
MINECART(42, ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(44, ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(40, ABSTRACT_MINECART),
|
||||
TNT_MINECART(45, ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(47, ABSTRACT_MINECART),
|
||||
|
||||
ABSTRACT_SKELETON(-1, ENTITY_INSENTIENT),
|
||||
SKELETON(51, ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(5, ABSTRACT_SKELETON),
|
||||
STRAY(6, ABSTRACT_SKELETON),
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART),
|
||||
CHEST_MINECART(43, ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(46, ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
SPIDER(52, ENTITY_INSENTIENT),
|
||||
GIANT(53, ENTITY_INSENTIENT),
|
||||
LIVING_ENTITY_BASE(ENTITY),
|
||||
ARMOR_STAND(30, LIVING_ENTITY_BASE),
|
||||
PLAYER(LIVING_ENTITY_BASE), // Needed for entity (un)tracking
|
||||
|
||||
ZOMBIE(54, ENTITY_INSENTIENT),
|
||||
HUSK(23, ZOMBIE),
|
||||
ZOMBIE_VILLAGER(27, ZOMBIE),
|
||||
|
||||
SLIME(55, ENTITY_INSENTIENT),
|
||||
GHAST(56, ENTITY_INSENTIENT),
|
||||
PIG_ZOMBIE(57, ZOMBIE),
|
||||
ENDERMAN(58, ENTITY_INSENTIENT),
|
||||
CAVE_SPIDER(59, SPIDER),
|
||||
SILVERFISH(60, ENTITY_INSENTIENT),
|
||||
BLAZE(61, ENTITY_INSENTIENT),
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(LIVING_ENTITY_BASE),
|
||||
ENDER_DRAGON(63, LIVING_ENTITY),
|
||||
ABSTRACT_CREATURE(LIVING_ENTITY),
|
||||
SLIME(55, LIVING_ENTITY),
|
||||
MAGMA_CUBE(62, SLIME),
|
||||
ENDER_DRAGON(63, ENTITY_INSENTIENT),
|
||||
WITHER(64, ENTITY_INSENTIENT),
|
||||
BAT(65, ENTITY_INSENTIENT),
|
||||
WITCH(66, ENTITY_INSENTIENT),
|
||||
ENDERMITE(67, ENTITY_INSENTIENT),
|
||||
|
||||
GUARDIAN(68, ENTITY_INSENTIENT),
|
||||
ELDER_GUARDIAN(4, GUARDIAN), // Moved down to avoid illegal forward reference
|
||||
// Flying entities
|
||||
FLYING_MOB(LIVING_ENTITY),
|
||||
GHAST(56, FLYING_MOB),
|
||||
|
||||
IRON_GOLEM(99, ENTITY_INSENTIENT), // moved up to avoid illegal forward references
|
||||
SHULKER(69, IRON_GOLEM),
|
||||
PIG(90, ENTITY_AGEABLE),
|
||||
SHEEP(91, ENTITY_AGEABLE),
|
||||
COW(92, ENTITY_AGEABLE),
|
||||
CHICKEN(93, ENTITY_AGEABLE),
|
||||
SQUID(94, ENTITY_INSENTIENT),
|
||||
WOLF(95, ENTITY_TAMEABLE_ANIMAL),
|
||||
MUSHROOM_COW(96, COW),
|
||||
SNOWMAN(97, IRON_GOLEM),
|
||||
OCELOT(98, ENTITY_TAMEABLE_ANIMAL),
|
||||
AMBIENT_CREATURE(LIVING_ENTITY),
|
||||
BAT(65, AMBIENT_CREATURE),
|
||||
|
||||
ABSTRACT_HORSE(-1, ENTITY_AGEABLE),
|
||||
ABSTRACT_GOLEM(ABSTRACT_CREATURE),
|
||||
SNOW_GOLEM(97, ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(99, ABSTRACT_GOLEM),
|
||||
SHULKER(69, ABSTRACT_GOLEM),
|
||||
|
||||
WATER_ANIMAL(ABSTRACT_CREATURE),
|
||||
SQUID(94, WATER_ANIMAL),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(ABSTRACT_CREATURE),
|
||||
VILLAGER(120, ABSTRACT_AGEABLE),
|
||||
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE),
|
||||
CHICKEN(93, ABSTRACT_ANIMAL),
|
||||
COW(92, ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(96, COW),
|
||||
PIG(90, ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(102, ABSTRACT_ANIMAL),
|
||||
RABBIT(101, ABSTRACT_ANIMAL),
|
||||
SHEEP(91, ABSTRACT_ANIMAL),
|
||||
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL),
|
||||
OCELOT(98, TAMABLE_ANIMAL),
|
||||
WOLF(95, TAMABLE_ANIMAL),
|
||||
|
||||
// Horses
|
||||
ABSTRACT_HORSE(ABSTRACT_ANIMAL),
|
||||
HORSE(100, ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(28, ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(29, ABSTRACT_HORSE),
|
||||
|
||||
CHESTED_HORSE(-1, ABSTRACT_HORSE),
|
||||
CHESTED_HORSE(ABSTRACT_HORSE),
|
||||
DONKEY(31, CHESTED_HORSE),
|
||||
MULE(32, CHESTED_HORSE),
|
||||
LIAMA(103, CHESTED_HORSE),
|
||||
LLAMA(103, CHESTED_HORSE),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(ABSTRACT_CREATURE),
|
||||
BLAZE(61, ABSTRACT_MONSTER),
|
||||
CREEPER(50, ABSTRACT_MONSTER),
|
||||
ENDERMITE(67, ABSTRACT_MONSTER),
|
||||
ENDERMAN(58, ABSTRACT_MONSTER),
|
||||
GIANT(53, ABSTRACT_MONSTER),
|
||||
SILVERFISH(60, ABSTRACT_MONSTER),
|
||||
VEX(35, ABSTRACT_MONSTER),
|
||||
WITCH(66, ABSTRACT_MONSTER),
|
||||
WITHER(64, ABSTRACT_MONSTER),
|
||||
|
||||
RABBIT(101, ENTITY_AGEABLE),
|
||||
POLAR_BEAR(102, ENTITY_AGEABLE),
|
||||
VILLAGER(120, ENTITY_AGEABLE),
|
||||
ENDER_CRYSTAL(200, ENTITY),
|
||||
SPLASH_POTION(-1, ENTITY),
|
||||
LINGERING_POTION(-1, SPLASH_POTION),
|
||||
AREA_EFFECT_CLOUD(-1, ENTITY),
|
||||
EGG(-1, ENTITY),
|
||||
FISHING_HOOK(-1, ENTITY),
|
||||
LIGHTNING(-1, ENTITY),
|
||||
WEATHER(-1, ENTITY),
|
||||
PLAYER(-1, ENTITY_HUMAN),
|
||||
COMPLEX_PART(-1, ENTITY),
|
||||
LIAMA_SPIT(-1, ENTITY);
|
||||
ABSTRACT_SKELETON(ABSTRACT_MONSTER),
|
||||
SKELETON(51, ABSTRACT_SKELETON),
|
||||
STRAY(6, ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(5, ABSTRACT_SKELETON),
|
||||
|
||||
ZOMBIE(54, ABSTRACT_MONSTER),
|
||||
HUSK(23, ZOMBIE),
|
||||
ZOMBIE_PIGMEN(57, ZOMBIE),
|
||||
ZOMBIE_VILLAGER(27, ZOMBIE),
|
||||
|
||||
GUARDIAN(68, ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(4, GUARDIAN),
|
||||
SPIDER(52, ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(59, ABSTRACT_MONSTER),
|
||||
|
||||
// Illagers
|
||||
EVOKER(34, ABSTRACT_MONSTER),
|
||||
VINDICATOR(36, ABSTRACT_MONSTER);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
|
||||
private final int id;
|
||||
private final EntityType parent;
|
||||
|
||||
EntityType(int id) {
|
||||
this.id = id;
|
||||
EntityType() {
|
||||
this.id = -1;
|
||||
this.parent = null;
|
||||
}
|
||||
|
||||
EntityType(EntityType parent) {
|
||||
this.id = -1;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
EntityType(int id, EntityType parent) {
|
||||
this.id = id;
|
||||
this.parent = parent;
|
||||
@@ -202,20 +230,21 @@ public class EntityTypes1_11 {
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<EntityType> findById(int id) {
|
||||
if (id == -1) // Check if this is called
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(TYPES.get(id));
|
||||
public static EntityType findById(final int id) {
|
||||
if (id == -1) {
|
||||
return null;
|
||||
}
|
||||
return TYPES.get(id);
|
||||
}
|
||||
}
|
||||
|
||||
public enum ObjectType implements com.viaversion.viaversion.api.minecraft.entities.ObjectType {
|
||||
BOAT(1, EntityType.BOAT),
|
||||
ITEM(2, EntityType.DROPPED_ITEM),
|
||||
ITEM(2, EntityType.ITEM),
|
||||
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
|
||||
MINECART(10, EntityType.MINECART_RIDEABLE),
|
||||
TNT_PRIMED(50, EntityType.PRIMED_TNT),
|
||||
ENDER_CRYSTAL(51, EntityType.ENDER_CRYSTAL),
|
||||
MINECART(10, EntityType.MINECART), // There are multiple types, but we don't need them
|
||||
TNT_PRIMED(50, EntityType.TNT),
|
||||
ENDER_CRYSTAL(51, EntityType.END_CRYSTAL),
|
||||
TIPPED_ARROW(60, EntityType.ARROW),
|
||||
SNOWBALL(61, EntityType.SNOWBALL),
|
||||
EGG(62, EntityType.EGG),
|
||||
@@ -224,16 +253,16 @@ public class EntityTypes1_11 {
|
||||
ENDER_PEARL(65, EntityType.ENDER_PEARL),
|
||||
WITHER_SKULL(66, EntityType.WITHER_SKULL),
|
||||
SHULKER_BULLET(67, EntityType.SHULKER_BULLET),
|
||||
LIAMA_SPIT(68, EntityType.LIAMA_SPIT),
|
||||
LLAMA_SPIT(68, EntityType.LLAMA_SPIT),
|
||||
FALLING_BLOCK(70, EntityType.FALLING_BLOCK),
|
||||
ITEM_FRAME(71, EntityType.ITEM_FRAME),
|
||||
ENDER_SIGNAL(72, EntityType.ENDER_SIGNAL),
|
||||
POTION(73, EntityType.SPLASH_POTION),
|
||||
THROWN_EXP_BOTTLE(75, EntityType.THROWN_EXP_BOTTLE),
|
||||
FIREWORK(76, EntityType.FIREWORK),
|
||||
LEASH(77, EntityType.LEASH_HITCH),
|
||||
EYE_OF_ENDER(72, EntityType.EYE_OF_ENDER),
|
||||
POTION(73, EntityType.POTION),
|
||||
EXPERIENCE_BOTTLE(75, EntityType.EXPERIENCE_BOTTLE),
|
||||
FIREWORK_ROCKET(76, EntityType.FIREWORK_ROCKET),
|
||||
LEASH(77, EntityType.LEASH_KNOT),
|
||||
ARMOR_STAND(78, EntityType.ARMOR_STAND),
|
||||
EVOCATION_FANGS(79, EntityType.EVOCATION_FANGS),
|
||||
EVOKER_FANGS(79, EntityType.EVOKER_FANGS),
|
||||
FISHIHNG_HOOK(90, EntityType.FISHING_HOOK),
|
||||
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
||||
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
|
||||
@@ -264,18 +293,16 @@ public class EntityTypes1_11 {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static Optional<ObjectType> findById(int id) {
|
||||
if (id == -1)
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(TYPES.get(id));
|
||||
public static ObjectType findById(final int id) {
|
||||
if (id == -1) {
|
||||
return null;
|
||||
}
|
||||
return TYPES.get(id);
|
||||
}
|
||||
|
||||
public static Optional<EntityType> getPCEntity(int id) {
|
||||
Optional<ObjectType> output = findById(id);
|
||||
|
||||
if (!output.isPresent())
|
||||
return Optional.empty();
|
||||
return Optional.of(output.get().type);
|
||||
public static EntityType getEntityType(final int id) {
|
||||
final ObjectType objectType = findById(id);
|
||||
return objectType != null ? objectType.type : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+162
-133
@@ -20,161 +20,191 @@
|
||||
* 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.viaversion.viaversion.api.Via;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
// 1.12 Entity / Object taken from https://github.com/Matsv/ViaBackwards/blob/master/core/src/main/java/nl/matsv/viabackwards/api/entities/types/EntityType1_12.java
|
||||
public class EntityTypes1_12 {
|
||||
|
||||
public static EntityType getTypeFromId(int typeID, boolean isObject) {
|
||||
Optional<EntityType> type;
|
||||
public static EntityType getTypeFromId(final int typeId, final boolean object) {
|
||||
EntityType type;
|
||||
|
||||
if (isObject)
|
||||
type = ObjectType.getPCEntity(typeID);
|
||||
else
|
||||
type = EntityType.findById(typeID);
|
||||
|
||||
if (!type.isPresent()) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.12 type id " + typeID + " isObject=" + isObject);
|
||||
if (object) {
|
||||
type = ObjectType.getEntityType(typeId);
|
||||
} else {
|
||||
type = EntityType.findById(typeId);
|
||||
}
|
||||
if (type == null) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.12 type id " + typeId + " objectType=" + object);
|
||||
return EntityType.ENTITY; // Fall back to the basic ENTITY
|
||||
}
|
||||
|
||||
return type.get();
|
||||
return type;
|
||||
}
|
||||
|
||||
public enum EntityType implements com.viaversion.viaversion.api.minecraft.entities.EntityType {
|
||||
ENTITY(-1),
|
||||
DROPPED_ITEM(1, ENTITY),
|
||||
|
||||
ENTITY,
|
||||
|
||||
AREA_EFFECT_CLOUD(3, ENTITY),
|
||||
END_CRYSTAL(200, ENTITY),
|
||||
EVOKER_FANGS(33, ENTITY),
|
||||
EXPERIENCE_ORB(2, ENTITY),
|
||||
LEASH_HITCH(8, ENTITY), // Actually entity hanging but it doesn't make a lot of difference for metadata
|
||||
PAINTING(9, ENTITY), // Actually entity hanging but it doesn't make a lot of difference for metadata
|
||||
ARROW(10, ENTITY),
|
||||
SNOWBALL(11, ENTITY), // Actually EntityProjectile
|
||||
FIREBALL(12, ENTITY),
|
||||
SMALL_FIREBALL(13, ENTITY),
|
||||
ENDER_PEARL(14, ENTITY), // Actually EntityProjectile
|
||||
ENDER_SIGNAL(15, ENTITY),
|
||||
THROWN_EXP_BOTTLE(17, ENTITY),
|
||||
ITEM_FRAME(18, ENTITY), // Actually EntityHanging
|
||||
WITHER_SKULL(19, ENTITY),
|
||||
PRIMED_TNT(20, ENTITY),
|
||||
EYE_OF_ENDER(15, ENTITY),
|
||||
FALLING_BLOCK(21, ENTITY),
|
||||
FIREWORK(22, ENTITY),
|
||||
SPECTRAL_ARROW(24, ARROW),
|
||||
ITEM(1, ENTITY),
|
||||
TNT(20, ENTITY),
|
||||
LIGHTNING_BOLT(ENTITY), // Needed for entity (un)tracking
|
||||
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY),
|
||||
LEASH_KNOT(8, HANGING_ENTITY),
|
||||
ITEM_FRAME(18, HANGING_ENTITY),
|
||||
PAINTING(9, HANGING_ENTITY),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE(ENTITY),
|
||||
FIREWORK_ROCKET(22, ENTITY),
|
||||
LLAMA_SPIT(104, ENTITY),
|
||||
SHULKER_BULLET(25, ENTITY),
|
||||
DRAGON_FIREBALL(26, FIREBALL),
|
||||
EVOCATION_FANGS(33, ENTITY),
|
||||
SNOWBALL(11, PROJECTILE),
|
||||
ENDER_PEARL(14, PROJECTILE),
|
||||
EGG(7, PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(17, PROJECTILE),
|
||||
POTION(16, PROJECTILE),
|
||||
FISHING_HOOK(ENTITY),
|
||||
|
||||
ABSTRACT_ARROW(ENTITY),
|
||||
ARROW(10, ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(24, ABSTRACT_ARROW),
|
||||
|
||||
ENTITY_LIVING(-1, ENTITY),
|
||||
ENTITY_INSENTIENT(-1, ENTITY_LIVING),
|
||||
ENTITY_AGEABLE(-1, ENTITY_INSENTIENT),
|
||||
ENTITY_TAMEABLE_ANIMAL(-1, ENTITY_AGEABLE),
|
||||
ENTITY_HUMAN(-1, ENTITY_LIVING),
|
||||
|
||||
ARMOR_STAND(30, ENTITY_LIVING),
|
||||
ENTITY_ILLAGER_ABSTRACT(-1, ENTITY_INSENTIENT),
|
||||
EVOCATION_ILLAGER(34, ENTITY_ILLAGER_ABSTRACT),
|
||||
VEX(35, ENTITY_INSENTIENT),
|
||||
VINDICATION_ILLAGER(36, ENTITY_ILLAGER_ABSTRACT),
|
||||
ILLUSION_ILLAGER(37, EVOCATION_ILLAGER),
|
||||
HURTING_PROJECTILE(ENTITY),
|
||||
DRAGON_FIREBALL(26, HURTING_PROJECTILE),
|
||||
FIREBALL(12, HURTING_PROJECTILE),
|
||||
SMALL_FIREBALL(13, HURTING_PROJECTILE),
|
||||
WITHER_SKULL(19, HURTING_PROJECTILE),
|
||||
|
||||
// Vehicles
|
||||
MINECART_ABSTRACT(-1, ENTITY),
|
||||
MINECART_COMMAND(40, MINECART_ABSTRACT),
|
||||
BOAT(41, ENTITY),
|
||||
MINECART_RIDEABLE(42, MINECART_ABSTRACT),
|
||||
MINECART_CHEST(43, MINECART_ABSTRACT),
|
||||
MINECART_FURNACE(44, MINECART_ABSTRACT),
|
||||
MINECART_TNT(45, MINECART_ABSTRACT),
|
||||
MINECART_HOPPER(46, MINECART_ABSTRACT),
|
||||
MINECART_MOB_SPAWNER(47, MINECART_ABSTRACT),
|
||||
|
||||
CREEPER(50, ENTITY_INSENTIENT),
|
||||
ABSTRACT_MINECART(ENTITY),
|
||||
MINECART(42, ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(44, ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(40, ABSTRACT_MINECART),
|
||||
TNT_MINECART(45, ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(47, ABSTRACT_MINECART),
|
||||
|
||||
ABSTRACT_SKELETON(-1, ENTITY_INSENTIENT),
|
||||
SKELETON(51, ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(5, ABSTRACT_SKELETON),
|
||||
STRAY(6, ABSTRACT_SKELETON),
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART),
|
||||
CHEST_MINECART(43, ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(46, ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
SPIDER(52, ENTITY_INSENTIENT),
|
||||
GIANT(53, ENTITY_INSENTIENT),
|
||||
LIVING_ENTITY_BASE(ENTITY),
|
||||
ARMOR_STAND(30, LIVING_ENTITY_BASE),
|
||||
PLAYER(ENTITY), // Needed for entity (un)tracking
|
||||
|
||||
ZOMBIE(54, ENTITY_INSENTIENT),
|
||||
HUSK(23, ZOMBIE),
|
||||
ZOMBIE_VILLAGER(27, ZOMBIE),
|
||||
|
||||
SLIME(55, ENTITY_INSENTIENT),
|
||||
GHAST(56, ENTITY_INSENTIENT),
|
||||
PIG_ZOMBIE(57, ZOMBIE),
|
||||
ENDERMAN(58, ENTITY_INSENTIENT),
|
||||
CAVE_SPIDER(59, SPIDER),
|
||||
SILVERFISH(60, ENTITY_INSENTIENT),
|
||||
BLAZE(61, ENTITY_INSENTIENT),
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(LIVING_ENTITY_BASE),
|
||||
ENDER_DRAGON(63, LIVING_ENTITY),
|
||||
ABSTRACT_CREATURE(LIVING_ENTITY),
|
||||
SLIME(55, LIVING_ENTITY),
|
||||
MAGMA_CUBE(62, SLIME),
|
||||
ENDER_DRAGON(63, ENTITY_INSENTIENT),
|
||||
WITHER(64, ENTITY_INSENTIENT),
|
||||
BAT(65, ENTITY_INSENTIENT),
|
||||
WITCH(66, ENTITY_INSENTIENT),
|
||||
ENDERMITE(67, ENTITY_INSENTIENT),
|
||||
|
||||
GUARDIAN(68, ENTITY_INSENTIENT),
|
||||
ELDER_GUARDIAN(4, GUARDIAN), // Moved down to avoid illegal forward reference
|
||||
// Flying entities
|
||||
FLYING_MOB(LIVING_ENTITY),
|
||||
GHAST(56, FLYING_MOB),
|
||||
|
||||
IRON_GOLEM(99, ENTITY_INSENTIENT), // moved up to avoid illegal forward references
|
||||
SHULKER(69, IRON_GOLEM),
|
||||
PIG(90, ENTITY_AGEABLE),
|
||||
SHEEP(91, ENTITY_AGEABLE),
|
||||
COW(92, ENTITY_AGEABLE),
|
||||
CHICKEN(93, ENTITY_AGEABLE),
|
||||
SQUID(94, ENTITY_INSENTIENT),
|
||||
WOLF(95, ENTITY_TAMEABLE_ANIMAL),
|
||||
MUSHROOM_COW(96, COW),
|
||||
SNOWMAN(97, IRON_GOLEM),
|
||||
OCELOT(98, ENTITY_TAMEABLE_ANIMAL),
|
||||
PARROT(105, ENTITY_TAMEABLE_ANIMAL),
|
||||
AMBIENT_CREATURE(LIVING_ENTITY),
|
||||
BAT(65, AMBIENT_CREATURE),
|
||||
|
||||
ABSTRACT_HORSE(-1, ENTITY_AGEABLE),
|
||||
ABSTRACT_GOLEM(ABSTRACT_CREATURE),
|
||||
SNOW_GOLEM(97, ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(99, ABSTRACT_GOLEM),
|
||||
SHULKER(69, ABSTRACT_GOLEM),
|
||||
|
||||
WATER_ANIMAL(ABSTRACT_CREATURE),
|
||||
SQUID(94, WATER_ANIMAL),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(ABSTRACT_CREATURE),
|
||||
VILLAGER(120, ABSTRACT_AGEABLE),
|
||||
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE),
|
||||
CHICKEN(93, ABSTRACT_ANIMAL),
|
||||
COW(92, ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(96, COW),
|
||||
PIG(90, ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(102, ABSTRACT_ANIMAL),
|
||||
RABBIT(101, ABSTRACT_ANIMAL),
|
||||
SHEEP(91, ABSTRACT_ANIMAL),
|
||||
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL),
|
||||
OCELOT(98, TAMABLE_ANIMAL),
|
||||
WOLF(95, TAMABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_SHOULDER_RIDING(TAMABLE_ANIMAL),
|
||||
PARROT(105, ABSTRACT_SHOULDER_RIDING),
|
||||
|
||||
// Horses
|
||||
ABSTRACT_HORSE(ABSTRACT_ANIMAL),
|
||||
HORSE(100, ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(28, ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(29, ABSTRACT_HORSE),
|
||||
|
||||
CHESTED_HORSE(-1, ABSTRACT_HORSE),
|
||||
CHESTED_HORSE(ABSTRACT_HORSE),
|
||||
DONKEY(31, CHESTED_HORSE),
|
||||
MULE(32, CHESTED_HORSE),
|
||||
LIAMA(103, CHESTED_HORSE),
|
||||
LLAMA(103, CHESTED_HORSE),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(ABSTRACT_CREATURE),
|
||||
BLAZE(61, ABSTRACT_MONSTER),
|
||||
CREEPER(50, ABSTRACT_MONSTER),
|
||||
ENDERMITE(67, ABSTRACT_MONSTER),
|
||||
ENDERMAN(58, ABSTRACT_MONSTER),
|
||||
GIANT(53, ABSTRACT_MONSTER),
|
||||
SILVERFISH(60, ABSTRACT_MONSTER),
|
||||
VEX(35, ABSTRACT_MONSTER),
|
||||
WITCH(66, ABSTRACT_MONSTER),
|
||||
WITHER(64, ABSTRACT_MONSTER),
|
||||
|
||||
RABBIT(101, ENTITY_AGEABLE),
|
||||
POLAR_BEAR(102, ENTITY_AGEABLE),
|
||||
VILLAGER(120, ENTITY_AGEABLE),
|
||||
ENDER_CRYSTAL(200, ENTITY),
|
||||
SPLASH_POTION(-1, ENTITY),
|
||||
LINGERING_POTION(-1, SPLASH_POTION),
|
||||
AREA_EFFECT_CLOUD(-1, ENTITY),
|
||||
EGG(-1, ENTITY),
|
||||
FISHING_HOOK(-1, ENTITY),
|
||||
LIGHTNING(-1, ENTITY),
|
||||
WEATHER(-1, ENTITY),
|
||||
PLAYER(-1, ENTITY_HUMAN),
|
||||
COMPLEX_PART(-1, ENTITY),
|
||||
LIAMA_SPIT(-1, ENTITY);
|
||||
ABSTRACT_SKELETON(ABSTRACT_MONSTER),
|
||||
SKELETON(51, ABSTRACT_SKELETON),
|
||||
STRAY(6, ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(5, ABSTRACT_SKELETON),
|
||||
|
||||
ZOMBIE(54, ABSTRACT_MONSTER),
|
||||
HUSK(23, ZOMBIE),
|
||||
ZOMBIE_PIGMEN(57, ZOMBIE),
|
||||
ZOMBIE_VILLAGER(27, ZOMBIE),
|
||||
|
||||
GUARDIAN(68, ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(4, GUARDIAN),
|
||||
SPIDER(52, ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(59, ABSTRACT_MONSTER),
|
||||
|
||||
// Illagers
|
||||
ABSTRACT_ILLAGER(ABSTRACT_MONSTER),
|
||||
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER),
|
||||
VINDICATOR(36, ABSTRACT_ILLAGER),
|
||||
EVOKER(34, SPELLCASTER_ILLAGER),
|
||||
ILLUSIONER(37, SPELLCASTER_ILLAGER);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
|
||||
private final int id;
|
||||
private final EntityType parent;
|
||||
|
||||
EntityType(int id) {
|
||||
this.id = id;
|
||||
EntityType() {
|
||||
this.id = -1;
|
||||
this.parent = null;
|
||||
}
|
||||
|
||||
EntityType(EntityType parent) {
|
||||
this.id = -1;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
EntityType(int id, EntityType parent) {
|
||||
this.id = id;
|
||||
this.parent = parent;
|
||||
@@ -206,20 +236,21 @@ public class EntityTypes1_12 {
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<EntityType> findById(int id) {
|
||||
if (id == -1) // Check if this is called
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(TYPES.get(id));
|
||||
public static EntityType findById(final int id) {
|
||||
if (id == -1) {
|
||||
return null;
|
||||
}
|
||||
return TYPES.get(id);
|
||||
}
|
||||
}
|
||||
|
||||
public enum ObjectType implements com.viaversion.viaversion.api.minecraft.entities.ObjectType {
|
||||
BOAT(1, EntityType.BOAT),
|
||||
ITEM(2, EntityType.DROPPED_ITEM),
|
||||
ITEM(2, EntityType.ITEM),
|
||||
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
|
||||
MINECART(10, EntityType.MINECART_RIDEABLE),
|
||||
TNT_PRIMED(50, EntityType.PRIMED_TNT),
|
||||
ENDER_CRYSTAL(51, EntityType.ENDER_CRYSTAL),
|
||||
MINECART(10, EntityType.MINECART), // There are multiple types, but we don't need them
|
||||
TNT_PRIMED(50, EntityType.TNT),
|
||||
ENDER_CRYSTAL(51, EntityType.END_CRYSTAL),
|
||||
TIPPED_ARROW(60, EntityType.ARROW),
|
||||
SNOWBALL(61, EntityType.SNOWBALL),
|
||||
EGG(62, EntityType.EGG),
|
||||
@@ -228,16 +259,16 @@ public class EntityTypes1_12 {
|
||||
ENDER_PEARL(65, EntityType.ENDER_PEARL),
|
||||
WITHER_SKULL(66, EntityType.WITHER_SKULL),
|
||||
SHULKER_BULLET(67, EntityType.SHULKER_BULLET),
|
||||
LIAMA_SPIT(68, EntityType.LIAMA_SPIT),
|
||||
LLAMA_SPIT(68, EntityType.LLAMA_SPIT),
|
||||
FALLING_BLOCK(70, EntityType.FALLING_BLOCK),
|
||||
ITEM_FRAME(71, EntityType.ITEM_FRAME),
|
||||
ENDER_SIGNAL(72, EntityType.ENDER_SIGNAL),
|
||||
POTION(73, EntityType.SPLASH_POTION),
|
||||
THROWN_EXP_BOTTLE(75, EntityType.THROWN_EXP_BOTTLE),
|
||||
FIREWORK(76, EntityType.FIREWORK),
|
||||
LEASH(77, EntityType.LEASH_HITCH),
|
||||
EYE_OF_ENDER(72, EntityType.EYE_OF_ENDER),
|
||||
POTION(73, EntityType.POTION),
|
||||
EXPERIENCE_BOTTLE(75, EntityType.EXPERIENCE_BOTTLE),
|
||||
FIREWORK_ROCKET(76, EntityType.FIREWORK_ROCKET),
|
||||
LEASH(77, EntityType.LEASH_KNOT),
|
||||
ARMOR_STAND(78, EntityType.ARMOR_STAND),
|
||||
EVOCATION_FANGS(79, EntityType.EVOCATION_FANGS),
|
||||
EVOKER_FANGS(79, EntityType.EVOKER_FANGS),
|
||||
FISHIHNG_HOOK(90, EntityType.FISHING_HOOK),
|
||||
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
||||
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
|
||||
@@ -268,18 +299,16 @@ public class EntityTypes1_12 {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static Optional<ObjectType> findById(int id) {
|
||||
if (id == -1)
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(TYPES.get(id));
|
||||
public static ObjectType findById(final int id) {
|
||||
if (id == -1) {
|
||||
return null;
|
||||
}
|
||||
return TYPES.get(id);
|
||||
}
|
||||
|
||||
public static Optional<EntityType> getPCEntity(int id) {
|
||||
Optional<ObjectType> output = findById(id);
|
||||
|
||||
if (!output.isPresent())
|
||||
return Optional.empty();
|
||||
return Optional.of(output.get().type);
|
||||
public static EntityType getEntityType(final int id) {
|
||||
final ObjectType objectType = findById(id);
|
||||
return objectType != null ? objectType.type : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+180
-195
@@ -25,205 +25,197 @@ 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;
|
||||
|
||||
public class EntityTypes1_13 {
|
||||
|
||||
public static EntityType getTypeFromId(int typeID, boolean isObject) {
|
||||
Optional<EntityType> type;
|
||||
public static EntityType getTypeFromId(final int typeId, final boolean object) {
|
||||
EntityType type;
|
||||
|
||||
if (isObject)
|
||||
type = ObjectType.getPCEntity(typeID);
|
||||
else
|
||||
type = EntityType.findById(typeID);
|
||||
|
||||
if (!type.isPresent()) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.13 type id " + typeID + " isObject=" + isObject);
|
||||
if (object) {
|
||||
type = ObjectType.getEntityType(typeId);
|
||||
} else {
|
||||
type = EntityType.findById(typeId);
|
||||
}
|
||||
if (type == null) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.13 type id " + typeId + " objectType=" + object);
|
||||
return EntityType.ENTITY; // Fall back to the basic ENTITY
|
||||
}
|
||||
|
||||
return type.get();
|
||||
return type;
|
||||
}
|
||||
|
||||
public enum EntityType implements com.viaversion.viaversion.api.minecraft.entities.EntityType {
|
||||
// Auto generated
|
||||
|
||||
ENTITY(-1), // abm
|
||||
ENTITY,
|
||||
|
||||
AREA_EFFECT_CLOUD(0, ENTITY), // abk
|
||||
END_CRYSTAL(16, ENTITY), // aho
|
||||
EVOKER_FANGS(20, ENTITY), // ala
|
||||
EXPERIENCE_ORB(22, ENTITY), // abs
|
||||
EYE_OF_ENDER(23, ENTITY), // alb
|
||||
FALLING_BLOCK(24, ENTITY), // aix
|
||||
FIREWORK_ROCKET(25, ENTITY), // alc
|
||||
ITEM(32, ENTITY), // aiy
|
||||
LLAMA_SPIT(37, ENTITY), // ale
|
||||
TNT(55, ENTITY), // aiz
|
||||
SHULKER_BULLET(60, ENTITY), // alh
|
||||
FISHING_BOBBER(93, ENTITY), // ais
|
||||
AREA_EFFECT_CLOUD(0, ENTITY),
|
||||
END_CRYSTAL(16, ENTITY),
|
||||
EVOKER_FANGS(20, ENTITY),
|
||||
EXPERIENCE_ORB(22, ENTITY),
|
||||
EYE_OF_ENDER(23, ENTITY),
|
||||
FALLING_BLOCK(24, ENTITY),
|
||||
ITEM(32, ENTITY),
|
||||
TNT(55, ENTITY),
|
||||
LIGHTNING_BOLT(91, ENTITY), // Weather effect entity
|
||||
|
||||
LIVINGENTITY(-1, ENTITY), // abv
|
||||
ARMOR_STAND(1, LIVINGENTITY), // ail
|
||||
PLAYER(92, LIVINGENTITY), // aks
|
||||
|
||||
ABSTRACT_INSENTIENT(-1, LIVINGENTITY), // abw
|
||||
ENDER_DRAGON(17, ABSTRACT_INSENTIENT), // ahp
|
||||
|
||||
ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT), // acd
|
||||
|
||||
ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE), // abj
|
||||
VILLAGER(79, ABSTRACT_AGEABLE), // akn
|
||||
|
||||
// Animals
|
||||
ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE), // agd
|
||||
CHICKEN(7, ABSTRACT_ANIMAL), // age
|
||||
COW(9, ABSTRACT_ANIMAL), // agg
|
||||
MOOSHROOM(47, COW), // agi
|
||||
PIG(51, ABSTRACT_ANIMAL), // agl
|
||||
POLAR_BEAR(54, ABSTRACT_ANIMAL), // agm
|
||||
RABBIT(56, ABSTRACT_ANIMAL), // ago
|
||||
SHEEP(58, ABSTRACT_ANIMAL), // agq
|
||||
TURTLE(73, ABSTRACT_ANIMAL), // agv
|
||||
|
||||
ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL), // acg
|
||||
OCELOT(48, ABSTRACT_TAMEABLE_ANIMAL), // agj
|
||||
WOLF(86, ABSTRACT_TAMEABLE_ANIMAL), // agy
|
||||
|
||||
ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL), // agr
|
||||
PARROT(50, ABSTRACT_PARROT), // agk
|
||||
|
||||
// Horses
|
||||
ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL), // aha
|
||||
CHESTED_HORSE(-1, ABSTRACT_HORSE), // agz
|
||||
DONKEY(11, CHESTED_HORSE), // ahb
|
||||
MULE(46, CHESTED_HORSE), // ahf
|
||||
LLAMA(36, CHESTED_HORSE), // ahe
|
||||
HORSE(29, ABSTRACT_HORSE), // ahc
|
||||
SKELETON_HORSE(63, ABSTRACT_HORSE), // ahg
|
||||
ZOMBIE_HORSE(88, ABSTRACT_HORSE), // ahi
|
||||
|
||||
// Golem
|
||||
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE), // agc
|
||||
SNOW_GOLEM(66, ABSTRACT_GOLEM), // ags
|
||||
IRON_GOLEM(80, ABSTRACT_GOLEM), // agw
|
||||
SHULKER(59, ABSTRACT_GOLEM), // ajx
|
||||
|
||||
// Fish
|
||||
ABSTRACT_FISHES(-1, ABSTRACT_CREATURE), // agb
|
||||
COD(8, ABSTRACT_FISHES), // agf
|
||||
PUFFERFISH(52, ABSTRACT_FISHES), // agn
|
||||
SALMON(57, ABSTRACT_FISHES), // agp
|
||||
TROPICAL_FISH(72, ABSTRACT_FISHES), // agu
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE), // ajs
|
||||
BLAZE(4, ABSTRACT_MONSTER), // ajd
|
||||
CREEPER(10, ABSTRACT_MONSTER), // ajf
|
||||
ENDERMITE(19, ABSTRACT_MONSTER), // ajj
|
||||
ENDERMAN(18, ABSTRACT_MONSTER), // aji
|
||||
GIANT(27, ABSTRACT_MONSTER), // ajn
|
||||
SILVERFISH(61, ABSTRACT_MONSTER), // ajy
|
||||
VEX(78, ABSTRACT_MONSTER), // ake
|
||||
WITCH(82, ABSTRACT_MONSTER), // akg
|
||||
WITHER(83, ABSTRACT_MONSTER), // aij
|
||||
|
||||
// Illagers
|
||||
ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER), // ajb
|
||||
ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE), // akb
|
||||
EVOKER(21, ABSTRACT_EVO_ILLU_ILLAGER), // ajl
|
||||
ILLUSIONER(31, ABSTRACT_EVO_ILLU_ILLAGER), // ajq
|
||||
VINDICATOR(81, ABSTRACT_ILLAGER_BASE), // akf
|
||||
|
||||
// Skeletons
|
||||
ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER), // ajc
|
||||
SKELETON(62, ABSTRACT_SKELETON), // ajz
|
||||
STRAY(71, ABSTRACT_SKELETON), // akd
|
||||
WITHER_SKELETON(84, ABSTRACT_SKELETON), // akh
|
||||
|
||||
// Guardians
|
||||
GUARDIAN(28, ABSTRACT_MONSTER), // ajo
|
||||
ELDER_GUARDIAN(15, GUARDIAN), // ajh
|
||||
|
||||
// Spiders
|
||||
SPIDER(69, ABSTRACT_MONSTER), // akc
|
||||
CAVE_SPIDER(6, SPIDER), // aje
|
||||
|
||||
// Zombies - META CHECKED
|
||||
ZOMBIE(87, ABSTRACT_MONSTER), // aki
|
||||
DROWNED(14, ZOMBIE), // ajg
|
||||
HUSK(30, ZOMBIE), // ajp
|
||||
ZOMBIE_PIGMAN(53, ZOMBIE), // aju
|
||||
ZOMBIE_VILLAGER(89, ZOMBIE), // akj
|
||||
|
||||
// Flying entities
|
||||
ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT), // abt
|
||||
GHAST(26, ABSTRACT_FLYING), // ajm
|
||||
PHANTOM(90, ABSTRACT_FLYING), // ajt
|
||||
|
||||
ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT), // afy
|
||||
BAT(3, ABSTRACT_AMBIENT), // afz
|
||||
|
||||
ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT), // agx
|
||||
SQUID(70, ABSTRACT_WATERMOB), // agt
|
||||
DOLPHIN(12, ABSTRACT_WATERMOB),
|
||||
|
||||
// Slimes
|
||||
SLIME(64, ABSTRACT_INSENTIENT), // aka
|
||||
MAGMA_CUBE(38, SLIME), // ajr
|
||||
|
||||
// Hangable objects
|
||||
ABSTRACT_HANGING(-1, ENTITY), // aim
|
||||
LEASH_KNOT(35, ABSTRACT_HANGING), // aio
|
||||
ITEM_FRAME(33, ABSTRACT_HANGING), // ain
|
||||
PAINTING(49, ABSTRACT_HANGING), // aiq
|
||||
|
||||
ABSTRACT_LIGHTNING(-1, ENTITY), // aiu
|
||||
LIGHTNING_BOLT(91, ABSTRACT_LIGHTNING), // aiv
|
||||
|
||||
// Arrows
|
||||
ABSTRACT_ARROW(-1, ENTITY), // akw
|
||||
ARROW(2, ABSTRACT_ARROW), // aky
|
||||
SPECTRAL_ARROW(68, ABSTRACT_ARROW), // alk
|
||||
TRIDENT(94, ABSTRACT_ARROW), // alq
|
||||
|
||||
// Fireballs
|
||||
ABSTRACT_FIREBALL(-1, ENTITY), // akx
|
||||
DRAGON_FIREBALL(13, ABSTRACT_FIREBALL), // akz
|
||||
FIREBALL(34, ABSTRACT_FIREBALL), // ald
|
||||
SMALL_FIREBALL(65, ABSTRACT_FIREBALL), // ali
|
||||
WITHER_SKULL(85, ABSTRACT_FIREBALL), // alr
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY),
|
||||
LEASH_KNOT(35, HANGING_ENTITY),
|
||||
ITEM_FRAME(33, HANGING_ENTITY),
|
||||
PAINTING(49, HANGING_ENTITY),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE_ABSTRACT(-1, ENTITY), // all
|
||||
SNOWBALL(67, PROJECTILE_ABSTRACT), // alj
|
||||
ENDER_PEARL(75, PROJECTILE_ABSTRACT), // aln
|
||||
EGG(74, PROJECTILE_ABSTRACT), // alm
|
||||
POTION(77, PROJECTILE_ABSTRACT), // alp
|
||||
EXPERIENCE_BOTTLE(76, PROJECTILE_ABSTRACT), // alo
|
||||
PROJECTILE(ENTITY),
|
||||
FIREWORK_ROCKET(25, ENTITY),
|
||||
LLAMA_SPIT(37, ENTITY),
|
||||
SHULKER_BULLET(60, ENTITY),
|
||||
SNOWBALL(67, PROJECTILE),
|
||||
ENDER_PEARL(75, PROJECTILE),
|
||||
EGG(74, PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(76, PROJECTILE),
|
||||
POTION(77, PROJECTILE),
|
||||
FISHING_BOBBER(93, ENTITY),
|
||||
|
||||
ABSTRACT_ARROW(ENTITY),
|
||||
ARROW(2, ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(68, ABSTRACT_ARROW),
|
||||
TRIDENT(94, ABSTRACT_ARROW),
|
||||
|
||||
HURTING_PROJECTILE(ENTITY),
|
||||
DRAGON_FIREBALL(13, HURTING_PROJECTILE),
|
||||
FIREBALL(34, HURTING_PROJECTILE),
|
||||
SMALL_FIREBALL(65, HURTING_PROJECTILE),
|
||||
WITHER_SKULL(85, HURTING_PROJECTILE),
|
||||
|
||||
// Vehicles
|
||||
MINECART_ABSTRACT(-1, ENTITY), // alt
|
||||
CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT), // alu
|
||||
CHEST_MINECART(40, CHESTED_MINECART_ABSTRACT), // alx
|
||||
HOPPER_MINECART(43, CHESTED_MINECART_ABSTRACT), // ama
|
||||
MINECART(39, MINECART_ABSTRACT), // alw
|
||||
FURNACE_MINECART(42, MINECART_ABSTRACT), // alz
|
||||
COMMAND_BLOCK_MINECART(41, MINECART_ABSTRACT), // aly
|
||||
TNT_MINECART(45, MINECART_ABSTRACT), // amc
|
||||
SPAWNER_MINECART(44, MINECART_ABSTRACT), // amb
|
||||
BOAT(5, ENTITY); // alv
|
||||
BOAT(5, ENTITY),
|
||||
|
||||
ABSTRACT_MINECART(ENTITY),
|
||||
MINECART(39, ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(42, ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(41, ABSTRACT_MINECART),
|
||||
TNT_MINECART(45, ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(44, ABSTRACT_MINECART),
|
||||
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART),
|
||||
CHEST_MINECART(40, ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(43, ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
LIVING_ENTITY_BASE(ENTITY),
|
||||
ARMOR_STAND(1, LIVING_ENTITY_BASE),
|
||||
PLAYER(92, LIVING_ENTITY_BASE),
|
||||
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(LIVING_ENTITY_BASE),
|
||||
ENDER_DRAGON(17, LIVING_ENTITY),
|
||||
ABSTRACT_CREATURE(LIVING_ENTITY),
|
||||
SLIME(64, LIVING_ENTITY),
|
||||
MAGMA_CUBE(38, SLIME),
|
||||
|
||||
// Flying entities
|
||||
FLYING_MOB(ABSTRACT_CREATURE),
|
||||
GHAST(26, FLYING_MOB),
|
||||
PHANTOM(90, FLYING_MOB),
|
||||
|
||||
AMBIENT_CREATURE(-1, LIVING_ENTITY),
|
||||
BAT(3, AMBIENT_CREATURE),
|
||||
|
||||
ABSTRACT_GOLEM(ABSTRACT_CREATURE),
|
||||
SNOW_GOLEM(66, ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(80, ABSTRACT_GOLEM),
|
||||
SHULKER(59, ABSTRACT_GOLEM),
|
||||
|
||||
WATER_ANIMAL(ABSTRACT_CREATURE),
|
||||
SQUID(70, WATER_ANIMAL),
|
||||
DOLPHIN(12, WATER_ANIMAL),
|
||||
|
||||
ABSTRACT_FISH(WATER_ANIMAL),
|
||||
COD(8, ABSTRACT_FISH),
|
||||
PUFFERFISH(52, ABSTRACT_FISH),
|
||||
SALMON(57, ABSTRACT_FISH),
|
||||
TROPICAL_FISH(72, ABSTRACT_FISH),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(ABSTRACT_CREATURE),
|
||||
VILLAGER(79, ABSTRACT_AGEABLE),
|
||||
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE),
|
||||
CHICKEN(7, ABSTRACT_ANIMAL),
|
||||
COW(9, ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(47, COW),
|
||||
PIG(51, ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(54, ABSTRACT_ANIMAL),
|
||||
RABBIT(56, ABSTRACT_ANIMAL),
|
||||
SHEEP(58, ABSTRACT_ANIMAL),
|
||||
TURTLE(73, ABSTRACT_ANIMAL),
|
||||
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL),
|
||||
OCELOT(48, TAMABLE_ANIMAL),
|
||||
WOLF(86, TAMABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_SHOULDER_RIDING(TAMABLE_ANIMAL),
|
||||
PARROT(50, ABSTRACT_SHOULDER_RIDING),
|
||||
|
||||
// Horses
|
||||
ABSTRACT_HORSE(ABSTRACT_ANIMAL),
|
||||
HORSE(29, ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(63, ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(88, ABSTRACT_HORSE),
|
||||
|
||||
CHESTED_HORSE(ABSTRACT_HORSE),
|
||||
DONKEY(11, CHESTED_HORSE),
|
||||
MULE(46, CHESTED_HORSE),
|
||||
LLAMA(36, CHESTED_HORSE),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(ABSTRACT_CREATURE),
|
||||
BLAZE(4, ABSTRACT_MONSTER),
|
||||
CREEPER(10, ABSTRACT_MONSTER),
|
||||
ENDERMITE(19, ABSTRACT_MONSTER),
|
||||
ENDERMAN(18, ABSTRACT_MONSTER),
|
||||
GIANT(27, ABSTRACT_MONSTER),
|
||||
SILVERFISH(61, ABSTRACT_MONSTER),
|
||||
VEX(78, ABSTRACT_MONSTER),
|
||||
WITCH(82, ABSTRACT_MONSTER),
|
||||
WITHER(83, ABSTRACT_MONSTER),
|
||||
|
||||
ABSTRACT_SKELETON(ABSTRACT_MONSTER),
|
||||
SKELETON(62, ABSTRACT_SKELETON),
|
||||
STRAY(71, ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(84, ABSTRACT_SKELETON),
|
||||
|
||||
ZOMBIE(87, ABSTRACT_MONSTER),
|
||||
DROWNED(14, ZOMBIE),
|
||||
HUSK(30, ZOMBIE),
|
||||
ZOMBIE_PIGMAN(53, ZOMBIE),
|
||||
ZOMBIE_VILLAGER(89, ZOMBIE),
|
||||
|
||||
GUARDIAN(28, ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(15, GUARDIAN),
|
||||
SPIDER(69, ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(6, SPIDER),
|
||||
|
||||
// Illagers
|
||||
ABSTRACT_ILLAGER(ABSTRACT_MONSTER),
|
||||
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER),
|
||||
VINDICATOR(81, ABSTRACT_ILLAGER),
|
||||
EVOKER(21, SPELLCASTER_ILLAGER),
|
||||
ILLUSIONER(31, SPELLCASTER_ILLAGER);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
|
||||
private final int id;
|
||||
private final EntityType parent;
|
||||
|
||||
EntityType(int id) {
|
||||
this.id = id;
|
||||
EntityType() {
|
||||
this.id = -1;
|
||||
this.parent = null;
|
||||
}
|
||||
|
||||
EntityType(EntityType parent) {
|
||||
this.id = -1;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
EntityType(int id, EntityType parent) {
|
||||
this.id = id;
|
||||
this.parent = parent;
|
||||
@@ -255,10 +247,11 @@ public class EntityTypes1_13 {
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<EntityType> findById(int id) {
|
||||
if (id == -1) // Check if this is called
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(TYPES.get(id));
|
||||
public static EntityType findById(final int id) {
|
||||
if (id == -1) {
|
||||
return null;
|
||||
}
|
||||
return TYPES.get(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +259,7 @@ public class EntityTypes1_13 {
|
||||
BOAT(1, EntityType.BOAT),
|
||||
ITEM(2, EntityType.ITEM),
|
||||
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
|
||||
MINECART(10, EntityType.MINECART),
|
||||
MINECART(10, EntityType.MINECART), // There are multiple types, but we don't need them
|
||||
TNT_PRIMED(50, EntityType.TNT),
|
||||
ENDER_CRYSTAL(51, EntityType.END_CRYSTAL),
|
||||
TIPPED_ARROW(60, EntityType.ARROW),
|
||||
@@ -318,24 +311,16 @@ public class EntityTypes1_13 {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static Optional<ObjectType> findById(int id) {
|
||||
if (id == -1)
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(TYPES.get(id));
|
||||
public static ObjectType findById(final int id) {
|
||||
if (id == -1) {
|
||||
return null;
|
||||
}
|
||||
return TYPES.get(id);
|
||||
}
|
||||
|
||||
public static Optional<EntityType> getPCEntity(int id) {
|
||||
Optional<ObjectType> output = findById(id);
|
||||
if (!output.isPresent())
|
||||
return Optional.empty();
|
||||
return Optional.of(output.get().type);
|
||||
}
|
||||
|
||||
public static Optional<ObjectType> fromEntityType(EntityType type) {
|
||||
for (ObjectType ent : ObjectType.values())
|
||||
if (ent.type == type)
|
||||
return Optional.of(ent);
|
||||
return Optional.empty();
|
||||
public static EntityType getEntityType(final int id) {
|
||||
final ObjectType objectType = findById(id);
|
||||
return objectType != null ? objectType.type : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+195
-185
@@ -22,223 +22,233 @@
|
||||
*/
|
||||
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 com.viaversion.viaversion.util.Key;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum EntityTypes1_14 implements EntityType {
|
||||
|
||||
ENTITY(-1),
|
||||
ENTITY(null, null),
|
||||
|
||||
AREA_EFFECT_CLOUD(0, ENTITY),
|
||||
END_CRYSTAL(17, ENTITY),
|
||||
EVOKER_FANGS(21, ENTITY),
|
||||
EXPERIENCE_ORB(23, ENTITY),
|
||||
EYE_OF_ENDER(24, ENTITY),
|
||||
FALLING_BLOCK(25, ENTITY),
|
||||
FIREWORK_ROCKET(26, ENTITY),
|
||||
ITEM(34, ENTITY),
|
||||
LLAMA_SPIT(39, ENTITY),
|
||||
TNT(58, ENTITY),
|
||||
SHULKER_BULLET(63, ENTITY),
|
||||
FISHING_BOBBER(101, ENTITY),
|
||||
AREA_EFFECT_CLOUD(ENTITY),
|
||||
END_CRYSTAL(ENTITY),
|
||||
EVOKER_FANGS(ENTITY),
|
||||
EXPERIENCE_ORB(ENTITY),
|
||||
EYE_OF_ENDER(ENTITY),
|
||||
FALLING_BLOCK(ENTITY),
|
||||
ITEM(ENTITY),
|
||||
TNT(ENTITY),
|
||||
LIGHTNING_BOLT(ENTITY),
|
||||
|
||||
LIVINGENTITY(-1, ENTITY),
|
||||
ARMOR_STAND(1, LIVINGENTITY),
|
||||
PLAYER(100, LIVINGENTITY),
|
||||
|
||||
ABSTRACT_INSENTIENT(-1, LIVINGENTITY),
|
||||
ENDER_DRAGON(18, ABSTRACT_INSENTIENT),
|
||||
|
||||
ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT),
|
||||
|
||||
ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE),
|
||||
VILLAGER(84, ABSTRACT_AGEABLE),
|
||||
WANDERING_TRADER(88, ABSTRACT_AGEABLE),
|
||||
|
||||
// Animals
|
||||
ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE),
|
||||
DOLPHIN(13, ABSTRACT_INSENTIENT),
|
||||
CHICKEN(8, ABSTRACT_ANIMAL),
|
||||
COW(10, ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(49, COW),
|
||||
PANDA(52, ABSTRACT_INSENTIENT),
|
||||
PIG(54, ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(57, ABSTRACT_ANIMAL),
|
||||
RABBIT(59, ABSTRACT_ANIMAL),
|
||||
SHEEP(61, ABSTRACT_ANIMAL),
|
||||
TURTLE(77, ABSTRACT_ANIMAL),
|
||||
FOX(27, ABSTRACT_ANIMAL),
|
||||
|
||||
ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL),
|
||||
CAT(6, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
OCELOT(50, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
WOLF(93, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
PARROT(53, ABSTRACT_PARROT),
|
||||
|
||||
// Horses
|
||||
ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL),
|
||||
CHESTED_HORSE(-1, ABSTRACT_HORSE),
|
||||
DONKEY(12, CHESTED_HORSE),
|
||||
MULE(48, CHESTED_HORSE),
|
||||
LLAMA(38, CHESTED_HORSE),
|
||||
TRADER_LLAMA(75, CHESTED_HORSE),
|
||||
HORSE(31, ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(66, ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(95, ABSTRACT_HORSE),
|
||||
|
||||
// Golem
|
||||
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE),
|
||||
SNOW_GOLEM(69, ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(85, ABSTRACT_GOLEM),
|
||||
SHULKER(62, ABSTRACT_GOLEM),
|
||||
|
||||
// Fish
|
||||
ABSTRACT_FISHES(-1, ABSTRACT_CREATURE),
|
||||
COD(9, ABSTRACT_FISHES),
|
||||
PUFFERFISH(55, ABSTRACT_FISHES),
|
||||
SALMON(60, ABSTRACT_FISHES),
|
||||
TROPICAL_FISH(76, ABSTRACT_FISHES),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE),
|
||||
BLAZE(4, ABSTRACT_MONSTER),
|
||||
CREEPER(11, ABSTRACT_MONSTER),
|
||||
ENDERMITE(20, ABSTRACT_MONSTER),
|
||||
ENDERMAN(19, ABSTRACT_MONSTER),
|
||||
GIANT(29, ABSTRACT_MONSTER),
|
||||
SILVERFISH(64, ABSTRACT_MONSTER),
|
||||
VEX(83, ABSTRACT_MONSTER),
|
||||
WITCH(89, ABSTRACT_MONSTER),
|
||||
WITHER(90, ABSTRACT_MONSTER),
|
||||
RAVAGER(98, ABSTRACT_MONSTER),
|
||||
|
||||
// Illagers
|
||||
ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER),
|
||||
ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE),
|
||||
EVOKER(22, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
ILLUSIONER(33, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
VINDICATOR(86, ABSTRACT_ILLAGER_BASE),
|
||||
PILLAGER(87, ABSTRACT_ILLAGER_BASE),
|
||||
|
||||
// Skeletons
|
||||
ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER),
|
||||
SKELETON(65, ABSTRACT_SKELETON),
|
||||
STRAY(74, ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(91, ABSTRACT_SKELETON),
|
||||
|
||||
// Guardians
|
||||
GUARDIAN(30, ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(16, GUARDIAN),
|
||||
|
||||
// Spiders
|
||||
SPIDER(72, ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(7, SPIDER),
|
||||
|
||||
// Zombies - META CHECKED
|
||||
ZOMBIE(94, ABSTRACT_MONSTER),
|
||||
DROWNED(15, ZOMBIE),
|
||||
HUSK(32, ZOMBIE),
|
||||
ZOMBIE_PIGMAN(56, ZOMBIE),
|
||||
ZOMBIE_VILLAGER(96, ZOMBIE),
|
||||
|
||||
// Flying entities
|
||||
ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT),
|
||||
GHAST(28, ABSTRACT_FLYING),
|
||||
PHANTOM(97, ABSTRACT_FLYING),
|
||||
|
||||
ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT),
|
||||
BAT(3, ABSTRACT_AMBIENT),
|
||||
|
||||
ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT),
|
||||
SQUID(73, ABSTRACT_WATERMOB),
|
||||
|
||||
// Slimes
|
||||
SLIME(67, ABSTRACT_INSENTIENT),
|
||||
MAGMA_CUBE(40, SLIME),
|
||||
|
||||
// Hangable objects
|
||||
ABSTRACT_HANGING(-1, ENTITY),
|
||||
LEASH_KNOT(37, ABSTRACT_HANGING),
|
||||
ITEM_FRAME(35, ABSTRACT_HANGING),
|
||||
PAINTING(51, ABSTRACT_HANGING),
|
||||
|
||||
ABSTRACT_LIGHTNING(-1, ENTITY),
|
||||
LIGHTNING_BOLT(99, ABSTRACT_LIGHTNING),
|
||||
|
||||
// Arrows
|
||||
ABSTRACT_ARROW(-1, ENTITY),
|
||||
ARROW(2, ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(71, ABSTRACT_ARROW),
|
||||
TRIDENT(82, ABSTRACT_ARROW),
|
||||
|
||||
// Fireballs
|
||||
ABSTRACT_FIREBALL(-1, ENTITY),
|
||||
DRAGON_FIREBALL(14, ABSTRACT_FIREBALL),
|
||||
FIREBALL(36, ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(68, ABSTRACT_FIREBALL),
|
||||
WITHER_SKULL(92, ABSTRACT_FIREBALL),
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY, null),
|
||||
LEASH_KNOT(HANGING_ENTITY),
|
||||
PAINTING(HANGING_ENTITY),
|
||||
ITEM_FRAME(HANGING_ENTITY),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE_ABSTRACT(-1, ENTITY),
|
||||
SNOWBALL(70, PROJECTILE_ABSTRACT),
|
||||
ENDER_PEARL(79, PROJECTILE_ABSTRACT),
|
||||
EGG(78, PROJECTILE_ABSTRACT),
|
||||
POTION(81, PROJECTILE_ABSTRACT),
|
||||
EXPERIENCE_BOTTLE(80, PROJECTILE_ABSTRACT),
|
||||
PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing
|
||||
SNOWBALL(PROJECTILE),
|
||||
ENDER_PEARL(PROJECTILE),
|
||||
EGG(PROJECTILE),
|
||||
POTION(PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(PROJECTILE),
|
||||
FIREWORK_ROCKET(PROJECTILE),
|
||||
LLAMA_SPIT(PROJECTILE),
|
||||
SHULKER_BULLET(PROJECTILE),
|
||||
FISHING_BOBBER(PROJECTILE),
|
||||
WITHER_SKULL(PROJECTILE),
|
||||
DRAGON_FIREBALL(PROJECTILE), // Doesn't actually inherit fireball
|
||||
|
||||
ABSTRACT_ARROW(PROJECTILE, null),
|
||||
ARROW(ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(ABSTRACT_ARROW),
|
||||
TRIDENT(ABSTRACT_ARROW),
|
||||
|
||||
ABSTRACT_FIREBALL(ENTITY, null),
|
||||
FIREBALL(ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(ABSTRACT_FIREBALL),
|
||||
|
||||
// Vehicles
|
||||
MINECART_ABSTRACT(-1, ENTITY),
|
||||
CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT),
|
||||
CHEST_MINECART(42, CHESTED_MINECART_ABSTRACT),
|
||||
HOPPER_MINECART(45, CHESTED_MINECART_ABSTRACT),
|
||||
MINECART(41, MINECART_ABSTRACT),
|
||||
FURNACE_MINECART(44, MINECART_ABSTRACT),
|
||||
COMMAND_BLOCK_MINECART(43, MINECART_ABSTRACT),
|
||||
TNT_MINECART(47, MINECART_ABSTRACT),
|
||||
SPAWNER_MINECART(46, MINECART_ABSTRACT),
|
||||
BOAT(5, ENTITY);
|
||||
VEHICLE(ENTITY, null),
|
||||
BOAT(VEHICLE),
|
||||
|
||||
private static final EntityType[] TYPES;
|
||||
ABSTRACT_MINECART(VEHICLE, null),
|
||||
MINECART(ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(ABSTRACT_MINECART),
|
||||
TNT_MINECART(ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(ABSTRACT_MINECART),
|
||||
|
||||
private final int id;
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART, null),
|
||||
CHEST_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(ENTITY, null),
|
||||
ARMOR_STAND(LIVING_ENTITY),
|
||||
PLAYER(LIVING_ENTITY),
|
||||
|
||||
// Mobs as a larger subclass
|
||||
MOB(LIVING_ENTITY, null),
|
||||
ENDER_DRAGON(MOB),
|
||||
|
||||
SLIME(MOB),
|
||||
MAGMA_CUBE(SLIME),
|
||||
|
||||
// Ambient mobs
|
||||
AMBIENT_CREATURE(MOB, null),
|
||||
BAT(AMBIENT_CREATURE),
|
||||
|
||||
// Flying mobs
|
||||
FLYING_MOB(MOB, null),
|
||||
GHAST(FLYING_MOB),
|
||||
PHANTOM(FLYING_MOB),
|
||||
|
||||
// Pathfinder mobs and its subclasses
|
||||
PATHFINDER_MOB(MOB, null),
|
||||
|
||||
ABSTRACT_GOLEM(PATHFINDER_MOB, null),
|
||||
SNOW_GOLEM(ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(ABSTRACT_GOLEM),
|
||||
SHULKER(ABSTRACT_GOLEM),
|
||||
|
||||
// Water mobs
|
||||
WATER_ANIMAL(PATHFINDER_MOB, null),
|
||||
DOLPHIN(WATER_ANIMAL),
|
||||
SQUID(WATER_ANIMAL),
|
||||
|
||||
ABSTRACT_FISH(WATER_ANIMAL, null),
|
||||
PUFFERFISH(ABSTRACT_FISH),
|
||||
|
||||
ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISH, null),
|
||||
COD(ABSTRACT_SCHOOLING_FISH),
|
||||
SALMON(ABSTRACT_SCHOOLING_FISH),
|
||||
TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(PATHFINDER_MOB, null),
|
||||
ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null),
|
||||
VILLAGER(ABSTRACT_VILLAGER),
|
||||
WANDERING_TRADER(ABSTRACT_VILLAGER),
|
||||
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
|
||||
CHICKEN(ABSTRACT_ANIMAL),
|
||||
PANDA(ABSTRACT_ANIMAL),
|
||||
PIG(ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(ABSTRACT_ANIMAL),
|
||||
RABBIT(ABSTRACT_ANIMAL),
|
||||
SHEEP(ABSTRACT_ANIMAL),
|
||||
TURTLE(ABSTRACT_ANIMAL),
|
||||
FOX(ABSTRACT_ANIMAL),
|
||||
|
||||
COW(ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(COW),
|
||||
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(TAMABLE_ANIMAL),
|
||||
OCELOT(TAMABLE_ANIMAL),
|
||||
WOLF(TAMABLE_ANIMAL),
|
||||
PARROT(TAMABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
|
||||
HORSE(ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(ABSTRACT_HORSE),
|
||||
|
||||
ABSTRACT_CHESTED_HORSE(ABSTRACT_HORSE, null),
|
||||
DONKEY(ABSTRACT_CHESTED_HORSE),
|
||||
MULE(ABSTRACT_CHESTED_HORSE),
|
||||
LLAMA(ABSTRACT_CHESTED_HORSE),
|
||||
TRADER_LLAMA(LLAMA),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(PATHFINDER_MOB, null),
|
||||
BLAZE(ABSTRACT_MONSTER),
|
||||
CREEPER(ABSTRACT_MONSTER),
|
||||
ENDERMITE(ABSTRACT_MONSTER),
|
||||
ENDERMAN(ABSTRACT_MONSTER),
|
||||
GIANT(ABSTRACT_MONSTER),
|
||||
SILVERFISH(ABSTRACT_MONSTER),
|
||||
VEX(ABSTRACT_MONSTER),
|
||||
WITHER(ABSTRACT_MONSTER),
|
||||
|
||||
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
|
||||
SKELETON(ABSTRACT_SKELETON),
|
||||
STRAY(ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(ABSTRACT_SKELETON),
|
||||
|
||||
ZOMBIE(ABSTRACT_MONSTER),
|
||||
DROWNED(ZOMBIE),
|
||||
HUSK(ZOMBIE),
|
||||
ZOMBIE_PIGMAN(ZOMBIE),
|
||||
ZOMBIE_VILLAGER(ZOMBIE),
|
||||
|
||||
GUARDIAN(ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(GUARDIAN),
|
||||
|
||||
SPIDER(ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(SPIDER),
|
||||
|
||||
// Raiders
|
||||
ABSTRACT_RAIDER(ABSTRACT_MONSTER, null),
|
||||
WITCH(ABSTRACT_RAIDER),
|
||||
RAVAGER(ABSTRACT_RAIDER),
|
||||
|
||||
ABSTRACT_ILLAGER(ABSTRACT_RAIDER, null),
|
||||
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER, null),
|
||||
VINDICATOR(ABSTRACT_ILLAGER),
|
||||
PILLAGER(ABSTRACT_ILLAGER),
|
||||
EVOKER(SPELLCASTER_ILLAGER),
|
||||
ILLUSIONER(SPELLCASTER_ILLAGER);
|
||||
|
||||
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
|
||||
private final EntityType parent;
|
||||
private final String identifier;
|
||||
private int id = -1;
|
||||
|
||||
EntityTypes1_14(int id) {
|
||||
this.id = id;
|
||||
this.parent = null;
|
||||
EntityTypes1_14(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_14(int id, EntityType parent) {
|
||||
this.id = id;
|
||||
EntityTypes1_14(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 EntityType getParent() {
|
||||
public String identifier() {
|
||||
Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type");
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable EntityType getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
return identifier == null;
|
||||
}
|
||||
|
||||
static {
|
||||
TYPES = EntityTypeUtil.toOrderedArray(values());
|
||||
}
|
||||
|
||||
public static EntityType getTypeFromId(int typeId) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
+196
-187
@@ -22,225 +22,234 @@
|
||||
*/
|
||||
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 com.viaversion.viaversion.util.Key;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum EntityTypes1_15 implements EntityType {
|
||||
|
||||
ENTITY(-1),
|
||||
ENTITY(null, null),
|
||||
|
||||
AREA_EFFECT_CLOUD(0, ENTITY),
|
||||
END_CRYSTAL(18, ENTITY),
|
||||
EVOKER_FANGS(22, ENTITY),
|
||||
EXPERIENCE_ORB(24, ENTITY),
|
||||
EYE_OF_ENDER(25, ENTITY),
|
||||
FALLING_BLOCK(26, ENTITY),
|
||||
FIREWORK_ROCKET(27, ENTITY),
|
||||
ITEM(35, ENTITY),
|
||||
LLAMA_SPIT(40, ENTITY),
|
||||
TNT(59, ENTITY),
|
||||
SHULKER_BULLET(64, ENTITY),
|
||||
FISHING_BOBBER(102, ENTITY),
|
||||
AREA_EFFECT_CLOUD(ENTITY),
|
||||
END_CRYSTAL(ENTITY),
|
||||
EVOKER_FANGS(ENTITY),
|
||||
EXPERIENCE_ORB(ENTITY),
|
||||
EYE_OF_ENDER(ENTITY),
|
||||
FALLING_BLOCK(ENTITY),
|
||||
ITEM(ENTITY),
|
||||
TNT(ENTITY),
|
||||
LIGHTNING_BOLT(ENTITY),
|
||||
|
||||
LIVINGENTITY(-1, ENTITY),
|
||||
ARMOR_STAND(1, LIVINGENTITY),
|
||||
PLAYER(101, LIVINGENTITY),
|
||||
|
||||
ABSTRACT_INSENTIENT(-1, LIVINGENTITY),
|
||||
ENDER_DRAGON(19, ABSTRACT_INSENTIENT),
|
||||
|
||||
BEE(4, ABSTRACT_INSENTIENT),
|
||||
|
||||
ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT),
|
||||
|
||||
ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE),
|
||||
VILLAGER(85, ABSTRACT_AGEABLE),
|
||||
WANDERING_TRADER(89, ABSTRACT_AGEABLE),
|
||||
|
||||
// Animals
|
||||
ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE),
|
||||
DOLPHIN(14, ABSTRACT_INSENTIENT),
|
||||
CHICKEN(9, ABSTRACT_ANIMAL),
|
||||
COW(11, ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(50, COW),
|
||||
PANDA(53, ABSTRACT_INSENTIENT),
|
||||
PIG(55, ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(58, ABSTRACT_ANIMAL),
|
||||
RABBIT(60, ABSTRACT_ANIMAL),
|
||||
SHEEP(62, ABSTRACT_ANIMAL),
|
||||
TURTLE(78, ABSTRACT_ANIMAL),
|
||||
FOX(28, ABSTRACT_ANIMAL),
|
||||
|
||||
ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL),
|
||||
CAT(7, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
OCELOT(51, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
WOLF(94, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
PARROT(54, ABSTRACT_PARROT),
|
||||
|
||||
// Horses
|
||||
ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL),
|
||||
CHESTED_HORSE(-1, ABSTRACT_HORSE),
|
||||
DONKEY(13, CHESTED_HORSE),
|
||||
MULE(49, CHESTED_HORSE),
|
||||
LLAMA(39, CHESTED_HORSE),
|
||||
TRADER_LLAMA(76, CHESTED_HORSE),
|
||||
HORSE(32, ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(67, ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(96, ABSTRACT_HORSE),
|
||||
|
||||
// Golem
|
||||
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE),
|
||||
SNOW_GOLEM(70, ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(86, ABSTRACT_GOLEM),
|
||||
SHULKER(63, ABSTRACT_GOLEM),
|
||||
|
||||
// Fish
|
||||
ABSTRACT_FISHES(-1, ABSTRACT_CREATURE),
|
||||
COD(10, ABSTRACT_FISHES),
|
||||
PUFFERFISH(56, ABSTRACT_FISHES),
|
||||
SALMON(61, ABSTRACT_FISHES),
|
||||
TROPICAL_FISH(77, ABSTRACT_FISHES),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE),
|
||||
BLAZE(5, ABSTRACT_MONSTER),
|
||||
CREEPER(12, ABSTRACT_MONSTER),
|
||||
ENDERMITE(21, ABSTRACT_MONSTER),
|
||||
ENDERMAN(20, ABSTRACT_MONSTER),
|
||||
GIANT(30, ABSTRACT_MONSTER),
|
||||
SILVERFISH(65, ABSTRACT_MONSTER),
|
||||
VEX(84, ABSTRACT_MONSTER),
|
||||
WITCH(90, ABSTRACT_MONSTER),
|
||||
WITHER(91, ABSTRACT_MONSTER),
|
||||
RAVAGER(99, ABSTRACT_MONSTER),
|
||||
|
||||
// Illagers
|
||||
ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER),
|
||||
ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE),
|
||||
EVOKER(23, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
ILLUSIONER(34, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
VINDICATOR(87, ABSTRACT_ILLAGER_BASE),
|
||||
PILLAGER(88, ABSTRACT_ILLAGER_BASE),
|
||||
|
||||
// Skeletons
|
||||
ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER),
|
||||
SKELETON(66, ABSTRACT_SKELETON),
|
||||
STRAY(75, ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(92, ABSTRACT_SKELETON),
|
||||
|
||||
// Guardians
|
||||
GUARDIAN(31, ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(17, GUARDIAN),
|
||||
|
||||
// Spiders
|
||||
SPIDER(73, ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(8, SPIDER),
|
||||
|
||||
// Zombies
|
||||
ZOMBIE(95, ABSTRACT_MONSTER),
|
||||
DROWNED(16, ZOMBIE),
|
||||
HUSK(33, ZOMBIE),
|
||||
ZOMBIE_PIGMAN(57, ZOMBIE),
|
||||
ZOMBIE_VILLAGER(97, ZOMBIE),
|
||||
|
||||
// Flying entities
|
||||
ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT),
|
||||
GHAST(29, ABSTRACT_FLYING),
|
||||
PHANTOM(98, ABSTRACT_FLYING),
|
||||
|
||||
ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT),
|
||||
BAT(3, ABSTRACT_AMBIENT),
|
||||
|
||||
ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT),
|
||||
SQUID(74, ABSTRACT_WATERMOB),
|
||||
|
||||
// Slimes
|
||||
SLIME(68, ABSTRACT_INSENTIENT),
|
||||
MAGMA_CUBE(41, SLIME),
|
||||
|
||||
// Hangable objects
|
||||
ABSTRACT_HANGING(-1, ENTITY),
|
||||
LEASH_KNOT(38, ABSTRACT_HANGING),
|
||||
ITEM_FRAME(36, ABSTRACT_HANGING),
|
||||
PAINTING(52, ABSTRACT_HANGING),
|
||||
|
||||
ABSTRACT_LIGHTNING(-1, ENTITY),
|
||||
LIGHTNING_BOLT(100, ABSTRACT_LIGHTNING),
|
||||
|
||||
// Arrows
|
||||
ABSTRACT_ARROW(-1, ENTITY),
|
||||
ARROW(2, ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(72, ABSTRACT_ARROW),
|
||||
TRIDENT(83, ABSTRACT_ARROW),
|
||||
|
||||
// Fireballs
|
||||
ABSTRACT_FIREBALL(-1, ENTITY),
|
||||
DRAGON_FIREBALL(15, ABSTRACT_FIREBALL),
|
||||
FIREBALL(37, ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(69, ABSTRACT_FIREBALL),
|
||||
WITHER_SKULL(93, ABSTRACT_FIREBALL),
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY, null),
|
||||
LEASH_KNOT(HANGING_ENTITY),
|
||||
PAINTING(HANGING_ENTITY),
|
||||
ITEM_FRAME(HANGING_ENTITY),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE_ABSTRACT(-1, ENTITY),
|
||||
SNOWBALL(71, PROJECTILE_ABSTRACT),
|
||||
ENDER_PEARL(80, PROJECTILE_ABSTRACT),
|
||||
EGG(79, PROJECTILE_ABSTRACT),
|
||||
POTION(82, PROJECTILE_ABSTRACT),
|
||||
EXPERIENCE_BOTTLE(81, PROJECTILE_ABSTRACT),
|
||||
PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing
|
||||
SNOWBALL(PROJECTILE),
|
||||
ENDER_PEARL(PROJECTILE),
|
||||
EGG(PROJECTILE),
|
||||
POTION(PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(PROJECTILE),
|
||||
FIREWORK_ROCKET(PROJECTILE),
|
||||
LLAMA_SPIT(PROJECTILE),
|
||||
SHULKER_BULLET(PROJECTILE),
|
||||
FISHING_BOBBER(PROJECTILE),
|
||||
WITHER_SKULL(PROJECTILE),
|
||||
DRAGON_FIREBALL(PROJECTILE), // Doesn't actually inherit fireball
|
||||
|
||||
ABSTRACT_ARROW(PROJECTILE, null),
|
||||
ARROW(ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(ABSTRACT_ARROW),
|
||||
TRIDENT(ABSTRACT_ARROW),
|
||||
|
||||
ABSTRACT_FIREBALL(ENTITY, null),
|
||||
FIREBALL(ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(ABSTRACT_FIREBALL),
|
||||
|
||||
// Vehicles
|
||||
MINECART_ABSTRACT(-1, ENTITY),
|
||||
CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT),
|
||||
CHEST_MINECART(43, CHESTED_MINECART_ABSTRACT),
|
||||
HOPPER_MINECART(46, CHESTED_MINECART_ABSTRACT),
|
||||
MINECART(42, MINECART_ABSTRACT),
|
||||
FURNACE_MINECART(45, MINECART_ABSTRACT),
|
||||
COMMAND_BLOCK_MINECART(44, MINECART_ABSTRACT),
|
||||
TNT_MINECART(48, MINECART_ABSTRACT),
|
||||
SPAWNER_MINECART(47, MINECART_ABSTRACT),
|
||||
BOAT(6, ENTITY);
|
||||
VEHICLE(ENTITY, null),
|
||||
BOAT(VEHICLE),
|
||||
|
||||
private static final EntityType[] TYPES;
|
||||
ABSTRACT_MINECART(VEHICLE, null),
|
||||
MINECART(ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(ABSTRACT_MINECART),
|
||||
TNT_MINECART(ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(ABSTRACT_MINECART),
|
||||
|
||||
private final int id;
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART, null),
|
||||
CHEST_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(ENTITY, null),
|
||||
ARMOR_STAND(LIVING_ENTITY),
|
||||
PLAYER(LIVING_ENTITY),
|
||||
|
||||
// Mobs as a larger subclass
|
||||
MOB(LIVING_ENTITY, null),
|
||||
ENDER_DRAGON(MOB),
|
||||
|
||||
SLIME(MOB),
|
||||
MAGMA_CUBE(SLIME),
|
||||
|
||||
// Ambient mobs
|
||||
AMBIENT_CREATURE(MOB, null),
|
||||
BAT(AMBIENT_CREATURE),
|
||||
|
||||
// Flying mobs
|
||||
FLYING_MOB(MOB, null),
|
||||
GHAST(FLYING_MOB),
|
||||
PHANTOM(FLYING_MOB),
|
||||
|
||||
// Pathfinder mobs and its subclasses
|
||||
PATHFINDER_MOB(MOB, null),
|
||||
|
||||
ABSTRACT_GOLEM(PATHFINDER_MOB, null),
|
||||
SNOW_GOLEM(ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(ABSTRACT_GOLEM),
|
||||
SHULKER(ABSTRACT_GOLEM),
|
||||
|
||||
// Water mobs
|
||||
WATER_ANIMAL(PATHFINDER_MOB, null),
|
||||
DOLPHIN(WATER_ANIMAL),
|
||||
SQUID(WATER_ANIMAL),
|
||||
|
||||
ABSTRACT_FISH(WATER_ANIMAL, null),
|
||||
PUFFERFISH(ABSTRACT_FISH),
|
||||
|
||||
ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISH, null),
|
||||
COD(ABSTRACT_SCHOOLING_FISH),
|
||||
SALMON(ABSTRACT_SCHOOLING_FISH),
|
||||
TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(PATHFINDER_MOB, null),
|
||||
ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null),
|
||||
VILLAGER(ABSTRACT_VILLAGER),
|
||||
WANDERING_TRADER(ABSTRACT_VILLAGER),
|
||||
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
|
||||
CHICKEN(ABSTRACT_ANIMAL),
|
||||
PANDA(ABSTRACT_ANIMAL),
|
||||
PIG(ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(ABSTRACT_ANIMAL),
|
||||
RABBIT(ABSTRACT_ANIMAL),
|
||||
SHEEP(ABSTRACT_ANIMAL),
|
||||
BEE(ABSTRACT_ANIMAL),
|
||||
TURTLE(ABSTRACT_ANIMAL),
|
||||
FOX(ABSTRACT_ANIMAL),
|
||||
|
||||
COW(ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(COW),
|
||||
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(TAMABLE_ANIMAL),
|
||||
OCELOT(TAMABLE_ANIMAL),
|
||||
WOLF(TAMABLE_ANIMAL),
|
||||
PARROT(TAMABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
|
||||
HORSE(ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(ABSTRACT_HORSE),
|
||||
|
||||
ABSTRACT_CHESTED_HORSE(ABSTRACT_HORSE, null),
|
||||
DONKEY(ABSTRACT_CHESTED_HORSE),
|
||||
MULE(ABSTRACT_CHESTED_HORSE),
|
||||
LLAMA(ABSTRACT_CHESTED_HORSE),
|
||||
TRADER_LLAMA(LLAMA),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(PATHFINDER_MOB, null),
|
||||
BLAZE(ABSTRACT_MONSTER),
|
||||
CREEPER(ABSTRACT_MONSTER),
|
||||
ENDERMITE(ABSTRACT_MONSTER),
|
||||
ENDERMAN(ABSTRACT_MONSTER),
|
||||
GIANT(ABSTRACT_MONSTER),
|
||||
SILVERFISH(ABSTRACT_MONSTER),
|
||||
VEX(ABSTRACT_MONSTER),
|
||||
WITHER(ABSTRACT_MONSTER),
|
||||
|
||||
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
|
||||
SKELETON(ABSTRACT_SKELETON),
|
||||
STRAY(ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(ABSTRACT_SKELETON),
|
||||
|
||||
ZOMBIE(ABSTRACT_MONSTER),
|
||||
DROWNED(ZOMBIE),
|
||||
HUSK(ZOMBIE),
|
||||
ZOMBIE_PIGMAN(ZOMBIE),
|
||||
ZOMBIE_VILLAGER(ZOMBIE),
|
||||
|
||||
GUARDIAN(ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(GUARDIAN),
|
||||
|
||||
SPIDER(ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(SPIDER),
|
||||
|
||||
// Raiders
|
||||
ABSTRACT_RAIDER(ABSTRACT_MONSTER, null),
|
||||
WITCH(ABSTRACT_RAIDER),
|
||||
RAVAGER(ABSTRACT_RAIDER),
|
||||
|
||||
ABSTRACT_ILLAGER(ABSTRACT_RAIDER, null),
|
||||
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER, null),
|
||||
VINDICATOR(ABSTRACT_ILLAGER),
|
||||
PILLAGER(ABSTRACT_ILLAGER),
|
||||
EVOKER(SPELLCASTER_ILLAGER),
|
||||
ILLUSIONER(SPELLCASTER_ILLAGER);
|
||||
|
||||
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
|
||||
private final EntityType parent;
|
||||
private final String identifier;
|
||||
private int id = -1;
|
||||
|
||||
EntityTypes1_15(int id) {
|
||||
this.id = id;
|
||||
this.parent = null;
|
||||
EntityTypes1_15(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_15(int id, EntityType parent) {
|
||||
this.id = id;
|
||||
EntityTypes1_15(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 EntityType getParent() {
|
||||
public String identifier() {
|
||||
Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type");
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable EntityType getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
return identifier == null;
|
||||
}
|
||||
|
||||
static {
|
||||
TYPES = EntityTypeUtil.toOrderedArray(values());
|
||||
}
|
||||
|
||||
public static EntityType getTypeFromId(int typeId) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
+200
-192
@@ -22,230 +22,238 @@
|
||||
*/
|
||||
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 com.viaversion.viaversion.util.Key;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum EntityTypes1_16 implements EntityType {
|
||||
|
||||
ENTITY(-1),
|
||||
ENTITY(null, null),
|
||||
|
||||
AREA_EFFECT_CLOUD(0, ENTITY),
|
||||
END_CRYSTAL(18, ENTITY),
|
||||
EVOKER_FANGS(23, ENTITY),
|
||||
EXPERIENCE_ORB(24, ENTITY),
|
||||
EYE_OF_ENDER(25, ENTITY),
|
||||
FALLING_BLOCK(26, ENTITY),
|
||||
FIREWORK_ROCKET(27, ENTITY),
|
||||
ITEM(37, ENTITY),
|
||||
LLAMA_SPIT(43, ENTITY),
|
||||
TNT(63, ENTITY),
|
||||
SHULKER_BULLET(70, ENTITY),
|
||||
FISHING_BOBBER(106, ENTITY),
|
||||
AREA_EFFECT_CLOUD(ENTITY),
|
||||
END_CRYSTAL(ENTITY),
|
||||
EVOKER_FANGS(ENTITY),
|
||||
EXPERIENCE_ORB(ENTITY),
|
||||
EYE_OF_ENDER(ENTITY),
|
||||
FALLING_BLOCK(ENTITY),
|
||||
ITEM(ENTITY),
|
||||
TNT(ENTITY),
|
||||
LIGHTNING_BOLT(ENTITY),
|
||||
|
||||
LIVINGENTITY(-1, ENTITY),
|
||||
ARMOR_STAND(1, LIVINGENTITY),
|
||||
PLAYER(105, LIVINGENTITY),
|
||||
|
||||
ABSTRACT_INSENTIENT(-1, LIVINGENTITY),
|
||||
ENDER_DRAGON(19, ABSTRACT_INSENTIENT),
|
||||
|
||||
BEE(4, ABSTRACT_INSENTIENT),
|
||||
|
||||
ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT),
|
||||
|
||||
ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE),
|
||||
VILLAGER(92, ABSTRACT_AGEABLE),
|
||||
WANDERING_TRADER(94, ABSTRACT_AGEABLE),
|
||||
|
||||
// Animals
|
||||
ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE),
|
||||
DOLPHIN(13, ABSTRACT_INSENTIENT),
|
||||
CHICKEN(9, ABSTRACT_ANIMAL),
|
||||
COW(11, ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(53, COW),
|
||||
PANDA(56, ABSTRACT_INSENTIENT),
|
||||
PIG(59, ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(62, ABSTRACT_ANIMAL),
|
||||
RABBIT(65, ABSTRACT_ANIMAL),
|
||||
SHEEP(68, ABSTRACT_ANIMAL),
|
||||
TURTLE(90, ABSTRACT_ANIMAL),
|
||||
FOX(28, ABSTRACT_ANIMAL),
|
||||
|
||||
ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL),
|
||||
CAT(7, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
OCELOT(54, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
WOLF(99, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
PARROT(57, ABSTRACT_PARROT),
|
||||
|
||||
// Horses
|
||||
ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL),
|
||||
CHESTED_HORSE(-1, ABSTRACT_HORSE),
|
||||
DONKEY(14, CHESTED_HORSE),
|
||||
MULE(52, CHESTED_HORSE),
|
||||
LLAMA(42, CHESTED_HORSE),
|
||||
TRADER_LLAMA(88, CHESTED_HORSE),
|
||||
HORSE(33, ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(73, ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(102, ABSTRACT_HORSE),
|
||||
|
||||
// Golem
|
||||
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE),
|
||||
SNOW_GOLEM(76, ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(36, ABSTRACT_GOLEM),
|
||||
SHULKER(69, ABSTRACT_GOLEM),
|
||||
|
||||
// Fish
|
||||
ABSTRACT_FISHES(-1, ABSTRACT_CREATURE),
|
||||
COD(10, ABSTRACT_FISHES),
|
||||
PUFFERFISH(64, ABSTRACT_FISHES),
|
||||
SALMON(67, ABSTRACT_FISHES),
|
||||
TROPICAL_FISH(89, ABSTRACT_FISHES),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE),
|
||||
BLAZE(5, ABSTRACT_MONSTER),
|
||||
CREEPER(12, ABSTRACT_MONSTER),
|
||||
ENDERMITE(21, ABSTRACT_MONSTER),
|
||||
ENDERMAN(20, ABSTRACT_MONSTER),
|
||||
GIANT(30, ABSTRACT_MONSTER),
|
||||
SILVERFISH(71, ABSTRACT_MONSTER),
|
||||
VEX(91, ABSTRACT_MONSTER),
|
||||
WITCH(95, ABSTRACT_MONSTER),
|
||||
WITHER(96, ABSTRACT_MONSTER),
|
||||
RAVAGER(66, ABSTRACT_MONSTER),
|
||||
PIGLIN(60, ABSTRACT_MONSTER),
|
||||
|
||||
HOGLIN(32, ABSTRACT_ANIMAL),
|
||||
STRIDER(82, ABSTRACT_ANIMAL),
|
||||
ZOGLIN(100, ABSTRACT_MONSTER),
|
||||
|
||||
// Illagers
|
||||
ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER),
|
||||
ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE),
|
||||
EVOKER(22, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
ILLUSIONER(35, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
VINDICATOR(93, ABSTRACT_ILLAGER_BASE),
|
||||
PILLAGER(61, ABSTRACT_ILLAGER_BASE),
|
||||
|
||||
// Skeletons
|
||||
ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER),
|
||||
SKELETON(72, ABSTRACT_SKELETON),
|
||||
STRAY(81, ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(97, ABSTRACT_SKELETON),
|
||||
|
||||
// Guardians
|
||||
GUARDIAN(31, ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(17, GUARDIAN),
|
||||
|
||||
// Spiders
|
||||
SPIDER(79, ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(8, SPIDER),
|
||||
|
||||
// Zombies
|
||||
ZOMBIE(101, ABSTRACT_MONSTER),
|
||||
DROWNED(16, ZOMBIE),
|
||||
HUSK(34, ZOMBIE),
|
||||
ZOMBIFIED_PIGLIN(104, ZOMBIE),
|
||||
ZOMBIE_VILLAGER(103, ZOMBIE),
|
||||
|
||||
// Flying entities
|
||||
ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT),
|
||||
GHAST(29, ABSTRACT_FLYING),
|
||||
PHANTOM(58, ABSTRACT_FLYING),
|
||||
|
||||
ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT),
|
||||
BAT(3, ABSTRACT_AMBIENT),
|
||||
|
||||
ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT),
|
||||
SQUID(80, ABSTRACT_WATERMOB),
|
||||
|
||||
// Slimes
|
||||
SLIME(74, ABSTRACT_INSENTIENT),
|
||||
MAGMA_CUBE(44, SLIME),
|
||||
|
||||
// Hangable objects
|
||||
ABSTRACT_HANGING(-1, ENTITY),
|
||||
LEASH_KNOT(40, ABSTRACT_HANGING),
|
||||
ITEM_FRAME(38, ABSTRACT_HANGING),
|
||||
PAINTING(55, ABSTRACT_HANGING),
|
||||
|
||||
ABSTRACT_LIGHTNING(-1, ENTITY),
|
||||
LIGHTNING_BOLT(41, ABSTRACT_LIGHTNING),
|
||||
|
||||
// Arrows
|
||||
ABSTRACT_ARROW(-1, ENTITY),
|
||||
ARROW(2, ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(78, ABSTRACT_ARROW),
|
||||
TRIDENT(87, ABSTRACT_ARROW),
|
||||
|
||||
// Fireballs
|
||||
ABSTRACT_FIREBALL(-1, ENTITY),
|
||||
DRAGON_FIREBALL(15, ABSTRACT_FIREBALL),
|
||||
FIREBALL(39, ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(75, ABSTRACT_FIREBALL),
|
||||
WITHER_SKULL(98, ABSTRACT_FIREBALL),
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY, null),
|
||||
LEASH_KNOT(HANGING_ENTITY),
|
||||
PAINTING(HANGING_ENTITY),
|
||||
ITEM_FRAME(HANGING_ENTITY),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE_ABSTRACT(-1, ENTITY),
|
||||
SNOWBALL(77, PROJECTILE_ABSTRACT),
|
||||
ENDER_PEARL(84, PROJECTILE_ABSTRACT),
|
||||
EGG(83, PROJECTILE_ABSTRACT),
|
||||
POTION(86, PROJECTILE_ABSTRACT),
|
||||
EXPERIENCE_BOTTLE(85, PROJECTILE_ABSTRACT),
|
||||
PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing
|
||||
SNOWBALL(PROJECTILE),
|
||||
ENDER_PEARL(PROJECTILE),
|
||||
EGG(PROJECTILE),
|
||||
POTION(PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(PROJECTILE),
|
||||
FIREWORK_ROCKET(PROJECTILE),
|
||||
LLAMA_SPIT(PROJECTILE),
|
||||
SHULKER_BULLET(PROJECTILE),
|
||||
FISHING_BOBBER(PROJECTILE),
|
||||
WITHER_SKULL(PROJECTILE),
|
||||
DRAGON_FIREBALL(PROJECTILE), // Doesn't actually inherit fireball
|
||||
|
||||
ABSTRACT_ARROW(PROJECTILE, null),
|
||||
ARROW(ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(ABSTRACT_ARROW),
|
||||
TRIDENT(ABSTRACT_ARROW),
|
||||
|
||||
ABSTRACT_FIREBALL(ENTITY, null),
|
||||
FIREBALL(ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(ABSTRACT_FIREBALL),
|
||||
|
||||
// Vehicles
|
||||
MINECART_ABSTRACT(-1, ENTITY),
|
||||
CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT),
|
||||
CHEST_MINECART(46, CHESTED_MINECART_ABSTRACT),
|
||||
HOPPER_MINECART(49, CHESTED_MINECART_ABSTRACT),
|
||||
MINECART(45, MINECART_ABSTRACT),
|
||||
FURNACE_MINECART(48, MINECART_ABSTRACT),
|
||||
COMMAND_BLOCK_MINECART(47, MINECART_ABSTRACT),
|
||||
TNT_MINECART(51, MINECART_ABSTRACT),
|
||||
SPAWNER_MINECART(50, MINECART_ABSTRACT),
|
||||
BOAT(6, ENTITY);
|
||||
VEHICLE(ENTITY, null),
|
||||
BOAT(VEHICLE),
|
||||
|
||||
private static final EntityType[] TYPES;
|
||||
ABSTRACT_MINECART(VEHICLE, null),
|
||||
MINECART(ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(ABSTRACT_MINECART),
|
||||
TNT_MINECART(ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(ABSTRACT_MINECART),
|
||||
|
||||
private final int id;
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART, null),
|
||||
CHEST_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(ENTITY, null),
|
||||
ARMOR_STAND(LIVING_ENTITY),
|
||||
PLAYER(LIVING_ENTITY),
|
||||
|
||||
// Mobs as a larger subclass
|
||||
MOB(LIVING_ENTITY, null),
|
||||
ENDER_DRAGON(MOB),
|
||||
|
||||
SLIME(MOB),
|
||||
MAGMA_CUBE(SLIME),
|
||||
|
||||
// Ambient mobs
|
||||
AMBIENT_CREATURE(MOB, null),
|
||||
BAT(AMBIENT_CREATURE),
|
||||
|
||||
// Flying mobs
|
||||
FLYING_MOB(MOB, null),
|
||||
GHAST(FLYING_MOB),
|
||||
PHANTOM(FLYING_MOB),
|
||||
|
||||
// Pathfinder mobs and its subclasses
|
||||
PATHFINDER_MOB(MOB, null),
|
||||
|
||||
ABSTRACT_GOLEM(PATHFINDER_MOB, null),
|
||||
SNOW_GOLEM(ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(ABSTRACT_GOLEM),
|
||||
SHULKER(ABSTRACT_GOLEM),
|
||||
|
||||
// Water mobs
|
||||
WATER_ANIMAL(PATHFINDER_MOB, null),
|
||||
DOLPHIN(WATER_ANIMAL),
|
||||
SQUID(WATER_ANIMAL),
|
||||
|
||||
ABSTRACT_FISH(WATER_ANIMAL, null),
|
||||
PUFFERFISH(ABSTRACT_FISH),
|
||||
|
||||
ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISH, null),
|
||||
COD(ABSTRACT_SCHOOLING_FISH),
|
||||
SALMON(ABSTRACT_SCHOOLING_FISH),
|
||||
TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(PATHFINDER_MOB, null),
|
||||
ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null),
|
||||
VILLAGER(ABSTRACT_VILLAGER),
|
||||
WANDERING_TRADER(ABSTRACT_VILLAGER),
|
||||
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
|
||||
CHICKEN(ABSTRACT_ANIMAL),
|
||||
PANDA(ABSTRACT_ANIMAL),
|
||||
PIG(ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(ABSTRACT_ANIMAL),
|
||||
RABBIT(ABSTRACT_ANIMAL),
|
||||
SHEEP(ABSTRACT_ANIMAL),
|
||||
BEE(ABSTRACT_ANIMAL),
|
||||
TURTLE(ABSTRACT_ANIMAL),
|
||||
FOX(ABSTRACT_ANIMAL),
|
||||
HOGLIN(ABSTRACT_ANIMAL),
|
||||
STRIDER(ABSTRACT_ANIMAL),
|
||||
|
||||
COW(ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(COW),
|
||||
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(TAMABLE_ANIMAL),
|
||||
OCELOT(TAMABLE_ANIMAL),
|
||||
WOLF(TAMABLE_ANIMAL),
|
||||
PARROT(TAMABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
|
||||
HORSE(ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(ABSTRACT_HORSE),
|
||||
|
||||
ABSTRACT_CHESTED_HORSE(ABSTRACT_HORSE, null),
|
||||
DONKEY(ABSTRACT_CHESTED_HORSE),
|
||||
MULE(ABSTRACT_CHESTED_HORSE),
|
||||
LLAMA(ABSTRACT_CHESTED_HORSE),
|
||||
TRADER_LLAMA(LLAMA),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(PATHFINDER_MOB, null),
|
||||
BLAZE(ABSTRACT_MONSTER),
|
||||
CREEPER(ABSTRACT_MONSTER),
|
||||
ENDERMITE(ABSTRACT_MONSTER),
|
||||
ENDERMAN(ABSTRACT_MONSTER),
|
||||
GIANT(ABSTRACT_MONSTER),
|
||||
SILVERFISH(ABSTRACT_MONSTER),
|
||||
VEX(ABSTRACT_MONSTER),
|
||||
WITHER(ABSTRACT_MONSTER),
|
||||
ZOGLIN(ABSTRACT_MONSTER),
|
||||
PIGLIN(ABSTRACT_MONSTER),
|
||||
|
||||
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
|
||||
SKELETON(ABSTRACT_SKELETON),
|
||||
STRAY(ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(ABSTRACT_SKELETON),
|
||||
|
||||
ZOMBIE(ABSTRACT_MONSTER),
|
||||
DROWNED(ZOMBIE),
|
||||
HUSK(ZOMBIE),
|
||||
ZOMBIFIED_PIGLIN(ZOMBIE),
|
||||
ZOMBIE_VILLAGER(ZOMBIE),
|
||||
|
||||
GUARDIAN(ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(GUARDIAN),
|
||||
|
||||
SPIDER(ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(SPIDER),
|
||||
|
||||
// Raiders
|
||||
ABSTRACT_RAIDER(ABSTRACT_MONSTER, null),
|
||||
WITCH(ABSTRACT_RAIDER),
|
||||
RAVAGER(ABSTRACT_RAIDER),
|
||||
|
||||
ABSTRACT_ILLAGER(ABSTRACT_RAIDER, null),
|
||||
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER, null),
|
||||
VINDICATOR(ABSTRACT_ILLAGER),
|
||||
PILLAGER(ABSTRACT_ILLAGER),
|
||||
EVOKER(SPELLCASTER_ILLAGER),
|
||||
ILLUSIONER(SPELLCASTER_ILLAGER);
|
||||
|
||||
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
|
||||
private final EntityType parent;
|
||||
private final String identifier;
|
||||
private int id = -1;
|
||||
|
||||
EntityTypes1_16(int id) {
|
||||
this.id = id;
|
||||
this.parent = null;
|
||||
EntityTypes1_16(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_16(int id, EntityType parent) {
|
||||
this.id = id;
|
||||
EntityTypes1_16(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 EntityType getParent() {
|
||||
public String identifier() {
|
||||
Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type");
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable EntityType getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
return identifier == null;
|
||||
}
|
||||
|
||||
static {
|
||||
TYPES = EntityTypeUtil.toOrderedArray(values());
|
||||
}
|
||||
|
||||
public static EntityType getTypeFromId(int typeId) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
+204
-197
@@ -22,234 +22,241 @@
|
||||
*/
|
||||
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 com.viaversion.viaversion.util.Key;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum EntityTypes1_16_2 implements EntityType {
|
||||
|
||||
ENTITY(-1),
|
||||
ENTITY(null, null),
|
||||
|
||||
AREA_EFFECT_CLOUD(0, ENTITY),
|
||||
END_CRYSTAL(18, ENTITY),
|
||||
EVOKER_FANGS(23, ENTITY),
|
||||
EXPERIENCE_ORB(24, ENTITY),
|
||||
EYE_OF_ENDER(25, ENTITY),
|
||||
FALLING_BLOCK(26, ENTITY),
|
||||
FIREWORK_ROCKET(27, ENTITY),
|
||||
ITEM(37, ENTITY),
|
||||
LLAMA_SPIT(43, ENTITY),
|
||||
TNT(64, ENTITY),
|
||||
SHULKER_BULLET(71, ENTITY),
|
||||
FISHING_BOBBER(107, ENTITY),
|
||||
AREA_EFFECT_CLOUD(ENTITY),
|
||||
END_CRYSTAL(ENTITY),
|
||||
EVOKER_FANGS(ENTITY),
|
||||
EXPERIENCE_ORB(ENTITY),
|
||||
EYE_OF_ENDER(ENTITY),
|
||||
FALLING_BLOCK(ENTITY),
|
||||
ITEM(ENTITY),
|
||||
TNT(ENTITY),
|
||||
LIGHTNING_BOLT(ENTITY),
|
||||
|
||||
LIVINGENTITY(-1, ENTITY),
|
||||
ARMOR_STAND(1, LIVINGENTITY),
|
||||
PLAYER(106, LIVINGENTITY),
|
||||
|
||||
ABSTRACT_INSENTIENT(-1, LIVINGENTITY),
|
||||
ENDER_DRAGON(19, ABSTRACT_INSENTIENT),
|
||||
|
||||
BEE(4, ABSTRACT_INSENTIENT),
|
||||
|
||||
ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT),
|
||||
|
||||
ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE),
|
||||
VILLAGER(93, ABSTRACT_AGEABLE),
|
||||
WANDERING_TRADER(95, ABSTRACT_AGEABLE),
|
||||
|
||||
// Animals
|
||||
ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE),
|
||||
DOLPHIN(13, ABSTRACT_INSENTIENT),
|
||||
CHICKEN(9, ABSTRACT_ANIMAL),
|
||||
COW(11, ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(53, COW),
|
||||
PANDA(56, ABSTRACT_INSENTIENT),
|
||||
PIG(59, ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(63, ABSTRACT_ANIMAL),
|
||||
RABBIT(66, ABSTRACT_ANIMAL),
|
||||
SHEEP(69, ABSTRACT_ANIMAL),
|
||||
TURTLE(91, ABSTRACT_ANIMAL),
|
||||
FOX(28, ABSTRACT_ANIMAL),
|
||||
|
||||
ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL),
|
||||
CAT(7, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
OCELOT(54, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
WOLF(100, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
PARROT(57, ABSTRACT_PARROT),
|
||||
|
||||
// Horses
|
||||
ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL),
|
||||
CHESTED_HORSE(-1, ABSTRACT_HORSE),
|
||||
DONKEY(14, CHESTED_HORSE),
|
||||
MULE(52, CHESTED_HORSE),
|
||||
LLAMA(42, CHESTED_HORSE),
|
||||
TRADER_LLAMA(89, CHESTED_HORSE),
|
||||
HORSE(33, ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(74, ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(103, ABSTRACT_HORSE),
|
||||
|
||||
// Golem
|
||||
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE),
|
||||
SNOW_GOLEM(77, ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(36, ABSTRACT_GOLEM),
|
||||
SHULKER(70, ABSTRACT_GOLEM),
|
||||
|
||||
// Fish
|
||||
ABSTRACT_FISHES(-1, ABSTRACT_CREATURE),
|
||||
COD(10, ABSTRACT_FISHES),
|
||||
PUFFERFISH(65, ABSTRACT_FISHES),
|
||||
SALMON(68, ABSTRACT_FISHES),
|
||||
TROPICAL_FISH(90, ABSTRACT_FISHES),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE),
|
||||
BLAZE(5, ABSTRACT_MONSTER),
|
||||
CREEPER(12, ABSTRACT_MONSTER),
|
||||
ENDERMITE(21, ABSTRACT_MONSTER),
|
||||
ENDERMAN(20, ABSTRACT_MONSTER),
|
||||
GIANT(30, ABSTRACT_MONSTER),
|
||||
SILVERFISH(72, ABSTRACT_MONSTER),
|
||||
VEX(92, ABSTRACT_MONSTER),
|
||||
WITCH(96, ABSTRACT_MONSTER),
|
||||
WITHER(97, ABSTRACT_MONSTER),
|
||||
RAVAGER(67, ABSTRACT_MONSTER),
|
||||
|
||||
ABSTRACT_PIGLIN(-1, ABSTRACT_MONSTER),
|
||||
|
||||
PIGLIN(60, ABSTRACT_PIGLIN),
|
||||
PIGLIN_BRUTE(61, ABSTRACT_PIGLIN),
|
||||
|
||||
HOGLIN(32, ABSTRACT_ANIMAL),
|
||||
STRIDER(83, ABSTRACT_ANIMAL),
|
||||
ZOGLIN(101, ABSTRACT_MONSTER),
|
||||
|
||||
// Illagers
|
||||
ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER),
|
||||
ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE),
|
||||
EVOKER(22, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
ILLUSIONER(35, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
VINDICATOR(94, ABSTRACT_ILLAGER_BASE),
|
||||
PILLAGER(62, ABSTRACT_ILLAGER_BASE),
|
||||
|
||||
// Skeletons
|
||||
ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER),
|
||||
SKELETON(73, ABSTRACT_SKELETON),
|
||||
STRAY(82, ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(98, ABSTRACT_SKELETON),
|
||||
|
||||
// Guardians
|
||||
GUARDIAN(31, ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(17, GUARDIAN),
|
||||
|
||||
// Spiders
|
||||
SPIDER(80, ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(8, SPIDER),
|
||||
|
||||
// Zombies
|
||||
ZOMBIE(102, ABSTRACT_MONSTER),
|
||||
DROWNED(16, ZOMBIE),
|
||||
HUSK(34, ZOMBIE),
|
||||
ZOMBIFIED_PIGLIN(105, ZOMBIE),
|
||||
ZOMBIE_VILLAGER(104, ZOMBIE),
|
||||
|
||||
// Flying entities
|
||||
ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT),
|
||||
GHAST(29, ABSTRACT_FLYING),
|
||||
PHANTOM(58, ABSTRACT_FLYING),
|
||||
|
||||
ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT),
|
||||
BAT(3, ABSTRACT_AMBIENT),
|
||||
|
||||
ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT),
|
||||
SQUID(81, ABSTRACT_WATERMOB),
|
||||
|
||||
// Slimes
|
||||
SLIME(75, ABSTRACT_INSENTIENT),
|
||||
MAGMA_CUBE(44, SLIME),
|
||||
|
||||
// Hangable objects
|
||||
ABSTRACT_HANGING(-1, ENTITY),
|
||||
LEASH_KNOT(40, ABSTRACT_HANGING),
|
||||
ITEM_FRAME(38, ABSTRACT_HANGING),
|
||||
PAINTING(55, ABSTRACT_HANGING),
|
||||
|
||||
ABSTRACT_LIGHTNING(-1, ENTITY),
|
||||
LIGHTNING_BOLT(41, ABSTRACT_LIGHTNING),
|
||||
|
||||
// Arrows
|
||||
ABSTRACT_ARROW(-1, ENTITY),
|
||||
ARROW(2, ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(79, ABSTRACT_ARROW),
|
||||
TRIDENT(88, ABSTRACT_ARROW),
|
||||
|
||||
// Fireballs
|
||||
ABSTRACT_FIREBALL(-1, ENTITY),
|
||||
DRAGON_FIREBALL(15, ABSTRACT_FIREBALL),
|
||||
FIREBALL(39, ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(76, ABSTRACT_FIREBALL),
|
||||
WITHER_SKULL(99, ABSTRACT_FIREBALL),
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY, null),
|
||||
LEASH_KNOT(HANGING_ENTITY),
|
||||
PAINTING(HANGING_ENTITY),
|
||||
ITEM_FRAME(HANGING_ENTITY),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE_ABSTRACT(-1, ENTITY),
|
||||
SNOWBALL(78, PROJECTILE_ABSTRACT),
|
||||
ENDER_PEARL(85, PROJECTILE_ABSTRACT),
|
||||
EGG(84, PROJECTILE_ABSTRACT),
|
||||
POTION(87, PROJECTILE_ABSTRACT),
|
||||
EXPERIENCE_BOTTLE(86, PROJECTILE_ABSTRACT),
|
||||
PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing
|
||||
SNOWBALL(PROJECTILE),
|
||||
ENDER_PEARL(PROJECTILE),
|
||||
EGG(PROJECTILE),
|
||||
POTION(PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(PROJECTILE),
|
||||
FIREWORK_ROCKET(PROJECTILE),
|
||||
LLAMA_SPIT(PROJECTILE),
|
||||
SHULKER_BULLET(PROJECTILE),
|
||||
FISHING_BOBBER(PROJECTILE),
|
||||
WITHER_SKULL(PROJECTILE),
|
||||
DRAGON_FIREBALL(PROJECTILE), // Doesn't actually inherit fireball
|
||||
|
||||
ABSTRACT_ARROW(PROJECTILE, null),
|
||||
ARROW(ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(ABSTRACT_ARROW),
|
||||
TRIDENT(ABSTRACT_ARROW),
|
||||
|
||||
ABSTRACT_FIREBALL(ENTITY, null),
|
||||
FIREBALL(ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(ABSTRACT_FIREBALL),
|
||||
|
||||
// Vehicles
|
||||
MINECART_ABSTRACT(-1, ENTITY),
|
||||
CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT),
|
||||
CHEST_MINECART(46, CHESTED_MINECART_ABSTRACT),
|
||||
HOPPER_MINECART(49, CHESTED_MINECART_ABSTRACT),
|
||||
MINECART(45, MINECART_ABSTRACT),
|
||||
FURNACE_MINECART(48, MINECART_ABSTRACT),
|
||||
COMMAND_BLOCK_MINECART(47, MINECART_ABSTRACT),
|
||||
TNT_MINECART(51, MINECART_ABSTRACT),
|
||||
SPAWNER_MINECART(50, MINECART_ABSTRACT),
|
||||
BOAT(6, ENTITY);
|
||||
VEHICLE(ENTITY, null),
|
||||
BOAT(VEHICLE),
|
||||
|
||||
private static final EntityType[] TYPES;
|
||||
ABSTRACT_MINECART(VEHICLE, null),
|
||||
MINECART(ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(ABSTRACT_MINECART),
|
||||
TNT_MINECART(ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(ABSTRACT_MINECART),
|
||||
|
||||
private final int id;
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART, null),
|
||||
CHEST_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(ENTITY, null),
|
||||
ARMOR_STAND(LIVING_ENTITY),
|
||||
PLAYER(LIVING_ENTITY),
|
||||
|
||||
// Mobs as a larger subclass
|
||||
MOB(LIVING_ENTITY, null),
|
||||
ENDER_DRAGON(MOB),
|
||||
|
||||
SLIME(MOB),
|
||||
MAGMA_CUBE(SLIME),
|
||||
|
||||
// Ambient mobs
|
||||
AMBIENT_CREATURE(MOB, null),
|
||||
BAT(AMBIENT_CREATURE),
|
||||
|
||||
// Flying mobs
|
||||
FLYING_MOB(MOB, null),
|
||||
GHAST(FLYING_MOB),
|
||||
PHANTOM(FLYING_MOB),
|
||||
|
||||
// Pathfinder mobs and its subclasses
|
||||
PATHFINDER_MOB(MOB, null),
|
||||
|
||||
ABSTRACT_GOLEM(PATHFINDER_MOB, null),
|
||||
SNOW_GOLEM(ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(ABSTRACT_GOLEM),
|
||||
SHULKER(ABSTRACT_GOLEM),
|
||||
|
||||
// Water mobs
|
||||
WATER_ANIMAL(PATHFINDER_MOB, null),
|
||||
DOLPHIN(WATER_ANIMAL),
|
||||
SQUID(WATER_ANIMAL),
|
||||
|
||||
ABSTRACT_FISH(WATER_ANIMAL, null),
|
||||
PUFFERFISH(ABSTRACT_FISH),
|
||||
|
||||
ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISH, null),
|
||||
COD(ABSTRACT_SCHOOLING_FISH),
|
||||
SALMON(ABSTRACT_SCHOOLING_FISH),
|
||||
TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(PATHFINDER_MOB, null),
|
||||
ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null),
|
||||
VILLAGER(ABSTRACT_VILLAGER),
|
||||
WANDERING_TRADER(ABSTRACT_VILLAGER),
|
||||
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
|
||||
CHICKEN(ABSTRACT_ANIMAL),
|
||||
PANDA(ABSTRACT_ANIMAL),
|
||||
PIG(ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(ABSTRACT_ANIMAL),
|
||||
RABBIT(ABSTRACT_ANIMAL),
|
||||
SHEEP(ABSTRACT_ANIMAL),
|
||||
BEE(ABSTRACT_ANIMAL),
|
||||
TURTLE(ABSTRACT_ANIMAL),
|
||||
FOX(ABSTRACT_ANIMAL),
|
||||
HOGLIN(ABSTRACT_ANIMAL),
|
||||
STRIDER(ABSTRACT_ANIMAL),
|
||||
|
||||
COW(ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(COW),
|
||||
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(TAMABLE_ANIMAL),
|
||||
OCELOT(TAMABLE_ANIMAL),
|
||||
WOLF(TAMABLE_ANIMAL),
|
||||
PARROT(TAMABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
|
||||
HORSE(ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(ABSTRACT_HORSE),
|
||||
|
||||
ABSTRACT_CHESTED_HORSE(ABSTRACT_HORSE, null),
|
||||
DONKEY(ABSTRACT_CHESTED_HORSE),
|
||||
MULE(ABSTRACT_CHESTED_HORSE),
|
||||
LLAMA(ABSTRACT_CHESTED_HORSE),
|
||||
TRADER_LLAMA(LLAMA),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(PATHFINDER_MOB, null),
|
||||
BLAZE(ABSTRACT_MONSTER),
|
||||
CREEPER(ABSTRACT_MONSTER),
|
||||
ENDERMITE(ABSTRACT_MONSTER),
|
||||
ENDERMAN(ABSTRACT_MONSTER),
|
||||
GIANT(ABSTRACT_MONSTER),
|
||||
SILVERFISH(ABSTRACT_MONSTER),
|
||||
VEX(ABSTRACT_MONSTER),
|
||||
WITHER(ABSTRACT_MONSTER),
|
||||
ZOGLIN(ABSTRACT_MONSTER),
|
||||
|
||||
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
|
||||
SKELETON(ABSTRACT_SKELETON),
|
||||
STRAY(ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(ABSTRACT_SKELETON),
|
||||
|
||||
ZOMBIE(ABSTRACT_MONSTER),
|
||||
DROWNED(ZOMBIE),
|
||||
HUSK(ZOMBIE),
|
||||
ZOMBIFIED_PIGLIN(ZOMBIE),
|
||||
ZOMBIE_VILLAGER(ZOMBIE),
|
||||
|
||||
GUARDIAN(ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(GUARDIAN),
|
||||
|
||||
SPIDER(ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(SPIDER),
|
||||
|
||||
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
|
||||
PIGLIN(ABSTRACT_PIGLIN),
|
||||
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
|
||||
|
||||
// Raiders
|
||||
ABSTRACT_RAIDER(ABSTRACT_MONSTER, null),
|
||||
WITCH(ABSTRACT_RAIDER),
|
||||
RAVAGER(ABSTRACT_RAIDER),
|
||||
|
||||
ABSTRACT_ILLAGER(ABSTRACT_RAIDER, null),
|
||||
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER, null),
|
||||
VINDICATOR(ABSTRACT_ILLAGER),
|
||||
PILLAGER(ABSTRACT_ILLAGER),
|
||||
EVOKER(SPELLCASTER_ILLAGER),
|
||||
ILLUSIONER(SPELLCASTER_ILLAGER);
|
||||
|
||||
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
|
||||
private final EntityType parent;
|
||||
private final String identifier;
|
||||
private int id = -1;
|
||||
|
||||
EntityTypes1_16_2(int id) {
|
||||
this.id = id;
|
||||
this.parent = null;
|
||||
EntityTypes1_16_2(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_16_2(int id, EntityType parent) {
|
||||
this.id = id;
|
||||
EntityTypes1_16_2(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 EntityType getParent() {
|
||||
public String identifier() {
|
||||
Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type");
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable EntityType getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
return identifier == null;
|
||||
}
|
||||
|
||||
static {
|
||||
TYPES = EntityTypeUtil.toOrderedArray(values());
|
||||
}
|
||||
|
||||
public static EntityType getTypeFromId(int typeId) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
+209
-201
@@ -22,239 +22,247 @@
|
||||
*/
|
||||
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 com.viaversion.viaversion.util.Key;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum EntityTypes1_17 implements EntityType {
|
||||
|
||||
ENTITY(-1),
|
||||
ENTITY(null, null),
|
||||
|
||||
AREA_EFFECT_CLOUD(0, ENTITY),
|
||||
END_CRYSTAL(19, ENTITY),
|
||||
EVOKER_FANGS(24, ENTITY),
|
||||
EXPERIENCE_ORB(25, ENTITY),
|
||||
EYE_OF_ENDER(26, ENTITY),
|
||||
FALLING_BLOCK(27, ENTITY),
|
||||
FIREWORK_ROCKET(28, ENTITY),
|
||||
ITEM(41, ENTITY),
|
||||
LLAMA_SPIT(47, ENTITY),
|
||||
TNT(69, ENTITY),
|
||||
SHULKER_BULLET(76, ENTITY),
|
||||
FISHING_BOBBER(112, ENTITY),
|
||||
AREA_EFFECT_CLOUD(ENTITY),
|
||||
END_CRYSTAL(ENTITY),
|
||||
EVOKER_FANGS(ENTITY),
|
||||
EXPERIENCE_ORB(ENTITY),
|
||||
EYE_OF_ENDER(ENTITY),
|
||||
FALLING_BLOCK(ENTITY),
|
||||
ITEM(ENTITY),
|
||||
TNT(ENTITY),
|
||||
MARKER(ENTITY),
|
||||
LIGHTNING_BOLT(ENTITY),
|
||||
|
||||
LIVINGENTITY(-1, ENTITY),
|
||||
ARMOR_STAND(1, LIVINGENTITY),
|
||||
MARKER(49, ENTITY),
|
||||
PLAYER(111, LIVINGENTITY),
|
||||
|
||||
ABSTRACT_INSENTIENT(-1, LIVINGENTITY),
|
||||
ENDER_DRAGON(20, ABSTRACT_INSENTIENT),
|
||||
|
||||
BEE(5, ABSTRACT_INSENTIENT),
|
||||
|
||||
ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT),
|
||||
|
||||
ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE),
|
||||
VILLAGER(98, ABSTRACT_AGEABLE),
|
||||
WANDERING_TRADER(100, ABSTRACT_AGEABLE),
|
||||
|
||||
// Animals
|
||||
ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE),
|
||||
AXOLOTL(3, ABSTRACT_ANIMAL),
|
||||
DOLPHIN(14, ABSTRACT_INSENTIENT),
|
||||
CHICKEN(10, ABSTRACT_ANIMAL),
|
||||
COW(12, ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(58, COW),
|
||||
PANDA(61, ABSTRACT_INSENTIENT),
|
||||
PIG(64, ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(68, ABSTRACT_ANIMAL),
|
||||
RABBIT(71, ABSTRACT_ANIMAL),
|
||||
SHEEP(74, ABSTRACT_ANIMAL),
|
||||
TURTLE(96, ABSTRACT_ANIMAL),
|
||||
FOX(29, ABSTRACT_ANIMAL),
|
||||
GOAT(34, ABSTRACT_ANIMAL),
|
||||
|
||||
ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL),
|
||||
CAT(8, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
OCELOT(59, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
WOLF(105, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
PARROT(62, ABSTRACT_PARROT),
|
||||
|
||||
// Horses
|
||||
ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL),
|
||||
CHESTED_HORSE(-1, ABSTRACT_HORSE),
|
||||
DONKEY(15, CHESTED_HORSE),
|
||||
MULE(57, CHESTED_HORSE),
|
||||
LLAMA(46, CHESTED_HORSE),
|
||||
TRADER_LLAMA(94, CHESTED_HORSE),
|
||||
HORSE(37, ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(79, ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(108, ABSTRACT_HORSE),
|
||||
|
||||
// Golem
|
||||
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE),
|
||||
SNOW_GOLEM(82, ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(40, ABSTRACT_GOLEM),
|
||||
SHULKER(75, ABSTRACT_GOLEM),
|
||||
|
||||
// Fish
|
||||
ABSTRACT_FISHES(-1, ABSTRACT_CREATURE),
|
||||
COD(11, ABSTRACT_FISHES),
|
||||
PUFFERFISH(70, ABSTRACT_FISHES),
|
||||
SALMON(73, ABSTRACT_FISHES),
|
||||
TROPICAL_FISH(95, ABSTRACT_FISHES),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE),
|
||||
BLAZE(6, ABSTRACT_MONSTER),
|
||||
CREEPER(13, ABSTRACT_MONSTER),
|
||||
ENDERMITE(22, ABSTRACT_MONSTER),
|
||||
ENDERMAN(21, ABSTRACT_MONSTER),
|
||||
GIANT(31, ABSTRACT_MONSTER),
|
||||
SILVERFISH(77, ABSTRACT_MONSTER),
|
||||
VEX(97, ABSTRACT_MONSTER),
|
||||
WITCH(101, ABSTRACT_MONSTER),
|
||||
WITHER(102, ABSTRACT_MONSTER),
|
||||
RAVAGER(72, ABSTRACT_MONSTER),
|
||||
|
||||
ABSTRACT_PIGLIN(-1, ABSTRACT_MONSTER),
|
||||
|
||||
PIGLIN(65, ABSTRACT_PIGLIN),
|
||||
PIGLIN_BRUTE(66, ABSTRACT_PIGLIN),
|
||||
|
||||
HOGLIN(36, ABSTRACT_ANIMAL),
|
||||
STRIDER(88, ABSTRACT_ANIMAL),
|
||||
ZOGLIN(106, ABSTRACT_MONSTER),
|
||||
|
||||
// Illagers
|
||||
ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER),
|
||||
ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE),
|
||||
EVOKER(23, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
ILLUSIONER(39, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
VINDICATOR(99, ABSTRACT_ILLAGER_BASE),
|
||||
PILLAGER(67, ABSTRACT_ILLAGER_BASE),
|
||||
|
||||
// Skeletons
|
||||
ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER),
|
||||
SKELETON(78, ABSTRACT_SKELETON),
|
||||
STRAY(87, ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(103, ABSTRACT_SKELETON),
|
||||
|
||||
// Guardians
|
||||
GUARDIAN(35, ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(18, GUARDIAN),
|
||||
|
||||
// Spiders
|
||||
SPIDER(85, ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(9, SPIDER),
|
||||
|
||||
// Zombies
|
||||
ZOMBIE(107, ABSTRACT_MONSTER),
|
||||
DROWNED(17, ZOMBIE),
|
||||
HUSK(38, ZOMBIE),
|
||||
ZOMBIFIED_PIGLIN(110, ZOMBIE),
|
||||
ZOMBIE_VILLAGER(109, ZOMBIE),
|
||||
|
||||
// Flying entities
|
||||
ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT),
|
||||
GHAST(30, ABSTRACT_FLYING),
|
||||
PHANTOM(63, ABSTRACT_FLYING),
|
||||
|
||||
ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT),
|
||||
BAT(4, ABSTRACT_AMBIENT),
|
||||
|
||||
ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT),
|
||||
SQUID(86, ABSTRACT_WATERMOB),
|
||||
GLOW_SQUID(33, SQUID),
|
||||
|
||||
// Slimes
|
||||
SLIME(80, ABSTRACT_INSENTIENT),
|
||||
MAGMA_CUBE(48, SLIME),
|
||||
|
||||
// Hangable objects
|
||||
ABSTRACT_HANGING(-1, ENTITY),
|
||||
LEASH_KNOT(44, ABSTRACT_HANGING),
|
||||
ITEM_FRAME(42, ABSTRACT_HANGING),
|
||||
GLOW_ITEM_FRAME(32, ITEM_FRAME),
|
||||
PAINTING(60, ABSTRACT_HANGING),
|
||||
|
||||
ABSTRACT_LIGHTNING(-1, ENTITY),
|
||||
LIGHTNING_BOLT(45, ABSTRACT_LIGHTNING),
|
||||
|
||||
// Arrows
|
||||
ABSTRACT_ARROW(-1, ENTITY),
|
||||
ARROW(2, ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(84, ABSTRACT_ARROW),
|
||||
TRIDENT(93, ABSTRACT_ARROW),
|
||||
|
||||
// Fireballs
|
||||
ABSTRACT_FIREBALL(-1, ENTITY),
|
||||
DRAGON_FIREBALL(16, ABSTRACT_FIREBALL),
|
||||
FIREBALL(43, ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(81, ABSTRACT_FIREBALL),
|
||||
WITHER_SKULL(104, ABSTRACT_FIREBALL),
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY, null),
|
||||
LEASH_KNOT(HANGING_ENTITY),
|
||||
PAINTING(HANGING_ENTITY),
|
||||
ITEM_FRAME(HANGING_ENTITY),
|
||||
GLOW_ITEM_FRAME(ITEM_FRAME),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE_ABSTRACT(-1, ENTITY),
|
||||
SNOWBALL(83, PROJECTILE_ABSTRACT),
|
||||
ENDER_PEARL(90, PROJECTILE_ABSTRACT),
|
||||
EGG(89, PROJECTILE_ABSTRACT),
|
||||
POTION(92, PROJECTILE_ABSTRACT),
|
||||
EXPERIENCE_BOTTLE(91, PROJECTILE_ABSTRACT),
|
||||
PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing
|
||||
SNOWBALL(PROJECTILE),
|
||||
ENDER_PEARL(PROJECTILE),
|
||||
EGG(PROJECTILE),
|
||||
POTION(PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(PROJECTILE),
|
||||
FIREWORK_ROCKET(PROJECTILE),
|
||||
LLAMA_SPIT(PROJECTILE),
|
||||
SHULKER_BULLET(PROJECTILE),
|
||||
FISHING_BOBBER(PROJECTILE),
|
||||
WITHER_SKULL(PROJECTILE),
|
||||
DRAGON_FIREBALL(PROJECTILE), // Doesn't actually inherit fireball
|
||||
|
||||
ABSTRACT_ARROW(PROJECTILE, null),
|
||||
ARROW(ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(ABSTRACT_ARROW),
|
||||
TRIDENT(ABSTRACT_ARROW),
|
||||
|
||||
ABSTRACT_FIREBALL(ENTITY, null),
|
||||
FIREBALL(ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(ABSTRACT_FIREBALL),
|
||||
|
||||
// Vehicles
|
||||
MINECART_ABSTRACT(-1, ENTITY),
|
||||
CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT),
|
||||
CHEST_MINECART(51, CHESTED_MINECART_ABSTRACT),
|
||||
HOPPER_MINECART(54, CHESTED_MINECART_ABSTRACT),
|
||||
MINECART(50, MINECART_ABSTRACT),
|
||||
FURNACE_MINECART(53, MINECART_ABSTRACT),
|
||||
COMMAND_BLOCK_MINECART(52, MINECART_ABSTRACT),
|
||||
TNT_MINECART(56, MINECART_ABSTRACT),
|
||||
SPAWNER_MINECART(55, MINECART_ABSTRACT),
|
||||
BOAT(7, ENTITY);
|
||||
VEHICLE(ENTITY, null),
|
||||
BOAT(VEHICLE),
|
||||
|
||||
private static final EntityType[] TYPES;
|
||||
ABSTRACT_MINECART(VEHICLE, null),
|
||||
MINECART(ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(ABSTRACT_MINECART),
|
||||
TNT_MINECART(ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(ABSTRACT_MINECART),
|
||||
|
||||
private final int id;
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART, null),
|
||||
CHEST_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(ENTITY, null),
|
||||
ARMOR_STAND(LIVING_ENTITY),
|
||||
PLAYER(LIVING_ENTITY),
|
||||
|
||||
// Mobs as a larger subclass
|
||||
MOB(LIVING_ENTITY, null),
|
||||
ENDER_DRAGON(MOB),
|
||||
|
||||
SLIME(MOB),
|
||||
MAGMA_CUBE(SLIME),
|
||||
|
||||
// Ambient mobs
|
||||
AMBIENT_CREATURE(MOB, null),
|
||||
BAT(AMBIENT_CREATURE),
|
||||
|
||||
// Flying mobs
|
||||
FLYING_MOB(MOB, null),
|
||||
GHAST(FLYING_MOB),
|
||||
PHANTOM(FLYING_MOB),
|
||||
|
||||
// Pathfinder mobs and its subclasses
|
||||
PATHFINDER_MOB(MOB, null),
|
||||
|
||||
ABSTRACT_GOLEM(PATHFINDER_MOB, null),
|
||||
SNOW_GOLEM(ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(ABSTRACT_GOLEM),
|
||||
SHULKER(ABSTRACT_GOLEM),
|
||||
|
||||
// Water mobs
|
||||
WATER_ANIMAL(PATHFINDER_MOB, null),
|
||||
DOLPHIN(WATER_ANIMAL),
|
||||
|
||||
SQUID(WATER_ANIMAL),
|
||||
GLOW_SQUID(SQUID),
|
||||
|
||||
ABSTRACT_FISH(WATER_ANIMAL, null),
|
||||
PUFFERFISH(ABSTRACT_FISH),
|
||||
|
||||
ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISH, null),
|
||||
COD(ABSTRACT_SCHOOLING_FISH),
|
||||
SALMON(ABSTRACT_SCHOOLING_FISH),
|
||||
TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(PATHFINDER_MOB, null),
|
||||
ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null),
|
||||
VILLAGER(ABSTRACT_VILLAGER),
|
||||
WANDERING_TRADER(ABSTRACT_VILLAGER),
|
||||
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
|
||||
AXOLOTL(ABSTRACT_ANIMAL),
|
||||
CHICKEN(ABSTRACT_ANIMAL),
|
||||
PANDA(ABSTRACT_ANIMAL),
|
||||
PIG(ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(ABSTRACT_ANIMAL),
|
||||
RABBIT(ABSTRACT_ANIMAL),
|
||||
SHEEP(ABSTRACT_ANIMAL),
|
||||
BEE(ABSTRACT_ANIMAL),
|
||||
TURTLE(ABSTRACT_ANIMAL),
|
||||
FOX(ABSTRACT_ANIMAL),
|
||||
GOAT(ABSTRACT_ANIMAL),
|
||||
HOGLIN(ABSTRACT_ANIMAL),
|
||||
STRIDER(ABSTRACT_ANIMAL),
|
||||
|
||||
COW(ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(COW),
|
||||
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(TAMABLE_ANIMAL),
|
||||
OCELOT(TAMABLE_ANIMAL),
|
||||
WOLF(TAMABLE_ANIMAL),
|
||||
PARROT(TAMABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
|
||||
HORSE(ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(ABSTRACT_HORSE),
|
||||
|
||||
ABSTRACT_CHESTED_HORSE(ABSTRACT_HORSE, null),
|
||||
DONKEY(ABSTRACT_CHESTED_HORSE),
|
||||
MULE(ABSTRACT_CHESTED_HORSE),
|
||||
LLAMA(ABSTRACT_CHESTED_HORSE),
|
||||
TRADER_LLAMA(LLAMA),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(PATHFINDER_MOB, null),
|
||||
BLAZE(ABSTRACT_MONSTER),
|
||||
CREEPER(ABSTRACT_MONSTER),
|
||||
ENDERMITE(ABSTRACT_MONSTER),
|
||||
ENDERMAN(ABSTRACT_MONSTER),
|
||||
GIANT(ABSTRACT_MONSTER),
|
||||
SILVERFISH(ABSTRACT_MONSTER),
|
||||
VEX(ABSTRACT_MONSTER),
|
||||
WITHER(ABSTRACT_MONSTER),
|
||||
ZOGLIN(ABSTRACT_MONSTER),
|
||||
|
||||
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
|
||||
SKELETON(ABSTRACT_SKELETON),
|
||||
STRAY(ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(ABSTRACT_SKELETON),
|
||||
|
||||
ZOMBIE(ABSTRACT_MONSTER),
|
||||
DROWNED(ZOMBIE),
|
||||
HUSK(ZOMBIE),
|
||||
ZOMBIFIED_PIGLIN(ZOMBIE),
|
||||
ZOMBIE_VILLAGER(ZOMBIE),
|
||||
|
||||
GUARDIAN(ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(GUARDIAN),
|
||||
|
||||
SPIDER(ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(SPIDER),
|
||||
|
||||
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
|
||||
PIGLIN(ABSTRACT_PIGLIN),
|
||||
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
|
||||
|
||||
// Raiders
|
||||
ABSTRACT_RAIDER(ABSTRACT_MONSTER, null),
|
||||
WITCH(ABSTRACT_RAIDER),
|
||||
RAVAGER(ABSTRACT_RAIDER),
|
||||
|
||||
ABSTRACT_ILLAGER(ABSTRACT_RAIDER, null),
|
||||
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER, null),
|
||||
VINDICATOR(ABSTRACT_ILLAGER),
|
||||
PILLAGER(ABSTRACT_ILLAGER),
|
||||
EVOKER(SPELLCASTER_ILLAGER),
|
||||
ILLUSIONER(SPELLCASTER_ILLAGER);
|
||||
|
||||
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
|
||||
private final EntityType parent;
|
||||
private final String identifier;
|
||||
private int id = -1;
|
||||
|
||||
EntityTypes1_17(int id) {
|
||||
this.id = id;
|
||||
this.parent = null;
|
||||
EntityTypes1_17(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_17(int id, EntityType parent) {
|
||||
this.id = id;
|
||||
EntityTypes1_17(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 EntityType getParent() {
|
||||
public String identifier() {
|
||||
Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type");
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable EntityType getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
return identifier == null;
|
||||
}
|
||||
|
||||
static {
|
||||
TYPES = EntityTypeUtil.toOrderedArray(values());
|
||||
}
|
||||
|
||||
public static EntityType getTypeFromId(int typeId) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
+142
-142
@@ -26,6 +26,7 @@ import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.util.EntityTypeUtil;
|
||||
import java.util.Locale;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum EntityTypes1_19 implements EntityType {
|
||||
@@ -38,80 +39,147 @@ public enum EntityTypes1_19 implements EntityType {
|
||||
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),
|
||||
LIGHTNING_BOLT(ENTITY),
|
||||
|
||||
ABSTRACT_INSENTIENT(LIVINGENTITY, null),
|
||||
ENDER_DRAGON(ABSTRACT_INSENTIENT),
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY, null),
|
||||
LEASH_KNOT(HANGING_ENTITY),
|
||||
PAINTING(HANGING_ENTITY),
|
||||
ITEM_FRAME(HANGING_ENTITY),
|
||||
GLOW_ITEM_FRAME(ITEM_FRAME),
|
||||
|
||||
BEE(ABSTRACT_INSENTIENT),
|
||||
// Projectiles
|
||||
PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing
|
||||
SNOWBALL(PROJECTILE),
|
||||
ENDER_PEARL(PROJECTILE),
|
||||
EGG(PROJECTILE),
|
||||
POTION(PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(PROJECTILE),
|
||||
FIREWORK_ROCKET(PROJECTILE),
|
||||
LLAMA_SPIT(PROJECTILE),
|
||||
SHULKER_BULLET(PROJECTILE),
|
||||
FISHING_BOBBER(PROJECTILE),
|
||||
WITHER_SKULL(PROJECTILE),
|
||||
DRAGON_FIREBALL(PROJECTILE), // Doesn't actually inherit fireball
|
||||
|
||||
ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null),
|
||||
ABSTRACT_ARROW(PROJECTILE, null),
|
||||
ARROW(ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(ABSTRACT_ARROW),
|
||||
TRIDENT(ABSTRACT_ARROW),
|
||||
|
||||
ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null),
|
||||
VILLAGER(ABSTRACT_AGEABLE),
|
||||
WANDERING_TRADER(ABSTRACT_AGEABLE),
|
||||
ABSTRACT_FIREBALL(ENTITY, null),
|
||||
FIREBALL(ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(ABSTRACT_FIREBALL),
|
||||
|
||||
// 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),
|
||||
// Vehicles
|
||||
VEHICLE(ENTITY, null),
|
||||
BOAT(VEHICLE),
|
||||
|
||||
ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
OCELOT(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
WOLF(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
ABSTRACT_MINECART(VEHICLE, null),
|
||||
MINECART(ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(ABSTRACT_MINECART),
|
||||
TNT_MINECART(ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(ABSTRACT_MINECART),
|
||||
CHEST_BOAT(BOAT),
|
||||
|
||||
ABSTRACT_PARROT(ABSTRACT_TAMEABLE_ANIMAL, null),
|
||||
PARROT(ABSTRACT_PARROT),
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART, null),
|
||||
CHEST_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
// 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),
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(ENTITY, null),
|
||||
ARMOR_STAND(LIVING_ENTITY),
|
||||
PLAYER(LIVING_ENTITY),
|
||||
|
||||
// Golem
|
||||
ABSTRACT_GOLEM(ABSTRACT_CREATURE, null),
|
||||
// Mobs as a larger subclass
|
||||
MOB(LIVING_ENTITY, null),
|
||||
ENDER_DRAGON(MOB),
|
||||
|
||||
SLIME(MOB),
|
||||
MAGMA_CUBE(SLIME),
|
||||
|
||||
// Ambient mobs
|
||||
AMBIENT_CREATURE(MOB, null),
|
||||
BAT(AMBIENT_CREATURE),
|
||||
|
||||
// Flying mobs
|
||||
FLYING_MOB(MOB, null),
|
||||
GHAST(FLYING_MOB),
|
||||
PHANTOM(FLYING_MOB),
|
||||
|
||||
// Pathfinder mobs and its subclasses
|
||||
PATHFINDER_MOB(MOB, null),
|
||||
ALLAY(PATHFINDER_MOB),
|
||||
|
||||
ABSTRACT_GOLEM(PATHFINDER_MOB, 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),
|
||||
// Water mobs
|
||||
WATER_ANIMAL(PATHFINDER_MOB, null),
|
||||
DOLPHIN(WATER_ANIMAL),
|
||||
|
||||
SQUID(WATER_ANIMAL),
|
||||
GLOW_SQUID(SQUID),
|
||||
|
||||
ABSTRACT_FISH(WATER_ANIMAL, null),
|
||||
PUFFERFISH(ABSTRACT_FISH),
|
||||
TADPOLE(ABSTRACT_FISH),
|
||||
|
||||
ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISH, null),
|
||||
COD(ABSTRACT_SCHOOLING_FISH),
|
||||
SALMON(ABSTRACT_SCHOOLING_FISH),
|
||||
TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(PATHFINDER_MOB, null),
|
||||
ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null),
|
||||
VILLAGER(ABSTRACT_VILLAGER),
|
||||
WANDERING_TRADER(ABSTRACT_VILLAGER),
|
||||
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
|
||||
AXOLOTL(ABSTRACT_ANIMAL),
|
||||
CHICKEN(ABSTRACT_ANIMAL),
|
||||
PANDA(ABSTRACT_ANIMAL),
|
||||
PIG(ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(ABSTRACT_ANIMAL),
|
||||
RABBIT(ABSTRACT_ANIMAL),
|
||||
SHEEP(ABSTRACT_ANIMAL),
|
||||
BEE(ABSTRACT_ANIMAL),
|
||||
TURTLE(ABSTRACT_ANIMAL),
|
||||
FOX(ABSTRACT_ANIMAL),
|
||||
FROG(ABSTRACT_ANIMAL),
|
||||
GOAT(ABSTRACT_ANIMAL),
|
||||
HOGLIN(ABSTRACT_ANIMAL),
|
||||
STRIDER(ABSTRACT_ANIMAL),
|
||||
|
||||
COW(ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(COW),
|
||||
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(TAMABLE_ANIMAL),
|
||||
OCELOT(TAMABLE_ANIMAL),
|
||||
WOLF(TAMABLE_ANIMAL),
|
||||
PARROT(TAMABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
|
||||
HORSE(ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(ABSTRACT_HORSE),
|
||||
|
||||
ABSTRACT_CHESTED_HORSE(ABSTRACT_HORSE, null),
|
||||
DONKEY(ABSTRACT_CHESTED_HORSE),
|
||||
MULE(ABSTRACT_CHESTED_HORSE),
|
||||
LLAMA(ABSTRACT_CHESTED_HORSE),
|
||||
TRADER_LLAMA(LLAMA),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(ABSTRACT_CREATURE, null),
|
||||
ABSTRACT_MONSTER(PATHFINDER_MOB, null),
|
||||
BLAZE(ABSTRACT_MONSTER),
|
||||
CREEPER(ABSTRACT_MONSTER),
|
||||
ENDERMITE(ABSTRACT_MONSTER),
|
||||
@@ -119,110 +187,42 @@ public enum EntityTypes1_19 implements EntityType {
|
||||
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),
|
||||
GUARDIAN(ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(GUARDIAN),
|
||||
|
||||
ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null),
|
||||
BAT(ABSTRACT_AMBIENT),
|
||||
ALLAY(ABSTRACT_CREATURE),
|
||||
SPIDER(ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(SPIDER),
|
||||
|
||||
ABSTRACT_WATERMOB(ABSTRACT_INSENTIENT, null),
|
||||
SQUID(ABSTRACT_WATERMOB),
|
||||
GLOW_SQUID(SQUID),
|
||||
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
|
||||
PIGLIN(ABSTRACT_PIGLIN),
|
||||
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
|
||||
|
||||
// Slimes
|
||||
SLIME(ABSTRACT_INSENTIENT),
|
||||
MAGMA_CUBE(SLIME),
|
||||
// Raiders
|
||||
ABSTRACT_RAIDER(ABSTRACT_MONSTER, null),
|
||||
WITCH(ABSTRACT_RAIDER),
|
||||
RAVAGER(ABSTRACT_RAIDER),
|
||||
|
||||
// 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);
|
||||
ABSTRACT_ILLAGER(ABSTRACT_RAIDER, null),
|
||||
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER, null),
|
||||
VINDICATOR(ABSTRACT_ILLAGER),
|
||||
PILLAGER(ABSTRACT_ILLAGER),
|
||||
EVOKER(SPELLCASTER_ILLAGER),
|
||||
ILLUSIONER(SPELLCASTER_ILLAGER);
|
||||
|
||||
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
|
||||
private final EntityType parent;
|
||||
@@ -231,7 +231,7 @@ public enum EntityTypes1_19 implements EntityType {
|
||||
|
||||
EntityTypes1_19(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT);
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_19(final EntityType parent, @Nullable final String identifier) {
|
||||
|
||||
+131
-131
@@ -26,6 +26,7 @@ import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.util.EntityTypeUtil;
|
||||
import java.util.Locale;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum EntityTypes1_19_3 implements EntityType {
|
||||
@@ -38,81 +39,148 @@ public enum EntityTypes1_19_3 implements EntityType {
|
||||
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),
|
||||
LIGHTNING_BOLT(ENTITY),
|
||||
|
||||
ABSTRACT_INSENTIENT(LIVINGENTITY, null),
|
||||
ENDER_DRAGON(ABSTRACT_INSENTIENT),
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY, null),
|
||||
LEASH_KNOT(HANGING_ENTITY),
|
||||
PAINTING(HANGING_ENTITY),
|
||||
ITEM_FRAME(HANGING_ENTITY),
|
||||
GLOW_ITEM_FRAME(ITEM_FRAME),
|
||||
|
||||
BEE(ABSTRACT_INSENTIENT),
|
||||
// Projectiles
|
||||
PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing
|
||||
SNOWBALL(PROJECTILE),
|
||||
ENDER_PEARL(PROJECTILE),
|
||||
EGG(PROJECTILE),
|
||||
POTION(PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(PROJECTILE),
|
||||
FIREWORK_ROCKET(PROJECTILE),
|
||||
LLAMA_SPIT(PROJECTILE),
|
||||
SHULKER_BULLET(PROJECTILE),
|
||||
FISHING_BOBBER(PROJECTILE),
|
||||
WITHER_SKULL(PROJECTILE),
|
||||
DRAGON_FIREBALL(PROJECTILE), // Doesn't actually inherit fireball
|
||||
|
||||
ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null),
|
||||
ABSTRACT_ARROW(PROJECTILE, null),
|
||||
ARROW(ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(ABSTRACT_ARROW),
|
||||
TRIDENT(ABSTRACT_ARROW),
|
||||
|
||||
ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null),
|
||||
VILLAGER(ABSTRACT_AGEABLE),
|
||||
WANDERING_TRADER(ABSTRACT_AGEABLE),
|
||||
ABSTRACT_FIREBALL(ENTITY, null),
|
||||
FIREBALL(ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(ABSTRACT_FIREBALL),
|
||||
|
||||
// Vehicles
|
||||
VEHICLE(ENTITY, null),
|
||||
BOAT(VEHICLE),
|
||||
|
||||
ABSTRACT_MINECART(VEHICLE, null),
|
||||
MINECART(ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(ABSTRACT_MINECART),
|
||||
TNT_MINECART(ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(ABSTRACT_MINECART),
|
||||
CHEST_BOAT(BOAT),
|
||||
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART, null),
|
||||
CHEST_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(ENTITY, null),
|
||||
ARMOR_STAND(LIVING_ENTITY),
|
||||
PLAYER(LIVING_ENTITY),
|
||||
|
||||
// Mobs as a larger subclass
|
||||
MOB(LIVING_ENTITY, null),
|
||||
ENDER_DRAGON(MOB),
|
||||
|
||||
SLIME(MOB),
|
||||
MAGMA_CUBE(SLIME),
|
||||
|
||||
// Ambient mobs
|
||||
AMBIENT_CREATURE(MOB, null),
|
||||
BAT(AMBIENT_CREATURE),
|
||||
|
||||
// Flying mobs
|
||||
FLYING_MOB(MOB, null),
|
||||
GHAST(FLYING_MOB),
|
||||
PHANTOM(FLYING_MOB),
|
||||
|
||||
// Pathfinder mobs and its subclasses
|
||||
PATHFINDER_MOB(MOB, null),
|
||||
ALLAY(PATHFINDER_MOB),
|
||||
|
||||
ABSTRACT_GOLEM(PATHFINDER_MOB, null),
|
||||
SNOW_GOLEM(ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(ABSTRACT_GOLEM),
|
||||
SHULKER(ABSTRACT_GOLEM),
|
||||
|
||||
// Water mobs
|
||||
WATER_ANIMAL(PATHFINDER_MOB, null),
|
||||
DOLPHIN(WATER_ANIMAL),
|
||||
|
||||
SQUID(WATER_ANIMAL),
|
||||
GLOW_SQUID(SQUID),
|
||||
|
||||
ABSTRACT_FISH(WATER_ANIMAL, null),
|
||||
PUFFERFISH(ABSTRACT_FISH),
|
||||
TADPOLE(ABSTRACT_FISH),
|
||||
|
||||
ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISH, null),
|
||||
COD(ABSTRACT_SCHOOLING_FISH),
|
||||
SALMON(ABSTRACT_SCHOOLING_FISH),
|
||||
TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(PATHFINDER_MOB, null),
|
||||
ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null),
|
||||
VILLAGER(ABSTRACT_VILLAGER),
|
||||
WANDERING_TRADER(ABSTRACT_VILLAGER),
|
||||
|
||||
// Animals
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
|
||||
AXOLOTL(ABSTRACT_ANIMAL),
|
||||
DOLPHIN(ABSTRACT_INSENTIENT),
|
||||
CHICKEN(ABSTRACT_ANIMAL),
|
||||
COW(ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(COW),
|
||||
PANDA(ABSTRACT_INSENTIENT),
|
||||
PANDA(ABSTRACT_ANIMAL),
|
||||
PIG(ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(ABSTRACT_ANIMAL),
|
||||
RABBIT(ABSTRACT_ANIMAL),
|
||||
SHEEP(ABSTRACT_ANIMAL),
|
||||
BEE(ABSTRACT_ANIMAL),
|
||||
TURTLE(ABSTRACT_ANIMAL),
|
||||
FOX(ABSTRACT_ANIMAL),
|
||||
FROG(ABSTRACT_ANIMAL),
|
||||
GOAT(ABSTRACT_ANIMAL),
|
||||
HOGLIN(ABSTRACT_ANIMAL),
|
||||
STRIDER(ABSTRACT_ANIMAL),
|
||||
|
||||
ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
OCELOT(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
WOLF(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
COW(ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(COW),
|
||||
|
||||
ABSTRACT_PARROT(ABSTRACT_TAMEABLE_ANIMAL, null),
|
||||
PARROT(ABSTRACT_PARROT),
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(TAMABLE_ANIMAL),
|
||||
OCELOT(TAMABLE_ANIMAL),
|
||||
WOLF(TAMABLE_ANIMAL),
|
||||
PARROT(TAMABLE_ANIMAL),
|
||||
|
||||
// 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),
|
||||
ABSTRACT_CHESTED_HORSE(ABSTRACT_HORSE, null),
|
||||
DONKEY(ABSTRACT_CHESTED_HORSE),
|
||||
MULE(ABSTRACT_CHESTED_HORSE),
|
||||
LLAMA(ABSTRACT_CHESTED_HORSE),
|
||||
TRADER_LLAMA(LLAMA),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(ABSTRACT_CREATURE, null),
|
||||
ABSTRACT_MONSTER(PATHFINDER_MOB, null),
|
||||
BLAZE(ABSTRACT_MONSTER),
|
||||
CREEPER(ABSTRACT_MONSTER),
|
||||
ENDERMITE(ABSTRACT_MONSTER),
|
||||
@@ -120,110 +188,42 @@ public enum EntityTypes1_19_3 implements EntityType {
|
||||
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),
|
||||
GUARDIAN(ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(GUARDIAN),
|
||||
|
||||
ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null),
|
||||
BAT(ABSTRACT_AMBIENT),
|
||||
ALLAY(ABSTRACT_CREATURE),
|
||||
SPIDER(ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(SPIDER),
|
||||
|
||||
ABSTRACT_WATERMOB(ABSTRACT_INSENTIENT, null),
|
||||
SQUID(ABSTRACT_WATERMOB),
|
||||
GLOW_SQUID(SQUID),
|
||||
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
|
||||
PIGLIN(ABSTRACT_PIGLIN),
|
||||
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
|
||||
|
||||
// Slimes
|
||||
SLIME(ABSTRACT_INSENTIENT),
|
||||
MAGMA_CUBE(SLIME),
|
||||
// Raiders
|
||||
ABSTRACT_RAIDER(ABSTRACT_MONSTER, null),
|
||||
WITCH(ABSTRACT_RAIDER),
|
||||
RAVAGER(ABSTRACT_RAIDER),
|
||||
|
||||
// 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);
|
||||
ABSTRACT_ILLAGER(ABSTRACT_RAIDER, null),
|
||||
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER, null),
|
||||
VINDICATOR(ABSTRACT_ILLAGER),
|
||||
PILLAGER(ABSTRACT_ILLAGER),
|
||||
EVOKER(SPELLCASTER_ILLAGER),
|
||||
ILLUSIONER(SPELLCASTER_ILLAGER);
|
||||
|
||||
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
|
||||
private final EntityType parent;
|
||||
@@ -232,7 +232,7 @@ public enum EntityTypes1_19_3 implements EntityType {
|
||||
|
||||
EntityTypes1_19_3(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT);
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_19_3(final EntityType parent, @Nullable final String identifier) {
|
||||
|
||||
+132
-132
@@ -26,6 +26,7 @@ import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.util.EntityTypeUtil;
|
||||
import java.util.Locale;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum EntityTypes1_19_4 implements EntityType {
|
||||
@@ -38,88 +39,155 @@ public enum EntityTypes1_19_4 implements EntityType {
|
||||
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),
|
||||
LIGHTNING_BOLT(ENTITY),
|
||||
INTERACTION(ENTITY),
|
||||
|
||||
DISPLAY(ENTITY, null),
|
||||
BLOCK_DISPLAY(DISPLAY),
|
||||
ITEM_DISPLAY(DISPLAY),
|
||||
TEXT_DISPLAY(DISPLAY),
|
||||
INTERACTION(ENTITY),
|
||||
|
||||
ABSTRACT_INSENTIENT(LIVINGENTITY, null),
|
||||
ENDER_DRAGON(ABSTRACT_INSENTIENT),
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY, null),
|
||||
LEASH_KNOT(HANGING_ENTITY),
|
||||
PAINTING(HANGING_ENTITY),
|
||||
ITEM_FRAME(HANGING_ENTITY),
|
||||
GLOW_ITEM_FRAME(ITEM_FRAME),
|
||||
|
||||
BEE(ABSTRACT_INSENTIENT),
|
||||
// Projectiles
|
||||
PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing
|
||||
SNOWBALL(PROJECTILE),
|
||||
ENDER_PEARL(PROJECTILE),
|
||||
EGG(PROJECTILE),
|
||||
POTION(PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(PROJECTILE),
|
||||
FIREWORK_ROCKET(PROJECTILE),
|
||||
LLAMA_SPIT(PROJECTILE),
|
||||
SHULKER_BULLET(PROJECTILE),
|
||||
FISHING_BOBBER(PROJECTILE),
|
||||
WITHER_SKULL(PROJECTILE),
|
||||
DRAGON_FIREBALL(PROJECTILE), // Doesn't actually inherit fireball
|
||||
|
||||
ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null),
|
||||
ABSTRACT_ARROW(PROJECTILE, null),
|
||||
ARROW(ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(ABSTRACT_ARROW),
|
||||
TRIDENT(ABSTRACT_ARROW),
|
||||
|
||||
ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null),
|
||||
VILLAGER(ABSTRACT_AGEABLE),
|
||||
WANDERING_TRADER(ABSTRACT_AGEABLE),
|
||||
ABSTRACT_FIREBALL(ENTITY, null),
|
||||
FIREBALL(ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(ABSTRACT_FIREBALL),
|
||||
|
||||
// Vehicles
|
||||
VEHICLE(ENTITY, null),
|
||||
BOAT(VEHICLE),
|
||||
|
||||
ABSTRACT_MINECART(VEHICLE, null),
|
||||
MINECART(ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(ABSTRACT_MINECART),
|
||||
TNT_MINECART(ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(ABSTRACT_MINECART),
|
||||
CHEST_BOAT(BOAT),
|
||||
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART, null),
|
||||
CHEST_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(ENTITY, null),
|
||||
ARMOR_STAND(LIVING_ENTITY),
|
||||
PLAYER(LIVING_ENTITY),
|
||||
|
||||
// Mobs as a larger subclass
|
||||
MOB(LIVING_ENTITY, null),
|
||||
ENDER_DRAGON(MOB),
|
||||
|
||||
SLIME(MOB),
|
||||
MAGMA_CUBE(SLIME),
|
||||
|
||||
// Ambient mobs
|
||||
AMBIENT_CREATURE(MOB, null),
|
||||
BAT(AMBIENT_CREATURE),
|
||||
|
||||
// Flying mobs
|
||||
FLYING_MOB(MOB, null),
|
||||
GHAST(FLYING_MOB),
|
||||
PHANTOM(FLYING_MOB),
|
||||
|
||||
// Pathfinder mobs and its subclasses
|
||||
PATHFINDER_MOB(MOB, null),
|
||||
ALLAY(PATHFINDER_MOB),
|
||||
|
||||
ABSTRACT_GOLEM(PATHFINDER_MOB, null),
|
||||
SNOW_GOLEM(ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(ABSTRACT_GOLEM),
|
||||
SHULKER(ABSTRACT_GOLEM),
|
||||
|
||||
// Water mobs
|
||||
WATER_ANIMAL(PATHFINDER_MOB, null),
|
||||
DOLPHIN(WATER_ANIMAL),
|
||||
|
||||
SQUID(WATER_ANIMAL),
|
||||
GLOW_SQUID(SQUID),
|
||||
|
||||
ABSTRACT_FISH(WATER_ANIMAL, null),
|
||||
PUFFERFISH(ABSTRACT_FISH),
|
||||
TADPOLE(ABSTRACT_FISH),
|
||||
|
||||
ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISH, null),
|
||||
COD(ABSTRACT_SCHOOLING_FISH),
|
||||
SALMON(ABSTRACT_SCHOOLING_FISH),
|
||||
TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(PATHFINDER_MOB, null),
|
||||
ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null),
|
||||
VILLAGER(ABSTRACT_VILLAGER),
|
||||
WANDERING_TRADER(ABSTRACT_VILLAGER),
|
||||
|
||||
// Animals
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
|
||||
AXOLOTL(ABSTRACT_ANIMAL),
|
||||
DOLPHIN(ABSTRACT_INSENTIENT),
|
||||
CHICKEN(ABSTRACT_ANIMAL),
|
||||
COW(ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(COW),
|
||||
PANDA(ABSTRACT_INSENTIENT),
|
||||
PANDA(ABSTRACT_ANIMAL),
|
||||
PIG(ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(ABSTRACT_ANIMAL),
|
||||
RABBIT(ABSTRACT_ANIMAL),
|
||||
SHEEP(ABSTRACT_ANIMAL),
|
||||
BEE(ABSTRACT_ANIMAL),
|
||||
TURTLE(ABSTRACT_ANIMAL),
|
||||
FOX(ABSTRACT_ANIMAL),
|
||||
FROG(ABSTRACT_ANIMAL),
|
||||
GOAT(ABSTRACT_ANIMAL),
|
||||
HOGLIN(ABSTRACT_ANIMAL),
|
||||
STRIDER(ABSTRACT_ANIMAL),
|
||||
SNIFFER(ABSTRACT_ANIMAL),
|
||||
|
||||
ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
OCELOT(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
WOLF(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
COW(ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(COW),
|
||||
|
||||
ABSTRACT_PARROT(ABSTRACT_TAMEABLE_ANIMAL, null),
|
||||
PARROT(ABSTRACT_PARROT),
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(TAMABLE_ANIMAL),
|
||||
OCELOT(TAMABLE_ANIMAL),
|
||||
WOLF(TAMABLE_ANIMAL),
|
||||
PARROT(TAMABLE_ANIMAL),
|
||||
|
||||
// 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),
|
||||
ABSTRACT_CHESTED_HORSE(ABSTRACT_HORSE, null),
|
||||
DONKEY(ABSTRACT_CHESTED_HORSE),
|
||||
MULE(ABSTRACT_CHESTED_HORSE),
|
||||
LLAMA(ABSTRACT_CHESTED_HORSE),
|
||||
TRADER_LLAMA(LLAMA),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(ABSTRACT_CREATURE, null),
|
||||
ABSTRACT_MONSTER(PATHFINDER_MOB, null),
|
||||
BLAZE(ABSTRACT_MONSTER),
|
||||
CREEPER(ABSTRACT_MONSTER),
|
||||
ENDERMITE(ABSTRACT_MONSTER),
|
||||
@@ -127,110 +195,42 @@ public enum EntityTypes1_19_4 implements EntityType {
|
||||
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),
|
||||
GUARDIAN(ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(GUARDIAN),
|
||||
|
||||
ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null),
|
||||
BAT(ABSTRACT_AMBIENT),
|
||||
ALLAY(ABSTRACT_CREATURE),
|
||||
SPIDER(ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(SPIDER),
|
||||
|
||||
ABSTRACT_WATERMOB(ABSTRACT_INSENTIENT, null),
|
||||
SQUID(ABSTRACT_WATERMOB),
|
||||
GLOW_SQUID(SQUID),
|
||||
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
|
||||
PIGLIN(ABSTRACT_PIGLIN),
|
||||
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
|
||||
|
||||
// Slimes
|
||||
SLIME(ABSTRACT_INSENTIENT),
|
||||
MAGMA_CUBE(SLIME),
|
||||
// Raiders
|
||||
ABSTRACT_RAIDER(ABSTRACT_MONSTER, null),
|
||||
WITCH(ABSTRACT_RAIDER),
|
||||
RAVAGER(ABSTRACT_RAIDER),
|
||||
|
||||
// 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);
|
||||
ABSTRACT_ILLAGER(ABSTRACT_RAIDER, null),
|
||||
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER, null),
|
||||
VINDICATOR(ABSTRACT_ILLAGER),
|
||||
PILLAGER(ABSTRACT_ILLAGER),
|
||||
EVOKER(SPELLCASTER_ILLAGER),
|
||||
ILLUSIONER(SPELLCASTER_ILLAGER);
|
||||
|
||||
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
|
||||
private final EntityType parent;
|
||||
@@ -239,7 +239,7 @@ public enum EntityTypes1_19_4 implements EntityType {
|
||||
|
||||
EntityTypes1_19_4(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT);
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_19_4(final EntityType parent, @Nullable final String identifier) {
|
||||
|
||||
+133
-133
@@ -26,6 +26,7 @@ import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.util.EntityTypeUtil;
|
||||
import java.util.Locale;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum EntityTypes1_20_3 implements EntityType {
|
||||
@@ -38,88 +39,156 @@ public enum EntityTypes1_20_3 implements EntityType {
|
||||
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),
|
||||
LIGHTNING_BOLT(ENTITY),
|
||||
INTERACTION(ENTITY),
|
||||
|
||||
DISPLAY(ENTITY, null),
|
||||
BLOCK_DISPLAY(DISPLAY),
|
||||
ITEM_DISPLAY(DISPLAY),
|
||||
TEXT_DISPLAY(DISPLAY),
|
||||
INTERACTION(ENTITY),
|
||||
|
||||
ABSTRACT_INSENTIENT(LIVINGENTITY, null),
|
||||
ENDER_DRAGON(ABSTRACT_INSENTIENT),
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY, null),
|
||||
LEASH_KNOT(HANGING_ENTITY),
|
||||
PAINTING(HANGING_ENTITY),
|
||||
ITEM_FRAME(HANGING_ENTITY),
|
||||
GLOW_ITEM_FRAME(ITEM_FRAME),
|
||||
|
||||
BEE(ABSTRACT_INSENTIENT),
|
||||
// Projectiles
|
||||
PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing
|
||||
SNOWBALL(PROJECTILE),
|
||||
ENDER_PEARL(PROJECTILE),
|
||||
EGG(PROJECTILE),
|
||||
POTION(PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(PROJECTILE),
|
||||
FIREWORK_ROCKET(PROJECTILE),
|
||||
LLAMA_SPIT(PROJECTILE),
|
||||
SHULKER_BULLET(PROJECTILE),
|
||||
FISHING_BOBBER(PROJECTILE),
|
||||
WITHER_SKULL(PROJECTILE),
|
||||
DRAGON_FIREBALL(PROJECTILE), // Doesn't actually inherit fireball
|
||||
WIND_CHARGE(PROJECTILE),
|
||||
|
||||
ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null),
|
||||
ABSTRACT_ARROW(PROJECTILE, null),
|
||||
ARROW(ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(ABSTRACT_ARROW),
|
||||
TRIDENT(ABSTRACT_ARROW),
|
||||
|
||||
ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null),
|
||||
VILLAGER(ABSTRACT_AGEABLE),
|
||||
WANDERING_TRADER(ABSTRACT_AGEABLE),
|
||||
ABSTRACT_FIREBALL(ENTITY, null),
|
||||
FIREBALL(ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(ABSTRACT_FIREBALL),
|
||||
|
||||
// Vehicles
|
||||
VEHICLE(ENTITY, null),
|
||||
BOAT(VEHICLE),
|
||||
|
||||
ABSTRACT_MINECART(VEHICLE, null),
|
||||
MINECART(ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(ABSTRACT_MINECART),
|
||||
TNT_MINECART(ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(ABSTRACT_MINECART),
|
||||
CHEST_BOAT(BOAT),
|
||||
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART, null),
|
||||
CHEST_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(ENTITY, null),
|
||||
ARMOR_STAND(LIVING_ENTITY),
|
||||
PLAYER(LIVING_ENTITY),
|
||||
|
||||
// Mobs as a larger subclass
|
||||
MOB(LIVING_ENTITY, null),
|
||||
ENDER_DRAGON(MOB),
|
||||
|
||||
SLIME(MOB),
|
||||
MAGMA_CUBE(SLIME),
|
||||
|
||||
// Ambient mobs
|
||||
AMBIENT_CREATURE(MOB, null),
|
||||
BAT(AMBIENT_CREATURE),
|
||||
|
||||
// Flying mobs
|
||||
FLYING_MOB(MOB, null),
|
||||
GHAST(FLYING_MOB),
|
||||
PHANTOM(FLYING_MOB),
|
||||
|
||||
// Pathfinder mobs and its subclasses
|
||||
PATHFINDER_MOB(MOB, null),
|
||||
ALLAY(PATHFINDER_MOB),
|
||||
|
||||
ABSTRACT_GOLEM(PATHFINDER_MOB, null),
|
||||
SNOW_GOLEM(ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(ABSTRACT_GOLEM),
|
||||
SHULKER(ABSTRACT_GOLEM),
|
||||
|
||||
// Water mobs
|
||||
WATER_ANIMAL(PATHFINDER_MOB, null),
|
||||
DOLPHIN(WATER_ANIMAL),
|
||||
|
||||
SQUID(WATER_ANIMAL),
|
||||
GLOW_SQUID(SQUID),
|
||||
|
||||
ABSTRACT_FISH(WATER_ANIMAL, null),
|
||||
PUFFERFISH(ABSTRACT_FISH),
|
||||
TADPOLE(ABSTRACT_FISH),
|
||||
|
||||
ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISH, null),
|
||||
COD(ABSTRACT_SCHOOLING_FISH),
|
||||
SALMON(ABSTRACT_SCHOOLING_FISH),
|
||||
TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(PATHFINDER_MOB, null),
|
||||
ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null),
|
||||
VILLAGER(ABSTRACT_VILLAGER),
|
||||
WANDERING_TRADER(ABSTRACT_VILLAGER),
|
||||
|
||||
// Animals
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
|
||||
AXOLOTL(ABSTRACT_ANIMAL),
|
||||
DOLPHIN(ABSTRACT_INSENTIENT),
|
||||
CHICKEN(ABSTRACT_ANIMAL),
|
||||
COW(ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(COW),
|
||||
PANDA(ABSTRACT_INSENTIENT),
|
||||
PANDA(ABSTRACT_ANIMAL),
|
||||
PIG(ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(ABSTRACT_ANIMAL),
|
||||
RABBIT(ABSTRACT_ANIMAL),
|
||||
SHEEP(ABSTRACT_ANIMAL),
|
||||
BEE(ABSTRACT_ANIMAL),
|
||||
TURTLE(ABSTRACT_ANIMAL),
|
||||
FOX(ABSTRACT_ANIMAL),
|
||||
FROG(ABSTRACT_ANIMAL),
|
||||
GOAT(ABSTRACT_ANIMAL),
|
||||
HOGLIN(ABSTRACT_ANIMAL),
|
||||
STRIDER(ABSTRACT_ANIMAL),
|
||||
SNIFFER(ABSTRACT_ANIMAL),
|
||||
|
||||
ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
OCELOT(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
WOLF(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
COW(ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(COW),
|
||||
|
||||
ABSTRACT_PARROT(ABSTRACT_TAMEABLE_ANIMAL, null),
|
||||
PARROT(ABSTRACT_PARROT),
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(TAMABLE_ANIMAL),
|
||||
OCELOT(TAMABLE_ANIMAL),
|
||||
WOLF(TAMABLE_ANIMAL),
|
||||
PARROT(TAMABLE_ANIMAL),
|
||||
|
||||
// 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),
|
||||
ABSTRACT_CHESTED_HORSE(ABSTRACT_HORSE, null),
|
||||
DONKEY(ABSTRACT_CHESTED_HORSE),
|
||||
MULE(ABSTRACT_CHESTED_HORSE),
|
||||
LLAMA(ABSTRACT_CHESTED_HORSE),
|
||||
TRADER_LLAMA(LLAMA),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(ABSTRACT_CREATURE, null),
|
||||
ABSTRACT_MONSTER(PATHFINDER_MOB, null),
|
||||
BLAZE(ABSTRACT_MONSTER),
|
||||
CREEPER(ABSTRACT_MONSTER),
|
||||
ENDERMITE(ABSTRACT_MONSTER),
|
||||
@@ -127,112 +196,43 @@ public enum EntityTypes1_20_3 implements EntityType {
|
||||
GIANT(ABSTRACT_MONSTER),
|
||||
SILVERFISH(ABSTRACT_MONSTER),
|
||||
VEX(ABSTRACT_MONSTER),
|
||||
WITCH(ABSTRACT_MONSTER),
|
||||
WITHER(ABSTRACT_MONSTER),
|
||||
RAVAGER(ABSTRACT_MONSTER),
|
||||
BREEZE(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),
|
||||
GUARDIAN(ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(GUARDIAN),
|
||||
|
||||
ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null),
|
||||
BAT(ABSTRACT_AMBIENT),
|
||||
ALLAY(ABSTRACT_CREATURE),
|
||||
SPIDER(ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(SPIDER),
|
||||
|
||||
ABSTRACT_WATERMOB(ABSTRACT_INSENTIENT, null),
|
||||
SQUID(ABSTRACT_WATERMOB),
|
||||
GLOW_SQUID(SQUID),
|
||||
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
|
||||
PIGLIN(ABSTRACT_PIGLIN),
|
||||
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
|
||||
|
||||
// Slimes
|
||||
SLIME(ABSTRACT_INSENTIENT),
|
||||
MAGMA_CUBE(SLIME),
|
||||
// Raiders
|
||||
ABSTRACT_RAIDER(ABSTRACT_MONSTER, null),
|
||||
WITCH(ABSTRACT_RAIDER),
|
||||
RAVAGER(ABSTRACT_RAIDER),
|
||||
|
||||
// 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),
|
||||
WIND_CHARGE(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);
|
||||
ABSTRACT_ILLAGER(ABSTRACT_RAIDER, null),
|
||||
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER, null),
|
||||
VINDICATOR(ABSTRACT_ILLAGER),
|
||||
PILLAGER(ABSTRACT_ILLAGER),
|
||||
EVOKER(SPELLCASTER_ILLAGER),
|
||||
ILLUSIONER(SPELLCASTER_ILLAGER);
|
||||
|
||||
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
|
||||
private final EntityType parent;
|
||||
@@ -241,7 +241,7 @@ public enum EntityTypes1_20_3 implements EntityType {
|
||||
|
||||
EntityTypes1_20_3(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT);
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_20_3(final EntityType parent, @Nullable final String identifier) {
|
||||
|
||||
+289
@@ -0,0 +1,289 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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 com.viaversion.viaversion.util.Key;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum EntityTypes1_20_5 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),
|
||||
ITEM(ENTITY),
|
||||
TNT(ENTITY),
|
||||
OMINOUS_ITEM_SPAWNER(ENTITY),
|
||||
MARKER(ENTITY),
|
||||
LIGHTNING_BOLT(ENTITY),
|
||||
INTERACTION(ENTITY),
|
||||
|
||||
DISPLAY(ENTITY, null),
|
||||
BLOCK_DISPLAY(DISPLAY),
|
||||
ITEM_DISPLAY(DISPLAY),
|
||||
TEXT_DISPLAY(DISPLAY),
|
||||
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY, null),
|
||||
LEASH_KNOT(HANGING_ENTITY),
|
||||
PAINTING(HANGING_ENTITY),
|
||||
ITEM_FRAME(HANGING_ENTITY),
|
||||
GLOW_ITEM_FRAME(ITEM_FRAME),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE(ENTITY, null), // Not actually its own abstract type, but useful for categorizing
|
||||
SNOWBALL(PROJECTILE),
|
||||
ENDER_PEARL(PROJECTILE),
|
||||
EGG(PROJECTILE),
|
||||
POTION(PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(PROJECTILE),
|
||||
FIREWORK_ROCKET(PROJECTILE),
|
||||
LLAMA_SPIT(PROJECTILE),
|
||||
SHULKER_BULLET(PROJECTILE),
|
||||
FISHING_BOBBER(PROJECTILE),
|
||||
WITHER_SKULL(PROJECTILE),
|
||||
DRAGON_FIREBALL(PROJECTILE), // Doesn't actually inherit fireball
|
||||
|
||||
ABSTRACT_ARROW(PROJECTILE, null),
|
||||
ARROW(ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(ABSTRACT_ARROW),
|
||||
TRIDENT(ABSTRACT_ARROW),
|
||||
|
||||
ABSTRACT_FIREBALL(ENTITY, null),
|
||||
FIREBALL(ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(ABSTRACT_FIREBALL),
|
||||
|
||||
ABSTRACT_WIND_CHARGE(PROJECTILE, null),
|
||||
WIND_CHARGE(ABSTRACT_WIND_CHARGE),
|
||||
BREEZE_WIND_CHARGE(ABSTRACT_WIND_CHARGE),
|
||||
|
||||
// Vehicles
|
||||
VEHICLE(ENTITY, null),
|
||||
BOAT(VEHICLE),
|
||||
|
||||
ABSTRACT_MINECART(VEHICLE, null),
|
||||
MINECART(ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(ABSTRACT_MINECART),
|
||||
TNT_MINECART(ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(ABSTRACT_MINECART),
|
||||
CHEST_BOAT(BOAT),
|
||||
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART, null),
|
||||
CHEST_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(ENTITY, null),
|
||||
ARMOR_STAND(LIVING_ENTITY),
|
||||
PLAYER(LIVING_ENTITY),
|
||||
|
||||
// Mobs as a larger subclass
|
||||
MOB(LIVING_ENTITY, null),
|
||||
ENDER_DRAGON(MOB),
|
||||
|
||||
SLIME(MOB),
|
||||
MAGMA_CUBE(SLIME),
|
||||
|
||||
// Ambient mobs
|
||||
AMBIENT_CREATURE(MOB, null),
|
||||
BAT(AMBIENT_CREATURE),
|
||||
|
||||
// Flying mobs
|
||||
FLYING_MOB(MOB, null),
|
||||
GHAST(FLYING_MOB),
|
||||
PHANTOM(FLYING_MOB),
|
||||
|
||||
// Pathfinder mobs and its subclasses
|
||||
PATHFINDER_MOB(MOB, null),
|
||||
ALLAY(PATHFINDER_MOB),
|
||||
|
||||
ABSTRACT_GOLEM(PATHFINDER_MOB, null),
|
||||
SNOW_GOLEM(ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(ABSTRACT_GOLEM),
|
||||
SHULKER(ABSTRACT_GOLEM),
|
||||
|
||||
// Water mobs
|
||||
WATER_ANIMAL(PATHFINDER_MOB, null),
|
||||
DOLPHIN(WATER_ANIMAL),
|
||||
|
||||
SQUID(WATER_ANIMAL),
|
||||
GLOW_SQUID(SQUID),
|
||||
|
||||
ABSTRACT_FISH(WATER_ANIMAL, null),
|
||||
PUFFERFISH(ABSTRACT_FISH),
|
||||
TADPOLE(ABSTRACT_FISH),
|
||||
|
||||
ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISH, null),
|
||||
COD(ABSTRACT_SCHOOLING_FISH),
|
||||
SALMON(ABSTRACT_SCHOOLING_FISH),
|
||||
TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(PATHFINDER_MOB, null),
|
||||
ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null),
|
||||
VILLAGER(ABSTRACT_VILLAGER),
|
||||
WANDERING_TRADER(ABSTRACT_VILLAGER),
|
||||
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
|
||||
AXOLOTL(ABSTRACT_ANIMAL),
|
||||
CHICKEN(ABSTRACT_ANIMAL),
|
||||
PANDA(ABSTRACT_ANIMAL),
|
||||
PIG(ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(ABSTRACT_ANIMAL),
|
||||
RABBIT(ABSTRACT_ANIMAL),
|
||||
SHEEP(ABSTRACT_ANIMAL),
|
||||
BEE(ABSTRACT_ANIMAL),
|
||||
TURTLE(ABSTRACT_ANIMAL),
|
||||
FOX(ABSTRACT_ANIMAL),
|
||||
FROG(ABSTRACT_ANIMAL),
|
||||
GOAT(ABSTRACT_ANIMAL),
|
||||
HOGLIN(ABSTRACT_ANIMAL),
|
||||
STRIDER(ABSTRACT_ANIMAL),
|
||||
SNIFFER(ABSTRACT_ANIMAL),
|
||||
ARMADILLO(ABSTRACT_ANIMAL),
|
||||
|
||||
COW(ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(COW),
|
||||
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(TAMABLE_ANIMAL),
|
||||
OCELOT(TAMABLE_ANIMAL),
|
||||
WOLF(TAMABLE_ANIMAL),
|
||||
PARROT(TAMABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
|
||||
HORSE(ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(ABSTRACT_HORSE),
|
||||
CAMEL(ABSTRACT_HORSE),
|
||||
|
||||
ABSTRACT_CHESTED_HORSE(ABSTRACT_HORSE, null),
|
||||
DONKEY(ABSTRACT_CHESTED_HORSE),
|
||||
MULE(ABSTRACT_CHESTED_HORSE),
|
||||
LLAMA(ABSTRACT_CHESTED_HORSE),
|
||||
TRADER_LLAMA(LLAMA),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(PATHFINDER_MOB, null),
|
||||
BLAZE(ABSTRACT_MONSTER),
|
||||
CREEPER(ABSTRACT_MONSTER),
|
||||
ENDERMITE(ABSTRACT_MONSTER),
|
||||
ENDERMAN(ABSTRACT_MONSTER),
|
||||
GIANT(ABSTRACT_MONSTER),
|
||||
SILVERFISH(ABSTRACT_MONSTER),
|
||||
VEX(ABSTRACT_MONSTER),
|
||||
WITHER(ABSTRACT_MONSTER),
|
||||
BREEZE(ABSTRACT_MONSTER),
|
||||
ZOGLIN(ABSTRACT_MONSTER),
|
||||
WARDEN(ABSTRACT_MONSTER),
|
||||
|
||||
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
|
||||
SKELETON(ABSTRACT_SKELETON),
|
||||
STRAY(ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(ABSTRACT_SKELETON),
|
||||
BOGGED(ABSTRACT_SKELETON),
|
||||
|
||||
ZOMBIE(ABSTRACT_MONSTER),
|
||||
DROWNED(ZOMBIE),
|
||||
HUSK(ZOMBIE),
|
||||
ZOMBIFIED_PIGLIN(ZOMBIE),
|
||||
ZOMBIE_VILLAGER(ZOMBIE),
|
||||
|
||||
GUARDIAN(ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(GUARDIAN),
|
||||
|
||||
SPIDER(ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(SPIDER),
|
||||
|
||||
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
|
||||
PIGLIN(ABSTRACT_PIGLIN),
|
||||
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
|
||||
|
||||
// Raiders
|
||||
ABSTRACT_RAIDER(ABSTRACT_MONSTER, null),
|
||||
WITCH(ABSTRACT_RAIDER),
|
||||
RAVAGER(ABSTRACT_RAIDER),
|
||||
|
||||
ABSTRACT_ILLAGER(ABSTRACT_RAIDER, null),
|
||||
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER, null),
|
||||
VINDICATOR(ABSTRACT_ILLAGER),
|
||||
PILLAGER(ABSTRACT_ILLAGER),
|
||||
EVOKER(SPELLCASTER_ILLAGER),
|
||||
ILLUSIONER(SPELLCASTER_ILLAGER);
|
||||
|
||||
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
|
||||
private final EntityType parent;
|
||||
private final String identifier;
|
||||
private int id = -1;
|
||||
|
||||
EntityTypes1_20_5(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
EntityTypes1_20_5(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);
|
||||
}
|
||||
}
|
||||
+269
@@ -0,0 +1,269 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.viaversion.viaversion.api.Via;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class EntityTypes1_8 {
|
||||
|
||||
public static EntityType getTypeFromId(final int typeId, final boolean object) {
|
||||
EntityType type;
|
||||
|
||||
if (object) {
|
||||
type = ObjectType.getEntityType(typeId);
|
||||
} else {
|
||||
type = EntityType.findById(typeId);
|
||||
}
|
||||
if (type == null) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.8 type id " + typeId + " objectType=" + object);
|
||||
return EntityType.ENTITY; // Fall back to the basic ENTITY
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public enum EntityType implements com.viaversion.viaversion.api.minecraft.entities.EntityType {
|
||||
|
||||
ENTITY,
|
||||
|
||||
END_CRYSTAL(200, ENTITY),
|
||||
EXPERIENCE_ORB(2, ENTITY),
|
||||
EYE_OF_ENDER(15, ENTITY),
|
||||
FALLING_BLOCK(21, ENTITY),
|
||||
ITEM(1, ENTITY),
|
||||
TNT(20, ENTITY),
|
||||
LIGHTNING_BOLT(ENTITY), // Needed for entity (un)tracking
|
||||
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY),
|
||||
LEASH_KNOT(8, HANGING_ENTITY),
|
||||
ITEM_FRAME(18, HANGING_ENTITY),
|
||||
PAINTING(9, HANGING_ENTITY),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE(ENTITY),
|
||||
FIREWORK_ROCKET(22, ENTITY),
|
||||
SNOWBALL(11, PROJECTILE),
|
||||
ENDER_PEARL(14, PROJECTILE),
|
||||
EGG(7, PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(17, PROJECTILE),
|
||||
POTION(16, PROJECTILE),
|
||||
FISHING_HOOK(ENTITY),
|
||||
ARROW(10, ENTITY),
|
||||
|
||||
HURTING_PROJECTILE(ENTITY),
|
||||
FIREBALL(12, HURTING_PROJECTILE),
|
||||
SMALL_FIREBALL(13, HURTING_PROJECTILE),
|
||||
WITHER_SKULL(19, HURTING_PROJECTILE),
|
||||
|
||||
// Vehicles
|
||||
BOAT(41, ENTITY),
|
||||
|
||||
ABSTRACT_MINECART(ENTITY),
|
||||
MINECART(42, ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(44, ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(40, ABSTRACT_MINECART),
|
||||
TNT_MINECART(45, ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(47, ABSTRACT_MINECART),
|
||||
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART),
|
||||
CHEST_MINECART(43, ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(46, ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
LIVING_ENTITY_BASE(ENTITY),
|
||||
ARMOR_STAND(30, LIVING_ENTITY_BASE),
|
||||
PLAYER(LIVING_ENTITY_BASE), // Needed for entity (un)tracking and metadata indexing
|
||||
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(48, LIVING_ENTITY_BASE),
|
||||
ENDER_DRAGON(63, LIVING_ENTITY),
|
||||
ABSTRACT_CREATURE(LIVING_ENTITY),
|
||||
SLIME(55, LIVING_ENTITY),
|
||||
MAGMA_CUBE(62, SLIME),
|
||||
|
||||
// Flying entities
|
||||
FLYING_MOB(LIVING_ENTITY),
|
||||
GHAST(56, FLYING_MOB),
|
||||
|
||||
AMBIENT_CREATURE(LIVING_ENTITY),
|
||||
BAT(65, AMBIENT_CREATURE),
|
||||
|
||||
ABSTRACT_GOLEM(ABSTRACT_CREATURE),
|
||||
SNOW_GOLEM(97, ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(99, ABSTRACT_GOLEM),
|
||||
|
||||
WATER_ANIMAL(LIVING_ENTITY),
|
||||
SQUID(94, WATER_ANIMAL),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(ABSTRACT_CREATURE),
|
||||
VILLAGER(120, ABSTRACT_AGEABLE),
|
||||
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE),
|
||||
CHICKEN(93, ABSTRACT_ANIMAL),
|
||||
COW(92, ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(96, COW),
|
||||
PIG(90, ABSTRACT_ANIMAL),
|
||||
RABBIT(101, ABSTRACT_ANIMAL),
|
||||
SHEEP(91, ABSTRACT_ANIMAL),
|
||||
HORSE(100, ABSTRACT_ANIMAL),
|
||||
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL),
|
||||
OCELOT(98, TAMABLE_ANIMAL),
|
||||
WOLF(95, TAMABLE_ANIMAL),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(49, ABSTRACT_CREATURE),
|
||||
BLAZE(61, ABSTRACT_MONSTER),
|
||||
CREEPER(50, ABSTRACT_MONSTER),
|
||||
ENDERMITE(67, ABSTRACT_MONSTER),
|
||||
ENDERMAN(58, ABSTRACT_MONSTER),
|
||||
GIANT(53, ABSTRACT_MONSTER),
|
||||
SILVERFISH(60, ABSTRACT_MONSTER),
|
||||
WITCH(66, ABSTRACT_MONSTER),
|
||||
WITHER(64, ABSTRACT_MONSTER),
|
||||
SKELETON(51, ABSTRACT_MONSTER),
|
||||
ZOMBIE(54, ABSTRACT_MONSTER),
|
||||
ZOMBIE_PIGMEN(57, ZOMBIE),
|
||||
|
||||
GUARDIAN(68, ABSTRACT_MONSTER),
|
||||
SPIDER(52, ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(59, SPIDER);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
|
||||
private final int id;
|
||||
private final EntityType parent;
|
||||
|
||||
EntityType() {
|
||||
this.id = -1;
|
||||
this.parent = null;
|
||||
}
|
||||
|
||||
EntityType(EntityType parent) {
|
||||
this.id = -1;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
EntityType(int id, EntityType parent) {
|
||||
this.id = id;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getParent() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public static EntityType findById(final int id) {
|
||||
if (id == -1) {
|
||||
return null;
|
||||
}
|
||||
return TYPES.get(id);
|
||||
}
|
||||
}
|
||||
|
||||
public enum ObjectType implements com.viaversion.viaversion.api.minecraft.entities.ObjectType {
|
||||
BOAT(1, EntityType.BOAT),
|
||||
ITEM(2, EntityType.ITEM),
|
||||
MINECART(10, EntityType.MINECART), // There are multiple types, but we don't need them
|
||||
TNT_PRIMED(50, EntityType.TNT),
|
||||
ENDER_CRYSTAL(51, EntityType.END_CRYSTAL),
|
||||
TIPPED_ARROW(60, EntityType.ARROW),
|
||||
SNOWBALL(61, EntityType.SNOWBALL),
|
||||
EGG(62, EntityType.EGG),
|
||||
FIREBALL(63, EntityType.FIREBALL),
|
||||
SMALL_FIREBALL(64, EntityType.SMALL_FIREBALL),
|
||||
ENDER_PEARL(65, EntityType.ENDER_PEARL),
|
||||
WITHER_SKULL(66, EntityType.WITHER_SKULL),
|
||||
FALLING_BLOCK(70, EntityType.FALLING_BLOCK),
|
||||
ITEM_FRAME(71, EntityType.ITEM_FRAME),
|
||||
EYE_OF_ENDER(72, EntityType.EYE_OF_ENDER),
|
||||
POTION(73, EntityType.POTION),
|
||||
EXPERIENCE_BOTTLE(75, EntityType.EXPERIENCE_BOTTLE),
|
||||
FIREWORK_ROCKET(76, EntityType.FIREWORK_ROCKET),
|
||||
LEASH(77, EntityType.LEASH_KNOT),
|
||||
ARMOR_STAND(78, EntityType.ARMOR_STAND),
|
||||
FISHIHNG_HOOK(90, EntityType.FISHING_HOOK);
|
||||
|
||||
private static final Map<Integer, ObjectType> TYPES = new HashMap<>();
|
||||
|
||||
private final int id;
|
||||
private final EntityType type;
|
||||
|
||||
static {
|
||||
for (ObjectType type : ObjectType.values()) {
|
||||
TYPES.put(type.id, type);
|
||||
}
|
||||
}
|
||||
|
||||
ObjectType(int id, EntityType type) {
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static ObjectType findById(final int id) {
|
||||
if (id == -1) {
|
||||
return null;
|
||||
}
|
||||
return TYPES.get(id);
|
||||
}
|
||||
|
||||
public static EntityType getEntityType(final int id) {
|
||||
final ObjectType objectType = findById(id);
|
||||
return objectType != null ? objectType.type : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+280
@@ -0,0 +1,280 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.viaversion.viaversion.api.Via;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class EntityTypes1_9 {
|
||||
|
||||
public static EntityType getTypeFromId(final int typeId, final boolean object) {
|
||||
EntityType type;
|
||||
|
||||
if (object) {
|
||||
type = ObjectType.getEntityType(typeId);
|
||||
} else {
|
||||
type = EntityType.findById(typeId);
|
||||
}
|
||||
if (type == null) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.9 type id " + typeId + " objectType=" + object);
|
||||
return EntityType.ENTITY; // Fall back to the basic ENTITY
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public enum EntityType implements com.viaversion.viaversion.api.minecraft.entities.EntityType {
|
||||
|
||||
ENTITY,
|
||||
|
||||
AREA_EFFECT_CLOUD(3, ENTITY),
|
||||
END_CRYSTAL(200, ENTITY),
|
||||
EXPERIENCE_ORB(2, ENTITY),
|
||||
EYE_OF_ENDER(15, ENTITY),
|
||||
FALLING_BLOCK(21, ENTITY),
|
||||
ITEM(1, ENTITY),
|
||||
TNT(20, ENTITY),
|
||||
LIGHTNING_BOLT(ENTITY), // Needed for entity (un)tracking
|
||||
|
||||
// Hanging entities
|
||||
HANGING_ENTITY(ENTITY),
|
||||
LEASH_KNOT(8, HANGING_ENTITY),
|
||||
ITEM_FRAME(18, HANGING_ENTITY),
|
||||
PAINTING(9, HANGING_ENTITY),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE(ENTITY),
|
||||
FIREWORK_ROCKET(22, ENTITY),
|
||||
SHULKER_BULLET(25, ENTITY),
|
||||
SNOWBALL(11, PROJECTILE),
|
||||
ENDER_PEARL(14, PROJECTILE),
|
||||
EGG(7, PROJECTILE),
|
||||
EXPERIENCE_BOTTLE(17, PROJECTILE),
|
||||
POTION(16, PROJECTILE),
|
||||
FISHING_HOOK(ENTITY),
|
||||
|
||||
ABSTRACT_ARROW(ENTITY),
|
||||
ARROW(10, ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(24, ABSTRACT_ARROW),
|
||||
|
||||
HURTING_PROJECTILE(ENTITY),
|
||||
DRAGON_FIREBALL(26, HURTING_PROJECTILE),
|
||||
FIREBALL(12, HURTING_PROJECTILE),
|
||||
SMALL_FIREBALL(13, HURTING_PROJECTILE),
|
||||
WITHER_SKULL(19, HURTING_PROJECTILE),
|
||||
|
||||
// Vehicles
|
||||
BOAT(41, ENTITY),
|
||||
|
||||
ABSTRACT_MINECART(ENTITY),
|
||||
MINECART(42, ABSTRACT_MINECART),
|
||||
FURNACE_MINECART(44, ABSTRACT_MINECART),
|
||||
COMMAND_BLOCK_MINECART(40, ABSTRACT_MINECART),
|
||||
TNT_MINECART(45, ABSTRACT_MINECART),
|
||||
SPAWNER_MINECART(47, ABSTRACT_MINECART),
|
||||
|
||||
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART),
|
||||
CHEST_MINECART(43, ABSTRACT_MINECART_CONTAINER),
|
||||
HOPPER_MINECART(46, ABSTRACT_MINECART_CONTAINER),
|
||||
|
||||
LIVING_ENTITY_BASE(ENTITY),
|
||||
ARMOR_STAND(30, LIVING_ENTITY_BASE),
|
||||
PLAYER(ENTITY), // Needed for entity (un)tracking
|
||||
|
||||
// Living entities as a larger subclass
|
||||
LIVING_ENTITY(48, LIVING_ENTITY_BASE),
|
||||
ENDER_DRAGON(63, LIVING_ENTITY),
|
||||
ABSTRACT_CREATURE(LIVING_ENTITY),
|
||||
SLIME(55, LIVING_ENTITY),
|
||||
MAGMA_CUBE(62, SLIME),
|
||||
|
||||
// Flying entities
|
||||
FLYING_MOB(LIVING_ENTITY),
|
||||
GHAST(56, FLYING_MOB),
|
||||
|
||||
AMBIENT_CREATURE(LIVING_ENTITY),
|
||||
BAT(65, AMBIENT_CREATURE),
|
||||
|
||||
ABSTRACT_GOLEM(ABSTRACT_CREATURE),
|
||||
SNOW_GOLEM(97, ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(99, ABSTRACT_GOLEM),
|
||||
SHULKER(69, ABSTRACT_GOLEM),
|
||||
|
||||
WATER_ANIMAL(LIVING_ENTITY),
|
||||
SQUID(94, WATER_ANIMAL),
|
||||
|
||||
// Ageable mobs and (tamable) animals
|
||||
ABSTRACT_AGEABLE(ABSTRACT_CREATURE),
|
||||
VILLAGER(120, ABSTRACT_AGEABLE),
|
||||
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE),
|
||||
CHICKEN(93, ABSTRACT_ANIMAL),
|
||||
COW(92, ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(96, COW),
|
||||
PIG(90, ABSTRACT_ANIMAL),
|
||||
RABBIT(101, ABSTRACT_ANIMAL),
|
||||
SHEEP(91, ABSTRACT_ANIMAL),
|
||||
HORSE(100, ABSTRACT_ANIMAL),
|
||||
|
||||
TAMABLE_ANIMAL(ABSTRACT_ANIMAL),
|
||||
OCELOT(98, TAMABLE_ANIMAL),
|
||||
WOLF(95, TAMABLE_ANIMAL),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(49, ABSTRACT_CREATURE),
|
||||
BLAZE(61, ABSTRACT_MONSTER),
|
||||
CREEPER(50, ABSTRACT_MONSTER),
|
||||
ENDERMITE(67, ABSTRACT_MONSTER),
|
||||
ENDERMAN(58, ABSTRACT_MONSTER),
|
||||
GIANT(53, ABSTRACT_MONSTER),
|
||||
SILVERFISH(60, ABSTRACT_MONSTER),
|
||||
WITCH(66, ABSTRACT_MONSTER),
|
||||
WITHER(64, ABSTRACT_MONSTER),
|
||||
SKELETON(51, ABSTRACT_MONSTER),
|
||||
ZOMBIE(54, ABSTRACT_MONSTER),
|
||||
ZOMBIE_PIGMEN(57, ZOMBIE),
|
||||
|
||||
GUARDIAN(68, ABSTRACT_MONSTER),
|
||||
SPIDER(52, ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(59, SPIDER);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
|
||||
private final int id;
|
||||
private final EntityType parent;
|
||||
|
||||
EntityType() {
|
||||
this.id = -1;
|
||||
this.parent = null;
|
||||
}
|
||||
|
||||
EntityType(EntityType parent) {
|
||||
this.id = -1;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
EntityType(int id, EntityType parent) {
|
||||
this.id = id;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getParent() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public static EntityType findById(final int id) {
|
||||
if (id == -1) {
|
||||
return null;
|
||||
}
|
||||
return TYPES.get(id);
|
||||
}
|
||||
}
|
||||
|
||||
public enum ObjectType implements com.viaversion.viaversion.api.minecraft.entities.ObjectType {
|
||||
BOAT(1, EntityType.BOAT),
|
||||
ITEM(2, EntityType.ITEM),
|
||||
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
|
||||
MINECART(10, EntityType.MINECART), // There are multiple types, but we don't need them
|
||||
TNT_PRIMED(50, EntityType.TNT),
|
||||
ENDER_CRYSTAL(51, EntityType.END_CRYSTAL),
|
||||
TIPPED_ARROW(60, EntityType.ARROW),
|
||||
SNOWBALL(61, EntityType.SNOWBALL),
|
||||
EGG(62, EntityType.EGG),
|
||||
FIREBALL(63, EntityType.FIREBALL),
|
||||
SMALL_FIREBALL(64, EntityType.SMALL_FIREBALL),
|
||||
ENDER_PEARL(65, EntityType.ENDER_PEARL),
|
||||
WITHER_SKULL(66, EntityType.WITHER_SKULL),
|
||||
SHULKER_BULLET(67, EntityType.SHULKER_BULLET),
|
||||
FALLING_BLOCK(70, EntityType.FALLING_BLOCK),
|
||||
ITEM_FRAME(71, EntityType.ITEM_FRAME),
|
||||
EYE_OF_ENDER(72, EntityType.EYE_OF_ENDER),
|
||||
POTION(73, EntityType.POTION),
|
||||
EXPERIENCE_BOTTLE(75, EntityType.EXPERIENCE_BOTTLE),
|
||||
FIREWORK_ROCKET(76, EntityType.FIREWORK_ROCKET),
|
||||
LEASH(77, EntityType.LEASH_KNOT),
|
||||
ARMOR_STAND(78, EntityType.ARMOR_STAND),
|
||||
FISHIHNG_HOOK(90, EntityType.FISHING_HOOK),
|
||||
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
||||
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
|
||||
|
||||
private static final Map<Integer, ObjectType> TYPES = new HashMap<>();
|
||||
|
||||
private final int id;
|
||||
private final EntityType type;
|
||||
|
||||
static {
|
||||
for (ObjectType type : ObjectType.values()) {
|
||||
TYPES.put(type.id, type);
|
||||
}
|
||||
}
|
||||
|
||||
ObjectType(int id, EntityType type) {
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static ObjectType findById(final int id) {
|
||||
if (id == -1) {
|
||||
return null;
|
||||
}
|
||||
return TYPES.get(id);
|
||||
}
|
||||
|
||||
public static EntityType getEntityType(final int id) {
|
||||
final ObjectType objectType = findById(id);
|
||||
return objectType != null ? objectType.type : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
-17
@@ -20,15 +20,15 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.metadata;
|
||||
package com.viaversion.viaversion.api.minecraft.entitydata;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.Objects;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class Metadata {
|
||||
public final class EntityData {
|
||||
private int id;
|
||||
private MetaType metaType;
|
||||
private EntityDataType metaType;
|
||||
private Object value;
|
||||
|
||||
/**
|
||||
@@ -39,7 +39,7 @@ public final class Metadata {
|
||||
* @param value value if present
|
||||
* @throws IllegalArgumentException if the value and metaType are incompatible
|
||||
*/
|
||||
public Metadata(int id, MetaType metaType, @Nullable Object value) {
|
||||
public EntityData(int id, EntityDataType metaType, @Nullable Object value) {
|
||||
this.id = id;
|
||||
this.metaType = metaType;
|
||||
this.value = checkValue(metaType, value);
|
||||
@@ -53,7 +53,7 @@ public final class Metadata {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public MetaType metaType() {
|
||||
public EntityDataType dataType() {
|
||||
return metaType;
|
||||
}
|
||||
|
||||
@@ -62,9 +62,9 @@ public final class Metadata {
|
||||
*
|
||||
* @param metaType metadata type
|
||||
* @throws IllegalArgumentException if the metadata type and current value are incompatible
|
||||
* @see #setTypeAndValue(MetaType, Object)
|
||||
* @see #setTypeAndValue(EntityDataType, Object)
|
||||
*/
|
||||
public void setMetaType(MetaType metaType) {
|
||||
public void setDataType(EntityDataType metaType) {
|
||||
checkValue(metaType, this.value);
|
||||
this.metaType = metaType;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public final class Metadata {
|
||||
*
|
||||
* @param value value
|
||||
* @throws IllegalArgumentException if the value and current metaType are incompatible
|
||||
* @see #setTypeAndValue(MetaType, Object)
|
||||
* @see #setTypeAndValue(EntityDataType, Object)
|
||||
*/
|
||||
public void setValue(@Nullable Object value) {
|
||||
this.value = checkValue(this.metaType, value);
|
||||
@@ -95,22 +95,22 @@ public final class Metadata {
|
||||
* @param value value
|
||||
* @throws IllegalArgumentException if the value and metaType are incompatible
|
||||
*/
|
||||
public void setTypeAndValue(MetaType metaType, @Nullable Object value) {
|
||||
public void setTypeAndValue(EntityDataType metaType, @Nullable Object value) {
|
||||
this.value = checkValue(metaType, value);
|
||||
this.metaType = metaType;
|
||||
}
|
||||
|
||||
private Object checkValue(MetaType metaType, @Nullable Object value) {
|
||||
private Object checkValue(EntityDataType metaType, @Nullable Object value) {
|
||||
Preconditions.checkNotNull(metaType);
|
||||
if (value != null && !metaType.type().getOutputClass().isAssignableFrom(value.getClass())) {
|
||||
throw new IllegalArgumentException("Metadata value and metaType are incompatible. Type=" + metaType
|
||||
+ ", value=" + value + " (" + value.getClass().getSimpleName() + ")");
|
||||
+ ", value=" + value + " (" + value.getClass().getSimpleName() + ")");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setMetaTypeUnsafe(MetaType type) {
|
||||
public void setDataTypeUnsafe(EntityDataType type) {
|
||||
this.metaType = type;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public final class Metadata {
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Metadata metadata = (Metadata) o;
|
||||
EntityData metadata = (EntityData) o;
|
||||
if (id != metadata.id) return false;
|
||||
if (metaType != metadata.metaType) return false;
|
||||
return Objects.equals(value, metadata.value);
|
||||
@@ -135,9 +135,9 @@ public final class Metadata {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Metadata{" +
|
||||
"id=" + id +
|
||||
", metaType=" + metaType +
|
||||
", value=" + value +
|
||||
'}';
|
||||
"id=" + id +
|
||||
", metaType=" + metaType +
|
||||
", value=" + value +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+13
-11
@@ -20,11 +20,12 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.metadata;
|
||||
package com.viaversion.viaversion.api.minecraft.entitydata;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
|
||||
public interface MetaType {
|
||||
public interface EntityDataType {
|
||||
|
||||
/**
|
||||
* Get the write/read type
|
||||
@@ -40,15 +41,16 @@ public interface MetaType {
|
||||
*/
|
||||
int typeId();
|
||||
|
||||
static MetaType create(final int typeId, final Type<?> type) {
|
||||
return new MetaTypeImpl(typeId, type);
|
||||
static EntityDataType create(final int typeId, final Type<?> type) {
|
||||
return new EntityDataTypeImpl(typeId, type);
|
||||
}
|
||||
|
||||
final class MetaTypeImpl implements MetaType {
|
||||
final class EntityDataTypeImpl implements EntityDataType {
|
||||
private final int typeId;
|
||||
private final Type<?> type;
|
||||
|
||||
MetaTypeImpl(final int typeId, final Type<?> type) {
|
||||
EntityDataTypeImpl(final int typeId, final Type<?> type) {
|
||||
Preconditions.checkNotNull(type);
|
||||
this.typeId = typeId;
|
||||
this.type = type;
|
||||
}
|
||||
@@ -65,17 +67,17 @@ public interface MetaType {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MetaType{" +
|
||||
"typeId=" + typeId +
|
||||
", type=" + type +
|
||||
'}';
|
||||
return "EntityDataType{" +
|
||||
"typeId=" + typeId +
|
||||
", type=" + type +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final MetaTypeImpl metaType = (MetaTypeImpl) o;
|
||||
final EntityDataTypeImpl metaType = (EntityDataTypeImpl) o;
|
||||
if (typeId != metaType.typeId) return false;
|
||||
return type.equals(metaType.type);
|
||||
}
|
||||
+10
-10
@@ -20,31 +20,31 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.metadata.types;
|
||||
package com.viaversion.viaversion.api.minecraft.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
|
||||
public abstract class AbstractMetaTypes implements MetaTypes {
|
||||
public abstract class AbstractEntityDataTypes implements EntityDataTypes {
|
||||
|
||||
private final MetaType[] values;
|
||||
private final EntityDataType[] values;
|
||||
|
||||
protected AbstractMetaTypes(final int values) {
|
||||
this.values = new MetaType[values];
|
||||
protected AbstractEntityDataTypes(final int values) {
|
||||
this.values = new EntityDataType[values];
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaType byId(final int id) {
|
||||
public EntityDataType byId(final int id) {
|
||||
return values[id];
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaType[] values() {
|
||||
public EntityDataType[] values() {
|
||||
return values;
|
||||
}
|
||||
|
||||
protected MetaType add(final int typeId, final Type<?> type) {
|
||||
final MetaType metaType = MetaType.create(typeId, type);
|
||||
protected EntityDataType add(final int typeId, final Type<?> type) {
|
||||
final EntityDataType metaType = EntityDataType.create(typeId, type);
|
||||
values[typeId] = metaType;
|
||||
return metaType;
|
||||
}
|
||||
+5
-5
@@ -20,11 +20,11 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.metadata.types;
|
||||
package com.viaversion.viaversion.api.minecraft.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
|
||||
public interface MetaTypes {
|
||||
public interface EntityDataTypes {
|
||||
|
||||
/**
|
||||
* Returns the meta type by the given id.
|
||||
@@ -33,12 +33,12 @@ public interface MetaTypes {
|
||||
* @return meta type by id
|
||||
* @throws IndexOutOfBoundsException if id is out of bounds
|
||||
*/
|
||||
MetaType byId(int id);
|
||||
EntityDataType byId(int id);
|
||||
|
||||
/**
|
||||
* Returns an array of meta types.
|
||||
*
|
||||
* @return array of meta types
|
||||
*/
|
||||
MetaType[] values();
|
||||
EntityDataType[] values();
|
||||
}
|
||||
+22
-22
@@ -20,41 +20,41 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.metadata.types;
|
||||
package com.viaversion.viaversion.api.minecraft.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
|
||||
public enum MetaType1_9 implements MetaType {
|
||||
Byte(0, Type.BYTE),
|
||||
VarInt(1, Type.VAR_INT),
|
||||
Float(2, Type.FLOAT),
|
||||
String(3, Type.STRING),
|
||||
Chat(4, Type.COMPONENT),
|
||||
Slot(5, Type.ITEM1_8),
|
||||
Boolean(6, Type.BOOLEAN),
|
||||
Vector3F(7, Type.ROTATION),
|
||||
Position(8, Type.POSITION1_8),
|
||||
OptPosition(9, Type.OPTIONAL_POSITION1_8),
|
||||
Direction(10, Type.VAR_INT),
|
||||
OptUUID(11, Type.OPTIONAL_UUID),
|
||||
BlockID(12, Type.VAR_INT);
|
||||
public enum EntityDataTypes1_12 implements EntityDataType {
|
||||
BYTE(Types.BYTE),
|
||||
VAR_INT(Types.VAR_INT),
|
||||
FLOAT(Types.FLOAT),
|
||||
STRING(Types.STRING),
|
||||
COMPONENT(Types.COMPONENT),
|
||||
ITEM(Types.ITEM1_8),
|
||||
BOOLEAN(Types.BOOLEAN),
|
||||
ROTATIONS(Types.ROTATIONS),
|
||||
BLOCK_POSITION(Types.BLOCK_POSITION1_8),
|
||||
OPTIONAL_BLOCK_POSITION(Types.OPTIONAL_POSITION1_8),
|
||||
DIRECTION(Types.VAR_INT),
|
||||
OPTIONAL_UUID(Types.OPTIONAL_UUID),
|
||||
OPTIONAL_BLOCK_STATE(Types.VAR_INT),
|
||||
COMPOUND_TAG(Types.NAMED_COMPOUND_TAG);
|
||||
|
||||
private final int typeID;
|
||||
private final Type type;
|
||||
private final Type<?> type;
|
||||
|
||||
MetaType1_9(int typeID, Type type) {
|
||||
this.typeID = typeID;
|
||||
EntityDataTypes1_12(Type<?> type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static MetaType1_9 byId(int id) {
|
||||
public static EntityDataTypes1_12 byId(int id) {
|
||||
return values()[id];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int typeId() {
|
||||
return typeID;
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
|
||||
public final class EntityDataTypes1_13 extends AbstractEntityDataTypes {
|
||||
|
||||
public final EntityDataType byteType = add(0, Types.BYTE);
|
||||
public final EntityDataType varIntType = add(1, Types.VAR_INT);
|
||||
public final EntityDataType floatType = add(2, Types.FLOAT);
|
||||
public final EntityDataType stringType = add(3, Types.STRING);
|
||||
public final EntityDataType componentType = add(4, Types.COMPONENT);
|
||||
public final EntityDataType optionalComponentType = add(5, Types.OPTIONAL_COMPONENT);
|
||||
public final EntityDataType itemType = add(6, Types.ITEM1_13);
|
||||
public final EntityDataType booleanType = add(7, Types.BOOLEAN);
|
||||
public final EntityDataType rotationsType = add(8, Types.ROTATIONS);
|
||||
public final EntityDataType blockPositionType = add(9, Types.BLOCK_POSITION1_8);
|
||||
public final EntityDataType optionalBlockPositionType = add(10, Types.OPTIONAL_POSITION1_8);
|
||||
public final EntityDataType directionType = add(11, Types.VAR_INT);
|
||||
public final EntityDataType optionalUUIDType = add(12, Types.OPTIONAL_UUID);
|
||||
public final EntityDataType optionalBlockStateType = add(13, Types.VAR_INT);
|
||||
public final EntityDataType compoundTagType = add(14, Types.NAMED_COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
|
||||
public EntityDataTypes1_13(final ParticleType particleType) {
|
||||
super(16);
|
||||
this.particleType = add(15, particleType);
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
|
||||
public final class EntityDataTypes1_13_2 extends AbstractEntityDataTypes {
|
||||
|
||||
public final EntityDataType byteType = add(0, Types.BYTE);
|
||||
public final EntityDataType varIntType = add(1, Types.VAR_INT);
|
||||
public final EntityDataType floatType = add(2, Types.FLOAT);
|
||||
public final EntityDataType stringType = add(3, Types.STRING);
|
||||
public final EntityDataType componentType = add(4, Types.COMPONENT);
|
||||
public final EntityDataType optionalComponentType = add(5, Types.OPTIONAL_COMPONENT);
|
||||
public final EntityDataType itemType = add(6, Types.ITEM1_13_2);
|
||||
public final EntityDataType booleanType = add(7, Types.BOOLEAN);
|
||||
public final EntityDataType rotationsType = add(8, Types.ROTATIONS);
|
||||
public final EntityDataType blockPositionType = add(9, Types.BLOCK_POSITION1_8);
|
||||
public final EntityDataType optionalBlockPositionType = add(10, Types.OPTIONAL_POSITION1_8);
|
||||
public final EntityDataType directionType = add(11, Types.VAR_INT);
|
||||
public final EntityDataType optionalUUIDType = add(12, Types.OPTIONAL_UUID);
|
||||
public final EntityDataType optionalBlockStateType = add(13, Types.VAR_INT);
|
||||
public final EntityDataType compoundTagType = add(14, Types.NAMED_COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
|
||||
public EntityDataTypes1_13_2(final ParticleType particleType) {
|
||||
super(16);
|
||||
this.particleType = add(15, particleType);
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
|
||||
public final class EntityDataTypes1_14 extends AbstractEntityDataTypes {
|
||||
|
||||
public final EntityDataType byteType = add(0, Types.BYTE);
|
||||
public final EntityDataType varIntType = add(1, Types.VAR_INT);
|
||||
public final EntityDataType floatType = add(2, Types.FLOAT);
|
||||
public final EntityDataType stringType = add(3, Types.STRING);
|
||||
public final EntityDataType componentType = add(4, Types.COMPONENT);
|
||||
public final EntityDataType optionalComponentType = add(5, Types.OPTIONAL_COMPONENT);
|
||||
public final EntityDataType itemType = add(6, Types.ITEM1_13_2);
|
||||
public final EntityDataType booleanType = add(7, Types.BOOLEAN);
|
||||
public final EntityDataType rotationsType = add(8, Types.ROTATIONS);
|
||||
public final EntityDataType blockPositionType = add(9, Types.BLOCK_POSITION1_14);
|
||||
public final EntityDataType optionalBlockPositionType = add(10, Types.OPTIONAL_POSITION_1_14);
|
||||
public final EntityDataType directionType = add(11, Types.VAR_INT);
|
||||
public final EntityDataType optionalUUIDType = add(12, Types.OPTIONAL_UUID);
|
||||
public final EntityDataType optionalBlockStateType = add(13, Types.VAR_INT);
|
||||
public final EntityDataType compoundTagType = add(14, Types.NAMED_COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType villagerDatatType = add(16, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(17, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(18, Types.VAR_INT);
|
||||
|
||||
public EntityDataTypes1_14(final ParticleType particleType) {
|
||||
super(19);
|
||||
this.particleType = add(15, particleType);
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
|
||||
public final class EntityDataTypes1_19 extends AbstractEntityDataTypes {
|
||||
|
||||
public final EntityDataType byteType = add(0, Types.BYTE);
|
||||
public final EntityDataType varIntType = add(1, Types.VAR_INT);
|
||||
public final EntityDataType floatType = add(2, Types.FLOAT);
|
||||
public final EntityDataType stringType = add(3, Types.STRING);
|
||||
public final EntityDataType componentType = add(4, Types.COMPONENT);
|
||||
public final EntityDataType optionalComponentType = add(5, Types.OPTIONAL_COMPONENT);
|
||||
public final EntityDataType itemType = add(6, Types.ITEM1_13_2);
|
||||
public final EntityDataType booleanType = add(7, Types.BOOLEAN);
|
||||
public final EntityDataType rotationsType = add(8, Types.ROTATIONS);
|
||||
public final EntityDataType blockPositionType = add(9, Types.BLOCK_POSITION1_14);
|
||||
public final EntityDataType optionalBlockPositionType = add(10, Types.OPTIONAL_POSITION_1_14);
|
||||
public final EntityDataType directionType = add(11, Types.VAR_INT);
|
||||
public final EntityDataType optionalUUIDType = add(12, Types.OPTIONAL_UUID);
|
||||
public final EntityDataType optionalBlockStateType = add(13, Types.VAR_INT);
|
||||
public final EntityDataType compoundTagType = add(14, Types.NAMED_COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType villagerDatatType = add(16, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(17, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(18, Types.VAR_INT);
|
||||
public final EntityDataType catVariantType = add(19, Types.VAR_INT);
|
||||
public final EntityDataType frogVariantType = add(20, Types.VAR_INT);
|
||||
public final EntityDataType optionalGlobalPosition = add(21, Types.OPTIONAL_GLOBAL_POSITION);
|
||||
public final EntityDataType paintingVariantType = add(22, Types.VAR_INT);
|
||||
|
||||
public EntityDataTypes1_19(final ParticleType particleType) {
|
||||
super(23);
|
||||
this.particleType = add(15, particleType);
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
|
||||
public final class EntityDataTypes1_19_3 extends AbstractEntityDataTypes {
|
||||
|
||||
public final EntityDataType byteType = add(0, Types.BYTE);
|
||||
public final EntityDataType varIntType = add(1, Types.VAR_INT);
|
||||
public final EntityDataType longType = add(2, Types.VAR_LONG);
|
||||
public final EntityDataType floatType = add(3, Types.FLOAT);
|
||||
public final EntityDataType stringType = add(4, Types.STRING);
|
||||
public final EntityDataType componentType = add(5, Types.COMPONENT);
|
||||
public final EntityDataType optionalComponentType = add(6, Types.OPTIONAL_COMPONENT);
|
||||
public final EntityDataType itemType = add(7, Types.ITEM1_13_2);
|
||||
public final EntityDataType booleanType = add(8, Types.BOOLEAN);
|
||||
public final EntityDataType rotationsType = add(9, Types.ROTATIONS);
|
||||
public final EntityDataType blockPositionType = add(10, Types.BLOCK_POSITION1_14);
|
||||
public final EntityDataType optionalBlockPositionType = add(11, Types.OPTIONAL_POSITION_1_14);
|
||||
public final EntityDataType directionType = add(12, Types.VAR_INT);
|
||||
public final EntityDataType optionalUUIDType = add(13, Types.OPTIONAL_UUID);
|
||||
public final EntityDataType optionalBlockStateType = add(14, Types.VAR_INT);
|
||||
public final EntityDataType compoundTagType = add(15, Types.NAMED_COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType villagerDatatType = add(17, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(18, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(19, Types.VAR_INT);
|
||||
public final EntityDataType catVariantType = add(20, Types.VAR_INT);
|
||||
public final EntityDataType frogVariantType = add(21, Types.VAR_INT);
|
||||
public final EntityDataType optionalGlobalPosition = add(22, Types.OPTIONAL_GLOBAL_POSITION);
|
||||
public final EntityDataType paintingVariantType = add(23, Types.VAR_INT);
|
||||
|
||||
public EntityDataTypes1_19_3(final ParticleType particleType) {
|
||||
super(24);
|
||||
this.particleType = add(16, particleType);
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
|
||||
public final class EntityDataTypes1_19_4 extends AbstractEntityDataTypes {
|
||||
|
||||
public final EntityDataType byteType = add(0, Types.BYTE);
|
||||
public final EntityDataType varIntType = add(1, Types.VAR_INT);
|
||||
public final EntityDataType longType = add(2, Types.VAR_LONG);
|
||||
public final EntityDataType floatType = add(3, Types.FLOAT);
|
||||
public final EntityDataType stringType = add(4, Types.STRING);
|
||||
public final EntityDataType componentType = add(5, Types.COMPONENT);
|
||||
public final EntityDataType optionalComponentType = add(6, Types.OPTIONAL_COMPONENT);
|
||||
public final EntityDataType itemType = add(7, Types.ITEM1_13_2);
|
||||
public final EntityDataType booleanType = add(8, Types.BOOLEAN);
|
||||
public final EntityDataType rotationsType = add(9, Types.ROTATIONS);
|
||||
public final EntityDataType blockPositionType = add(10, Types.BLOCK_POSITION1_14);
|
||||
public final EntityDataType optionalBlockPositionType = add(11, Types.OPTIONAL_POSITION_1_14);
|
||||
public final EntityDataType directionType = add(12, Types.VAR_INT);
|
||||
public final EntityDataType optionalUUIDType = add(13, Types.OPTIONAL_UUID);
|
||||
public final EntityDataType blockStateType = add(14, Types.VAR_INT);
|
||||
public final EntityDataType optionalBlockStateType = add(15, Types.VAR_INT);
|
||||
public final EntityDataType compoundTagType = add(16, Types.NAMED_COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType villagerDatatType = add(18, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(19, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(20, Types.VAR_INT);
|
||||
public final EntityDataType catVariantType = add(21, Types.VAR_INT);
|
||||
public final EntityDataType frogVariantType = add(22, Types.VAR_INT);
|
||||
public final EntityDataType optionalGlobalPosition = add(23, Types.OPTIONAL_GLOBAL_POSITION);
|
||||
public final EntityDataType paintingVariantType = add(24, Types.VAR_INT);
|
||||
public final EntityDataType snifferState = add(25, Types.VAR_INT);
|
||||
public final EntityDataType vector3FType = add(26, Types.VECTOR3F);
|
||||
public final EntityDataType quaternionType = add(27, Types.QUATERNION);
|
||||
|
||||
public EntityDataTypes1_19_4(final ParticleType particleType) {
|
||||
super(28);
|
||||
this.particleType = add(17, particleType);
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
|
||||
public final class EntityDataTypes1_20_2 extends AbstractEntityDataTypes {
|
||||
|
||||
public final EntityDataType byteType = add(0, Types.BYTE);
|
||||
public final EntityDataType varIntType = add(1, Types.VAR_INT);
|
||||
public final EntityDataType longType = add(2, Types.VAR_LONG);
|
||||
public final EntityDataType floatType = add(3, Types.FLOAT);
|
||||
public final EntityDataType stringType = add(4, Types.STRING);
|
||||
public final EntityDataType componentType = add(5, Types.COMPONENT);
|
||||
public final EntityDataType optionalComponentType = add(6, Types.OPTIONAL_COMPONENT);
|
||||
public final EntityDataType itemType = add(7, Types.ITEM1_20_2);
|
||||
public final EntityDataType booleanType = add(8, Types.BOOLEAN);
|
||||
public final EntityDataType rotationsType = add(9, Types.ROTATIONS);
|
||||
public final EntityDataType blockPositionType = add(10, Types.BLOCK_POSITION1_14);
|
||||
public final EntityDataType optionalBlockPositionType = add(11, Types.OPTIONAL_POSITION_1_14);
|
||||
public final EntityDataType directionType = add(12, Types.VAR_INT);
|
||||
public final EntityDataType optionalUUIDType = add(13, Types.OPTIONAL_UUID);
|
||||
public final EntityDataType blockStateType = add(14, Types.VAR_INT);
|
||||
public final EntityDataType optionalBlockStateType = add(15, Types.VAR_INT);
|
||||
public final EntityDataType compoundTagType = add(16, Types.COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType villagerDatatType = add(18, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(19, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(20, Types.VAR_INT);
|
||||
public final EntityDataType catVariantType = add(21, Types.VAR_INT);
|
||||
public final EntityDataType frogVariantType = add(22, Types.VAR_INT);
|
||||
public final EntityDataType optionalGlobalPosition = add(23, Types.OPTIONAL_GLOBAL_POSITION);
|
||||
public final EntityDataType paintingVariantType = add(24, Types.VAR_INT);
|
||||
public final EntityDataType snifferState = add(25, Types.VAR_INT);
|
||||
public final EntityDataType vector3FType = add(26, Types.VECTOR3F);
|
||||
public final EntityDataType quaternionType = add(27, Types.QUATERNION);
|
||||
|
||||
public EntityDataTypes1_20_2(final ParticleType particleType) {
|
||||
super(28);
|
||||
this.particleType = add(17, particleType);
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
|
||||
public final class EntityDataTypes1_20_3 extends AbstractEntityDataTypes {
|
||||
|
||||
public final EntityDataType byteType = add(0, Types.BYTE);
|
||||
public final EntityDataType varIntType = add(1, Types.VAR_INT);
|
||||
public final EntityDataType longType = add(2, Types.VAR_LONG);
|
||||
public final EntityDataType floatType = add(3, Types.FLOAT);
|
||||
public final EntityDataType stringType = add(4, Types.STRING);
|
||||
public final EntityDataType componentType = add(5, Types.TAG);
|
||||
public final EntityDataType optionalComponentType = add(6, Types.OPTIONAL_TAG);
|
||||
public final EntityDataType itemType = add(7, Types.ITEM1_20_2);
|
||||
public final EntityDataType booleanType = add(8, Types.BOOLEAN);
|
||||
public final EntityDataType rotationsType = add(9, Types.ROTATIONS);
|
||||
public final EntityDataType blockPositionType = add(10, Types.BLOCK_POSITION1_14);
|
||||
public final EntityDataType optionalBlockPositionType = add(11, Types.OPTIONAL_POSITION_1_14);
|
||||
public final EntityDataType directionType = add(12, Types.VAR_INT);
|
||||
public final EntityDataType optionalUUIDType = add(13, Types.OPTIONAL_UUID);
|
||||
public final EntityDataType blockStateType = add(14, Types.VAR_INT);
|
||||
public final EntityDataType optionalBlockStateType = add(15, Types.VAR_INT);
|
||||
public final EntityDataType compoundTagType = add(16, Types.COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType villagerDatatType = add(18, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(19, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(20, Types.VAR_INT);
|
||||
public final EntityDataType catVariantType = add(21, Types.VAR_INT);
|
||||
public final EntityDataType frogVariantType = add(22, Types.VAR_INT);
|
||||
public final EntityDataType optionalGlobalPosition = add(23, Types.OPTIONAL_GLOBAL_POSITION);
|
||||
public final EntityDataType paintingVariantType = add(24, Types.VAR_INT);
|
||||
public final EntityDataType snifferState = add(25, Types.VAR_INT);
|
||||
public final EntityDataType vector3FType = add(26, Types.VECTOR3F);
|
||||
public final EntityDataType quaternionType = add(27, Types.QUATERNION);
|
||||
|
||||
public EntityDataTypes1_20_3(final ParticleType particleType) {
|
||||
super(28);
|
||||
this.particleType = add(17, particleType);
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.ArrayType;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
|
||||
|
||||
public final class EntityDataTypes1_20_5 extends AbstractEntityDataTypes {
|
||||
|
||||
public final EntityDataType byteType = add(0, Types.BYTE);
|
||||
public final EntityDataType varIntType = add(1, Types.VAR_INT);
|
||||
public final EntityDataType longType = add(2, Types.VAR_LONG);
|
||||
public final EntityDataType floatType = add(3, Types.FLOAT);
|
||||
public final EntityDataType stringType = add(4, Types.STRING);
|
||||
public final EntityDataType componentType = add(5, Types.TAG);
|
||||
public final EntityDataType optionalComponentType = add(6, Types.OPTIONAL_TAG);
|
||||
public final EntityDataType itemType = add(7, Types1_20_5.ITEM);
|
||||
public final EntityDataType booleanType = add(8, Types.BOOLEAN);
|
||||
public final EntityDataType rotationsType = add(9, Types.ROTATIONS);
|
||||
public final EntityDataType blockPositionType = add(10, Types.BLOCK_POSITION1_14);
|
||||
public final EntityDataType optionalBlockPositionType = add(11, Types.OPTIONAL_POSITION_1_14);
|
||||
public final EntityDataType directionType = add(12, Types.VAR_INT);
|
||||
public final EntityDataType optionalUUIDType = add(13, Types.OPTIONAL_UUID);
|
||||
public final EntityDataType blockStateType = add(14, Types.VAR_INT);
|
||||
public final EntityDataType optionalBlockStateType = add(15, Types.VAR_INT);
|
||||
public final EntityDataType compoundTagType = add(16, Types.COMPOUND_TAG);
|
||||
public final EntityDataType particleType;
|
||||
public final EntityDataType particlesType;
|
||||
public final EntityDataType villagerDatatType = add(19, Types.VILLAGER_DATA);
|
||||
public final EntityDataType optionalVarIntType = add(20, Types.OPTIONAL_VAR_INT);
|
||||
public final EntityDataType poseType = add(21, Types.VAR_INT);
|
||||
public final EntityDataType catVariantType = add(22, Types.VAR_INT);
|
||||
public final EntityDataType wolfVariantType = add(23, Types.VAR_INT);
|
||||
public final EntityDataType frogVariantType = add(24, Types.VAR_INT);
|
||||
public final EntityDataType optionalGlobalPosition = add(25, Types.OPTIONAL_GLOBAL_POSITION);
|
||||
public final EntityDataType paintingVariantType = add(26, Types.VAR_INT);
|
||||
public final EntityDataType snifferState = add(27, Types.VAR_INT);
|
||||
public final EntityDataType armadilloState = add(28, Types.VAR_INT);
|
||||
public final EntityDataType vector3FType = add(29, Types.VECTOR3F);
|
||||
public final EntityDataType quaternionType = add(30, Types.QUATERNION);
|
||||
|
||||
public EntityDataTypes1_20_5(final ParticleType particleType, final ArrayType<Particle> particlesType) {
|
||||
super(31);
|
||||
this.particleType = add(17, particleType);
|
||||
this.particlesType = add(18, particlesType);
|
||||
}
|
||||
}
|
||||
+16
-20
@@ -20,39 +20,35 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.metadata.types;
|
||||
package com.viaversion.viaversion.api.minecraft.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.VoidType;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
|
||||
public enum MetaType1_8 implements MetaType {
|
||||
Byte(0, Type.BYTE),
|
||||
Short(1, Type.SHORT),
|
||||
Int(2, Type.INT),
|
||||
Float(3, Type.FLOAT),
|
||||
String(4, Type.STRING),
|
||||
Slot(5, Type.ITEM1_8),
|
||||
Position(6, Type.VECTOR),
|
||||
Rotation(7, Type.ROTATION),
|
||||
@Deprecated
|
||||
NonExistent(-1, new VoidType());
|
||||
public enum EntityDataTypes1_8 implements EntityDataType {
|
||||
BYTE(Types.BYTE),
|
||||
SHORT(Types.SHORT),
|
||||
INT(Types.INT),
|
||||
FLOAT(Types.FLOAT),
|
||||
STRING(Types.STRING),
|
||||
ITEM(Types.ITEM1_8),
|
||||
BLOCK_POSITION(Types.VECTOR),
|
||||
ROTATIONS(Types.ROTATIONS);
|
||||
|
||||
private final int typeID;
|
||||
private final Type type;
|
||||
private final Type<?> type;
|
||||
|
||||
MetaType1_8(int typeID, Type type) {
|
||||
this.typeID = typeID;
|
||||
EntityDataTypes1_8(Type<?> type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static MetaType1_8 byId(int id) {
|
||||
public static EntityDataTypes1_8 byId(int id) {
|
||||
return values()[id];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int typeId() {
|
||||
return typeID;
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
+21
-23
@@ -20,42 +20,40 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.metadata.types;
|
||||
package com.viaversion.viaversion.api.minecraft.entitydata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
|
||||
public enum MetaType1_12 implements MetaType {
|
||||
Byte(0, Type.BYTE),
|
||||
VarInt(1, Type.VAR_INT),
|
||||
Float(2, Type.FLOAT),
|
||||
String(3, Type.STRING),
|
||||
Chat(4, Type.COMPONENT),
|
||||
Slot(5, Type.ITEM1_8),
|
||||
Boolean(6, Type.BOOLEAN),
|
||||
Vector3F(7, Type.ROTATION),
|
||||
Position(8, Type.POSITION1_8),
|
||||
OptPosition(9, Type.OPTIONAL_POSITION1_8),
|
||||
Direction(10, Type.VAR_INT),
|
||||
OptUUID(11, Type.OPTIONAL_UUID),
|
||||
BlockID(12, Type.VAR_INT),
|
||||
NBTTag(13, Type.NAMED_COMPOUND_TAG);
|
||||
public enum EntityDataTypes1_9 implements EntityDataType {
|
||||
BYTE(Types.BYTE),
|
||||
VAR_INT(Types.VAR_INT),
|
||||
FLOAT(Types.FLOAT),
|
||||
STRING(Types.STRING),
|
||||
COMPONENT(Types.COMPONENT),
|
||||
ITEM(Types.ITEM1_8),
|
||||
BOOLEAN(Types.BOOLEAN),
|
||||
ROTATIONS(Types.ROTATIONS),
|
||||
BLOCK_POSITION(Types.BLOCK_POSITION1_8),
|
||||
OPTIONAL_BLOCK_POSITION(Types.OPTIONAL_POSITION1_8),
|
||||
DIRECTION(Types.VAR_INT),
|
||||
OPTIONAL_UUID(Types.OPTIONAL_UUID),
|
||||
OPTIONAL_BLOCK_STATE(Types.VAR_INT);
|
||||
|
||||
private final int typeID;
|
||||
private final Type type;
|
||||
private final Type<?> type;
|
||||
|
||||
MetaType1_12(int typeID, Type type) {
|
||||
this.typeID = typeID;
|
||||
EntityDataTypes1_9(Type<?> type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static MetaType1_12 byId(int id) {
|
||||
public static EntityDataTypes1_9 byId(int id) {
|
||||
return values()[id];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int typeId() {
|
||||
return typeID;
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -22,8 +22,9 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.item;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
|
||||
import java.util.Objects;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
@@ -37,6 +38,10 @@ public class DataItem implements Item {
|
||||
public DataItem() {
|
||||
}
|
||||
|
||||
public DataItem(int identifier, byte amount, @Nullable CompoundTag tag) {
|
||||
this(identifier, amount, (short) 0, tag);
|
||||
}
|
||||
|
||||
public DataItem(int identifier, byte amount, short data, @Nullable CompoundTag tag) {
|
||||
this.identifier = identifier;
|
||||
this.amount = amount;
|
||||
@@ -44,10 +49,6 @@ public class DataItem implements Item {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public DataItem(Item toCopy) {
|
||||
this(toCopy.identifier(), (byte) toCopy.amount(), toCopy.data(), toCopy.tag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int identifier() {
|
||||
return identifier;
|
||||
@@ -65,7 +66,7 @@ public class DataItem implements Item {
|
||||
|
||||
@Override
|
||||
public void setAmount(int amount) {
|
||||
if (amount > Byte.MAX_VALUE || amount < Byte.MIN_VALUE) {
|
||||
if (amount != (byte) amount) {
|
||||
throw new IllegalArgumentException("Invalid item amount: " + amount);
|
||||
}
|
||||
this.amount = (byte) amount;
|
||||
@@ -92,8 +93,13 @@ public class DataItem implements Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item copy() {
|
||||
return new DataItem(identifier, amount, data, tag);
|
||||
public StructuredDataContainer dataContainer() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataItem copy() {
|
||||
return new DataItem(identifier, amount, data, tag != null ? tag.copy() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,8 +116,8 @@ public class DataItem implements Item {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = identifier;
|
||||
result = 31 * result + (int) amount;
|
||||
result = 31 * result + (int) data;
|
||||
result = 31 * result + amount;
|
||||
result = 31 * result + data;
|
||||
result = 31 * result + (tag != null ? tag.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
@@ -119,10 +125,10 @@ public class DataItem implements Item {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Item{" +
|
||||
"identifier=" + identifier +
|
||||
", amount=" + amount +
|
||||
", data=" + data +
|
||||
", tag=" + tag +
|
||||
'}';
|
||||
"identifier=" + identifier +
|
||||
", amount=" + amount +
|
||||
", data=" + data +
|
||||
", tag=" + tag +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,8 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.item;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface Item {
|
||||
@@ -79,7 +80,8 @@ public interface Item {
|
||||
*
|
||||
* @return item tag
|
||||
*/
|
||||
@Nullable CompoundTag tag();
|
||||
@Nullable
|
||||
CompoundTag tag();
|
||||
|
||||
/**
|
||||
* Sets the item compound tag.
|
||||
@@ -88,10 +90,26 @@ public interface Item {
|
||||
*/
|
||||
void setTag(@Nullable CompoundTag tag);
|
||||
|
||||
/**
|
||||
* Returns the data container for item data components.
|
||||
*
|
||||
* @return the data container
|
||||
*/
|
||||
StructuredDataContainer dataContainer();
|
||||
|
||||
/**
|
||||
* Returns a copy of the item.
|
||||
*
|
||||
* @return copy of the item
|
||||
*/
|
||||
Item copy();
|
||||
|
||||
/**
|
||||
* Returns true if the item is empty.
|
||||
*
|
||||
* @return true if the item is empty
|
||||
*/
|
||||
default boolean isEmpty() {
|
||||
return identifier() == 0 || amount() <= 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.item;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class StructuredItem implements Item {
|
||||
private final StructuredDataContainer data;
|
||||
private int identifier;
|
||||
private int amount;
|
||||
|
||||
public StructuredItem(final int identifier, final int amount) {
|
||||
this(identifier, amount, new StructuredDataContainer());
|
||||
}
|
||||
|
||||
public StructuredItem(final int identifier, final int amount, final StructuredDataContainer data) {
|
||||
this.identifier = identifier;
|
||||
this.amount = amount;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static StructuredItem empty() {
|
||||
// Data is mutable, create a new item
|
||||
return new StructuredItem(0, 0);
|
||||
}
|
||||
|
||||
public static StructuredItem[] emptyArray(final int size) {
|
||||
final StructuredItem[] items = new StructuredItem[size];
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
items[i] = empty();
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int identifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdentifier(final int identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int amount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAmount(final int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable CompoundTag tag() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTag(@Nullable final CompoundTag tag) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructuredDataContainer dataContainer() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructuredItem copy() {
|
||||
return new StructuredItem(identifier, amount, data.copy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final StructuredItem that = (StructuredItem) o;
|
||||
if (identifier != that.identifier) return false;
|
||||
if (amount != that.amount) return false;
|
||||
return data.equals(that.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = data.hashCode();
|
||||
result = 31 * result + identifier;
|
||||
result = 31 * result + amount;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StructuredItem{" +
|
||||
"data=" + data +
|
||||
", identifier=" + identifier +
|
||||
", amount=" + amount +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 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.item.data;
|
||||
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public record AdventureModePredicate(BlockPredicate[] predicates, boolean showInTooltip) {
|
||||
|
||||
public static final Type<AdventureModePredicate> TYPE = new Type<>(AdventureModePredicate.class) {
|
||||
@Override
|
||||
public AdventureModePredicate read(final ByteBuf buffer) {
|
||||
final BlockPredicate[] predicates = BlockPredicate.ARRAY_TYPE.read(buffer);
|
||||
final boolean showInTooltip = buffer.readBoolean();
|
||||
return new AdventureModePredicate(predicates, showInTooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final ByteBuf buffer, final AdventureModePredicate value) {
|
||||
BlockPredicate.ARRAY_TYPE.write(buffer, value.predicates);
|
||||
buffer.writeBoolean(value.showInTooltip);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
Loaded 100 of 912 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user