Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9bccda259 | ||
|
|
9a34ff2a51 | ||
|
|
f01d9408de | ||
|
|
15ff7b4c9d | ||
|
|
d47765ce45 | ||
|
|
b82b067745 | ||
|
|
b7005f2400 | ||
|
|
312fe3a851 | ||
|
|
69d50fa992 | ||
|
|
1308dcb8dd | ||
|
|
b4ecba8382 | ||
|
|
3529d6a229 | ||
|
|
4213c4cce5 | ||
|
|
3d3e09977c | ||
|
|
90feac8c83 | ||
|
|
80a807e366 | ||
|
|
3eba8ba922 | ||
|
|
71a68bf36e | ||
|
|
e67501cde3 | ||
|
|
9aa7f5e879 | ||
|
|
854ecf0b47 | ||
|
|
f538f25d63 | ||
|
|
48a7fdc1d1 | ||
|
|
1d5ae0e3e0 | ||
|
|
f0462085d3 | ||
|
|
7dc7b62cc9 | ||
|
|
b9f80754e0 | ||
|
|
5b9f775743 | ||
|
|
0e66228a96 | ||
|
|
8df48bc378 | ||
|
|
d36d5d6def | ||
|
|
8b51430555 | ||
|
|
f71288e299 | ||
|
|
c0fc8195ce | ||
|
|
dd189411e6 | ||
|
|
4693b95bea | ||
|
|
596a42e312 | ||
|
|
71944be482 | ||
|
|
d1699fbb8d | ||
|
|
bd880b608f | ||
|
|
3386431749 | ||
|
|
c3fc8b5f18 | ||
|
|
ec740476da | ||
|
|
a536ad1d10 | ||
|
|
a1ae7818a2 | ||
|
|
365b3a8a38 | ||
|
|
823eb1f392 | ||
|
|
a12dfa405f | ||
|
|
9798ec296a | ||
|
|
c1b993c01b | ||
|
|
f55696a605 | ||
|
|
f361bd66ea | ||
|
|
3dfb96dec9 | ||
|
|
82ada0bcd8 | ||
|
|
28bd50a105 | ||
|
|
46bd5814e3 | ||
|
|
4e9cddac8f | ||
|
|
a85c5578c1 | ||
|
|
130ab70550 | ||
|
|
ee27cbdd22 | ||
|
|
bd0d238f23 | ||
|
|
3a5ac6f037 | ||
|
|
8db0f3ac6e | ||
|
|
60eda447b4 | ||
|
|
d5f2388723 | ||
|
|
d5a568b3fc | ||
|
|
2704d70c1f | ||
|
|
2a1e82ac6d | ||
|
|
755a69e912 | ||
|
|
101a4f63de | ||
|
|
84bdaa79e2 | ||
|
|
c3b6f5ce64 | ||
|
|
06a7260173 | ||
|
|
54236f718f | ||
|
|
2143e38d27 | ||
|
|
7d7651bc39 | ||
|
|
64c11b1f8f | ||
|
|
a1a0926c4b | ||
|
|
aade94a48f | ||
|
|
edebe64cf8 | ||
|
|
ae4f837091 | ||
|
|
5e6d87c8fd | ||
|
|
20e9723d21 | ||
|
|
54724ac540 | ||
|
|
a9c848e32e | ||
|
|
02f9e87233 | ||
|
|
22d546edc0 | ||
|
|
f464e8e287 | ||
|
|
bd5217acb4 | ||
|
|
e0cf62825b | ||
|
|
9ce356aff4 | ||
|
|
60fa54dddc | ||
|
|
99b457965b | ||
|
|
1d1a330ef1 | ||
|
|
4e9910c20e | ||
|
|
82f2958ac6 | ||
|
|
1afa441571 | ||
|
|
d159047dc0 | ||
|
|
3a529d00ce | ||
|
|
b14b2b86e8 | ||
|
|
9ab4319771 | ||
|
|
8de7a4c828 | ||
|
|
782d7a2172 | ||
|
|
2e5f3e4d66 | ||
|
|
6a00bf099e | ||
|
|
bc11bd4caf | ||
|
|
c133552d04 | ||
|
|
2065a83fa1 | ||
|
|
30ce0eaa45 | ||
|
|
8be1fc9340 | ||
|
|
6a8aa497b0 | ||
|
|
390155e03b | ||
|
|
3051ddb6c0 | ||
|
|
25d74632c2 | ||
|
|
2b77427d0b | ||
|
|
dfc77b6f84 | ||
|
|
6bc7f911c3 | ||
|
|
718614f81f | ||
|
|
8e1f3bb086 | ||
|
|
3a87eb463a | ||
|
|
a49c395486 | ||
|
|
ad7f782a1a | ||
|
|
3aa84b5a5a | ||
|
|
52457ea749 | ||
|
|
8104b96b8c | ||
|
|
a7835650bf | ||
|
|
d326dadb5d | ||
|
|
d9307dad0c | ||
|
|
752735159c | ||
|
|
7cc6eb2b66 | ||
|
|
0a19057606 | ||
|
|
a49d73c4c6 | ||
|
|
82ded0299c | ||
|
|
ab7cd4955b | ||
|
|
95493f3bbe | ||
|
|
a8c6f6b783 | ||
|
|
516f746061 | ||
|
|
d8d65ea989 | ||
|
|
d80735e248 | ||
|
|
ff5ad2385c | ||
|
|
2f28b25af3 | ||
|
|
02bf9501a9 | ||
|
|
a6292988d5 | ||
|
|
431f773b77 | ||
|
|
bd2bd1cf32 | ||
|
|
f5d92bf74f | ||
|
|
dbe8b6551a | ||
|
|
027e132749 | ||
|
|
7e3a157fcf | ||
|
|
9cd1ebf576 | ||
|
|
03f929163c | ||
|
|
e7e1ee7a2b | ||
|
|
3f229c4cb9 | ||
|
|
b2e0fdeaf8 | ||
|
|
0b541befbc | ||
|
|
fd9346d4da | ||
|
|
e744214ad6 | ||
|
|
3feff8e751 | ||
|
|
a2acd261d8 | ||
|
|
36b8884d92 | ||
|
|
c15d7b8882 | ||
|
|
9f33a09e87 | ||
|
|
cc78180a6c | ||
|
|
e5338688bb | ||
|
|
b19ec959b3 | ||
|
|
8b4a57985b | ||
|
|
7fb4e4a095 | ||
|
|
1bc4fc211d | ||
|
|
0a4d08886d | ||
|
|
0f5fa620d1 | ||
|
|
a0f26f1ca3 | ||
|
|
e64a0fb62e | ||
|
|
69409d71d1 | ||
|
|
68c63d20ed | ||
|
|
2afa3fd9de | ||
|
|
0bcaf3e422 | ||
|
|
6e5992c168 | ||
|
|
02122f8ce6 | ||
|
|
39f7f70a32 | ||
|
|
427b0a68d0 | ||
|
|
50f3a05fa5 | ||
|
|
a306c222d4 | ||
|
|
5bfee3339a | ||
|
|
2b9df69627 | ||
|
|
4f1e92f309 | ||
|
|
88165088a9 | ||
|
|
e38f76b8bc | ||
|
|
1f63fc7de1 | ||
|
|
763a88fe97 | ||
|
|
12e2be40e8 | ||
|
|
22379eda6f | ||
|
|
4485af577d | ||
|
|
0fcfd78b62 | ||
|
|
4940ed66c1 | ||
|
|
73093c0ff2 | ||
|
|
c5e27b89af | ||
|
|
111cd2fd46 | ||
|
|
5a90c8374c | ||
|
|
9ffa737a4d | ||
|
|
c565f2c9c7 | ||
|
|
eaa18f569a | ||
|
|
bfe6389377 | ||
|
|
f72412484a | ||
|
|
b4301adb3b | ||
|
|
d67269c9fe | ||
|
|
c264e639d6 | ||
|
|
32a84f24ef | ||
|
|
68e4146f3b | ||
|
|
f4f7215a6a | ||
|
|
a0b19872f8 | ||
|
|
f2147179c2 | ||
|
|
e7a0b4cf04 | ||
|
|
533572e8cd | ||
|
|
257eea5b04 | ||
|
|
47af0d634f | ||
|
|
5e11d9d51f | ||
|
|
7ffcff7a7b | ||
|
|
9ee548b967 | ||
|
|
c9142223fd | ||
|
|
2094397bca | ||
|
|
b81109f512 | ||
|
|
874dbafe26 | ||
|
|
46ca469a4a | ||
|
|
8fb51bf3b7 | ||
|
|
9874a9053a | ||
|
|
db87774426 | ||
|
|
d14db9396b | ||
|
|
d7966567e7 | ||
|
|
b4f8024eef | ||
|
|
e70f230f39 | ||
|
|
b28f743306 | ||
|
|
9f97a09942 | ||
|
|
4f7e655613 | ||
|
|
a7d94c2f8f | ||
|
|
c2172821fd | ||
|
|
24393d4ef4 | ||
|
|
622ea91648 | ||
|
|
aed1a63a77 | ||
|
|
14cd568e46 | ||
|
|
44d836e2e7 | ||
|
|
f9af6947f7 | ||
|
|
8e1da82793 | ||
|
|
860aca974b | ||
|
|
6a66d7653f | ||
|
|
d32a4541a9 | ||
|
|
26719169ee | ||
|
|
eae145543e | ||
|
|
48f1300908 | ||
|
|
5cdaabeaec | ||
|
|
40f87e9472 | ||
|
|
7f385d4762 | ||
|
|
389c5adaa3 | ||
|
|
7a82ded94b | ||
|
|
86278e837a | ||
|
|
34a0499152 | ||
|
|
68ccc6634d | ||
|
|
317af7ebc5 | ||
|
|
206368b777 | ||
|
|
204a81b0ea | ||
|
|
b940ecab9c | ||
|
|
15cbc96697 | ||
|
|
b5e5b46f77 | ||
|
|
42b6a1378c |
No files matched your search
@@ -1,5 +1,6 @@
|
||||
name: Bug Report
|
||||
description: Report a bug or console error
|
||||
labels: [Unconfirmed]
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
@@ -87,5 +88,5 @@ body:
|
||||
required: true
|
||||
- label: If applicable, I have included a paste (**not a screenshot**) of the error.
|
||||
required: true
|
||||
- label: I have tried a build from https://ci.viaversion.com/ and the issue still persists.
|
||||
- label: I have tried the latest build(s) from https://ci.viaversion.com/ and the issue still persists.
|
||||
required: true
|
||||
@@ -7,7 +7,7 @@ on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# Only run on PRs if the source branch is on a different repo. We do not need run everything twice.
|
||||
# Only run on PRs if the source branch is on a different repo. We do not need to run everything twice.
|
||||
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
@@ -18,7 +18,7 @@ jobs:
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
distribution: 'temurin'
|
||||
java-version: 11
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
|
||||
+4
-5
@@ -18,6 +18,8 @@ hs_err_pid*
|
||||
|
||||
# Ignore IDEA directory
|
||||
.idea/*
|
||||
!.idea/copyright/*
|
||||
!.idea/scopes/*
|
||||
|
||||
# Include the project's dictionary
|
||||
!.idea/dictionaries/
|
||||
@@ -106,8 +108,5 @@ nbactions.xml
|
||||
nb-configuration.xml
|
||||
.nb-gradle/
|
||||
|
||||
|
||||
|
||||
### Git ###
|
||||
# Don't exclude the .gitignore itself
|
||||
!.gitignore
|
||||
### MacOS ###
|
||||
.DS_Store
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
<component name="CopyrightManager">
|
||||
<settings>
|
||||
<module2copyright>
|
||||
<element module="ViaVersion-API" copyright="viaversion-mit" />
|
||||
<element module="ViaVersion" copyright="viaversion-gpl" />
|
||||
</module2copyright>
|
||||
<LanguageOptions name="__TEMPLATE__">
|
||||
<option name="addBlankAfter" value="false" />
|
||||
</LanguageOptions>
|
||||
</settings>
|
||||
</component>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion Copyright (C) 2016-2022 ViaVersion and contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>." />
|
||||
<option name="myName" value="viaversion-gpl" />
|
||||
</copyright>
|
||||
</component>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion Copyright (C) 2016-2022 ViaVersion and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." />
|
||||
<option name="myName" value="viaversion-mit" />
|
||||
</copyright>
|
||||
</component>
|
||||
Generated
+3
@@ -0,0 +1,3 @@
|
||||
<component name="DependencyValidationManager">
|
||||
<scope name="ViaVersion" pattern="com.viaversion.viaversion..*&&!src[viaversion-parent.viaversion-api*]:*..*" />
|
||||
</component>
|
||||
Generated
+3
@@ -0,0 +1,3 @@
|
||||
<component name="DependencyValidationManager">
|
||||
<scope name="ViaVersion-API" pattern="src[viaversion-parent.viaversion-api*]:*..*&&!src[viaversion-parent.viaversion-api.main]:com.viaversion.viaversion.api.minecraft.nbt.*" />
|
||||
</component>
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
Supported Versions:
|
||||
|
||||

|
||||

|
||||
|
||||
On Paper you may also use ProtocolSupport, but ensure you have the right build for your server version.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -79,6 +79,11 @@ public class ProtocolVersion {
|
||||
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 unknown = register(-1, "UNKNOWN");
|
||||
|
||||
public static ProtocolVersion register(int version, String name) {
|
||||
@@ -165,12 +170,12 @@ public class ProtocolVersion {
|
||||
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.getRangeFrom(); i <= versionRange.getRangeTo(); i++) {
|
||||
for (int i = versionRange.rangeFrom(); i <= versionRange.rangeTo(); i++) {
|
||||
if (i == 0) {
|
||||
includedVersions.add(versionRange.getBaseVersion()); // Keep both the base version and with ".0" appended
|
||||
includedVersions.add(versionRange.baseVersion()); // Keep both the base version and with ".0" appended
|
||||
}
|
||||
|
||||
includedVersions.add(versionRange.getBaseVersion() + "." + i);
|
||||
includedVersions.add(versionRange.baseVersion() + "." + i);
|
||||
}
|
||||
} else {
|
||||
includedVersions = Collections.singleton(name);
|
||||
|
||||
@@ -13,6 +13,8 @@ dependencies {
|
||||
targetConfiguration = "shadow"
|
||||
}
|
||||
api(libs.fastutil)
|
||||
api(libs.flare)
|
||||
api(libs.flareFastutil)
|
||||
api(libs.openNBT)
|
||||
api(libs.gson)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -46,13 +46,25 @@ import java.util.UUID;
|
||||
public interface ViaAPI<T> {
|
||||
|
||||
/**
|
||||
* Returns the API version incremented with meaningful API changes.
|
||||
* Returns the <b>major version</b> matching {@link #getVersion()}.
|
||||
* It is highly advised to check against the major version and to disable/not initiate
|
||||
* any hooks into ViaVersion if given and expected versions do not match.
|
||||
*
|
||||
* @return major plugin version
|
||||
* @since 4.0.2
|
||||
*/
|
||||
default int majorVersion() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an <b>internally based API version</b> incremented with meaningful API changes.
|
||||
* This includes breaking changes to existing API and larger additions.
|
||||
*
|
||||
* @return API version incremented with meaningful API changes
|
||||
*/
|
||||
default int apiVersion() {
|
||||
return 3;
|
||||
return 12;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,6 +24,7 @@ package com.viaversion.viaversion.api;
|
||||
|
||||
import com.viaversion.viaversion.api.command.ViaVersionCommand;
|
||||
import com.viaversion.viaversion.api.connection.ConnectionManager;
|
||||
import com.viaversion.viaversion.api.debug.DebugHandler;
|
||||
import com.viaversion.viaversion.api.platform.ViaInjector;
|
||||
import com.viaversion.viaversion.api.platform.ViaPlatform;
|
||||
import com.viaversion.viaversion.api.platform.ViaPlatformLoader;
|
||||
@@ -88,14 +89,27 @@ public interface ViaManager {
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean isDebug();
|
||||
@Deprecated
|
||||
default boolean isDebug() {
|
||||
return debugHandler().enabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the debug mode. If enabled, packets and other otherwise suppressed warnings will be logged.
|
||||
*
|
||||
* @param debug whether debug should be enabled
|
||||
*/
|
||||
void setDebug(boolean debug);
|
||||
@Deprecated
|
||||
default void setDebug(boolean debug) {
|
||||
debugHandler().setEnabled(debug);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the debug handler.
|
||||
*
|
||||
* @return debug handler
|
||||
*/
|
||||
DebugHandler debugHandler();
|
||||
|
||||
/**
|
||||
* Returns a mutable set of self-added subplatform version strings.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+43
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,6 +22,11 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.configuration;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
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;
|
||||
|
||||
public interface ViaVersionConfig {
|
||||
@@ -229,6 +234,13 @@ public interface ViaVersionConfig {
|
||||
*/
|
||||
int getPistonReplacementId();
|
||||
|
||||
/**
|
||||
* Fix 1.9+ clients not rendering the far away chunks
|
||||
*
|
||||
* @return true to fix chunk borders
|
||||
*/
|
||||
boolean isChunkBorderFix();
|
||||
|
||||
/**
|
||||
* Force json transform
|
||||
*
|
||||
@@ -257,12 +269,23 @@ public interface ViaVersionConfig {
|
||||
*/
|
||||
boolean is1_12QuickMoveActionFix();
|
||||
|
||||
/**
|
||||
* API to check for blocked protocol versions.
|
||||
*
|
||||
* @return blocked protocol versions
|
||||
*/
|
||||
BlockedProtocolVersions blockedProtocolVersions();
|
||||
|
||||
/**
|
||||
* Get the blocked protocols
|
||||
*
|
||||
* @return An Integer list
|
||||
* @deprecated use {@link #blockedProtocolVersions()}
|
||||
*/
|
||||
IntSet getBlockedProtocols();
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default IntSet getBlockedProtocols() {
|
||||
return blockedProtocolVersions().singleBlockedVersions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the custom disconnect message
|
||||
@@ -414,4 +437,22 @@ public interface ViaVersionConfig {
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean isForcedUse1_17ResourcePack();
|
||||
|
||||
/**
|
||||
* Get the message that is sent when a user displays a resource pack prompt.
|
||||
*
|
||||
* @return cached serialized component
|
||||
*/
|
||||
JsonElement get1_17ResourcePackPrompt();
|
||||
|
||||
/***
|
||||
* Get the world names that should be returned for each Vanilla dimension.
|
||||
* Note that this can be overriden per-user by using {@link UserConnection#put(StorableObject)} with
|
||||
* a custom instance of {@link WorldIdentifiers} for the user's {@link UserConnection}.
|
||||
*
|
||||
* @return the global map from vanilla dimensions to world name
|
||||
*/
|
||||
WorldIdentifiers get1_16WorldNamesMap();
|
||||
|
||||
boolean cache1_17Light();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,4 +29,13 @@ package com.viaversion.viaversion.api.connection;
|
||||
* @see UserConnection#put(StorableObject)
|
||||
*/
|
||||
public interface StorableObject {
|
||||
|
||||
/**
|
||||
* Returns whether the object should be uncached on a server switch.
|
||||
*
|
||||
* @return whether the object should be uncached on a server switch
|
||||
*/
|
||||
default boolean clearOnServerSwitch() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -58,6 +58,15 @@ public interface UserConnection {
|
||||
*/
|
||||
boolean has(Class<? extends StorableObject> objectClass);
|
||||
|
||||
/**
|
||||
* Removes and returns an object from the storage.
|
||||
*
|
||||
* @param objectClass class of the object to get
|
||||
* @param <T> type of the class you want to get
|
||||
* @return removed storable object if present
|
||||
*/
|
||||
@Nullable <T extends StorableObject> T remove(Class<T> objectClass);
|
||||
|
||||
/**
|
||||
* Put an object into the stored objects based on class.
|
||||
*
|
||||
@@ -83,6 +92,7 @@ public interface UserConnection {
|
||||
|
||||
/**
|
||||
* Adds an entity tracker to the user connection.
|
||||
* Does not override existing entity trackers.
|
||||
*
|
||||
* @param protocolClass protocol class
|
||||
* @param tracker entity tracker
|
||||
@@ -90,10 +100,19 @@ public interface UserConnection {
|
||||
void addEntityTracker(Class<? extends Protocol> protocolClass, EntityTracker tracker);
|
||||
|
||||
/**
|
||||
* Clear all the stored objects.
|
||||
* Used for bungee when switching servers.
|
||||
* Clear stored objects and entity trackers.
|
||||
*/
|
||||
void clearStoredObjects();
|
||||
default void clearStoredObjects() {
|
||||
clearStoredObjects(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear stored objects and entity trackers.
|
||||
* If cleared for a proxy server switch, some stored objects and tracker data will be retained.
|
||||
*
|
||||
* @param isServerSwitch whether the clear is due to a server switch
|
||||
*/
|
||||
void clearStoredObjects(boolean isServerSwitch);
|
||||
|
||||
/**
|
||||
* Sends a raw packet to the connection on the current thread.
|
||||
@@ -291,12 +310,26 @@ public interface UserConnection {
|
||||
boolean isClientSide();
|
||||
|
||||
/**
|
||||
* Returns whether {@link ViaVersionConfig#getBlockedProtocols()} should be checked for this connection.
|
||||
* Returns whether {@link ViaVersionConfig#blockedProtocolVersions()} should be checked for this connection.
|
||||
*
|
||||
* @return whether blocked protocols should be applied
|
||||
*/
|
||||
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}.
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Mappings containing the full string identifier mappings.
|
||||
*/
|
||||
public interface FullMappings {
|
||||
|
||||
Mappings mappings();
|
||||
|
||||
/**
|
||||
* Returns the unmapped integer id for the given identifier, or -1 if not found.
|
||||
*
|
||||
* @param identifier unmapped string identifier
|
||||
* @return unmapped int id, or -1 if not found
|
||||
*/
|
||||
int id(String identifier);
|
||||
|
||||
/**
|
||||
* Returns the mapped integer id for the given mapped identifier, or -1 if not found.
|
||||
*
|
||||
* @param mappedIdentifier mapped string identifier
|
||||
* @return mapped int id, or -1 if not found
|
||||
*/
|
||||
int mappedId(String mappedIdentifier);
|
||||
|
||||
/**
|
||||
* Returns the unmapped string identifier for the given mapped id.
|
||||
*
|
||||
* @param id unmapped id
|
||||
* @return unmapped string identifier
|
||||
*/
|
||||
String identifier(int id);
|
||||
|
||||
/**
|
||||
* Returns the mapped string identifier for the given mapped id.
|
||||
*
|
||||
* @param mappedId mapped id
|
||||
* @return mapped string identifier
|
||||
*/
|
||||
String mappedIdentifier(int mappedId);
|
||||
|
||||
/**
|
||||
* Returns the mapped string identifier for the given unmapped identifier.
|
||||
*
|
||||
* @param identifier unmapped identifier
|
||||
* @return mapped string identifier, or null if not found
|
||||
*/
|
||||
@Nullable String mappedIdentifier(String identifier);
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class FullMappingsBase implements FullMappings {
|
||||
private final Object2IntMap<String> stringToId;
|
||||
private final Object2IntMap<String> mappedStringToId;
|
||||
private final String[] idToString;
|
||||
private final String[] mappedIdToString;
|
||||
private final Mappings mappings;
|
||||
|
||||
public FullMappingsBase(final JsonArray oldMappings, final JsonArray newMappings, final Mappings mappings) {
|
||||
this.mappings = mappings;
|
||||
stringToId = MappingDataLoader.arrayToMap(oldMappings);
|
||||
mappedStringToId = MappingDataLoader.arrayToMap(newMappings);
|
||||
stringToId.defaultReturnValue(-1);
|
||||
mappedStringToId.defaultReturnValue(-1);
|
||||
|
||||
idToString = new String[oldMappings.size()];
|
||||
for (int i = 0; i < oldMappings.size(); i++) {
|
||||
idToString[i] = oldMappings.get(i).getAsString();
|
||||
}
|
||||
|
||||
mappedIdToString = new String[newMappings.size()];
|
||||
for (int i = 0; i < newMappings.size(); i++) {
|
||||
mappedIdToString[i] = newMappings.get(i).getAsString();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mappings mappings() {
|
||||
return mappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id(final String identifier) {
|
||||
return stringToId.getInt(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mappedId(final String mappedIdentifier) {
|
||||
return mappedStringToId.getInt(mappedIdentifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier(final int id) {
|
||||
return idToString[id];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String mappedIdentifier(final int mappedId) {
|
||||
return mappedIdToString[mappedId];
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String mappedIdentifier(final String identifier) {
|
||||
final int id = id(identifier);
|
||||
if (id == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final int mappedId = mappings.getNewId(id);
|
||||
return mappedId != -1 ? mappedIdentifier(mappedId) : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
|
||||
public class Int2IntMapMappings implements Mappings {
|
||||
private final Int2IntMap mappings;
|
||||
private final int mappedIds;
|
||||
|
||||
protected Int2IntMapMappings(final Int2IntMap mappings, final int mappedIds) {
|
||||
this.mappings = mappings;
|
||||
this.mappedIds = mappedIds;
|
||||
mappings.defaultReturnValue(-1);
|
||||
}
|
||||
|
||||
public static Int2IntMapMappings of(final Int2IntMap mappings, final int mappedIds) {
|
||||
return new Int2IntMapMappings(mappings, mappedIds);
|
||||
}
|
||||
|
||||
public static Int2IntMapMappings of() {
|
||||
|
||||
return new Int2IntMapMappings(new Int2IntOpenHashMap(), -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewId(final int id) {
|
||||
return mappings.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNewId(final int id, final int newId) {
|
||||
mappings.put(id, newId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return mappings.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mappedSize() {
|
||||
return mappedIds;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,79 +29,82 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class IntArrayMappings implements Mappings {
|
||||
protected final int[] oldToNew;
|
||||
private final int[] oldToNew;
|
||||
private final int mappedIds;
|
||||
|
||||
public IntArrayMappings(int[] oldToNew) {
|
||||
protected IntArrayMappings(final int[] oldToNew, final int mappedIds) {
|
||||
this.oldToNew = oldToNew;
|
||||
this.mappedIds = mappedIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps old identifiers to the new ones.
|
||||
* If an old value cannot be found in the new mappings, the diffmapping will be checked for the given entry.
|
||||
*
|
||||
* @param size set size of the underlying short array
|
||||
* @param oldMapping mappings to map from
|
||||
* @param newMapping mappings to map to
|
||||
* @param diffMapping extra mappings that will be used/scanned when an entry cannot be found
|
||||
*/
|
||||
public static IntArrayMappings of(final int[] oldToNew, final int mappedIds) {
|
||||
return new IntArrayMappings(oldToNew, mappedIds);
|
||||
}
|
||||
|
||||
public static Builder<IntArrayMappings> builder() {
|
||||
return Mappings.builder(IntArrayMappings::new);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(int[] oldToNew) {
|
||||
this(oldToNew, -1);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(int size, JsonObject oldMapping, JsonObject newMapping, @Nullable JsonObject diffMapping) {
|
||||
oldToNew = new int[size];
|
||||
Arrays.fill(oldToNew, -1);
|
||||
this.mappedIds = newMapping.size();
|
||||
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(JsonObject oldMapping, JsonObject newMapping, @Nullable JsonObject diffMapping) {
|
||||
this(oldMapping.entrySet().size(), oldMapping, newMapping, diffMapping);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps old identifiers to the new ones.
|
||||
*
|
||||
* @param size set size of the underlying short array
|
||||
* @param oldMapping mappings to map from
|
||||
* @param newMapping mappings to map to
|
||||
*/
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(int size, JsonObject oldMapping, JsonObject newMapping) {
|
||||
oldToNew = new int[size];
|
||||
Arrays.fill(oldToNew, -1);
|
||||
mappedIds = -1;
|
||||
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(JsonObject oldMapping, JsonObject newMapping) {
|
||||
this(oldMapping.entrySet().size(), oldMapping, newMapping);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps old identifiers to the new ones.
|
||||
*
|
||||
* @param size set size of the underlying short array
|
||||
* @param oldMapping mappings to map from
|
||||
* @param newMapping mappings to map to
|
||||
* @param diffMapping extra mappings that will be used/scanned when an entry cannot be found
|
||||
* @param warnOnMissing should "No key for x" be printed if there is no matching identifier
|
||||
*/
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(int size, JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping, boolean warnOnMissing) {
|
||||
oldToNew = new int[size];
|
||||
Arrays.fill(oldToNew, -1);
|
||||
mappedIds = -1;
|
||||
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping, warnOnMissing);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(int size, JsonArray oldMapping, JsonArray newMapping, boolean warnOnMissing) {
|
||||
this(size, oldMapping, newMapping, null, warnOnMissing);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(JsonArray oldMapping, JsonArray newMapping, boolean warnOnMissing) {
|
||||
this(oldMapping.size(), oldMapping, newMapping, warnOnMissing);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(int size, JsonArray oldMapping, JsonArray newMapping) {
|
||||
this(size, oldMapping, newMapping, true);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping) {
|
||||
this(oldMapping.size(), oldMapping, newMapping, diffMapping, true);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public IntArrayMappings(JsonArray oldMapping, JsonArray newMapping) {
|
||||
this(oldMapping.size(), oldMapping, newMapping, true);
|
||||
}
|
||||
@@ -116,6 +119,16 @@ public class IntArrayMappings implements Mappings {
|
||||
oldToNew[id] = newId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return oldToNew.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mappedSize() {
|
||||
return mappedIds;
|
||||
}
|
||||
|
||||
public int[] getOldToNew() {
|
||||
return oldToNew;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -95,9 +95,19 @@ public interface MappingData {
|
||||
|
||||
@Nullable Mappings getBlockMappings();
|
||||
|
||||
@Nullable Mappings getBlockEntityMappings();
|
||||
|
||||
@Nullable Mappings getBlockStateMappings();
|
||||
|
||||
@Nullable Mappings getSoundMappings();
|
||||
|
||||
@Nullable Mappings getStatisticsMappings();
|
||||
|
||||
@Nullable Mappings getEnchantmentMappings();
|
||||
|
||||
@Nullable FullMappings getEntityMappings();
|
||||
|
||||
@Nullable FullMappings getArgumentTypeMappings();
|
||||
|
||||
@Nullable Mappings getPaintingMappings();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -44,11 +44,16 @@ public class MappingDataBase implements MappingData {
|
||||
protected final String newVersion;
|
||||
protected final boolean hasDiffFile;
|
||||
protected Int2IntBiMap itemMappings;
|
||||
protected FullMappings argumentTypeMappings;
|
||||
protected FullMappings entityMappings;
|
||||
protected ParticleMappings particleMappings;
|
||||
protected Mappings blockMappings;
|
||||
protected Mappings blockStateMappings;
|
||||
protected Mappings blockEntityMappings;
|
||||
protected Mappings soundMappings;
|
||||
protected Mappings statisticsMappings;
|
||||
protected Mappings enchantmentMappings;
|
||||
protected Mappings paintingMappings;
|
||||
protected Map<RegistryType, List<TagData>> tags;
|
||||
protected boolean loadItems = true;
|
||||
|
||||
@@ -71,28 +76,34 @@ public class MappingDataBase implements MappingData {
|
||||
|
||||
blockMappings = loadFromObject(oldMappings, newMappings, diffmapping, "blocks");
|
||||
blockStateMappings = loadFromObject(oldMappings, newMappings, diffmapping, "blockstates");
|
||||
blockEntityMappings = loadFromArray(oldMappings, newMappings, diffmapping, "blockentities");
|
||||
soundMappings = loadFromArray(oldMappings, newMappings, diffmapping, "sounds");
|
||||
statisticsMappings = loadFromArray(oldMappings, newMappings, diffmapping, "statistics");
|
||||
enchantmentMappings = loadFromArray(oldMappings, newMappings, diffmapping, "enchantments");
|
||||
paintingMappings = loadFromArray(oldMappings, newMappings, diffmapping, "paintings");
|
||||
|
||||
entityMappings = loadFullMappings(oldMappings, newMappings, diffmapping, "entities");
|
||||
argumentTypeMappings = loadFullMappings(oldMappings, newMappings, diffmapping, "argumenttypes");
|
||||
|
||||
Mappings particles = loadFromArray(oldMappings, newMappings, diffmapping, "particles");
|
||||
if (particles != null) {
|
||||
particleMappings = new ParticleMappings(oldMappings.getAsJsonArray("particles"), particles);
|
||||
particleMappings = new ParticleMappings(oldMappings.getAsJsonArray("particles"), newMappings.getAsJsonArray("particles"), particles);
|
||||
}
|
||||
|
||||
if (loadItems && newMappings.has("items")) {
|
||||
itemMappings = new Int2IntBiHashMap();
|
||||
itemMappings.defaultReturnValue(-1);
|
||||
MappingDataLoader.mapIdentifiers(itemMappings, oldMappings.getAsJsonObject("items"), newMappings.getAsJsonObject("items"),
|
||||
diffmapping != null ? diffmapping.getAsJsonObject("items") : null);
|
||||
diffmapping != null ? diffmapping.getAsJsonObject("items") : null, true);
|
||||
}
|
||||
|
||||
if (diffmapping != null && diffmapping.has("tags")) {
|
||||
this.tags = new EnumMap<>(RegistryType.class);
|
||||
JsonObject tags = diffmapping.getAsJsonObject("tags");
|
||||
if (tags.has(RegistryType.ITEM.getResourceLocation())) {
|
||||
if (tags.has(RegistryType.ITEM.resourceLocation())) {
|
||||
loadTags(RegistryType.ITEM, tags, MappingDataLoader.indexedObjectToMap(newMappings.getAsJsonObject("items")));
|
||||
}
|
||||
if (tags.has(RegistryType.BLOCK.getResourceLocation())) {
|
||||
if (tags.has(RegistryType.BLOCK.resourceLocation())) {
|
||||
loadTags(RegistryType.BLOCK, tags, MappingDataLoader.indexedObjectToMap(newMappings.getAsJsonObject("blocks")));
|
||||
}
|
||||
}
|
||||
@@ -100,8 +111,13 @@ public class MappingDataBase implements MappingData {
|
||||
loadExtras(oldMappings, newMappings, diffmapping);
|
||||
}
|
||||
|
||||
protected FullMappings loadFullMappings(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
|
||||
Mappings mappings = loadFromArray(oldMappings, newMappings, diffMappings, key);
|
||||
return mappings != null ? new FullMappingsBase(oldMappings.getAsJsonArray(key), newMappings.getAsJsonArray(key), mappings) : null;
|
||||
}
|
||||
|
||||
private void loadTags(RegistryType type, JsonObject object, Object2IntMap<String> typeMapping) {
|
||||
JsonObject tags = object.getAsJsonObject(type.getResourceLocation());
|
||||
JsonObject tags = object.getAsJsonObject(type.resourceLocation());
|
||||
List<TagData> tagsList = new ArrayList<>(tags.size());
|
||||
for (Map.Entry<String, JsonElement> entry : tags.entrySet()) {
|
||||
JsonArray array = entry.getValue().getAsJsonArray();
|
||||
@@ -146,7 +162,7 @@ public class MappingDataBase implements MappingData {
|
||||
|
||||
@Override
|
||||
public int getNewParticleId(int id) {
|
||||
return checkValidity(id, particleMappings.getMappings().getNewId(id), "particles");
|
||||
return checkValidity(id, particleMappings.mappings().getNewId(id), "particles");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -169,6 +185,11 @@ public class MappingDataBase implements MappingData {
|
||||
return blockMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Mappings getBlockEntityMappings() {
|
||||
return blockEntityMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Mappings getBlockStateMappings() {
|
||||
return blockStateMappings;
|
||||
@@ -184,18 +205,40 @@ public class MappingDataBase implements MappingData {
|
||||
return statisticsMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Mappings getEnchantmentMappings() {
|
||||
return enchantmentMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FullMappings getEntityMappings() {
|
||||
return entityMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FullMappings getArgumentTypeMappings() {
|
||||
return argumentTypeMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Mappings getPaintingMappings() {
|
||||
return paintingMappings;
|
||||
}
|
||||
|
||||
protected @Nullable Mappings loadFromArray(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
|
||||
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
|
||||
|
||||
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
|
||||
return new IntArrayMappings(oldMappings.getAsJsonArray(key), newMappings.getAsJsonArray(key), diff);
|
||||
return IntArrayMappings.builder().unmapped(oldMappings.getAsJsonArray(key))
|
||||
.mapped(newMappings.getAsJsonArray(key)).diffMappings(diff).build();
|
||||
}
|
||||
|
||||
protected @Nullable Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
|
||||
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
|
||||
|
||||
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
|
||||
return new IntArrayMappings(oldMappings.getAsJsonObject(key), newMappings.getAsJsonObject(key), diff);
|
||||
return IntArrayMappings.builder().unmapped(oldMappings.getAsJsonObject(key))
|
||||
.mapped(newMappings.getAsJsonObject(key)).diffMappings(diff).build();
|
||||
}
|
||||
|
||||
protected @Nullable JsonObject loadDiffFile() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -135,31 +135,36 @@ public class MappingDataLoader {
|
||||
}
|
||||
}
|
||||
|
||||
public static void mapIdentifiers(Int2IntBiMap output, JsonObject oldIdentifiers, JsonObject newIdentifiers, @Nullable JsonObject diffIdentifiers) {
|
||||
public static void mapIdentifiers(Int2IntBiMap output, JsonObject oldIdentifiers, JsonObject newIdentifiers, @Nullable JsonObject diffIdentifiers, boolean warnOnMissing) {
|
||||
Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(newIdentifiers);
|
||||
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
|
||||
int value = mapIdentifierEntry(entry, newIdentifierMap, diffIdentifiers);
|
||||
int value = mapIdentifierEntry(entry, newIdentifierMap, diffIdentifiers, warnOnMissing);
|
||||
if (value != -1) {
|
||||
output.put(Integer.parseInt(entry.getKey()), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
|
||||
MappingDataLoader.mapIdentifiers(output, oldIdentifiers, newIdentifiers, null);
|
||||
mapIdentifiers(output, oldIdentifiers, newIdentifiers, null);
|
||||
}
|
||||
|
||||
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, @Nullable JsonObject diffIdentifiers) {
|
||||
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, @Nullable JsonObject diffIdentifiers, boolean warnOnMissing) {
|
||||
Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(newIdentifiers);
|
||||
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
|
||||
int value = mapIdentifierEntry(entry, newIdentifierMap, diffIdentifiers);
|
||||
int value = mapIdentifierEntry(entry, newIdentifierMap, diffIdentifiers, warnOnMissing);
|
||||
if (value != -1) {
|
||||
output[Integer.parseInt(entry.getKey())] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int mapIdentifierEntry(Map.Entry<String, JsonElement> entry, Object2IntMap newIdentifierMap, @Nullable JsonObject diffIdentifiers) {
|
||||
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, @Nullable JsonObject diffIdentifiers) {
|
||||
mapIdentifiers(output, oldIdentifiers, newIdentifiers, diffIdentifiers, true);
|
||||
}
|
||||
|
||||
private static int mapIdentifierEntry(Map.Entry<String, JsonElement> entry, Object2IntMap<String> newIdentifierMap, @Nullable JsonObject diffIdentifiers, boolean warnOnMissing) {
|
||||
int value = newIdentifierMap.getInt(entry.getValue().getAsString());
|
||||
if (value == -1) {
|
||||
// Search in diff mappings
|
||||
@@ -170,7 +175,7 @@ public class MappingDataLoader {
|
||||
}
|
||||
}
|
||||
if (value == -1) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
if (warnOnMissing && !Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
|
||||
}
|
||||
return -1;
|
||||
@@ -179,6 +184,7 @@ public class MappingDataLoader {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public static void mapIdentifiers(int[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, boolean warnOnMissing) {
|
||||
mapIdentifiers(output, oldIdentifiers, newIdentifiers, null, warnOnMissing);
|
||||
}
|
||||
@@ -217,7 +223,7 @@ public class MappingDataLoader {
|
||||
* @return map with indexes hashed by their id value
|
||||
*/
|
||||
public static Object2IntMap<String> indexedObjectToMap(JsonObject object) {
|
||||
Object2IntMap<String> map = new Object2IntOpenHashMap<>(object.size(), 1F);
|
||||
Object2IntMap<String> map = new Object2IntOpenHashMap<>(object.size(), .99F);
|
||||
map.defaultReturnValue(-1);
|
||||
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
map.put(entry.getValue().getAsString(), Integer.parseInt(entry.getKey()));
|
||||
@@ -232,7 +238,7 @@ public class MappingDataLoader {
|
||||
* @return map with indexes hashed by their id value
|
||||
*/
|
||||
public static Object2IntMap<String> arrayToMap(JsonArray array) {
|
||||
Object2IntMap<String> map = new Object2IntOpenHashMap<>(array.size(), 1F);
|
||||
Object2IntMap<String> map = new Object2IntOpenHashMap<>(array.size(), .99F);
|
||||
map.defaultReturnValue(-1);
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
map.put(array.get(i).getAsString(), i);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,6 +22,12 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public interface Mappings {
|
||||
|
||||
/**
|
||||
@@ -32,6 +38,28 @@ public interface Mappings {
|
||||
*/
|
||||
int getNewId(int id);
|
||||
|
||||
/**
|
||||
* Returns the mapped id from the given id, or the given default if unmapped/invalid.
|
||||
*
|
||||
* @param id unmapped id
|
||||
* @param def fallback return value
|
||||
* @return mapped id, or -1 if invalid/out of bounds
|
||||
*/
|
||||
default int getNewIdOrDefault(int id, int def) {
|
||||
final int mappedId = getNewId(id);
|
||||
return mappedId != -1 ? mappedId : def;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the id has a mapping.
|
||||
*
|
||||
* @param id unmapped id
|
||||
* @return whether the id has a mapped id
|
||||
*/
|
||||
default boolean contains(int id) {
|
||||
return getNewId(id) != -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually maps a specific id.
|
||||
*
|
||||
@@ -40,4 +68,137 @@ public interface Mappings {
|
||||
* @throws IndexOutOfBoundsException if the unmapped id is invalid
|
||||
*/
|
||||
void setNewId(int id, int newId);
|
||||
|
||||
/**
|
||||
* Returns amount of unmapped entries, being the size of the mapping.
|
||||
*
|
||||
* @return amount of unmapped entries
|
||||
*/
|
||||
int size();
|
||||
|
||||
/**
|
||||
* Returns the amount of new ids total, even if it does not have a direct mapping.
|
||||
* Returns -1 if unknown.
|
||||
*
|
||||
* @return amount of new ids, or -1 if unknown
|
||||
*/
|
||||
int mappedSize();
|
||||
|
||||
static <T extends Mappings> Builder<T> builder(final MappingsSupplier<T> supplier) {
|
||||
return new Builder(supplier);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
interface MappingsSupplier<T extends Mappings> {
|
||||
|
||||
T supply(int[] mappings, int mappedIds);
|
||||
}
|
||||
|
||||
class Builder<T extends Mappings> {
|
||||
|
||||
protected final MappingsSupplier<T> supplier;
|
||||
protected JsonElement unmapped;
|
||||
protected JsonElement mapped;
|
||||
protected JsonObject diffMappings;
|
||||
protected int mappedSize = -1;
|
||||
protected int size = -1;
|
||||
protected boolean warnOnMissing = true;
|
||||
|
||||
protected Builder(final MappingsSupplier<T> supplier) {
|
||||
this.supplier = supplier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a custom entry size different to the size of the unmapped collection.
|
||||
*
|
||||
* @param size custom entry size
|
||||
* @return self
|
||||
*/
|
||||
public Builder<T> customEntrySize(final int size) {
|
||||
this.size = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a custom entry mapped ids count different to the size of the mapped collection.
|
||||
*
|
||||
* @param size custom mapped id count
|
||||
* @return self
|
||||
*/
|
||||
public Builder<T> customMappedSize(final int size) {
|
||||
this.mappedSize = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether warnings should be logged for missing mapped ids.
|
||||
*
|
||||
* @param warnOnMissing whether warnings should be logged for missing mapped ids
|
||||
* @return self
|
||||
*/
|
||||
public Builder<T> warnOnMissing(final boolean warnOnMissing) {
|
||||
this.warnOnMissing = warnOnMissing;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<T> unmapped(final JsonArray unmappedArray) {
|
||||
this.unmapped = unmappedArray;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<T> unmapped(final JsonObject unmappedObject) {
|
||||
this.unmapped = unmappedObject;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<T> mapped(final JsonArray mappedArray) {
|
||||
this.mapped = mappedArray;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<T> mapped(final JsonObject mappedObject) {
|
||||
this.mapped = mappedObject;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<T> diffMappings(final JsonObject diffMappings) {
|
||||
this.diffMappings = diffMappings;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T build() {
|
||||
final int size = this.size != -1 ? this.size : size(unmapped);
|
||||
final int mappedSize = this.mappedSize != -1 ? this.mappedSize : size(mapped);
|
||||
final int[] mappings = new int[size];
|
||||
Arrays.fill(mappings, -1);
|
||||
|
||||
// Do conversion if one is an array and the other an object, otherwise directly map
|
||||
if (unmapped.isJsonArray()) {
|
||||
if (mapped.isJsonObject()) {
|
||||
MappingDataLoader.mapIdentifiers(mappings, toJsonObject(unmapped.getAsJsonArray()), mapped.getAsJsonObject(), diffMappings, warnOnMissing);
|
||||
} else {
|
||||
MappingDataLoader.mapIdentifiers(mappings, unmapped.getAsJsonArray(), mapped.getAsJsonArray(), diffMappings, warnOnMissing);
|
||||
}
|
||||
} else if (mapped.isJsonArray()) {
|
||||
MappingDataLoader.mapIdentifiers(mappings, unmapped.getAsJsonObject(), toJsonObject(mapped.getAsJsonArray()), diffMappings, warnOnMissing);
|
||||
} else {
|
||||
MappingDataLoader.mapIdentifiers(mappings, unmapped.getAsJsonObject(), mapped.getAsJsonObject(), diffMappings, warnOnMissing);
|
||||
}
|
||||
|
||||
return supplier.supply(mappings, mappedSize);
|
||||
}
|
||||
|
||||
protected int size(final JsonElement element) {
|
||||
return element.isJsonObject() ? element.getAsJsonObject().size() : element.getAsJsonArray().size();
|
||||
}
|
||||
|
||||
protected JsonObject toJsonObject(final JsonArray array) {
|
||||
final JsonObject object = new JsonObject();
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
final JsonElement element = array.get(i);
|
||||
object.add(Integer.toString(i), element);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,36 +23,51 @@
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
|
||||
public class ParticleMappings {
|
||||
private final Mappings mappings;
|
||||
private final int blockId;
|
||||
private final int fallingDustId;
|
||||
private final int itemId;
|
||||
public class ParticleMappings extends FullMappingsBase {
|
||||
private final IntList itemParticleIds = new IntArrayList(2);
|
||||
private final IntList blockParticleIds = new IntArrayList(4);
|
||||
|
||||
public ParticleMappings(JsonArray oldMappings, Mappings mappings) {
|
||||
this.mappings = mappings;
|
||||
|
||||
Object2IntMap<String> map = MappingDataLoader.arrayToMap(oldMappings);
|
||||
blockId = map.getInt("block");
|
||||
fallingDustId = map.getInt("falling_dust");
|
||||
itemId = map.getInt("item");
|
||||
public ParticleMappings(JsonArray oldMappings, JsonArray newMappings, Mappings mappings) {
|
||||
super(oldMappings, newMappings, mappings);
|
||||
addBlockParticle("block");
|
||||
addBlockParticle("falling_dust");
|
||||
addBlockParticle("block_marker");
|
||||
addItemParticle("item");
|
||||
}
|
||||
|
||||
public Mappings getMappings() {
|
||||
return mappings;
|
||||
public boolean addItemParticle(final String identifier) {
|
||||
final int id = id(identifier);
|
||||
return id != -1 && itemParticleIds.add(id);
|
||||
}
|
||||
|
||||
public boolean addBlockParticle(final String identifier) {
|
||||
final int id = id(identifier);
|
||||
return id != -1 && blockParticleIds.add(id);
|
||||
}
|
||||
|
||||
public boolean isBlockParticle(final int id) {
|
||||
return blockParticleIds.contains(id);
|
||||
}
|
||||
|
||||
public boolean isItemParticle(final int id) {
|
||||
return itemParticleIds.contains(id);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public int getBlockId() {
|
||||
return blockId;
|
||||
return id("block");
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public int getFallingDustId() {
|
||||
return fallingDustId;
|
||||
return id("falling_dust");
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public int getItemId() {
|
||||
return itemId;
|
||||
return id("item");
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+6
-10
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,15 +20,11 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.type.types.version;
|
||||
package com.viaversion.viaversion.api.data.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.minecraft.ModernMetaListType;
|
||||
public interface DimensionData {
|
||||
|
||||
public class MetadataList1_14Type extends ModernMetaListType {
|
||||
@Override
|
||||
protected Type<Metadata> getType() {
|
||||
return Types1_14.METADATA;
|
||||
}
|
||||
int minY();
|
||||
|
||||
int height();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,6 +26,8 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface EntityTracker {
|
||||
|
||||
/**
|
||||
@@ -67,12 +69,18 @@ public interface EntityTracker {
|
||||
*/
|
||||
void removeEntity(int id);
|
||||
|
||||
/**
|
||||
* Clears stored entity types and data.
|
||||
*/
|
||||
void clearEntities();
|
||||
|
||||
/**
|
||||
* Returns the stored entity data if an entity with the id is tracked, else null.
|
||||
* If no data has been initialized yet, it will be done and returned by this method.
|
||||
*
|
||||
* @param id entity id
|
||||
* @return stored entity data if an entity with the id is tracked, else null
|
||||
* @throws IllegalArgumentException if entitiy data storage has not been enabled via the implementation
|
||||
*/
|
||||
@Nullable StoredEntityData entityData(int id);
|
||||
|
||||
@@ -81,6 +89,7 @@ public interface EntityTracker {
|
||||
*
|
||||
* @param id entity id
|
||||
* @return stored entity data if it has previously been initialized by {@link #entityData(int)}
|
||||
* @throws IllegalArgumentException if entitiy data storage has not been enabled via the implementation
|
||||
*/
|
||||
@Nullable StoredEntityData entityDataIfPresent(int id);
|
||||
|
||||
@@ -99,8 +108,8 @@ public interface EntityTracker {
|
||||
void setClientEntityId(int clientEntityId);
|
||||
|
||||
/**
|
||||
* Returns the current world section height.
|
||||
* Always 16 for sub 1.17 worlds.
|
||||
* Returns the current world section height (block height / 16).
|
||||
* This is always 16 for sub 1.17 worlds.
|
||||
*
|
||||
* @return current world section height
|
||||
*/
|
||||
@@ -126,4 +135,36 @@ public interface EntityTracker {
|
||||
* @param currentMinY minimum y of the current world
|
||||
*/
|
||||
void setCurrentMinY(int currentMinY);
|
||||
|
||||
/**
|
||||
* Returns the name of the world the player is currently in.
|
||||
*
|
||||
* @return world name of the current world
|
||||
*/
|
||||
@Nullable String currentWorld();
|
||||
|
||||
/**
|
||||
* Sets the name of the world the player is currently in.
|
||||
*
|
||||
* @param currentWorld name of the current world
|
||||
*/
|
||||
void setCurrentWorld(String currentWorld);
|
||||
|
||||
int biomesSent();
|
||||
|
||||
void setBiomesSent(int biomesSent);
|
||||
|
||||
EntityType playerType();
|
||||
|
||||
@Nullable DimensionData dimensionData(String dimension);
|
||||
|
||||
void setDimensions(Map<String, DimensionData> dimensions);
|
||||
|
||||
/**
|
||||
* Adds the client player entity to the tracker.
|
||||
* If the client entity has not been set yet, this will return false.
|
||||
*
|
||||
* @return whether the client has been tracked
|
||||
*/
|
||||
boolean trackClientEntity();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -51,6 +51,15 @@ public interface StoredEntityData {
|
||||
*/
|
||||
@Nullable <T> T get(Class<T> objectClass);
|
||||
|
||||
/**
|
||||
* Removes and returns an object from the storage if present.
|
||||
*
|
||||
* @param objectClass class of the object to remove
|
||||
* @param <T> object type
|
||||
* @return removed object if present
|
||||
*/
|
||||
@Nullable <T> T remove(Class<T> objectClass);
|
||||
|
||||
/**
|
||||
* Stores an object based on its class.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.debug;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
|
||||
@Beta
|
||||
public interface DebugHandler {
|
||||
|
||||
/**
|
||||
* Returns whether debug mode is enabled.
|
||||
*
|
||||
* @return whether debug mode is enabled
|
||||
*/
|
||||
boolean enabled();
|
||||
|
||||
/**
|
||||
* Sets debug mode.
|
||||
*
|
||||
* @param enabled whether debug should be enabled
|
||||
*/
|
||||
void setEnabled(boolean enabled);
|
||||
|
||||
/**
|
||||
* Adds a packet type name to the list of packet types to log.
|
||||
*
|
||||
* @param packetTypeName packet type name
|
||||
*/
|
||||
void addPacketTypeNameToLog(String packetTypeName);
|
||||
|
||||
/**
|
||||
* Adds a packet id to the list of packet types to log.
|
||||
* Packets will be checked on each protocol transformer, so this is best used on single protocol pipes.
|
||||
*
|
||||
* @param packetType packet type
|
||||
*/
|
||||
void addPacketTypeToLog(PacketType packetType);
|
||||
|
||||
/**
|
||||
* Removes a packet type name from the list of packet types to log.
|
||||
*
|
||||
* @param packetTypeName packet type name
|
||||
*/
|
||||
boolean removePacketTypeNameToLog(String packetTypeName);
|
||||
|
||||
/**
|
||||
* Resets packet type filters.
|
||||
*/
|
||||
void clearPacketTypesToLog();
|
||||
|
||||
/**
|
||||
* Returns whether packets should be logged after being transformed.
|
||||
* Set to true by default.
|
||||
*
|
||||
* @return whether packets should be logged after being transformed
|
||||
*/
|
||||
boolean logPostPacketTransform();
|
||||
|
||||
/**
|
||||
* Sets whether packets should be logged after being transformed.
|
||||
*
|
||||
* @param logPostPacketTransform whether packets should be logged after being transformed
|
||||
*/
|
||||
void setLogPostPacketTransform(boolean logPostPacketTransform);
|
||||
|
||||
/**
|
||||
* Returns whether the given packet should be logged.
|
||||
* If no specific packet type has been added, all packet types will be logged.
|
||||
*
|
||||
* @param wrapper packet wrapper
|
||||
* @param direction packet direction
|
||||
* @return whether the packet should be logged
|
||||
*/
|
||||
boolean shouldLog(PacketWrapper wrapper, Direction direction);
|
||||
|
||||
default void enableAndLogIds(final PacketType... packetTypes) {
|
||||
setEnabled(true);
|
||||
for (final PacketType packetType : packetTypes) {
|
||||
addPacketTypeToLog(packetType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,7 +25,8 @@ package com.viaversion.viaversion.api.legacy.bossbar;
|
||||
public enum BossFlag {
|
||||
|
||||
DARKEN_SKY(1),
|
||||
PLAY_BOSS_MUSIC(2);
|
||||
PLAY_BOSS_MUSIC(2),
|
||||
CREATE_FOG(4);
|
||||
|
||||
private final int id;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -58,7 +58,7 @@ public class BlockChangeRecord1_16_2 implements BlockChangeRecord {
|
||||
|
||||
@Override
|
||||
public short getY(int chunkSectionY) {
|
||||
Preconditions.checkArgument(chunkSectionY >= 0 && chunkSectionY < 16, "Invalid chunkSectionY: " + chunkSectionY);
|
||||
Preconditions.checkArgument(chunkSectionY >= 0, "Invalid chunkSectionY: " + chunkSectionY);
|
||||
return (short) ((chunkSectionY << 4) + sectionY);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -33,6 +33,8 @@ public enum BlockFace {
|
||||
TOP((byte) 0, (byte) 1, (byte) 0, EnumAxis.Y),
|
||||
BOTTOM((byte) 0, (byte) -1, (byte) 0, EnumAxis.Y);
|
||||
|
||||
public static final BlockFace[] HORIZONTAL = new BlockFace[]{NORTH, SOUTH, EAST, WEST};
|
||||
|
||||
private static final Map<BlockFace, BlockFace> opposites = new HashMap<>();
|
||||
|
||||
static {
|
||||
@@ -60,18 +62,38 @@ public enum BlockFace {
|
||||
return opposites.get(this);
|
||||
}
|
||||
|
||||
public byte modX() {
|
||||
return modX;
|
||||
}
|
||||
|
||||
public byte modY() {
|
||||
return modY;
|
||||
}
|
||||
|
||||
public byte modZ() {
|
||||
return modZ;
|
||||
}
|
||||
|
||||
public EnumAxis axis() {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -34,6 +34,11 @@ public enum Environment {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -33,14 +33,29 @@ public class EulerAngle {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public final class GlobalPosition extends Position {
|
||||
private final String dimension;
|
||||
|
||||
public GlobalPosition(final String dimension, final int x, final int y, final int z) {
|
||||
super(x, y, z);
|
||||
this.dimension = dimension;
|
||||
}
|
||||
|
||||
public String dimension() {
|
||||
return dimension;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final GlobalPosition position = (GlobalPosition) o;
|
||||
if (x != position.x) return false;
|
||||
if (y != position.y) return false;
|
||||
if (z != position.z) return false;
|
||||
return dimension.equals(position.dimension);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = dimension.hashCode();
|
||||
result = 31 * result + x;
|
||||
result = 31 * result + y;
|
||||
result = 31 * result + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GlobalPosition{" +
|
||||
"dimension='" + dimension + '\'' +
|
||||
", x=" + x +
|
||||
", y=" + y +
|
||||
", z=" + z +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,9 +23,9 @@
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public class Position {
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
protected final int x;
|
||||
protected final int y;
|
||||
protected final int z;
|
||||
|
||||
public Position(int x, int y, int z) {
|
||||
this.x = x;
|
||||
@@ -33,28 +33,47 @@ public class Position {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public Position(int x, short y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this(x, (int) y, z);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public Position(Position toCopy) {
|
||||
this(toCopy.getX(), toCopy.getY(), toCopy.getZ());
|
||||
this(toCopy.x(), toCopy.y(), toCopy.z());
|
||||
}
|
||||
|
||||
public Position getRelative(BlockFace face) {
|
||||
return new Position(x + face.getModX(), (short) (y + face.getModY()), z + face.getModZ());
|
||||
return new Position(x + face.modX(), (short) (y + face.modY()), z + face.modZ());
|
||||
}
|
||||
|
||||
public int x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int z() {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public class Position3d {
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
|
||||
public Position3d(final double x, final double y, final double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public double x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double z() {
|
||||
return z;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -58,7 +58,12 @@ public enum RegistryType {
|
||||
this.resourceLocation = resourceLocation;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public String getResourceLocation() {
|
||||
return resourceLocation;
|
||||
}
|
||||
|
||||
public String resourceLocation() {
|
||||
return resourceLocation;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -33,26 +33,44 @@ public class Vector {
|
||||
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;
|
||||
}
|
||||
|
||||
public void setBlockX(int blockX) {
|
||||
this.blockX = blockX;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getBlockY() {
|
||||
return blockY;
|
||||
}
|
||||
|
||||
public void setBlockY(int blockY) {
|
||||
this.blockY = 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;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -33,14 +33,29 @@ public class VillagerData {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class WorldIdentifiers 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;
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.blockentity;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface BlockEntity {
|
||||
|
||||
default byte sectionX() {
|
||||
return (byte) ((packedXZ() >> 4) & 15);
|
||||
}
|
||||
|
||||
default byte sectionZ() {
|
||||
return (byte) (packedXZ() & 15);
|
||||
}
|
||||
|
||||
byte packedXZ();
|
||||
|
||||
short y();
|
||||
|
||||
int typeId();
|
||||
|
||||
@Nullable CompoundTag tag();
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.blockentity;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.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;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,6 +23,7 @@
|
||||
package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.BitSet;
|
||||
@@ -147,4 +148,9 @@ public class BaseChunk implements Chunk {
|
||||
public List<CompoundTag> getBlockEntities() {
|
||||
return blockEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockEntity> blockEntities() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,11 +23,13 @@
|
||||
package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
|
||||
// TODO specialized sub interfaces
|
||||
public interface Chunk {
|
||||
|
||||
/**
|
||||
@@ -115,4 +117,11 @@ public interface Chunk {
|
||||
* @return list of block entities
|
||||
*/
|
||||
List<CompoundTag> getBlockEntities();
|
||||
|
||||
/**
|
||||
* Returns a list of block entities.
|
||||
*
|
||||
* @return list of block entities
|
||||
*/
|
||||
List<BlockEntity> blockEntities();
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
|
||||
public class Chunk1_18 implements Chunk {
|
||||
protected final int x;
|
||||
protected final int z;
|
||||
protected ChunkSection[] sections;
|
||||
protected CompoundTag heightMap;
|
||||
protected final List<BlockEntity> blockEntities;
|
||||
|
||||
public Chunk1_18(int x, int z, ChunkSection[] sections, CompoundTag heightMap, List<BlockEntity> blockEntities) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.sections = sections;
|
||||
this.heightMap = heightMap;
|
||||
this.blockEntities = blockEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBiomeData() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullChunk() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnoreOldLightData() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIgnoreOldLightData(boolean ignoreOldLightData) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBitmask() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBitmask(int bitmask) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BitSet getChunkMask() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChunkMask(BitSet chunkSectionMask) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkSection[] getSections() {
|
||||
return sections;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSections(ChunkSection[] sections) {
|
||||
this.sections = sections;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int @Nullable [] getBiomeData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiomeData(int @Nullable [] biomeData) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable CompoundTag getHeightMap() {
|
||||
return heightMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeightMap(final CompoundTag heightMap) {
|
||||
this.heightMap = heightMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompoundTag> getBlockEntities() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockEntity> blockEntities() {
|
||||
return blockEntities;
|
||||
}
|
||||
}
|
||||
+62
-100
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -32,143 +32,93 @@ public interface ChunkSection {
|
||||
int SIZE = 16 * 16 * 16; // width * depth * height
|
||||
|
||||
/**
|
||||
* Returns the block index of the given coordinates within a section.
|
||||
*
|
||||
* @param x section x
|
||||
* @param y section y
|
||||
* @param z section z
|
||||
* @return section block index
|
||||
* Size (dimensions) of biomes in a chunks section.
|
||||
*/
|
||||
int BIOME_SIZE = 4 * 4 * 4;
|
||||
|
||||
static int index(int x, int y, int z) {
|
||||
return y << 8 | z << 4 | x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block state of the given index.
|
||||
*
|
||||
* @param idx block index within the section
|
||||
* @return block state of the given index
|
||||
*/
|
||||
int getFlatBlock(int idx);
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getFlatBlock(int idx) {
|
||||
return palette(PaletteType.BLOCKS).idAt(idx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block state of the section coordinate.
|
||||
*
|
||||
* @param x section x
|
||||
* @param y section y
|
||||
* @param z section z
|
||||
* @return block state of the given section coordinate
|
||||
*/
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getFlatBlock(int x, int y, int z) {
|
||||
return getFlatBlock(index(x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a block state in the chunk section.
|
||||
* This method will not update non-air blocks count.
|
||||
*
|
||||
* @param idx block index within the section
|
||||
* @param id raw or flat id of the block state
|
||||
*/
|
||||
void setFlatBlock(int idx, int id);
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void setFlatBlock(int idx, int id) {
|
||||
palette(PaletteType.BLOCKS).setIdAt(idx, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a block state in the chunk section.
|
||||
* This method will not update non-air blocks count.
|
||||
*
|
||||
* @param x section x
|
||||
* @param y section y
|
||||
* @param z section z
|
||||
* @param id raw or flat id of the block state
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a block in the chunks.
|
||||
* This method will not update non-air blocks count.
|
||||
*
|
||||
* @param x Block X
|
||||
* @param y Block Y
|
||||
* @param z Block Z
|
||||
* @param type The type of the block
|
||||
* @param data The data value of the block
|
||||
*/
|
||||
@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));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a block to the given palette index.
|
||||
*
|
||||
* @param idx block index
|
||||
* @param index palette index
|
||||
*/
|
||||
void setPaletteIndex(int idx, int index);
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void setPaletteIndex(int idx, int index) {
|
||||
palette(PaletteType.BLOCKS).setPaletteIndexAt(idx, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the palette index of the given block index.
|
||||
*
|
||||
* @param idx block index
|
||||
* @return palette index of the given block index
|
||||
*/
|
||||
int getPaletteIndex(int idx);
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getPaletteIndex(int idx) {
|
||||
return palette(PaletteType.BLOCKS).paletteIndexAt(idx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the palette.
|
||||
*
|
||||
* @return palette size
|
||||
*/
|
||||
int getPaletteSize();
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getPaletteSize() {
|
||||
return palette(PaletteType.BLOCKS).size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block state assigned to the given palette index.
|
||||
*
|
||||
* @param index palette index
|
||||
* @return block state assigned to the given palette index
|
||||
*/
|
||||
int getPaletteEntry(int index);
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getPaletteEntry(int index) {
|
||||
return palette(PaletteType.BLOCKS).idByIndex(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns a block state assigned to the given palette index.
|
||||
*
|
||||
* @param index palette index
|
||||
* @param id block state
|
||||
*/
|
||||
void setPaletteEntry(int index, int id);
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void setPaletteEntry(int index, int id) {
|
||||
palette(PaletteType.BLOCKS).setIdByIndex(index, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces a block state in the palette.
|
||||
*
|
||||
* @param oldId old block state
|
||||
* @param newId new block state
|
||||
*/
|
||||
void replacePaletteEntry(int oldId, int newId);
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void replacePaletteEntry(int oldId, int newId) {
|
||||
palette(PaletteType.BLOCKS).replaceId(oldId, newId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new block state to the palette.
|
||||
*
|
||||
* @param id block state
|
||||
*/
|
||||
void addPaletteEntry(int id);
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void addPaletteEntry(int id) {
|
||||
palette(PaletteType.BLOCKS).addId(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the palette.
|
||||
*/
|
||||
void clearPalette();
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void clearPalette() {
|
||||
palette(PaletteType.BLOCKS).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of non-air blocks in this section.
|
||||
@@ -198,4 +148,16 @@ public interface ChunkSection {
|
||||
@Nullable ChunkSectionLight getLight();
|
||||
|
||||
void setLight(@Nullable ChunkSectionLight light);
|
||||
|
||||
/**
|
||||
* Returns the palette of the given type if present.
|
||||
*
|
||||
* @param type type of the palette
|
||||
* @return palette
|
||||
*/
|
||||
@Nullable DataPalette palette(PaletteType type);
|
||||
|
||||
void addPalette(PaletteType type, DataPalette blockPalette);
|
||||
|
||||
void removePalette(PaletteType type);
|
||||
}
|
||||
+28
-102
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,120 +22,31 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
public class ChunkSectionImpl implements ChunkSection {
|
||||
|
||||
private final IntList palette;
|
||||
private final Int2IntMap inversePalette;
|
||||
private final int[] blocks;
|
||||
private final EnumMap<PaletteType, DataPalette> palettes = new EnumMap<>(PaletteType.class);
|
||||
private ChunkSectionLight light;
|
||||
private int nonAirBlocksCount;
|
||||
|
||||
public ChunkSectionImpl(boolean holdsLight) {
|
||||
this.blocks = new int[SIZE];
|
||||
palette = new IntArrayList();
|
||||
inversePalette = new Int2IntOpenHashMap();
|
||||
inversePalette.defaultReturnValue(-1);
|
||||
public ChunkSectionImpl() {
|
||||
}
|
||||
|
||||
public ChunkSectionImpl(final boolean holdsLight) {
|
||||
addPalette(PaletteType.BLOCKS, new DataPaletteImpl(ChunkSection.SIZE));
|
||||
if (holdsLight) {
|
||||
this.light = new ChunkSectionLightImpl();
|
||||
}
|
||||
}
|
||||
|
||||
public ChunkSectionImpl(boolean holdsLight, int expectedPaletteLength) {
|
||||
this.blocks = new int[SIZE];
|
||||
public ChunkSectionImpl(final boolean holdsLight, final int expectedPaletteLength) {
|
||||
addPalette(PaletteType.BLOCKS, new DataPaletteImpl(ChunkSection.SIZE, expectedPaletteLength));
|
||||
if (holdsLight) {
|
||||
this.light = new ChunkSectionLightImpl();
|
||||
}
|
||||
|
||||
// Pre-size the palette array/map
|
||||
palette = new IntArrayList(expectedPaletteLength);
|
||||
inversePalette = new Int2IntOpenHashMap(expectedPaletteLength);
|
||||
inversePalette.defaultReturnValue(-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlatBlock(int idx) {
|
||||
int index = blocks[idx];
|
||||
return palette.getInt(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlatBlock(int idx, int id) {
|
||||
int index = inversePalette.get(id);
|
||||
if (index == -1) {
|
||||
index = palette.size();
|
||||
palette.add(id);
|
||||
inversePalette.put(id, index);
|
||||
}
|
||||
|
||||
blocks[idx] = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPaletteIndex(int idx) {
|
||||
return blocks[idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPaletteIndex(int idx, int index) {
|
||||
blocks[idx] = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPaletteSize() {
|
||||
return palette.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPaletteEntry(int index) {
|
||||
return palette.getInt(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPaletteEntry(int index, int id) {
|
||||
int oldId = palette.set(index, id);
|
||||
if (oldId == id) return;
|
||||
|
||||
inversePalette.put(id, index);
|
||||
if (inversePalette.get(oldId) == index) {
|
||||
inversePalette.remove(oldId);
|
||||
for (int i = 0; i < palette.size(); i++) {
|
||||
if (palette.getInt(i) == oldId) {
|
||||
inversePalette.put(oldId, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replacePaletteEntry(int oldId, int newId) {
|
||||
int index = inversePalette.remove(oldId);
|
||||
if (index == -1) return;
|
||||
|
||||
inversePalette.put(newId, index);
|
||||
for (int i = 0; i < palette.size(); i++) {
|
||||
if (palette.getInt(i) == oldId) {
|
||||
palette.set(i, newId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPaletteEntry(int id) {
|
||||
inversePalette.put(id, palette.size());
|
||||
palette.add(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPalette() {
|
||||
palette.clear();
|
||||
inversePalette.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -144,7 +55,7 @@ public class ChunkSectionImpl implements ChunkSection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNonAirBlocksCount(int nonAirBlocksCount) {
|
||||
public void setNonAirBlocksCount(final int nonAirBlocksCount) {
|
||||
this.nonAirBlocksCount = nonAirBlocksCount;
|
||||
}
|
||||
|
||||
@@ -154,7 +65,22 @@ public class ChunkSectionImpl implements ChunkSection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLight(@Nullable ChunkSectionLight light) {
|
||||
public void setLight(@Nullable final ChunkSectionLight light) {
|
||||
this.light = light;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataPalette palette(final PaletteType type) {
|
||||
return palettes.get(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPalette(final PaletteType type, final DataPalette palette) {
|
||||
palettes.put(type, palette);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePalette(final PaletteType type) {
|
||||
palettes.remove(type);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
public interface DataPalette {
|
||||
|
||||
/**
|
||||
* Returns the packet section index of the given coordinates.
|
||||
*
|
||||
* @param x x
|
||||
* @param y y
|
||||
* @param z z
|
||||
* @return packed section index of the given coordinates
|
||||
*/
|
||||
int index(final int x, final int y, final int z);
|
||||
|
||||
/**
|
||||
* Returns the value of the given chunk coordinate.
|
||||
*
|
||||
* @param sectionCoordinate section index within the section
|
||||
* @return section state of the given index
|
||||
*/
|
||||
int idAt(int sectionCoordinate);
|
||||
|
||||
/**
|
||||
* Returns the value of the section coordinate.
|
||||
*
|
||||
* @param sectionX section x
|
||||
* @param sectionY section y
|
||||
* @param sectionZ section z
|
||||
* @return id of the given section coordinate
|
||||
*/
|
||||
default int idAt(final int sectionX, final int sectionY, final int sectionZ) {
|
||||
return idAt(index(sectionX, sectionY, sectionZ));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a value in the chunk section.
|
||||
* This method does not update non-air blocks count.
|
||||
*
|
||||
* @param sectionCoordinate section index within the section
|
||||
* @param id id value
|
||||
*/
|
||||
void setIdAt(int sectionCoordinate, int id);
|
||||
|
||||
/**
|
||||
* Set a value in the chunk section.
|
||||
* This method does not update non-air blocks count.
|
||||
*
|
||||
* @param sectionX section x
|
||||
* @param sectionY section y
|
||||
* @param sectionZ section z
|
||||
* @param id id value
|
||||
*/
|
||||
default void setIdAt(final int sectionX, final int sectionY, final int sectionZ, final int id) {
|
||||
setIdAt(index(sectionX, sectionY, sectionZ), id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the id assigned to the given palette index.
|
||||
*
|
||||
* @param index palette index
|
||||
* @return id assigned to the given palette index
|
||||
*/
|
||||
int idByIndex(int index);
|
||||
|
||||
/**
|
||||
* Assigns an id assigned to the given palette index.
|
||||
*
|
||||
* @param index palette index
|
||||
* @param id id value
|
||||
*/
|
||||
void setIdByIndex(int index, int id);
|
||||
|
||||
/**
|
||||
* Returns the palette index of the given section index.
|
||||
*
|
||||
* @param packedCoordinate section index
|
||||
* @return palette index of the given section index
|
||||
*/
|
||||
int paletteIndexAt(int packedCoordinate);
|
||||
|
||||
/**
|
||||
* Sets the index of the given section coordinate.
|
||||
*
|
||||
* @param sectionCoordinate section index
|
||||
* @param index palette index
|
||||
*/
|
||||
void setPaletteIndexAt(int sectionCoordinate, int index);
|
||||
|
||||
/**
|
||||
* Adds a new id to the palette.
|
||||
*
|
||||
* @param id id value
|
||||
*/
|
||||
void addId(int id);
|
||||
|
||||
/**
|
||||
* Replaces an id in the palette.
|
||||
*
|
||||
* @param oldId old id
|
||||
* @param newId new id
|
||||
*/
|
||||
void replaceId(int oldId, int newId);
|
||||
|
||||
/**
|
||||
* Returns the size of the palette.
|
||||
*
|
||||
* @return palette size
|
||||
*/
|
||||
int size();
|
||||
|
||||
/**
|
||||
* Clears the palette.
|
||||
*/
|
||||
void clear();
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
|
||||
public final class DataPaletteImpl implements DataPalette {
|
||||
|
||||
private final IntList palette;
|
||||
private final Int2IntMap inversePalette;
|
||||
private final int[] values;
|
||||
private final int sizeBits;
|
||||
|
||||
public DataPaletteImpl(final int valuesLength) {
|
||||
this(valuesLength, 8);
|
||||
}
|
||||
|
||||
public DataPaletteImpl(final int valuesLength, final int expectedPaletteLength) {
|
||||
this.values = new int[valuesLength];
|
||||
sizeBits = Integer.numberOfTrailingZeros(valuesLength) / 3;
|
||||
// Pre-size the palette array/map
|
||||
palette = new IntArrayList(expectedPaletteLength);
|
||||
inversePalette = new Int2IntOpenHashMap(expectedPaletteLength);
|
||||
inversePalette.defaultReturnValue(-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int index(final int x, final int y, final int z) {
|
||||
return (y << this.sizeBits | z) << this.sizeBits | x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int idAt(final int sectionCoordinate) {
|
||||
final int index = values[sectionCoordinate];
|
||||
return palette.getInt(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdAt(final int sectionCoordinate, final int id) {
|
||||
int index = inversePalette.get(id);
|
||||
if (index == -1) {
|
||||
index = palette.size();
|
||||
palette.add(id);
|
||||
inversePalette.put(id, index);
|
||||
}
|
||||
|
||||
values[sectionCoordinate] = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int paletteIndexAt(final int packedCoordinate) {
|
||||
return values[packedCoordinate];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPaletteIndexAt(final int sectionCoordinate, final int index) {
|
||||
values[sectionCoordinate] = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return palette.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int idByIndex(final int index) {
|
||||
return palette.getInt(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdByIndex(final int index, final int id) {
|
||||
final int oldId = palette.set(index, id);
|
||||
if (oldId == id) return;
|
||||
|
||||
inversePalette.put(id, index);
|
||||
if (inversePalette.get(oldId) == index) {
|
||||
inversePalette.remove(oldId);
|
||||
for (int i = 0; i < palette.size(); i++) {
|
||||
if (palette.getInt(i) == oldId) {
|
||||
inversePalette.put(oldId, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replaceId(final int oldId, final int newId) {
|
||||
final int index = inversePalette.remove(oldId);
|
||||
if (index == -1) return;
|
||||
|
||||
inversePalette.put(newId, index);
|
||||
for (int i = 0; i < palette.size(); i++) {
|
||||
if (palette.getInt(i) == oldId) {
|
||||
palette.set(i, newId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addId(final int id) {
|
||||
inversePalette.put(id, palette.size());
|
||||
palette.add(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
palette.clear();
|
||||
inversePalette.clear();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
public enum PaletteType {
|
||||
BLOCKS(ChunkSection.SIZE, 8),
|
||||
BIOMES(ChunkSection.BIOME_SIZE, 3);
|
||||
|
||||
private final int size;
|
||||
private final int highestBitsPerValue;
|
||||
|
||||
PaletteType(final int size, final int highestBitsPerValue) {
|
||||
this.size = size;
|
||||
this.highestBitsPerValue = highestBitsPerValue;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public int highestBitsPerValue() {
|
||||
return highestBitsPerValue;
|
||||
}
|
||||
}
|
||||
+11
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -170,6 +170,16 @@ public class Entity1_10Types {
|
||||
public EntityType getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ObjectType implements com.viaversion.viaversion.api.minecraft.entities.ObjectType {
|
||||
|
||||
+12
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -28,7 +28,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
// 1.11 Entity / Object ids TODO maybe in the future instead of copying it, some api.
|
||||
// 1.11 Entity / Object ids
|
||||
public class Entity1_11Types {
|
||||
|
||||
public static EntityType getTypeFromId(int typeID, boolean isObject) {
|
||||
@@ -187,6 +187,16 @@ public class Entity1_11Types {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
TYPES.put(type.id, type);
|
||||
|
||||
+11
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -191,6 +191,16 @@ public class Entity1_12Types {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
TYPES.put(type.id, type);
|
||||
|
||||
+11
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -240,6 +240,16 @@ public class Entity1_13Types {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
TYPES.put(type.id, type);
|
||||
|
||||
+11
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -224,6 +224,16 @@ public enum Entity1_14Types implements EntityType {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
static {
|
||||
TYPES = EntityTypeUtil.toOrderedArray(values());
|
||||
}
|
||||
|
||||
+11
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -226,6 +226,16 @@ public enum Entity1_15Types implements EntityType {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
static {
|
||||
TYPES = EntityTypeUtil.toOrderedArray(values());
|
||||
}
|
||||
|
||||
+11
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -231,6 +231,16 @@ public enum Entity1_16Types implements EntityType {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
static {
|
||||
TYPES = EntityTypeUtil.toOrderedArray(values());
|
||||
}
|
||||
|
||||
+11
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -235,6 +235,16 @@ public enum Entity1_16_2Types implements EntityType {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
static {
|
||||
TYPES = EntityTypeUtil.toOrderedArray(values());
|
||||
}
|
||||
|
||||
+11
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -240,6 +240,16 @@ public enum Entity1_17Types implements EntityType {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
static {
|
||||
TYPES = EntityTypeUtil.toOrderedArray(values());
|
||||
}
|
||||
|
||||
+283
@@ -0,0 +1,283 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
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 org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum Entity1_19Types implements EntityType {
|
||||
|
||||
ENTITY(null, null),
|
||||
|
||||
AREA_EFFECT_CLOUD(ENTITY),
|
||||
END_CRYSTAL(ENTITY),
|
||||
EVOKER_FANGS(ENTITY),
|
||||
EXPERIENCE_ORB(ENTITY),
|
||||
EYE_OF_ENDER(ENTITY),
|
||||
FALLING_BLOCK(ENTITY),
|
||||
FIREWORK_ROCKET(ENTITY),
|
||||
ITEM(ENTITY),
|
||||
LLAMA_SPIT(ENTITY),
|
||||
TNT(ENTITY),
|
||||
SHULKER_BULLET(ENTITY),
|
||||
FISHING_BOBBER(ENTITY),
|
||||
|
||||
LIVINGENTITY(ENTITY, null),
|
||||
ARMOR_STAND(LIVINGENTITY),
|
||||
MARKER(ENTITY),
|
||||
PLAYER(LIVINGENTITY),
|
||||
|
||||
ABSTRACT_INSENTIENT(LIVINGENTITY, null),
|
||||
ENDER_DRAGON(ABSTRACT_INSENTIENT),
|
||||
|
||||
BEE(ABSTRACT_INSENTIENT),
|
||||
|
||||
ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null),
|
||||
|
||||
ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null),
|
||||
VILLAGER(ABSTRACT_AGEABLE),
|
||||
WANDERING_TRADER(ABSTRACT_AGEABLE),
|
||||
|
||||
// Animals
|
||||
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
|
||||
AXOLOTL(ABSTRACT_ANIMAL),
|
||||
DOLPHIN(ABSTRACT_INSENTIENT),
|
||||
CHICKEN(ABSTRACT_ANIMAL),
|
||||
COW(ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(COW),
|
||||
PANDA(ABSTRACT_INSENTIENT),
|
||||
PIG(ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(ABSTRACT_ANIMAL),
|
||||
RABBIT(ABSTRACT_ANIMAL),
|
||||
SHEEP(ABSTRACT_ANIMAL),
|
||||
TURTLE(ABSTRACT_ANIMAL),
|
||||
FOX(ABSTRACT_ANIMAL),
|
||||
FROG(ABSTRACT_ANIMAL),
|
||||
GOAT(ABSTRACT_ANIMAL),
|
||||
|
||||
ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null),
|
||||
CAT(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
OCELOT(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
WOLF(ABSTRACT_TAMEABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_PARROT(ABSTRACT_TAMEABLE_ANIMAL, null),
|
||||
PARROT(ABSTRACT_PARROT),
|
||||
|
||||
// Horses
|
||||
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
|
||||
CHESTED_HORSE(ABSTRACT_HORSE, null),
|
||||
DONKEY(CHESTED_HORSE),
|
||||
MULE(CHESTED_HORSE),
|
||||
LLAMA(CHESTED_HORSE),
|
||||
TRADER_LLAMA(CHESTED_HORSE),
|
||||
HORSE(ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(ABSTRACT_HORSE),
|
||||
|
||||
// Golem
|
||||
ABSTRACT_GOLEM(ABSTRACT_CREATURE, null),
|
||||
SNOW_GOLEM(ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(ABSTRACT_GOLEM),
|
||||
SHULKER(ABSTRACT_GOLEM),
|
||||
|
||||
// Fish
|
||||
ABSTRACT_FISHES(ABSTRACT_CREATURE, null),
|
||||
COD(ABSTRACT_FISHES),
|
||||
PUFFERFISH(ABSTRACT_FISHES),
|
||||
SALMON(ABSTRACT_FISHES),
|
||||
TROPICAL_FISH(ABSTRACT_FISHES),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(ABSTRACT_CREATURE, null),
|
||||
BLAZE(ABSTRACT_MONSTER),
|
||||
CREEPER(ABSTRACT_MONSTER),
|
||||
ENDERMITE(ABSTRACT_MONSTER),
|
||||
ENDERMAN(ABSTRACT_MONSTER),
|
||||
GIANT(ABSTRACT_MONSTER),
|
||||
SILVERFISH(ABSTRACT_MONSTER),
|
||||
VEX(ABSTRACT_MONSTER),
|
||||
WITCH(ABSTRACT_MONSTER),
|
||||
WITHER(ABSTRACT_MONSTER),
|
||||
RAVAGER(ABSTRACT_MONSTER),
|
||||
|
||||
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
|
||||
|
||||
PIGLIN(ABSTRACT_PIGLIN),
|
||||
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
|
||||
|
||||
HOGLIN(ABSTRACT_ANIMAL),
|
||||
STRIDER(ABSTRACT_ANIMAL),
|
||||
TADPOLE(ABSTRACT_FISHES),
|
||||
ZOGLIN(ABSTRACT_MONSTER),
|
||||
WARDEN(ABSTRACT_MONSTER),
|
||||
|
||||
// Illagers
|
||||
ABSTRACT_ILLAGER_BASE(ABSTRACT_MONSTER, null),
|
||||
ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null),
|
||||
EVOKER(ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
VINDICATOR(ABSTRACT_ILLAGER_BASE),
|
||||
PILLAGER(ABSTRACT_ILLAGER_BASE),
|
||||
|
||||
// Skeletons
|
||||
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
|
||||
SKELETON(ABSTRACT_SKELETON),
|
||||
STRAY(ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(ABSTRACT_SKELETON),
|
||||
|
||||
// Guardians
|
||||
GUARDIAN(ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(GUARDIAN),
|
||||
|
||||
// Spiders
|
||||
SPIDER(ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(SPIDER),
|
||||
|
||||
// Zombies
|
||||
ZOMBIE(ABSTRACT_MONSTER),
|
||||
DROWNED(ZOMBIE),
|
||||
HUSK(ZOMBIE),
|
||||
ZOMBIFIED_PIGLIN(ZOMBIE),
|
||||
ZOMBIE_VILLAGER(ZOMBIE),
|
||||
|
||||
// Flying entities
|
||||
ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null),
|
||||
GHAST(ABSTRACT_FLYING),
|
||||
PHANTOM(ABSTRACT_FLYING),
|
||||
|
||||
ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null),
|
||||
BAT(ABSTRACT_AMBIENT),
|
||||
ALLAY(ABSTRACT_CREATURE),
|
||||
|
||||
ABSTRACT_WATERMOB(ABSTRACT_INSENTIENT, null),
|
||||
SQUID(ABSTRACT_WATERMOB),
|
||||
GLOW_SQUID(SQUID),
|
||||
|
||||
// Slimes
|
||||
SLIME(ABSTRACT_INSENTIENT),
|
||||
MAGMA_CUBE(SLIME),
|
||||
|
||||
// Hangable objects
|
||||
ABSTRACT_HANGING(ENTITY, null),
|
||||
LEASH_KNOT(ABSTRACT_HANGING),
|
||||
ITEM_FRAME(ABSTRACT_HANGING),
|
||||
GLOW_ITEM_FRAME(ITEM_FRAME),
|
||||
PAINTING(ABSTRACT_HANGING),
|
||||
|
||||
ABSTRACT_LIGHTNING(ENTITY, null),
|
||||
LIGHTNING_BOLT(ABSTRACT_LIGHTNING),
|
||||
|
||||
// Arrows
|
||||
ABSTRACT_ARROW(ENTITY, null),
|
||||
ARROW(ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(ABSTRACT_ARROW),
|
||||
TRIDENT(ABSTRACT_ARROW),
|
||||
|
||||
// Fireballs
|
||||
ABSTRACT_FIREBALL(ENTITY, null),
|
||||
DRAGON_FIREBALL(ABSTRACT_FIREBALL),
|
||||
FIREBALL(ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(ABSTRACT_FIREBALL),
|
||||
WITHER_SKULL(ABSTRACT_FIREBALL),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE_ABSTRACT(ENTITY, null),
|
||||
SNOWBALL(PROJECTILE_ABSTRACT),
|
||||
ENDER_PEARL(PROJECTILE_ABSTRACT),
|
||||
EGG(PROJECTILE_ABSTRACT),
|
||||
POTION(PROJECTILE_ABSTRACT),
|
||||
EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT),
|
||||
|
||||
// Vehicles
|
||||
MINECART_ABSTRACT(ENTITY, null),
|
||||
CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null),
|
||||
CHEST_MINECART(CHESTED_MINECART_ABSTRACT),
|
||||
HOPPER_MINECART(CHESTED_MINECART_ABSTRACT),
|
||||
MINECART(MINECART_ABSTRACT),
|
||||
FURNACE_MINECART(MINECART_ABSTRACT),
|
||||
COMMAND_BLOCK_MINECART(MINECART_ABSTRACT),
|
||||
TNT_MINECART(MINECART_ABSTRACT),
|
||||
SPAWNER_MINECART(MINECART_ABSTRACT),
|
||||
BOAT(ENTITY),
|
||||
CHEST_BOAT(BOAT);
|
||||
|
||||
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
|
||||
private final EntityType parent;
|
||||
private final String identifier;
|
||||
private int id = -1;
|
||||
|
||||
Entity1_19Types(final EntityType parent) {
|
||||
this.parent = parent;
|
||||
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
Entity1_19Types(final EntityType parent, @Nullable final String identifier) {
|
||||
this.parent = parent;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
if (id == -1) {
|
||||
throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")");
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type");
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable EntityType getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstractType() {
|
||||
return identifier == null;
|
||||
}
|
||||
|
||||
public static EntityType getTypeFromId(final int typeId) {
|
||||
return EntityTypeUtil.getTypeFromId(TYPES, typeId, ENTITY);
|
||||
}
|
||||
|
||||
public static void initialize(final Protocol<?, ?, ?, ?> protocol) {
|
||||
for (final Entity1_19Types type : values()) {
|
||||
if (type.isAbstractType()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final int id = protocol.getMappingData().getEntityMappings().mappedId(type.identifier());
|
||||
Preconditions.checkArgument(id != -1, "Entity type %s has no id", type.identifier());
|
||||
type.id = id;
|
||||
}
|
||||
EntityTypeUtil.fill(values(), TYPES);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -30,6 +30,7 @@ public interface EntityType {
|
||||
* Returns the entity id.
|
||||
*
|
||||
* @return entity id
|
||||
* @throws IllegalStateException if ids have not been loaded yet
|
||||
*/
|
||||
int getId();
|
||||
|
||||
@@ -47,6 +48,22 @@ public interface EntityType {
|
||||
*/
|
||||
String name();
|
||||
|
||||
/**
|
||||
* Returns the entity's Vanilla identifier.
|
||||
*
|
||||
* @return entity identifier
|
||||
* @throws IllegalArgumentException if {@link #isAbstractType()} returns true
|
||||
*/
|
||||
String identifier();
|
||||
|
||||
/**
|
||||
* Returns whether the type does not represent an actual entity, e.g. animal or monster.
|
||||
*
|
||||
* @return whether the type does not represent an actual entity
|
||||
*/
|
||||
boolean isAbstractType();
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default boolean is(EntityType... types) {
|
||||
for (EntityType type : types) {
|
||||
if (this == type) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -92,6 +92,11 @@ public class DataItem implements Item {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item copy() {
|
||||
return new DataItem(identifier, amount, data, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -87,4 +87,11 @@ public interface Item {
|
||||
* @param tag item tag
|
||||
*/
|
||||
void setTag(@Nullable CompoundTag tag);
|
||||
|
||||
/**
|
||||
* Returns a copy of the item.
|
||||
*
|
||||
* @return copy of the item
|
||||
*/
|
||||
Item copy();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -39,4 +39,44 @@ public interface MetaType {
|
||||
* @return Type id as an integer
|
||||
*/
|
||||
int typeId();
|
||||
|
||||
static MetaType create(final int typeId, final Type<?> type) {
|
||||
return new MetaTypeImpl(typeId, type);
|
||||
}
|
||||
|
||||
final class MetaTypeImpl implements MetaType {
|
||||
private final int typeId;
|
||||
private final Type<?> type;
|
||||
|
||||
MetaTypeImpl(final int typeId, final Type<?> type) {
|
||||
this.typeId = typeId;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int typeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<?> type() {
|
||||
return 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;
|
||||
if (typeId != metaType.typeId) return false;
|
||||
return type.equals(metaType.type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = typeId;
|
||||
result = 31 * result + type.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -105,7 +105,7 @@ public final class Metadata {
|
||||
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 != null ? value + " (" + value.getClass().getSimpleName() + ")" : "null"));
|
||||
+ ", value=" + value + " (" + value.getClass().getSimpleName() + ")");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public final class Metadata {
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Metadata metadata = (Metadata) o;
|
||||
if (id != metadata.id) return false;
|
||||
if (metaType != metaType) return false;
|
||||
if (metaType != metadata.metaType) return false;
|
||||
return Objects.equals(value, metadata.value);
|
||||
}
|
||||
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.metadata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
|
||||
public abstract class AbstractMetaTypes implements MetaTypes {
|
||||
|
||||
private final MetaType[] values;
|
||||
|
||||
protected AbstractMetaTypes(final int values) {
|
||||
this.values = new MetaType[values];
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaType byId(final int id) {
|
||||
return values[id];
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaType[] values() {
|
||||
return values;
|
||||
}
|
||||
|
||||
protected MetaType add(final int typeId, final Type<?> type) {
|
||||
final MetaType metaType = MetaType.create(typeId, type);
|
||||
values[typeId] = metaType;
|
||||
return metaType;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public enum MetaType1_13 implements MetaType {
|
||||
Byte(0, Type.BYTE),
|
||||
VarInt(1, Type.VAR_INT),
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public enum MetaType1_13_2 implements MetaType {
|
||||
Byte(0, Type.BYTE),
|
||||
VarInt(1, Type.VAR_INT),
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public enum MetaType1_14 implements MetaType {
|
||||
Byte(0, Type.BYTE),
|
||||
VarInt(1, Type.VAR_INT),
|
||||
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.metadata.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public enum MetaType1_16 implements MetaType {
|
||||
BYTE(0, Type.BYTE),
|
||||
VAR_INT(1, Type.VAR_INT),
|
||||
FLOAT(2, Type.FLOAT),
|
||||
STRING(3, Type.STRING),
|
||||
COMPONENT(4, Type.COMPONENT),
|
||||
OPT_COMPONENT(5, Type.OPTIONAL_COMPONENT),
|
||||
ITEM(6, Type.FLAT_VAR_INT_ITEM),
|
||||
BOOLEAN(7, Type.BOOLEAN),
|
||||
ROTATION(8, Type.ROTATION),
|
||||
POSITION(9, Type.POSITION1_14),
|
||||
OPT_POSITION(10, Type.OPTIONAL_POSITION_1_14),
|
||||
DIRECTION(11, Type.VAR_INT),
|
||||
OPT_UUID(12, Type.OPTIONAL_UUID),
|
||||
BLOCK_STATE(13, Type.VAR_INT),
|
||||
NBT(14, Type.NBT),
|
||||
PARTICLE(15, Types1_16.PARTICLE),
|
||||
VILLAGER_DATA(16, Type.VILLAGER_DATA),
|
||||
OPT_VAR_INT(17, Type.OPTIONAL_VAR_INT),
|
||||
POSE(18, Type.VAR_INT);
|
||||
|
||||
private static final MetaType1_16[] VALUES = values();
|
||||
private final int typeId;
|
||||
private final Type type;
|
||||
|
||||
MetaType1_16(int typeId, Type type) {
|
||||
this.typeId = typeId;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static MetaType1_16 byId(int id) {
|
||||
return VALUES[id];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int typeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type type() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_17;
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public enum MetaType1_17 implements MetaType {
|
||||
BYTE(0, Type.BYTE),
|
||||
VAR_INT(1, Type.VAR_INT),
|
||||
|
||||
Loaded 100 of 683 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user