Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40047330b4 | ||
|
|
98304168b8 | ||
|
|
3695df1e44 | ||
|
|
958f265e18 | ||
|
|
394c944c50 | ||
|
|
d559c7cff1 | ||
|
|
3d4f4438a8 | ||
|
|
2972fb8422 | ||
|
|
817593ee43 | ||
|
|
044980c1a8 | ||
|
|
245bd53850 | ||
|
|
b632e4772f | ||
|
|
b336b8a1fc | ||
|
|
304b21425c | ||
|
|
bb17bb3bfd | ||
|
|
941bb91be8 | ||
|
|
fb334c6c14 | ||
|
|
90460ee99f | ||
|
|
81a737886a | ||
|
|
356158a9d4 | ||
|
|
32bd9378e1 | ||
|
|
317af16975 | ||
|
|
3826be4f5f | ||
|
|
282afe94cc | ||
|
|
9d86b31cb7 | ||
|
|
80041606a7 | ||
|
|
41e4172136 | ||
|
|
a856658399 | ||
|
|
7173bbbbce | ||
|
|
54507c6175 | ||
|
|
4dd7d384c8 | ||
|
|
fc751aedf3 | ||
|
|
a1da3dc11c | ||
|
|
87c37b08e8 | ||
|
|
187b79f4e1 | ||
|
|
b84cda54c3 | ||
|
|
f474067eb2 | ||
|
|
6a700d228d | ||
|
|
f08223d1e9 | ||
|
|
a5e3a6b563 | ||
|
|
65afe42d2c | ||
|
|
9da206e280 | ||
|
|
c2ae3df1db | ||
|
|
dc9fe10779 | ||
|
|
08a583526e | ||
|
|
125fa885f6 | ||
|
|
4a1eefcf87 | ||
|
|
68c0a0b333 | ||
|
|
fdc73126f7 | ||
|
|
1e0c0ebb2d | ||
|
|
5bffa2c51c | ||
|
|
34fa4f85db | ||
|
|
ef0e412d36 | ||
|
|
7df02934f3 | ||
|
|
d64b259b77 | ||
|
|
8850d5c8ff | ||
|
|
15c7106430 | ||
|
|
56dfc985d2 | ||
|
|
dfa778942c | ||
|
|
bd71833f18 | ||
|
|
c6f25bf33f | ||
|
|
fc22d7e6c8 | ||
|
|
22f604cd7e | ||
|
|
a85b9e8100 | ||
|
|
8d380f4278 | ||
|
|
1486d58813 | ||
|
|
9d3de047a0 | ||
|
|
c75e5bd6a7 | ||
|
|
30a3a4fb89 | ||
|
|
9fe9cd3a8a | ||
|
|
12926980e2 | ||
|
|
31787b5e5b | ||
|
|
d56921b611 | ||
|
|
15a5e6f710 | ||
|
|
422f2b699b | ||
|
|
eda8abf55c | ||
|
|
2b955894d3 | ||
|
|
539c4e696a | ||
|
|
aa35ace816 | ||
|
|
8ea7686b2c | ||
|
|
7dbd620886 | ||
|
|
6a1b0e044a | ||
|
|
afe3584b70 | ||
|
|
d8096e7f2e | ||
|
|
121c735073 | ||
|
|
52698423d0 | ||
|
|
bbff706890 | ||
|
|
2a079be7c2 | ||
|
|
a8e767250a | ||
|
|
5593dfb8e5 | ||
|
|
afd072c313 | ||
|
|
d26cac9622 | ||
|
|
2c341ab7ad | ||
|
|
54eaccca0d | ||
|
|
0d5661f8a6 | ||
|
|
7a19cb8d04 | ||
|
|
9fddf7b176 | ||
|
|
f687dff702 | ||
|
|
249280312e | ||
|
|
a200975cda | ||
|
|
0163bc8c24 | ||
|
|
a5a789c440 | ||
|
|
87aed8f3f2 | ||
|
|
cadab9e6bb | ||
|
|
13b5545999 | ||
|
|
f4a6c20695 | ||
|
|
ff583e40fb | ||
|
|
c8b0ca48de | ||
|
|
8d35d16575 | ||
|
|
e70f595f76 | ||
|
|
888441b81d | ||
|
|
71f4012537 | ||
|
|
ce6ca4dc0f | ||
|
|
becba6498e | ||
|
|
95bc340b06 | ||
|
|
1ab93c4021 | ||
|
|
b36052465f | ||
|
|
5695726d9a | ||
|
|
025a892daf | ||
|
|
74aa5f4598 | ||
|
|
db345577a2 | ||
|
|
80f41c8c24 | ||
|
|
169650f17c | ||
|
|
4361ebe636 | ||
|
|
9d52fd6212 | ||
|
|
abb2abe5c9 | ||
|
|
e9d1d257ea | ||
|
|
a721eb4d03 | ||
|
|
fe644127c1 | ||
|
|
71cc1ca4b5 | ||
|
|
5df0dacf92 | ||
|
|
448f452965 | ||
|
|
3d6c31c479 | ||
|
|
067c93a63a | ||
|
|
04a970ef08 | ||
|
|
3d32cb3adf | ||
|
|
1ef1a861ca | ||
|
|
deb11bf1a9 | ||
|
|
87ad6bd2b1 | ||
|
|
3054b758df | ||
|
|
5777f4a117 | ||
|
|
9615a5aba2 | ||
|
|
8fff947863 | ||
|
|
68f77cc809 | ||
|
|
4f801b4228 | ||
|
|
54dc05046f | ||
|
|
e05c585b37 | ||
|
|
a03a3a2a8d | ||
|
|
e251565837 | ||
|
|
455bb546f0 | ||
|
|
fa707e5391 | ||
|
|
6f2961a00b | ||
|
|
43ebe3c3e3 | ||
|
|
f8d10be031 | ||
|
|
3f01f0100c | ||
|
|
29d3787de8 | ||
|
|
59df758ceb | ||
|
|
80360bf27c | ||
|
|
3da7d7513e | ||
|
|
a654becac8 | ||
|
|
77a5b2212b | ||
|
|
7013ed8acf | ||
|
|
9d41854e22 | ||
|
|
edf9ccca8b | ||
|
|
d62165bf51 | ||
|
|
00bc4a9d6a | ||
|
|
7885babe1e | ||
|
|
9a53678838 | ||
|
|
91874ffc3b | ||
|
|
e71c34255b | ||
|
|
8e78a14c14 | ||
|
|
3b85200641 | ||
|
|
1dc0f72e54 | ||
|
|
13d27a6f4d | ||
|
|
3cec1751c9 | ||
|
|
80f9dce513 | ||
|
|
cf7c718493 | ||
|
|
0ba20299a3 |
No files matched your search
@@ -1,5 +1,6 @@
|
||||
name: Bug Report
|
||||
description: Report a bug or console error
|
||||
labels: [unconfirmed]
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
name: Feature Request
|
||||
description: Suggest a feature to be added
|
||||
labels: [Feature Request]
|
||||
|
||||
body:
|
||||
- type: textarea
|
||||
@@ -34,4 +35,4 @@ body:
|
||||
description: |
|
||||
Does the feature apply to any specific version or environment?
|
||||
validations:
|
||||
required: false
|
||||
required: false
|
||||
+2
-6
@@ -18,6 +18,8 @@ hs_err_pid*
|
||||
|
||||
# Ignore IDEA directory
|
||||
.idea/*
|
||||
!.idea/copyright/*
|
||||
!.idea/scopes/*
|
||||
|
||||
# Include the project's dictionary
|
||||
!.idea/dictionaries/
|
||||
@@ -105,9 +107,3 @@ nbdist/
|
||||
nbactions.xml
|
||||
nb-configuration.xml
|
||||
.nb-gradle/
|
||||
|
||||
|
||||
|
||||
### Git ###
|
||||
# Don't exclude the .gitignore itself
|
||||
!.gitignore
|
||||
Generated
+10
@@ -0,0 +1,10 @@
|
||||
<component name="CopyrightManager">
|
||||
<settings>
|
||||
<module2copyright>
|
||||
<element module="ViaBackwards" copyright="viabackwards-gpl" />
|
||||
</module2copyright>
|
||||
<LanguageOptions name="__TEMPLATE__">
|
||||
<option name="addBlankAfter" value="false" />
|
||||
</LanguageOptions>
|
||||
</settings>
|
||||
</component>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards Copyright (C) 2016-2022 ViaVersion and contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>." />
|
||||
<option name="myName" value="viabackwards-gpl" />
|
||||
</copyright>
|
||||
</component>
|
||||
Generated
+3
@@ -0,0 +1,3 @@
|
||||
<component name="DependencyValidationManager">
|
||||
<scope name="ViaBackwards" pattern="com.viaversion.viabackwards..*" />
|
||||
</component>
|
||||
@@ -11,7 +11,7 @@ Supported Versions
|
||||
**Green** = ViaVersion\
|
||||
**Purple** = ViaBackwards addition
|
||||
|
||||

|
||||

|
||||
|
||||
Releases / Dev Builds
|
||||
-
|
||||
|
||||
@@ -8,5 +8,5 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
// version must be manually kept in sync with the one in root project settings.gradle.kts
|
||||
implementation("gradle.plugin.com.github.jengelman.gradle.plugins", "shadow", "7.0.0")
|
||||
implementation("gradle.plugin.com.github.johnrengelman", "shadow", "7.1.2")
|
||||
}
|
||||
@@ -6,7 +6,7 @@ plugins {
|
||||
tasks {
|
||||
// Variable replacements
|
||||
processResources {
|
||||
filesMatching(listOf("plugin.yml", "mcmod.info", "fabric.mod.json", "bungee.yml")) {
|
||||
filesMatching(listOf("plugin.yml", "META-INF/sponge_plugins.json", "fabric.mod.json", "bungee.yml")) {
|
||||
expand("version" to project.version, "description" to project.description, "url" to "https://github.com/ViaVersion/ViaBackwards")
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ plugins {
|
||||
|
||||
allprojects {
|
||||
group = "com.viaversion"
|
||||
version = "4.0.0"
|
||||
version = "4.4.2"
|
||||
description = "Allow older clients to join newer server versions."
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -50,6 +50,11 @@ public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform {
|
||||
}
|
||||
|
||||
private void onServerLoaded() {
|
||||
if (isOutdatedPostLoad()) {
|
||||
disable();
|
||||
return;
|
||||
}
|
||||
|
||||
BukkitViaLoader loader = (BukkitViaLoader) Via.getManager().getLoader();
|
||||
int protocolVersion = Via.getAPI().getServerVersion().highestSupportedVersion();
|
||||
if (protocolVersion >= ProtocolVersion.v1_16.getVersion()) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
@@ -4,7 +4,7 @@ description: Allow older Minecraft versions to connect to a newer server version
|
||||
main: com.viaversion.viabackwards.BukkitPlugin
|
||||
api-version: 1.13
|
||||
|
||||
authors: [Matsv, KennyTV, Gerrygames, creeper123123321, ForceUpdate1]
|
||||
authors: [Matsv, kennytv, Gerrygames, creeper123123321, ForceUpdate1]
|
||||
website: ${url}
|
||||
|
||||
depend: [ViaVersion]
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: ViaBackwards
|
||||
main: com.viaversion.viabackwards.BungeePlugin
|
||||
author: "Matsv, KennyTV, Gerrygames, creeper123123321, ForceUpdate1"
|
||||
author: "Matsv, kennytv, Gerrygames, creeper123123321, ForceUpdate1"
|
||||
version: ${version}
|
||||
depends: [ViaVersion]
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -18,10 +18,12 @@
|
||||
package com.viaversion.viabackwards;
|
||||
|
||||
import com.viaversion.viaversion.util.Config;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -31,6 +33,9 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
|
||||
private boolean addTeamColorToPrefix;
|
||||
private boolean fix1_13FacePlayer;
|
||||
private boolean alwaysShowOriginalMobName;
|
||||
private boolean fix1_13FormattedInventoryTitles;
|
||||
private boolean handlePingsAsInvAcknowledgements;
|
||||
private Map<String, String> chatTypeFormats;
|
||||
|
||||
public ViaBackwardsConfig(File configFile) {
|
||||
super(configFile);
|
||||
@@ -46,7 +51,10 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
|
||||
addCustomEnchantsToLore = getBoolean("add-custom-enchants-into-lore", true);
|
||||
addTeamColorToPrefix = getBoolean("add-teamcolor-to-prefix", true);
|
||||
fix1_13FacePlayer = getBoolean("fix-1_13-face-player", false);
|
||||
fix1_13FormattedInventoryTitles = getBoolean("fix-formatted-inventory-titles", true);
|
||||
alwaysShowOriginalMobName = getBoolean("always-show-original-mob-name", true);
|
||||
handlePingsAsInvAcknowledgements = getBoolean("handle-pings-as-inv-acknowledgements", false);
|
||||
chatTypeFormats = get("chat-types-1_19_1", Map.class, new HashMap<String, String>());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,11 +72,26 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
|
||||
return fix1_13FacePlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fix1_13FormattedInventoryTitle() {
|
||||
return fix1_13FormattedInventoryTitles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean alwaysShowOriginalMobName() {
|
||||
return alwaysShowOriginalMobName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePingsAsInvAcknowledgements() {
|
||||
return handlePingsAsInvAcknowledgements || Boolean.getBoolean("com.viaversion.handlePingsAsInvAcknowledgements");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String chatTypeFormat(final String translationKey) {
|
||||
return chatTypeFormats.get(translationKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getDefaultConfigURL() {
|
||||
return getClass().getClassLoader().getResource("assets/viabackwards/config.yml");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.api;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface ViaBackwardsConfig {
|
||||
|
||||
/**
|
||||
@@ -40,10 +42,16 @@ public interface ViaBackwardsConfig {
|
||||
*/
|
||||
boolean isFix1_13FacePlayer();
|
||||
|
||||
boolean fix1_13FormattedInventoryTitle();
|
||||
|
||||
/**
|
||||
* Always shows the original mob's name instead of only when hovering over them with the cursor.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean alwaysShowOriginalMobName();
|
||||
|
||||
boolean handlePingsAsInvAcknowledgements();
|
||||
|
||||
@Nullable String chatTypeFormat(String translationKey);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -43,6 +43,11 @@ import com.viaversion.viabackwards.protocol.protocol1_16_2to1_16_3.Protocol1_16_
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16_3to1_16_4.Protocol1_16_3To1_16_4;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16_4to1_17.Protocol1_16_4To1_17;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16to1_16_1.Protocol1_16To1_16_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.Protocol1_17_1To1_18;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_17to1_17_1.Protocol1_17To1_17_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.Protocol1_18_2To1_19;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_18to1_18_2.Protocol1_18To1_18_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.Protocol1_19To1_19_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.ProtocolManager;
|
||||
@@ -54,7 +59,7 @@ import java.util.logging.Logger;
|
||||
|
||||
public interface ViaBackwardsPlatform {
|
||||
|
||||
String MINIMUM_VV_VERSION = "4.0.0";
|
||||
String MINIMUM_VV_VERSION = "4.4.2";
|
||||
String IMPL_VERSION = "$IMPL_VERSION";
|
||||
|
||||
/**
|
||||
@@ -66,14 +71,17 @@ public interface ViaBackwardsPlatform {
|
||||
|
||||
ViaBackwards.init(this, config);
|
||||
|
||||
if (isOutdated()) return;
|
||||
if (isOutdated()) {
|
||||
disable();
|
||||
return;
|
||||
}
|
||||
|
||||
Via.getManager().getSubPlatforms().add(IMPL_VERSION);
|
||||
|
||||
getLogger().info("Loading translations...");
|
||||
TranslatableRewriter.loadTranslatables();
|
||||
|
||||
ProtocolManager protocolManager = Via.getManager().getProtocolManager();
|
||||
final ProtocolManager protocolManager = Via.getManager().getProtocolManager();
|
||||
protocolManager.registerProtocol(new Protocol1_9_4To1_10(), ProtocolVersion.v1_9_3, ProtocolVersion.v1_10);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_10To1_11(), ProtocolVersion.v1_10, ProtocolVersion.v1_11);
|
||||
@@ -104,6 +112,13 @@ public interface ViaBackwardsPlatform {
|
||||
protocolManager.registerProtocol(new Protocol1_16_3To1_16_4(), ProtocolVersion.v1_16_3, ProtocolVersion.v1_16_4);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_16_4To1_17(), ProtocolVersion.v1_16_4, ProtocolVersion.v1_17);
|
||||
protocolManager.registerProtocol(new Protocol1_17To1_17_1(), ProtocolVersion.v1_17, ProtocolVersion.v1_17_1);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_17_1To1_18(), ProtocolVersion.v1_17_1, ProtocolVersion.v1_18);
|
||||
protocolManager.registerProtocol(new Protocol1_18To1_18_2(), ProtocolVersion.v1_18, ProtocolVersion.v1_18_2);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_18_2To1_19(), ProtocolVersion.v1_18_2, ProtocolVersion.v1_19);
|
||||
protocolManager.registerProtocol(new Protocol1_19To1_19_1(), ProtocolVersion.v1_19, ProtocolVersion.v1_19_1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,11 +137,12 @@ public interface ViaBackwardsPlatform {
|
||||
getLogger().severe("LINK: https://ci.viaversion.com/");
|
||||
getLogger().severe("VIABACKWARDS WILL NOW DISABLE");
|
||||
getLogger().severe("================================");
|
||||
|
||||
disable();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean isOutdatedPostLoad() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -36,6 +36,7 @@ public class BackwardsMappings extends MappingDataBase {
|
||||
private final Class<? extends Protocol> vvProtocolClass;
|
||||
private Int2ObjectMap<MappedItem> backwardsItemMappings;
|
||||
private Map<String, String> backwardsSoundMappings;
|
||||
private Map<String, String> entityNames;
|
||||
|
||||
public BackwardsMappings(String oldVersion, String newVersion, @Nullable Class<? extends Protocol> vvProtocolClass) {
|
||||
this(oldVersion, newVersion, vvProtocolClass, false);
|
||||
@@ -50,7 +51,7 @@ public class BackwardsMappings extends MappingDataBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadExtras(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings) {
|
||||
protected final void loadExtras(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings) {
|
||||
if (diffMappings != null) {
|
||||
JsonObject diffItems = diffMappings.getAsJsonObject("items");
|
||||
if (diffItems != null) {
|
||||
@@ -60,7 +61,12 @@ public class BackwardsMappings extends MappingDataBase {
|
||||
|
||||
JsonObject diffSounds = diffMappings.getAsJsonObject("sounds");
|
||||
if (diffSounds != null) {
|
||||
backwardsSoundMappings = VBMappingDataLoader.objectToMap(diffSounds);
|
||||
backwardsSoundMappings = VBMappingDataLoader.objectToNamespacedMap(diffSounds);
|
||||
}
|
||||
|
||||
JsonObject diffEntityNames = diffMappings.getAsJsonObject("entitynames");
|
||||
if (diffEntityNames != null) {
|
||||
entityNames = VBMappingDataLoader.objectToMap(diffEntityNames);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +83,8 @@ public class BackwardsMappings extends MappingDataBase {
|
||||
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
|
||||
|
||||
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
|
||||
return new VBMappings(oldMappings.getAsJsonArray(key), newMappings.getAsJsonArray(key), diff, shouldWarnOnMissing(key));
|
||||
return VBMappings.vbBuilder().unmapped(oldMappings.getAsJsonArray(key)).mapped(newMappings.getAsJsonArray(key))
|
||||
.diffMappings(diff).warnOnMissing(shouldWarnOnMissing(key)).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,7 +92,8 @@ public class BackwardsMappings extends MappingDataBase {
|
||||
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
|
||||
|
||||
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
|
||||
return new VBMappings(oldMappings.getAsJsonObject(key), newMappings.getAsJsonObject(key), diff, shouldWarnOnMissing(key));
|
||||
return VBMappings.vbBuilder().unmapped(oldMappings.getAsJsonObject(key)).mapped(newMappings.getAsJsonObject(key))
|
||||
.diffMappings(diff).warnOnMissing(shouldWarnOnMissing(key)).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,7 +108,7 @@ public class BackwardsMappings extends MappingDataBase {
|
||||
}
|
||||
|
||||
protected boolean shouldWarnOnMissing(String key) {
|
||||
return !key.equals("blocks") && !key.equals("statistics");
|
||||
return !key.equals("blocks") && !key.equals("statistics") && !key.equals("entities");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,7 +142,7 @@ public class BackwardsMappings extends MappingDataBase {
|
||||
}
|
||||
|
||||
public @Nullable String getMappedNamedSound(String id) {
|
||||
if (backwardsItemMappings == null) {
|
||||
if (backwardsSoundMappings == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -145,6 +153,15 @@ public class BackwardsMappings extends MappingDataBase {
|
||||
return backwardsSoundMappings.get(id);
|
||||
}
|
||||
|
||||
public @Nullable String mappedEntityName(String entityName) {
|
||||
if (entityNames == null) {
|
||||
ViaBackwards.getPlatform().getLogger().severe("No entity mappings found when requesting them for " + entityName);
|
||||
new Exception().printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return entityNames.get(entityName);
|
||||
}
|
||||
|
||||
public @Nullable Int2ObjectMap<MappedItem> getBackwardsItemMappings() {
|
||||
return backwardsItemMappings;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+26
-21
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -29,6 +29,7 @@ import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.gson.JsonPrimitive;
|
||||
import com.viaversion.viaversion.libs.gson.JsonSyntaxException;
|
||||
import com.viaversion.viaversion.util.GsonUtil;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
@@ -38,7 +39,7 @@ import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class VBMappingDataLoader {
|
||||
public final class VBMappingDataLoader {
|
||||
|
||||
public static JsonObject loadFromDataDir(String name) {
|
||||
File file = new File(ViaBackwards.getPlatform().getDataFolder(), name);
|
||||
@@ -58,22 +59,22 @@ public class VBMappingDataLoader {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static @Nullable InputStream getResource(String name) {
|
||||
return VBMappingDataLoader.class.getClassLoader().getResourceAsStream("assets/viabackwards/data/" + name);
|
||||
}
|
||||
|
||||
public static JsonObject loadData(String name) {
|
||||
InputStream stream = VBMappingDataLoader.class.getClassLoader().getResourceAsStream("assets/viabackwards/data/" + name);
|
||||
try (InputStreamReader reader = new InputStreamReader(stream)) {
|
||||
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
|
||||
try (InputStream stream = getResource(name)) {
|
||||
if (stream == null) return null;
|
||||
return GsonUtil.getGson().fromJson(new InputStreamReader(stream), JsonObject.class);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers) {
|
||||
mapIdentifiers(output, oldIdentifiers, newIdentifiers, diffIdentifiers, true);
|
||||
}
|
||||
|
||||
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers, boolean warnOnMissing) {
|
||||
Object2IntMap newIdentifierMap = MappingDataLoader.indexedObjectToMap(newIdentifiers);
|
||||
Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(newIdentifiers);
|
||||
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
|
||||
String key = entry.getValue().getAsString();
|
||||
int mappedId = newIdentifierMap.getInt(key);
|
||||
@@ -113,8 +114,8 @@ public class VBMappingDataLoader {
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, String> objectToMap(JsonObject object) {
|
||||
Map<String, String> mappings = new HashMap<>();
|
||||
public static Map<String, String> objectToNamespacedMap(JsonObject object) {
|
||||
Map<String, String> mappings = new HashMap<>(object.size());
|
||||
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (key.indexOf(':') == -1) {
|
||||
@@ -129,18 +130,22 @@ public class VBMappingDataLoader {
|
||||
return mappings;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<MappedItem> loadItemMappings(JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping) {
|
||||
return loadItemMappings(oldMapping, newMapping, diffMapping, false);
|
||||
public static Map<String, String> objectToMap(JsonObject object) {
|
||||
Map<String, String> mappings = new HashMap<>(object.size());
|
||||
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
mappings.put(entry.getKey(), entry.getValue().getAsString());
|
||||
}
|
||||
return mappings;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<MappedItem> loadItemMappings(JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) {
|
||||
Int2ObjectMap<MappedItem> itemMapping = new Int2ObjectOpenHashMap<>(diffMapping.size(), 1F);
|
||||
Object2IntMap<String> newIdenfierMap = MappingDataLoader.indexedObjectToMap(newMapping);
|
||||
Object2IntMap<String> oldIdenfierMap = MappingDataLoader.indexedObjectToMap(oldMapping);
|
||||
Int2ObjectMap<MappedItem> itemMapping = new Int2ObjectOpenHashMap<>(diffMapping.size(), 0.99F);
|
||||
Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(newMapping);
|
||||
Object2IntMap<String> oldIdentifierMap = MappingDataLoader.indexedObjectToMap(oldMapping);
|
||||
for (Map.Entry<String, JsonElement> entry : diffMapping.entrySet()) {
|
||||
JsonObject object = entry.getValue().getAsJsonObject();
|
||||
String mappedIdName = object.getAsJsonPrimitive("id").getAsString();
|
||||
int mappedId = newIdenfierMap.getInt(mappedIdName);
|
||||
int mappedId = newIdentifierMap.getInt(mappedIdName);
|
||||
if (mappedId == -1) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No key for " + mappedIdName + " :( ");
|
||||
@@ -148,7 +153,7 @@ public class VBMappingDataLoader {
|
||||
continue;
|
||||
}
|
||||
|
||||
int oldId = oldIdenfierMap.getInt(entry.getKey());
|
||||
int oldId = oldIdentifierMap.getInt(entry.getKey());
|
||||
if (oldId == -1) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No old entry for " + mappedIdName + " :( ");
|
||||
@@ -162,8 +167,8 @@ public class VBMappingDataLoader {
|
||||
|
||||
// Look for missing keys
|
||||
if (warnOnMissing && !Via.getConfig().isSuppressConversionWarnings()) {
|
||||
for (Object2IntMap.Entry<String> entry : oldIdenfierMap.object2IntEntrySet()) {
|
||||
if (!newIdenfierMap.containsKey(entry.getKey()) && !itemMapping.containsKey(entry.getIntValue())) {
|
||||
for (Object2IntMap.Entry<String> entry : oldIdentifierMap.object2IntEntrySet()) {
|
||||
if (!newIdentifierMap.containsKey(entry.getKey()) && !itemMapping.containsKey(entry.getIntValue())) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No item mapping for " + entry.getKey() + " :( ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -18,33 +18,47 @@
|
||||
package com.viaversion.viabackwards.api.data;
|
||||
|
||||
import com.viaversion.viaversion.api.data.IntArrayMappings;
|
||||
import com.viaversion.viaversion.libs.gson.JsonArray;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||
import com.viaversion.viaversion.api.data.Mappings;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class VBMappings extends IntArrayMappings {
|
||||
public final class VBMappings extends IntArrayMappings {
|
||||
|
||||
public VBMappings(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) {
|
||||
super(create(size, oldMapping, newMapping, diffMapping, warnOnMissing));
|
||||
private VBMappings(final int[] oldToNew, final int mappedIds) {
|
||||
super(oldToNew, mappedIds);
|
||||
}
|
||||
|
||||
public VBMappings(JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) {
|
||||
super(create(oldMapping.entrySet().size(), oldMapping, newMapping, diffMapping, warnOnMissing));
|
||||
public static Mappings.Builder<VBMappings> vbBuilder() {
|
||||
return new Builder(VBMappings::new);
|
||||
}
|
||||
|
||||
public VBMappings(JsonObject oldMapping, JsonObject newMapping, boolean warnOnMissing) {
|
||||
this(oldMapping, newMapping, null, warnOnMissing);
|
||||
}
|
||||
public static final class Builder extends Mappings.Builder<VBMappings> {
|
||||
|
||||
public VBMappings(JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping, boolean warnOnMissing) {
|
||||
super(oldMapping.size(), oldMapping, newMapping, diffMapping, warnOnMissing);
|
||||
}
|
||||
private Builder(final MappingsSupplier<VBMappings> supplier) {
|
||||
super(supplier);
|
||||
}
|
||||
|
||||
private static int[] create(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) {
|
||||
int[] oldToNew = new int[size];
|
||||
Arrays.fill(oldToNew, -1);
|
||||
VBMappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping, warnOnMissing);
|
||||
return oldToNew;
|
||||
@Override
|
||||
public VBMappings build() {
|
||||
final int size = this.size != -1 ? this.size : size(unmapped);
|
||||
final int mappedSize = this.mappedSize != -1 ? this.mappedSize : size(mapped);
|
||||
final int[] mappings = new int[size];
|
||||
Arrays.fill(mappings, -1);
|
||||
// Do conversion if one is an array and the other an object, otherwise directly map
|
||||
if (unmapped.isJsonArray()) {
|
||||
if (mapped.isJsonObject()) {
|
||||
VBMappingDataLoader.mapIdentifiers(mappings, toJsonObject(unmapped.getAsJsonArray()), mapped.getAsJsonObject(), diffMappings, warnOnMissing);
|
||||
} else {
|
||||
// Use the normal loader
|
||||
MappingDataLoader.mapIdentifiers(mappings, unmapped.getAsJsonArray(), mapped.getAsJsonArray(), diffMappings, warnOnMissing);
|
||||
}
|
||||
} else if (mapped.isJsonArray()) {
|
||||
VBMappingDataLoader.mapIdentifiers(mappings, unmapped.getAsJsonObject(), toJsonObject(mapped.getAsJsonArray()), diffMappings, warnOnMissing);
|
||||
} else {
|
||||
VBMappingDataLoader.mapIdentifiers(mappings, unmapped.getAsJsonObject(), mapped.getAsJsonObject(), diffMappings, warnOnMissing);
|
||||
}
|
||||
return supplier.supply(mappings, mappedSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
+39
-11
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -18,27 +18,40 @@
|
||||
|
||||
package com.viaversion.viabackwards.api.entities.storage;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class EntityData {
|
||||
private final BackwardsProtocol<?, ?, ?, ?> protocol;
|
||||
private final int id;
|
||||
private final int replacementId;
|
||||
private Object mobName;
|
||||
private final String key;
|
||||
private NameVisibility nameVisibility = NameVisibility.NONE;
|
||||
private MetaCreator defaultMeta;
|
||||
|
||||
public EntityData(int id, int replacementId) {
|
||||
this.id = id;
|
||||
this.replacementId = replacementId;
|
||||
public EntityData(BackwardsProtocol<?, ?, ?, ?> protocol, EntityType type, int replacementId) {
|
||||
this(protocol, type.name(), type.getId(), replacementId);
|
||||
}
|
||||
|
||||
public EntityData jsonName(String name) {
|
||||
this.mobName = ChatRewriter.legacyTextToJson(name);
|
||||
public EntityData(BackwardsProtocol<?, ?, ?, ?> protocol, String key, int id, int replacementId) {
|
||||
this.protocol = protocol;
|
||||
this.id = id;
|
||||
this.replacementId = replacementId;
|
||||
this.key = key.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
public EntityData jsonName() {
|
||||
this.nameVisibility = NameVisibility.JSON;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityData mobName(String name) {
|
||||
this.mobName = name;
|
||||
public EntityData plainName() {
|
||||
this.nameVisibility = NameVisibility.PLAIN;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -59,7 +72,16 @@ public class EntityData {
|
||||
* @return custom mobname, can be either a String or a JsonElement
|
||||
*/
|
||||
public @Nullable Object mobName() {
|
||||
return mobName;
|
||||
if (nameVisibility == NameVisibility.NONE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String name = protocol.getMappingData().mappedEntityName(key);
|
||||
if (name == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Entity name for " + key + " not found in protocol " + protocol.getClass().getSimpleName());
|
||||
name = key;
|
||||
}
|
||||
return nameVisibility == NameVisibility.JSON ? ChatRewriter.legacyTextToJson(name) : name;
|
||||
}
|
||||
|
||||
public int replacementId() {
|
||||
@@ -82,7 +104,7 @@ public class EntityData {
|
||||
public String toString() {
|
||||
return "EntityData{" +
|
||||
"id=" + id +
|
||||
", mobName='" + mobName + '\'' +
|
||||
", mobName='" + key + '\'' +
|
||||
", replacementId=" + replacementId +
|
||||
", defaultMeta=" + defaultMeta +
|
||||
'}';
|
||||
@@ -93,4 +115,10 @@ public class EntityData {
|
||||
|
||||
void createMeta(WrappedMetadata storage);
|
||||
}
|
||||
|
||||
private enum NameVisibility {
|
||||
PLAIN,
|
||||
JSON,
|
||||
NONE
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -17,19 +17,19 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.api.entities.storage;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
|
||||
public class EntityObjectData extends EntityData {
|
||||
private final boolean isObject;
|
||||
private final int objectData;
|
||||
|
||||
public EntityObjectData(int id, boolean isObject, int replacementId, int objectData) {
|
||||
super(id, replacementId);
|
||||
this.isObject = isObject;
|
||||
public EntityObjectData(BackwardsProtocol<?, ?, ?, ?> protocol, String key, int id, int replacementId, int objectData) {
|
||||
super(protocol, key, id, replacementId);
|
||||
this.objectData = objectData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isObjectType() {
|
||||
return isObject;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+11
-6
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -63,14 +63,19 @@ public class EntityPositionHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPositionStorage positionStorage = create ? storageSupplier.get() : storedEntity.get(storageClass);
|
||||
if (positionStorage == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing " + storageClass.getSimpleName());
|
||||
return;
|
||||
EntityPositionStorage positionStorage;
|
||||
if (create) {
|
||||
positionStorage = storageSupplier.get();
|
||||
storedEntity.put(positionStorage);
|
||||
} else {
|
||||
positionStorage = storedEntity.get(storageClass);
|
||||
if (positionStorage == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing " + storageClass.getSimpleName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
positionStorage.setCoordinates(x, y, z, relative);
|
||||
storedEntity.put(positionStorage);
|
||||
}
|
||||
|
||||
public EntityPositionStorage getStorage(UserConnection user, int entityId) {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -87,10 +87,10 @@ public class EnchantmentRewriter {
|
||||
Iterator<Tag> iterator = enchantments.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
CompoundTag enchantmentEntry = (CompoundTag) iterator.next();
|
||||
StringTag idTag = enchantmentEntry.get("id");
|
||||
if (idTag == null) continue;
|
||||
Tag idTag = enchantmentEntry.get("id");
|
||||
if (!(idTag instanceof StringTag)) continue;
|
||||
|
||||
String enchantmentId = idTag.getValue();
|
||||
String enchantmentId = ((StringTag) idTag).getValue();
|
||||
String remappedName = enchantmentMappings.get(enchantmentId);
|
||||
if (remappedName != null) {
|
||||
if (!changed) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -18,19 +18,20 @@
|
||||
package com.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_14;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||
|
||||
public abstract class EntityRewriter<T extends BackwardsProtocol> extends EntityRewriterBase<T> {
|
||||
|
||||
protected EntityRewriter(T protocol) {
|
||||
this(protocol, MetaType1_14.OptChat, MetaType1_14.Boolean);
|
||||
this(protocol, Types1_14.META_TYPES.optionalComponentType, Types1_14.META_TYPES.booleanType);
|
||||
}
|
||||
|
||||
protected EntityRewriter(T protocol, MetaType displayType, MetaType displayVisibilityType) {
|
||||
@@ -67,6 +68,17 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Entity
|
||||
};
|
||||
}
|
||||
|
||||
public PacketHandler getSpawnTrackerWithDataHandler1_19(EntityType fallingBlockType) {
|
||||
return wrapper -> {
|
||||
// Check against the UNMAPPED entity type
|
||||
EntityType entityType = setOldEntityId(wrapper);
|
||||
if (entityType == fallingBlockType) {
|
||||
int blockState = wrapper.get(Type.VAR_INT, 2);
|
||||
wrapper.set(Type.VAR_INT, 2, protocol.getMappingData().getNewBlockStateId(blockState));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void registerSpawnTracker(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
@@ -79,7 +91,25 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Entity
|
||||
});
|
||||
}
|
||||
|
||||
private EntityType setOldEntityId(PacketWrapper wrapper) throws Exception {
|
||||
public PacketHandler worldTrackerHandlerByKey() {
|
||||
return wrapper -> {
|
||||
EntityTracker tracker = tracker(wrapper.user());
|
||||
String world = wrapper.get(Type.STRING, 1);
|
||||
if (tracker.currentWorld() != null && !tracker.currentWorld().equals(world)) {
|
||||
tracker.clearEntities();
|
||||
tracker.trackClientEntity();
|
||||
}
|
||||
tracker.setCurrentWorld(world);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the mapped entity id and returns the unmapped entity type.
|
||||
*
|
||||
* @param wrapper packet wrapper
|
||||
* @return unmapped (!) entity type
|
||||
*/
|
||||
protected EntityType setOldEntityId(PacketWrapper wrapper) throws Exception {
|
||||
int typeId = wrapper.get(Type.VAR_INT, 1);
|
||||
EntityType entityType = typeFromId(typeId);
|
||||
tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), entityType);
|
||||
|
||||
+14
-15
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -23,13 +23,13 @@ import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityData;
|
||||
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.Int2IntMapMappings;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
@@ -67,7 +67,9 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends En
|
||||
super.handleMetadata(entityId, metadataList, connection);
|
||||
|
||||
EntityType type = tracker(connection).entityType(entityId);
|
||||
if (type == null) return;
|
||||
if (type == null) {
|
||||
return; // Don't handle untracked entities - basically always the fault of a plugin sending virtual entities through concurrency-unsafe handling
|
||||
}
|
||||
|
||||
EntityData entityData = entityDataForType(type);
|
||||
|
||||
@@ -84,11 +86,9 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends En
|
||||
}
|
||||
|
||||
// Add any other extra meta for mapped entities
|
||||
if (entityData != null) {
|
||||
//TODO only do this once for a first meta packet?
|
||||
if (entityData != null && entityData.hasBaseMeta()) {
|
||||
entityData.defaultMeta().createMeta(new WrappedMetadata(metadataList));
|
||||
}
|
||||
//TODO only do this once for a first meta packet?
|
||||
if (entityData != null && entityData.hasBaseMeta()) {
|
||||
entityData.defaultMeta().createMeta(new WrappedMetadata(metadataList));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends En
|
||||
|
||||
// Already rewrite the id here
|
||||
int mappedReplacementId = newEntityId(mappedType.getId());
|
||||
EntityData data = new EntityData(type.getId(), mappedReplacementId);
|
||||
EntityData data = new EntityData(protocol, type, mappedReplacementId);
|
||||
mapEntityType(type.getId(), mappedReplacementId);
|
||||
entityDataMappings.put(type.getId(), data);
|
||||
return data;
|
||||
@@ -147,13 +147,12 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends En
|
||||
@Override
|
||||
public <E extends Enum<E> & EntityType> void mapTypes(EntityType[] oldTypes, Class<E> newTypeClass) {
|
||||
if (typeMappings == null) {
|
||||
typeMappings = new Int2IntOpenHashMap(oldTypes.length, 1F);
|
||||
typeMappings.defaultReturnValue(-1);
|
||||
typeMappings = Int2IntMapMappings.of();
|
||||
}
|
||||
for (EntityType oldType : oldTypes) {
|
||||
try {
|
||||
E newType = Enum.valueOf(newTypeClass, oldType.name());
|
||||
typeMappings.put(oldType.getId(), newType.getId());
|
||||
typeMappings.setNewId(oldType.getId(), newType.getId());
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
// Don't warn
|
||||
}
|
||||
@@ -180,9 +179,9 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends En
|
||||
}
|
||||
|
||||
// ONLY TRACKS, DOESN'T REWRITE IDS
|
||||
protected PacketHandler getTrackerHandler(Type intType, int typeIndex) {
|
||||
protected PacketHandler getTrackerHandler(Type<? extends Number> intType, int typeIndex) {
|
||||
return wrapper -> {
|
||||
Number id = (Number) wrapper.get(intType, typeIndex);
|
||||
Number id = wrapper.get(intType, typeIndex);
|
||||
tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), typeFromId(id.intValue()));
|
||||
};
|
||||
}
|
||||
@@ -191,7 +190,7 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends En
|
||||
return getTrackerHandler(Type.VAR_INT, 1);
|
||||
}
|
||||
|
||||
protected PacketHandler getTrackerHandler(EntityType entityType, Type intType) {
|
||||
protected PacketHandler getTrackerHandler(EntityType entityType, Type<? extends Number> intType) {
|
||||
return wrapper -> tracker(wrapper.user()).addEntity((int) wrapper.get(intType, 0), entityType);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -20,6 +20,10 @@ package com.viaversion.viabackwards.api.rewriters;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.MappedItem;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
@@ -30,11 +34,8 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewriterBase<T> {
|
||||
|
||||
private final TranslatableRewriter translatableRewriter;
|
||||
|
||||
protected ItemRewriter(T protocol, @Nullable TranslatableRewriter translatableRewriter) {
|
||||
protected ItemRewriter(T protocol) {
|
||||
super(protocol, true);
|
||||
this.translatableRewriter = translatableRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -42,11 +43,11 @@ public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewr
|
||||
if (item == null) return null;
|
||||
|
||||
CompoundTag display = item.tag() != null ? item.tag().get("display") : null;
|
||||
if (translatableRewriter != null && display != null) {
|
||||
if (protocol.getTranslatableRewriter() != null && display != null) {
|
||||
// Handle name and lore components
|
||||
StringTag name = display.get("Name");
|
||||
if (name != null) {
|
||||
String newValue = translatableRewriter.processText(name.getValue()).toString();
|
||||
String newValue = protocol.getTranslatableRewriter().processText(name.getValue()).toString();
|
||||
if (!newValue.equals(name.getValue())) {
|
||||
saveStringTag(display, name, "Name");
|
||||
}
|
||||
@@ -61,7 +62,7 @@ public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewr
|
||||
if (!(loreEntryTag instanceof StringTag)) continue;
|
||||
|
||||
StringTag loreEntry = (StringTag) loreEntryTag;
|
||||
String newValue = translatableRewriter.processText(loreEntry.getValue()).toString();
|
||||
String newValue = protocol.getTranslatableRewriter().processText(loreEntry.getValue()).toString();
|
||||
if (!changed && !newValue.equals(loreEntry.getValue())) {
|
||||
// Backup original lore before doing any modifications
|
||||
changed = true;
|
||||
@@ -111,4 +112,52 @@ public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewr
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAdvancements(ClientboundPacketType packetType, Type<Item> type) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
final int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Identifier
|
||||
|
||||
// Parent
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
}
|
||||
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
final JsonElement title = wrapper.passthrough(Type.COMPONENT);
|
||||
final JsonElement description = wrapper.passthrough(Type.COMPONENT);
|
||||
final TranslatableRewriter translatableRewriter = protocol.getTranslatableRewriter();
|
||||
if (translatableRewriter != null) {
|
||||
translatableRewriter.processText(title);
|
||||
translatableRewriter.processText(description);
|
||||
}
|
||||
|
||||
handleItemToClient(wrapper.passthrough(type)); // Icon
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0) {
|
||||
wrapper.passthrough(Type.STRING); // Background texture
|
||||
}
|
||||
wrapper.passthrough(Type.FLOAT); // X
|
||||
wrapper.passthrough(Type.FLOAT); // Y
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
|
||||
|
||||
final int arrayLength = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int array = 0; array < arrayLength; array++) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+3
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -174,6 +174,8 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
||||
tags.put(pos, tag);
|
||||
|
||||
// Handle given Block Entities
|
||||
if (pos.getY() < 0 || pos.getY() > 255) continue; // 1.17
|
||||
|
||||
ChunkSection section = chunk.getSections()[pos.getY() >> 4];
|
||||
if (section == null) continue;
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -52,7 +52,7 @@ public abstract class LegacyEntityRewriter<T extends BackwardsProtocol> extends
|
||||
}
|
||||
|
||||
protected EntityObjectData mapObjectType(ObjectType oldObjectType, ObjectType replacement, int data) {
|
||||
EntityObjectData entData = new EntityObjectData(oldObjectType.getId(), true, replacement.getId(), data);
|
||||
EntityObjectData entData = new EntityObjectData(protocol, oldObjectType.getType().name(), oldObjectType.getId(), replacement.getId(), data);
|
||||
objectTypes.put(oldObjectType, entData);
|
||||
return entData;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+12
-10
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -80,15 +80,6 @@ public class TranslatableRewriter extends ComponentRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void registerChatMessage(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerLegacyOpenWindow(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
@@ -123,6 +114,17 @@ public class TranslatableRewriter extends ComponentRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void registerCombatKill(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.INT);
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject root, String translate) {
|
||||
String newTranslate = newTranslatables.get(translate);
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -22,7 +22,7 @@ import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||
|
||||
public class PotionSplashHandler {
|
||||
|
||||
private static final Int2IntMap DATA = new Int2IntOpenHashMap(14, 1F);
|
||||
private static final Int2IntMap DATA = new Int2IntOpenHashMap(14, 0.99F);
|
||||
|
||||
static {
|
||||
DATA.defaultReturnValue(-1);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -62,7 +62,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SET_SLOT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE); // 0 - Window ID
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot ID
|
||||
map(Type.ITEM); // 2 - Slot Value
|
||||
|
||||
|
||||
+8
-8
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -215,10 +215,10 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<Protocol1_10To1_11>
|
||||
// Guardian
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.ELDER_GUARDIAN, Entity1_11Types.EntityType.GUARDIAN);
|
||||
// Skeletons
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.WITHER_SKELETON, Entity1_11Types.EntityType.SKELETON).mobName("Wither Skeleton").spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(1)));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.STRAY, Entity1_11Types.EntityType.SKELETON).mobName("Stray").spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(2)));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.WITHER_SKELETON, Entity1_11Types.EntityType.SKELETON).spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(1)));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.STRAY, Entity1_11Types.EntityType.SKELETON).plainName().spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(2)));
|
||||
// Zombies
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.HUSK, Entity1_11Types.EntityType.ZOMBIE).mobName("Husk").spawnMetadata(storage -> handleZombieType(storage, 6));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.HUSK, Entity1_11Types.EntityType.ZOMBIE).plainName().spawnMetadata(storage -> handleZombieType(storage, 6));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.ZOMBIE_VILLAGER, Entity1_11Types.EntityType.ZOMBIE).spawnMetadata(storage -> handleZombieType(storage, 1));
|
||||
// Horses
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(0))); // Nob able to ride the horse without having the MetaType sent.
|
||||
@@ -228,10 +228,10 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<Protocol1_10To1_11>
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.ZOMBIE_HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(3)));
|
||||
// New mobs
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.EVOCATION_FANGS, Entity1_11Types.EntityType.SHULKER);
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.EVOCATION_ILLAGER, Entity1_11Types.EntityType.VILLAGER).mobName("Evoker");
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.VEX, Entity1_11Types.EntityType.BAT).mobName("Vex");
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.VINDICATION_ILLAGER, Entity1_11Types.EntityType.VILLAGER).mobName("Vindicator").spawnMetadata(storage -> storage.add(new Metadata(13, MetaType1_9.VarInt, 4))); // Base Profession
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.LIAMA, Entity1_11Types.EntityType.HORSE).mobName("Llama").spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.EVOCATION_ILLAGER, Entity1_11Types.EntityType.VILLAGER).plainName();
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.VEX, Entity1_11Types.EntityType.BAT).plainName();
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.VINDICATION_ILLAGER, Entity1_11Types.EntityType.VILLAGER).plainName().spawnMetadata(storage -> storage.add(new Metadata(13, MetaType1_9.VarInt, 4))); // Base Profession
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.LIAMA, Entity1_11Types.EntityType.HORSE).plainName().spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.LIAMA_SPIT, Entity1_11Types.EntityType.SNOWBALL);
|
||||
|
||||
mapObjectType(Entity1_11Types.ObjectType.LIAMA_SPIT, Entity1_11Types.ObjectType.SNOWBALL, -1);
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -34,7 +34,7 @@ public class PlayerPackets1_11 {
|
||||
private static final ValueTransformer<Short, Float> TO_NEW_FLOAT = new ValueTransformer<Short, Float>(Type.FLOAT) {
|
||||
@Override
|
||||
public Float transform(PacketWrapper wrapper, Short inputValue) throws Exception {
|
||||
return inputValue / 15f;
|
||||
return inputValue / 16f;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+18
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -19,6 +19,7 @@
|
||||
package com.viaversion.viabackwards.protocol.protocol1_11_1to1_12;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappings;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.ShoulderTracker;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.BlockItemPackets1_12;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.ChatPackets1_12;
|
||||
@@ -39,6 +40,12 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
|
||||
public class Protocol1_11_1To1_12 extends BackwardsProtocol<ClientboundPackets1_12, ClientboundPackets1_9_3, ServerboundPackets1_12, ServerboundPackets1_9_3> {
|
||||
|
||||
private static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.12", "1.11", null, true) {
|
||||
@Override
|
||||
protected boolean shouldWarnOnMissing(final String key) {
|
||||
return super.shouldWarnOnMissing(key) && !key.equals("sounds");
|
||||
}
|
||||
};
|
||||
private final EntityPackets1_12 entityPackets = new EntityPackets1_12(this);
|
||||
private final BlockItemPackets1_12 blockItemPackets = new BlockItemPackets1_12(this);
|
||||
|
||||
@@ -83,6 +90,11 @@ public class Protocol1_11_1To1_12 extends BackwardsProtocol<ClientboundPackets1_
|
||||
user.put(new ShoulderTracker(user));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappings getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPackets1_12 getEntityRewriter() {
|
||||
return entityPackets;
|
||||
@@ -92,4 +104,9 @@ public class Protocol1_11_1To1_12 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public BlockItemPackets1_12 getItemRewriter() {
|
||||
return blockItemPackets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMappingDataToLoad() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -21,7 +21,7 @@ import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||
|
||||
public class MapColorMapping {
|
||||
private static final Int2IntMap MAPPING = new Int2IntOpenHashMap(64, 1F);
|
||||
private static final Int2IntMap MAPPING = new Int2IntOpenHashMap(64, 0.99F);
|
||||
|
||||
static {
|
||||
MAPPING.defaultReturnValue(-1);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -145,7 +145,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
|
||||
// Apologize (may happen in some cases, maybe if inventory is full?)
|
||||
PacketWrapper confirm = wrapper.create(ServerboundPackets1_12.WINDOW_CONFIRMATION);
|
||||
confirm.write(Type.BYTE, wrapper.get(Type.UNSIGNED_BYTE, 0).byteValue());
|
||||
confirm.write(Type.UNSIGNED_BYTE, wrapper.get(Type.UNSIGNED_BYTE, 0));
|
||||
confirm.write(Type.SHORT, wrapper.get(Type.SHORT, 1));
|
||||
confirm.write(Type.BOOLEAN, false); // Success - not used
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -212,8 +212,8 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<Protocol1_11_1To1_12
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
mapEntityTypeWithData(Entity1_12Types.EntityType.PARROT, Entity1_12Types.EntityType.BAT).mobName("Parrot").spawnMetadata(storage -> storage.add(new Metadata(12, MetaType1_12.Byte, (byte) 0x00)));
|
||||
mapEntityTypeWithData(Entity1_12Types.EntityType.ILLUSION_ILLAGER, Entity1_12Types.EntityType.EVOCATION_ILLAGER).mobName("Illusioner");
|
||||
mapEntityTypeWithData(Entity1_12Types.EntityType.PARROT, Entity1_12Types.EntityType.BAT).plainName().spawnMetadata(storage -> storage.add(new Metadata(12, MetaType1_12.Byte, (byte) 0x00)));
|
||||
mapEntityTypeWithData(Entity1_12Types.EntityType.ILLUSION_ILLAGER, Entity1_12Types.EntityType.EVOCATION_ILLAGER).plainName();
|
||||
|
||||
// Handle Illager
|
||||
filter().filterFamily(Entity1_12Types.EntityType.EVOCATION_ILLAGER).cancel(12);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -73,7 +73,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
};
|
||||
translatableRewriter.registerPing();
|
||||
translatableRewriter.registerBossBar(ClientboundPackets1_13.BOSSBAR);
|
||||
translatableRewriter.registerChatMessage(ClientboundPackets1_13.CHAT_MESSAGE);
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT_MESSAGE);
|
||||
translatableRewriter.registerLegacyOpenWindow(ClientboundPackets1_13.OPEN_WINDOW);
|
||||
translatableRewriter.registerDisconnect(ClientboundPackets1_13.DISCONNECT);
|
||||
translatableRewriter.registerCombatEvent(ClientboundPackets1_13.COMBAT_EVENT);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -29,7 +29,7 @@ import com.viaversion.viaversion.util.Pair;
|
||||
|
||||
public class FlowerPotHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||
|
||||
private static final Int2ObjectMap<Pair<String, Byte>> FLOWERS = new Int2ObjectOpenHashMap<>(22, 1F);
|
||||
private static final Int2ObjectMap<Pair<String, Byte>> FLOWERS = new Int2ObjectOpenHashMap<>(22, 0.99F);
|
||||
private static final Pair<String, Byte> AIR = new Pair<>("minecraft:air", (byte) 0);
|
||||
|
||||
static {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+5
-9
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -41,7 +41,6 @@ import java.util.Map;
|
||||
public class BackwardsMappings extends com.viaversion.viabackwards.api.data.BackwardsMappings {
|
||||
private final Int2ObjectMap<String> statisticMappings = new Int2ObjectOpenHashMap<>();
|
||||
private final Map<String, String> translateMappings = new HashMap<>();
|
||||
private Mappings enchantmentMappings;
|
||||
|
||||
public BackwardsMappings() {
|
||||
super("1.13", "1.12", Protocol1_13To1_12_2.class, true);
|
||||
@@ -49,7 +48,8 @@ public class BackwardsMappings extends com.viaversion.viabackwards.api.data.Back
|
||||
|
||||
@Override
|
||||
public void loadVBExtras(JsonObject oldMappings, JsonObject newMappings) {
|
||||
enchantmentMappings = new VBMappings(oldMappings.getAsJsonObject("enchantments"), newMappings.getAsJsonObject("enchantments"), false);
|
||||
enchantmentMappings = VBMappings.vbBuilder().warnOnMissing(false)
|
||||
.unmapped(oldMappings.getAsJsonArray("enchantments")).mapped(newMappings.getAsJsonObject("legacy_enchantments")).build();
|
||||
for (Map.Entry<String, Integer> entry : StatisticMappings.CUSTOM_STATS.entrySet()) {
|
||||
statisticMappings.put(entry.getValue().intValue(), entry.getKey());
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class BackwardsMappings extends com.viaversion.viabackwards.api.data.Back
|
||||
|
||||
// Has lots of compat layers, so we can't use the default Via method
|
||||
private static void mapIdentifiers(int[] output, JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) {
|
||||
Object2IntMap newIdentifierMap = MappingDataLoader.indexedObjectToMap(oldIdentifiers);
|
||||
Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(oldIdentifiers);
|
||||
for (Map.Entry<String, JsonElement> entry : newIdentifiers.entrySet()) {
|
||||
String key = entry.getValue().getAsString();
|
||||
int value = newIdentifierMap.getInt(key);
|
||||
@@ -101,7 +101,7 @@ public class BackwardsMappings extends com.viaversion.viabackwards.api.data.Back
|
||||
int[] oldToNew = new int[8582];
|
||||
Arrays.fill(oldToNew, -1);
|
||||
mapIdentifiers(oldToNew, oldMappings.getAsJsonObject("blockstates"), newMappings.getAsJsonObject("blocks"), diffMappings.getAsJsonObject("blockstates"));
|
||||
return new IntArrayMappings(oldToNew);
|
||||
return IntArrayMappings.of(oldToNew, -1);
|
||||
} else {
|
||||
return super.loadFromObject(oldMappings, newMappings, diffMappings, key);
|
||||
}
|
||||
@@ -144,8 +144,4 @@ public class BackwardsMappings extends com.viaversion.viabackwards.api.data.Back
|
||||
public Map<String, String> getTranslateMappings() {
|
||||
return translateMappings;
|
||||
}
|
||||
|
||||
public Mappings getEnchantmentMappings() {
|
||||
return enchantmentMappings;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -21,7 +21,7 @@ import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public class PaintingMapping {
|
||||
private static final Int2ObjectMap<String> PAINTINGS = new Int2ObjectOpenHashMap<>(26, 1F);
|
||||
private static final Int2ObjectMap<String> PAINTINGS = new Int2ObjectOpenHashMap<>(26, 0.99F);
|
||||
|
||||
public static void init() {
|
||||
add("Kebab");
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+30
-19
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -68,7 +68,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
private final String extraNbtTag;
|
||||
|
||||
public BlockItemPackets1_13(Protocol1_12_2To1_13 protocol) {
|
||||
super(protocol, null);
|
||||
super(protocol);
|
||||
extraNbtTag = "VB|" + protocol.getClass().getSimpleName() + "|2";
|
||||
}
|
||||
|
||||
@@ -91,21 +91,20 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
protocol.registerClientbound(ClientboundPackets1_13.COOLDOWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int itemId = wrapper.read(Type.VAR_INT);
|
||||
int oldId = protocol.getMappingData().getItemMappings().get(itemId);
|
||||
if (oldId != -1) {
|
||||
Optional<String> eggEntityId = SpawnEggRewriter.getEntityId(oldId);
|
||||
if (eggEntityId.isPresent()) {
|
||||
itemId = 383 << 16;
|
||||
} else {
|
||||
itemId = (oldId >> 4) << 16 | oldId & 0xF;
|
||||
}
|
||||
}
|
||||
wrapper.write(Type.VAR_INT, itemId);
|
||||
handler(wrapper -> {
|
||||
int itemId = wrapper.read(Type.VAR_INT);
|
||||
int oldId = protocol.getMappingData().getItemMappings().get(itemId);
|
||||
if (oldId == -1) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (SpawnEggRewriter.getEntityId(oldId).isPresent()) {
|
||||
wrapper.write(Type.VAR_INT, 383 << 4);
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper.write(Type.VAR_INT, oldId >> 4);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -271,7 +270,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SET_SLOT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE);
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
map(Type.SHORT);
|
||||
map(Type.FLAT_ITEM, Type.ITEM);
|
||||
|
||||
@@ -302,6 +301,11 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
if (!provider.isHandled(id)) continue;
|
||||
|
||||
int sectionIndex = ((NumberTag) tag.get("y")).asInt() >> 4;
|
||||
if (sectionIndex < 0 || sectionIndex > 15) {
|
||||
// 1.17 chunks
|
||||
continue;
|
||||
}
|
||||
|
||||
ChunkSection section = chunk.getSections()[sectionIndex];
|
||||
|
||||
int x = ((NumberTag) tag.get("x")).asInt();
|
||||
@@ -649,10 +653,17 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
for (Tag enchantmentEntryTag : enchantments.clone()) {
|
||||
CompoundTag enchantmentEntry = (CompoundTag) enchantmentEntryTag;
|
||||
Tag idTag = enchantmentEntry.get("id");
|
||||
if (!(idTag instanceof StringTag)) continue;
|
||||
if (!(idTag instanceof StringTag)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String newId = (String) idTag.getValue();
|
||||
int levelValue = ((NumberTag) enchantmentEntry.get("lvl")).asInt();
|
||||
NumberTag levelTag = enchantmentEntry.get("lvl");
|
||||
if (levelTag == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int levelValue = levelTag.asInt();
|
||||
short level = levelValue < Short.MAX_VALUE ? (short) levelValue : Short.MAX_VALUE;
|
||||
|
||||
String mappedEnchantmentId = enchantmentMappings.get(newId);
|
||||
|
||||
+9
-10
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -281,25 +281,25 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
// Rewrite new Entity 'drowned'
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.DROWNED, Entity1_13Types.EntityType.ZOMBIE_VILLAGER).mobName("Drowned");
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.DROWNED, Entity1_13Types.EntityType.ZOMBIE_VILLAGER).plainName();
|
||||
|
||||
// Fishy
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.COD, Entity1_13Types.EntityType.SQUID).mobName("Cod");
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.SALMON, Entity1_13Types.EntityType.SQUID).mobName("Salmon");
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.PUFFERFISH, Entity1_13Types.EntityType.SQUID).mobName("Puffer Fish");
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.TROPICAL_FISH, Entity1_13Types.EntityType.SQUID).mobName("Tropical Fish");
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.COD, Entity1_13Types.EntityType.SQUID).plainName();
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.SALMON, Entity1_13Types.EntityType.SQUID).plainName();
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.PUFFERFISH, Entity1_13Types.EntityType.SQUID).plainName();
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.TROPICAL_FISH, Entity1_13Types.EntityType.SQUID).plainName();
|
||||
|
||||
// Phantom
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.PHANTOM, Entity1_13Types.EntityType.PARROT).mobName("Phantom").spawnMetadata(storage -> {
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.PHANTOM, Entity1_13Types.EntityType.PARROT).plainName().spawnMetadata(storage -> {
|
||||
// The phantom is grey/blue so let's do yellow/blue
|
||||
storage.add(new Metadata(15, MetaType1_12.VarInt, 3));
|
||||
});
|
||||
|
||||
// Dolphin
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.DOLPHIN, Entity1_13Types.EntityType.SQUID).mobName("Dolphin");
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.DOLPHIN, Entity1_13Types.EntityType.SQUID).plainName();
|
||||
|
||||
// Turtle
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.TURTLE, Entity1_13Types.EntityType.OCELOT).mobName("Turtle");
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.TURTLE, Entity1_13Types.EntityType.OCELOT).plainName();
|
||||
|
||||
// Rewrite Meta types
|
||||
filter().handler((event, meta) -> {
|
||||
@@ -328,7 +328,6 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13
|
||||
typeId - 1
|
||||
));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Rewrite Custom Name from Chat to String
|
||||
|
||||
+24
-20
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -187,7 +187,7 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
UUID uuid = packetWrapper.passthrough(Type.UUID);
|
||||
if (action == 0) { // Add
|
||||
String name = packetWrapper.passthrough(Type.STRING);
|
||||
storage.usernames.put(uuid, name);
|
||||
storage.usernames().put(uuid, name);
|
||||
int nProperties = packetWrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < nProperties; j++) {
|
||||
packetWrapper.passthrough(Type.STRING);
|
||||
@@ -210,7 +210,7 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
packetWrapper.passthrough(Type.COMPONENT);
|
||||
}
|
||||
} else if (action == 4) { // Remove Player
|
||||
storage.usernames.remove(uuid);
|
||||
storage.usernames().remove(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -313,11 +313,12 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
|
||||
TabCompleteStorage storage = wrapper.user().get(TabCompleteStorage.class);
|
||||
|
||||
if (!storage.commands.isEmpty()) {
|
||||
storage.commands.clear();
|
||||
if (!storage.commands().isEmpty()) {
|
||||
storage.commands().clear();
|
||||
}
|
||||
|
||||
int size = wrapper.read(Type.VAR_INT);
|
||||
boolean initialNodes = true;
|
||||
for (int i = 0; i < size; i++) {
|
||||
byte flags = wrapper.read(Type.BYTE);
|
||||
wrapper.read(Type.VAR_INT_ARRAY_PRIMITIVE); // Children indices
|
||||
@@ -326,11 +327,14 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
}
|
||||
|
||||
byte nodeType = (byte) (flags & 0x03);
|
||||
if (initialNodes && nodeType == 2) {
|
||||
initialNodes = false;
|
||||
}
|
||||
|
||||
if (nodeType == 1 || nodeType == 2) { // Literal/argument node
|
||||
String name = wrapper.read(Type.STRING);
|
||||
|
||||
if (nodeType == 1) {
|
||||
storage.commands.add('/' + name);
|
||||
if (nodeType == 1 && initialNodes) {
|
||||
storage.commands().add('/' + name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,25 +357,25 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
TabCompleteStorage storage = wrapper.user().get(TabCompleteStorage.class);
|
||||
if (storage.lastRequest == null) {
|
||||
if (storage.lastRequest() == null) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
if (storage.lastId != wrapper.read(Type.VAR_INT)) wrapper.cancel();
|
||||
if (storage.lastId() != wrapper.read(Type.VAR_INT)) wrapper.cancel();
|
||||
int start = wrapper.read(Type.VAR_INT);
|
||||
int length = wrapper.read(Type.VAR_INT);
|
||||
|
||||
int lastRequestPartIndex = storage.lastRequest.lastIndexOf(' ') + 1;
|
||||
int lastRequestPartIndex = storage.lastRequest().lastIndexOf(' ') + 1;
|
||||
if (lastRequestPartIndex != start) wrapper.cancel(); // Client only replaces after space
|
||||
|
||||
if (length != storage.lastRequest.length() - lastRequestPartIndex) {
|
||||
if (length != storage.lastRequest().length() - lastRequestPartIndex) {
|
||||
wrapper.cancel(); // We can't set the length in previous versions
|
||||
}
|
||||
|
||||
int count = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < count; i++) {
|
||||
String match = wrapper.read(Type.STRING);
|
||||
wrapper.write(Type.STRING, (start == 0 && !storage.lastAssumeCommand ? "/" : "") + match);
|
||||
wrapper.write(Type.STRING, (start == 0 && !storage.isLastAssumeCommand() ? "/" : "") + match);
|
||||
// Ignore tooltip
|
||||
if (wrapper.read(Type.BOOLEAN)) {
|
||||
wrapper.read(Type.STRING);
|
||||
@@ -396,14 +400,14 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
if (!assumeCommand && !command.startsWith("/")) {
|
||||
// Complete usernames for non-commands
|
||||
String buffer = command.substring(command.lastIndexOf(' ') + 1);
|
||||
for (String value : storage.usernames.values()) {
|
||||
for (String value : storage.usernames().values()) {
|
||||
if (startsWithIgnoreCase(value, buffer)) {
|
||||
suggestions.add(value);
|
||||
}
|
||||
}
|
||||
} else if (!storage.commands.isEmpty() && !command.contains(" ")) {
|
||||
} else if (!storage.commands().isEmpty() && !command.contains(" ")) {
|
||||
// Complete commands names with values from 'Declare Commands' packet
|
||||
for (String value : storage.commands) {
|
||||
for (String value : storage.commands()) {
|
||||
if (startsWithIgnoreCase(value, command)) {
|
||||
suggestions.add(value);
|
||||
}
|
||||
@@ -418,7 +422,7 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
response.write(Type.STRING, value);
|
||||
}
|
||||
response.scheduleSend(Protocol1_12_2To1_13.class);
|
||||
storage.lastRequest = null;
|
||||
storage.setLastRequest(null);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -430,9 +434,9 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
wrapper.write(Type.VAR_INT, id);
|
||||
wrapper.write(Type.STRING, command);
|
||||
|
||||
storage.lastId = id;
|
||||
storage.lastAssumeCommand = assumeCommand;
|
||||
storage.lastRequest = command;
|
||||
storage.setLastId(id);
|
||||
storage.setLastAssumeCommand(assumeCommand);
|
||||
storage.setLastRequest(command);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
+7
-10
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -17,10 +17,8 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.NamedSoundMapping;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
@@ -39,14 +37,13 @@ public class SoundPackets1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.NAMED_SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING);
|
||||
handler(wrapper -> {
|
||||
String newSound = wrapper.get(Type.STRING, 0);
|
||||
String oldSound = NamedSoundMapping.getOldId(newSound);
|
||||
if (oldSound != null || (oldSound = protocol.getMappingData().getMappedNamedSound(newSound)) != null) {
|
||||
wrapper.set(Type.STRING, 0, oldSound);
|
||||
} else if (!Via.getConfig().isSuppressConversionWarnings()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Unknown named sound in 1.13->1.12 protocol: " + newSound);
|
||||
String sound = wrapper.read(Type.STRING);
|
||||
String mappedSound = NamedSoundMapping.getOldId(sound);
|
||||
if (mappedSound != null || (mappedSound = protocol.getMappingData().getMappedNamedSound(sound)) != null) {
|
||||
wrapper.write(Type.STRING, mappedSound);
|
||||
} else {
|
||||
wrapper.write(Type.STRING, sound);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+8
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -33,6 +33,7 @@ import com.viaversion.viaversion.api.platform.providers.Provider;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -67,7 +68,12 @@ public class BackwardsBlockEntityProvider implements Provider {
|
||||
* @param tag The block entity tag
|
||||
*/
|
||||
public CompoundTag transform(UserConnection user, Position position, CompoundTag tag) throws Exception {
|
||||
String id = (String) tag.get("id").getValue();
|
||||
final Tag idTag = tag.get("id");
|
||||
if (!(idTag instanceof StringTag)) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
String id = (String) idTag.getValue();
|
||||
BackwardsBlockEntityHandler handler = handlers.get(id);
|
||||
if (handler == null) {
|
||||
if (Via.getManager().isDebug()) {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+38
-6
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -26,9 +26,41 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TabCompleteStorage implements StorableObject {
|
||||
public int lastId;
|
||||
public String lastRequest;
|
||||
public boolean lastAssumeCommand;
|
||||
public Map<UUID, String> usernames = new HashMap<>();
|
||||
public Set<String> commands = new HashSet<>();
|
||||
private final Map<UUID, String> usernames = new HashMap<>();
|
||||
private final Set<String> commands = new HashSet<>();
|
||||
private int lastId;
|
||||
private String lastRequest;
|
||||
private boolean lastAssumeCommand;
|
||||
|
||||
public Map<UUID, String> usernames() {
|
||||
return usernames;
|
||||
}
|
||||
|
||||
public Set<String> commands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
public int lastId() {
|
||||
return lastId;
|
||||
}
|
||||
|
||||
public void setLastId(final int lastId) {
|
||||
this.lastId = lastId;
|
||||
}
|
||||
|
||||
public String lastRequest() {
|
||||
return lastRequest;
|
||||
}
|
||||
|
||||
public void setLastRequest(String lastRequest) {
|
||||
this.lastRequest = lastRequest;
|
||||
}
|
||||
|
||||
public boolean isLastAssumeCommand() {
|
||||
return lastAssumeCommand;
|
||||
}
|
||||
|
||||
public void setLastAssumeCommand(boolean lastAssumeCommand) {
|
||||
this.lastAssumeCommand = lastAssumeCommand;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+4
-12
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -19,8 +19,6 @@ package com.viaversion.viabackwards.protocol.protocol1_13_1to1_13_2.packets;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_1to1_13_2.Protocol1_13_1To1_13_2;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_13;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_13_2;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
@@ -54,9 +52,7 @@ public class EntityPackets1_13_2 {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (Metadata metadata : wrapper.get(Types1_13.METADATA_LIST, 0)) {
|
||||
if (metadata.metaType() == MetaType1_13_2.Slot) {
|
||||
metadata.setMetaType(MetaType1_13.Slot);
|
||||
}
|
||||
metadata.setMetaType(Types1_13.META_TYPES.byId(metadata.metaType().typeId()));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -79,9 +75,7 @@ public class EntityPackets1_13_2 {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (Metadata metadata : wrapper.get(Types1_13.METADATA_LIST, 0)) {
|
||||
if (metadata.metaType() == MetaType1_13_2.Slot) {
|
||||
metadata.setMetaType(MetaType1_13.Slot);
|
||||
}
|
||||
metadata.setMetaType(Types1_13.META_TYPES.byId(metadata.metaType().typeId()));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -98,9 +92,7 @@ public class EntityPackets1_13_2 {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (Metadata metadata : wrapper.get(Types1_13.METADATA_LIST, 0)) {
|
||||
if (metadata.metaType() == MetaType1_13_2.Slot) {
|
||||
metadata.setMetaType(MetaType1_13.Slot);
|
||||
}
|
||||
metadata.setMetaType(Types1_13.META_TYPES.byId(metadata.metaType().typeId()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -31,7 +31,7 @@ public class InventoryPackets1_13_2 {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SET_SLOT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE); // 0 - Window ID
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot ID
|
||||
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 2 - Slot Value
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
|
||||
+13
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -26,6 +26,7 @@ import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.packets.EntityP
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.packets.PlayerPackets1_14;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.packets.SoundPackets1_14;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.DifficultyStorage;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
@@ -46,6 +47,7 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
|
||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.14", "1.13.2", Protocol1_14To1_13_2.class, true);
|
||||
private final EntityRewriter entityRewriter = new EntityPackets1_14(this);
|
||||
private final TranslatableRewriter translatableRewriter = new TranslatableRewriter(this);
|
||||
private BlockItemPackets1_14 blockItemPackets;
|
||||
|
||||
public Protocol1_13_2To1_14() {
|
||||
@@ -56,9 +58,8 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
protected void registerPackets() {
|
||||
executeAsyncAfterLoaded(Protocol1_14To1_13_2.class, MAPPINGS::load);
|
||||
|
||||
TranslatableRewriter translatableRewriter = new TranslatableRewriter(this);
|
||||
translatableRewriter.registerBossBar(ClientboundPackets1_14.BOSSBAR);
|
||||
translatableRewriter.registerChatMessage(ClientboundPackets1_14.CHAT_MESSAGE);
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_14.CHAT_MESSAGE);
|
||||
translatableRewriter.registerCombatEvent(ClientboundPackets1_14.COMBAT_EVENT);
|
||||
translatableRewriter.registerDisconnect(ClientboundPackets1_14.DISCONNECT);
|
||||
translatableRewriter.registerTabList(ClientboundPackets1_14.TAB_LIST);
|
||||
@@ -67,7 +68,7 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
|
||||
new CommandRewriter1_14(this).registerDeclareCommands(ClientboundPackets1_14.DECLARE_COMMANDS);
|
||||
|
||||
blockItemPackets = new BlockItemPackets1_14(this, translatableRewriter);
|
||||
blockItemPackets = new BlockItemPackets1_14(this);
|
||||
blockItemPackets.register();
|
||||
entityRewriter.register();
|
||||
new PlayerPackets1_14(this).register();
|
||||
@@ -170,6 +171,7 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
|
||||
}
|
||||
|
||||
//TODO Soft memory leak: Don't store light if chunk is already loaded
|
||||
wrapper.user().get(ChunkLightStorage.class).setStoredLight(skyLight, blockLight, x, z);
|
||||
wrapper.cancel();
|
||||
}
|
||||
@@ -194,6 +196,8 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
if (!user.has(ChunkLightStorage.class)) {
|
||||
user.put(new ChunkLightStorage(user));
|
||||
}
|
||||
|
||||
user.put(new DifficultyStorage(user));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -210,4 +214,9 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public BlockItemPackets1_14 getItemRewriter() {
|
||||
return blockItemPackets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableRewriter getTranslatableRewriter() {
|
||||
return translatableRewriter;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -37,7 +37,7 @@ public class CommandRewriter1_14 extends CommandRewriter {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable String handleArgumentType(String argumentType) {
|
||||
public @Nullable String handleArgumentType(String argumentType) {
|
||||
switch (argumentType) {
|
||||
case "minecraft:nbt_compound_tag":
|
||||
return "minecraft:nbt";
|
||||
|
||||
+5
-7
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -20,7 +20,6 @@ package com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.packets;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.rewriters.EnchantmentRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
@@ -33,12 +32,12 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_13_2;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
@@ -65,8 +64,8 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
|
||||
private EnchantmentRewriter enchantmentRewriter;
|
||||
|
||||
public BlockItemPackets1_14(Protocol1_13_2To1_14 protocol, TranslatableRewriter translatableRewriter) {
|
||||
super(protocol, translatableRewriter);
|
||||
public BlockItemPackets1_14(Protocol1_13_2To1_14 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -284,12 +283,11 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
Item item = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||
int armorType = item == null || item.identifier() == 0 ? 0 : item.identifier() - 726;
|
||||
if (armorType < 0 || armorType > 3) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Received invalid horse armor: " + item);
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
List<Metadata> metadataList = new ArrayList<>();
|
||||
metadataList.add(new Metadata(16, MetaType1_13_2.VarInt, armorType));
|
||||
metadataList.add(new Metadata(16, Types1_13_2.META_TYPES.varIntType, armorType));
|
||||
wrapper.write(Types1_13.METADATA_LIST, metadataList);
|
||||
}
|
||||
}
|
||||
|
||||
+47
-45
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -23,6 +23,7 @@ import com.viaversion.viabackwards.api.entities.storage.EntityPositionHandler;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.DifficultyStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.EntityPositionStorage1_14;
|
||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
@@ -33,7 +34,6 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_13_2;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
@@ -51,7 +51,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
private EntityPositionHandler positionHandler;
|
||||
|
||||
public EntityPackets1_14(Protocol1_13_2To1_14 protocol) {
|
||||
super(protocol, MetaType1_13_2.OptChat, MetaType1_13_2.Boolean);
|
||||
super(protocol, Types1_13_2.META_TYPES.optionalComponentType, Types1_13_2.META_TYPES.booleanType);
|
||||
}
|
||||
|
||||
//TODO work the method into this class alone
|
||||
@@ -310,15 +310,19 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
|
||||
handler(getTrackerHandler(Entity1_14Types.PLAYER, Type.INT));
|
||||
handler(getDimensionHandler(1));
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) 0);
|
||||
handler(wrapper -> {
|
||||
short difficulty = wrapper.user().get(DifficultyStorage.class).getDifficulty();
|
||||
wrapper.write(Type.UNSIGNED_BYTE, difficulty);
|
||||
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Max Players
|
||||
wrapper.passthrough(Type.STRING); // Level Type
|
||||
wrapper.read(Type.VAR_INT); // Read View Distance
|
||||
}
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Max Players
|
||||
wrapper.passthrough(Type.STRING); // Level Type
|
||||
wrapper.read(Type.VAR_INT); // Read View Distance
|
||||
|
||||
//TODO Track client position
|
||||
// Manually add position storage
|
||||
/*int entitiyId = wrapper.get(Type.INT, 0);
|
||||
StoredEntityData storedEntity = protocol.getEntityRewriter().tracker(wrapper.user()).entityData(entitiyId);
|
||||
storedEntity.put(new EntityPositionStorage1_14());*/
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -328,16 +332,15 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Dimension ID
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, 0);
|
||||
clientWorld.setEnvironment(dimensionId);
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, 0);
|
||||
clientWorld.setEnvironment(dimensionId);
|
||||
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) 0); // Difficulty
|
||||
wrapper.user().get(ChunkLightStorage.class).clear();
|
||||
}
|
||||
short difficulty = wrapper.user().get(DifficultyStorage.class).getDifficulty();
|
||||
wrapper.write(Type.UNSIGNED_BYTE, difficulty);
|
||||
|
||||
wrapper.user().get(ChunkLightStorage.class).clear();
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -347,30 +350,29 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
protected void registerRewrites() {
|
||||
mapTypes(Entity1_14Types.values(), Entity1_13Types.EntityType.class);
|
||||
|
||||
mapEntityTypeWithData(Entity1_14Types.CAT, Entity1_14Types.OCELOT).jsonName("Cat");
|
||||
mapEntityTypeWithData(Entity1_14Types.TRADER_LLAMA, Entity1_14Types.LLAMA).jsonName("Trader Llama");
|
||||
mapEntityTypeWithData(Entity1_14Types.FOX, Entity1_14Types.WOLF).jsonName("Fox");
|
||||
mapEntityTypeWithData(Entity1_14Types.PANDA, Entity1_14Types.POLAR_BEAR).jsonName("Panda");
|
||||
mapEntityTypeWithData(Entity1_14Types.PILLAGER, Entity1_14Types.VILLAGER).jsonName("Pillager");
|
||||
mapEntityTypeWithData(Entity1_14Types.WANDERING_TRADER, Entity1_14Types.VILLAGER).jsonName("Wandering Trader");
|
||||
mapEntityTypeWithData(Entity1_14Types.RAVAGER, Entity1_14Types.COW).jsonName("Ravager");
|
||||
mapEntityTypeWithData(Entity1_14Types.CAT, Entity1_14Types.OCELOT).jsonName();
|
||||
mapEntityTypeWithData(Entity1_14Types.TRADER_LLAMA, Entity1_14Types.LLAMA).jsonName();
|
||||
mapEntityTypeWithData(Entity1_14Types.FOX, Entity1_14Types.WOLF).jsonName();
|
||||
mapEntityTypeWithData(Entity1_14Types.PANDA, Entity1_14Types.POLAR_BEAR).jsonName();
|
||||
mapEntityTypeWithData(Entity1_14Types.PILLAGER, Entity1_14Types.VILLAGER).jsonName();
|
||||
mapEntityTypeWithData(Entity1_14Types.WANDERING_TRADER, Entity1_14Types.VILLAGER).jsonName();
|
||||
mapEntityTypeWithData(Entity1_14Types.RAVAGER, Entity1_14Types.COW).jsonName();
|
||||
|
||||
filter().handler((event, meta) -> {
|
||||
int typeId = meta.metaType().typeId();
|
||||
if (typeId <= 15) {
|
||||
meta.setMetaType(MetaType1_13_2.byId(typeId));
|
||||
meta.setMetaType(Types1_13_2.META_TYPES.byId(typeId));
|
||||
}
|
||||
|
||||
MetaType type = meta.metaType();
|
||||
|
||||
if (type == MetaType1_13_2.Slot) {
|
||||
if (type == Types1_13_2.META_TYPES.itemType) {
|
||||
Item item = (Item) meta.getValue();
|
||||
meta.setValue(protocol.getItemRewriter().handleItemToClient(item));
|
||||
} else if (type == MetaType1_13_2.BlockID) {
|
||||
int blockstate = (Integer) meta.getValue();
|
||||
} else if (type == Types1_13_2.META_TYPES.blockStateType) {
|
||||
int blockstate = meta.value();
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(blockstate));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
filter().type(Entity1_14Types.PILLAGER).cancel(15);
|
||||
@@ -393,6 +395,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
|
||||
filter().handler((event, meta) -> {
|
||||
EntityType type = event.entityType();
|
||||
if (type == null) return;
|
||||
if (type.isOrHasParent(Entity1_14Types.ABSTRACT_ILLAGER_BASE) || type == Entity1_14Types.RAVAGER || type == Entity1_14Types.WITCH) {
|
||||
int index = event.index();
|
||||
if (index == 14) {
|
||||
@@ -408,7 +411,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
});
|
||||
|
||||
filter().type(Entity1_14Types.FIREWORK_ROCKET).index(8).handler((event, meta) -> {
|
||||
meta.setMetaType(MetaType1_13_2.VarInt);
|
||||
meta.setMetaType(Types1_13_2.META_TYPES.varIntType);
|
||||
Integer value = (Integer) meta.getValue();
|
||||
if (value == null) {
|
||||
meta.setValue(0);
|
||||
@@ -421,7 +424,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
|
||||
MetaHandler villagerDataHandler = (event, meta) -> {
|
||||
VillagerData villagerData = (VillagerData) meta.getValue();
|
||||
meta.setTypeAndValue(MetaType1_13_2.VarInt, villagerDataToProfession(villagerData));
|
||||
meta.setTypeAndValue(Types1_13_2.META_TYPES.varIntType, villagerDataToProfession(villagerData));
|
||||
if (meta.id() == 16) {
|
||||
event.setIndex(15); // decreased by 2 again in one of the following handlers
|
||||
}
|
||||
@@ -434,13 +437,13 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
filter().filterFamily(Entity1_14Types.ABSTRACT_SKELETON).index(13).handler((event, meta) -> {
|
||||
byte value = (byte) meta.getValue();
|
||||
if ((value & 4) != 0) {
|
||||
event.createExtraMeta(new Metadata(14, MetaType1_13_2.Boolean, true));
|
||||
event.createExtraMeta(new Metadata(14, Types1_13_2.META_TYPES.booleanType, true));
|
||||
}
|
||||
});
|
||||
filter().filterFamily(Entity1_14Types.ZOMBIE).index(13).handler((event, meta) -> {
|
||||
byte value = (byte) meta.getValue();
|
||||
if ((value & 4) != 0) {
|
||||
event.createExtraMeta(new Metadata(16, MetaType1_13_2.Boolean, true));
|
||||
event.createExtraMeta(new Metadata(16, Types1_13_2.META_TYPES.booleanType, true));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -470,19 +473,12 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
}
|
||||
});
|
||||
|
||||
// Something
|
||||
// Pose
|
||||
filter().removeIndex(6);
|
||||
|
||||
filter().handler((event, meta) -> {
|
||||
int typeId = meta.metaType().typeId();
|
||||
if (typeId > 15) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("New 1.14 metadata was not handled: " + meta + " entity: " + event.entityType());
|
||||
}
|
||||
});
|
||||
|
||||
filter().type(Entity1_14Types.OCELOT).index(13).handler((event, meta) -> {
|
||||
event.setIndex(15);
|
||||
meta.setTypeAndValue(MetaType1_13_2.VarInt, 0);
|
||||
meta.setTypeAndValue(Types1_13_2.META_TYPES.varIntType, 0);
|
||||
});
|
||||
|
||||
filter().type(Entity1_14Types.CAT).handler((event, meta) -> {
|
||||
@@ -492,6 +488,12 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
meta.setValue((byte) ((byte) meta.getValue() & 0x4));
|
||||
}
|
||||
});
|
||||
|
||||
filter().handler((event, meta) -> {
|
||||
if (meta.metaType().typeId() > 15) {
|
||||
throw new IllegalArgumentException("Unhandled metadata: " + meta);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public int villagerDataToProfession(VillagerData data) {
|
||||
|
||||
+8
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* 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
|
||||
@@ -18,6 +18,7 @@
|
||||
package com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.packets;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.DifficultyStorage;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
@@ -40,6 +41,10 @@ public class PlayerPackets1_14 extends RewriterBase<Protocol1_13_2To1_14> {
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
map(Type.BOOLEAN, Type.NOTHING); // Locked
|
||||
handler(wrapper -> {
|
||||
byte difficulty = wrapper.get(Type.UNSIGNED_BYTE, 0).byteValue();
|
||||
wrapper.user().get(DifficultyStorage.class).setDifficulty(difficulty);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -59,9 +64,8 @@ public class PlayerPackets1_14 extends RewriterBase<Protocol1_13_2To1_14> {
|
||||
protocol.registerServerbound(ServerboundPackets1_13.PLAYER_DIGGING, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.POSITION, Type.POSITION1_14);
|
||||
map(Type.BYTE);
|
||||
map(Type.VAR_INT); // Action
|
||||
map(Type.POSITION, Type.POSITION1_14); // Position
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Loaded 100 of 202 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user