Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79a2881a02 | ||
|
|
64e68830bc | ||
|
|
ab742c794f | ||
|
|
bf3834ab21 | ||
|
|
2f60c79ed8 | ||
|
|
5bb3e8a1fc | ||
|
|
b60464296b | ||
|
|
9241213fb5 | ||
|
|
e9c3889c82 | ||
|
|
dca8ecf1db | ||
|
|
170e5f224f | ||
|
|
4375a259dd | ||
|
|
8fc82cd331 | ||
|
|
de21548a8e | ||
|
|
8759f059b7 | ||
|
|
1f3555df4a | ||
|
|
b40f77fed3 | ||
|
|
9fd0df824f | ||
|
|
88df61605b | ||
|
|
6c2d43d7f9 | ||
|
|
2889daed61 | ||
|
|
651bf052fc | ||
|
|
83fa0c613f | ||
|
|
5334f77d49 | ||
|
|
96293e6e66 | ||
|
|
65faeb8574 | ||
|
|
6ad4a29d30 | ||
|
|
4fe53f5ab8 | ||
|
|
a390990178 | ||
|
|
e020dd69ef | ||
|
|
b09950dc64 | ||
|
|
7b8fd2b061 | ||
|
|
2d57e8c212 | ||
|
|
dcc3824a8c | ||
|
|
2dd19c778b | ||
|
|
e24a170e77 | ||
|
|
3a69dda548 | ||
|
|
77ecda3977 | ||
|
|
c44bc88d2d | ||
|
|
deede5347e | ||
|
|
255536e9d0 | ||
|
|
8a2c18863c | ||
|
|
375bb5a1b9 | ||
|
|
c739b54403 | ||
|
|
a0388cf541 | ||
|
|
3dd6e5043e | ||
|
|
d30766a17a | ||
|
|
f556a29d38 | ||
|
|
8a19fbdead | ||
|
|
d4011f3646 | ||
|
|
2bd687b19d | ||
|
|
4f4bff6898 | ||
|
|
adac67b85c | ||
|
|
0949ff4ba9 | ||
|
|
8f5683f764 | ||
|
|
995c0bf4c3 | ||
|
|
0f77acdc9f | ||
|
|
ac5fbdd7f4 | ||
|
|
fb7cd2d9e3 | ||
|
|
5284a581b3 | ||
|
|
8eca6bf0b2 | ||
|
|
c13a89a29c | ||
|
|
bce716caa4 | ||
|
|
71f08b9e4e | ||
|
|
59fc7f6a1a | ||
|
|
232180ee61 | ||
|
|
cfb97e1abe | ||
|
|
48907be813 | ||
|
|
ff87b1dc92 | ||
|
|
e68ddf42b0 | ||
|
|
8a9d4bd971 | ||
|
|
7f85d074af | ||
|
|
4cd65dd956 | ||
|
|
719bb11938 | ||
|
|
e419831e8a | ||
|
|
d121745a0f | ||
|
|
65158455cc | ||
|
|
0912e33358 | ||
|
|
02f595b109 | ||
|
|
f78d166acf | ||
|
|
2e0acf169b | ||
|
|
aa1f38674d | ||
|
|
9e883faa78 | ||
|
|
e27930b1d7 | ||
|
|
d46eb8719a | ||
|
|
d092c98897 | ||
|
|
75680296e8 | ||
|
|
80696a1273 | ||
|
|
54330702b1 |
No files matched your search
@@ -0,0 +1,13 @@
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = false
|
||||
tab_width = 4
|
||||
|
||||
[*.java]
|
||||
ij_java_class_count_to_use_import_on_demand = 999999
|
||||
ij_java_names_count_to_use_import_on_demand = 999999
|
||||
ij_java_imports_layout = *,|,$*
|
||||
ij_java_generate_final_locals = true
|
||||
ij_java_generate_final_parameters = true
|
||||
@@ -0,0 +1,2 @@
|
||||
github: kennytv
|
||||
patreon: kennytv
|
||||
@@ -21,11 +21,11 @@ body:
|
||||
attributes:
|
||||
label: Console Error
|
||||
description: |
|
||||
If you encounter warnings/errors in your console, **paste them with https://paste.gg/ and put the paste link here**.
|
||||
If you encounter warnings/errors in your console, **paste them with https://mclo.gs/ and put the paste link here**.
|
||||
If the error is small/less than 10 lines, you may put it directly into this field.
|
||||
value: |
|
||||
```
|
||||
Put the paste.gg link or text here.
|
||||
Put the mclo.gs link or text here.
|
||||
```
|
||||
placeholder: Please do not remove the grave accents; simply replace the line of text in the middle.
|
||||
validations:
|
||||
|
||||
@@ -13,11 +13,11 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 11
|
||||
java-version: 17
|
||||
check-latest: true
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
@@ -13,7 +13,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: gradle/wrapper-validation-action@v1
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards Copyright (C) &#36;originalComment.match("Copyright \(C\) (\d+)", 1, "-")&#36;today.year ViaVersion and contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>." />
|
||||
<option name="notice" value="This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards Copyright (C) 2016-&#36;today.year ViaVersion and contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>." />
|
||||
<option name="myName" value="viabackwards-gpl" />
|
||||
</copyright>
|
||||
</component>
|
||||
@@ -34,6 +34,8 @@ Known issues
|
||||
1.17 will not be able to see or interact with blocks below y=0 and above y=255
|
||||
* <1.17 clients on 1.17+ servers might experience inventory desyncs on certain inventory click actions
|
||||
* Sound mappings are incomplete ([see here](https://github.com/ViaVersion/ViaBackwards/issues/326))
|
||||
* <1.19.4 clients on 1.20+ servers won't be able to use the smithing table, this can be fixed by
|
||||
installing [AxSmithing](https://github.com/ViaVersionAddons/AxSmithing)
|
||||
|
||||
Other Links
|
||||
-
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import java.util.*
|
||||
|
||||
plugins {
|
||||
id("vb.shadow-conventions")
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
archiveFileName.set("ViaBackwards-${project.name.substringAfter("viabackwards-").replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}-${project.version}.jar")
|
||||
destinationDirectory.set(rootProject.layout.buildDirectory.dir("libs"))
|
||||
}
|
||||
}
|
||||
+5
-9
@@ -6,10 +6,12 @@ plugins {
|
||||
allprojects {
|
||||
group = "com.viaversion"
|
||||
version = property("projectVersion") as String // from gradle.properties
|
||||
description = "Allow older clients to join newer server versions."
|
||||
description = "Allows older Minecraft client versions to connect to newer server versions."
|
||||
}
|
||||
|
||||
val platforms = setOf(
|
||||
val main = setOf(
|
||||
projects.viabackwards,
|
||||
projects.viabackwardsCommon,
|
||||
projects.viabackwardsBukkit,
|
||||
projects.viabackwardsBungee,
|
||||
projects.viabackwardsFabric,
|
||||
@@ -17,15 +19,9 @@ val platforms = setOf(
|
||||
projects.viabackwardsVelocity
|
||||
).map { it.dependencyProject }
|
||||
|
||||
// Would otherwise contain api/depdency modules if at some point needed
|
||||
val special = setOf(
|
||||
projects.viabackwards
|
||||
).map { it.dependencyProject }
|
||||
|
||||
subprojects {
|
||||
when (this) {
|
||||
in platforms -> plugins.apply("vb.platform-conventions")
|
||||
in special -> plugins.apply("vb.base-conventions")
|
||||
in main -> plugins.apply("vb.shadow-conventions")
|
||||
else -> plugins.apply("vb.standard-conventions")
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
dependencies {
|
||||
implementation(projects.viabackwardsCommon)
|
||||
compileOnlyApi(projects.viabackwardsCommon)
|
||||
compileOnly(libs.paper) {
|
||||
exclude("com.google.code.gson", "gson")
|
||||
exclude("javax.persistence", "persistence-api")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
@@ -27,10 +27,12 @@ import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform {
|
||||
|
||||
public BukkitPlugin() {
|
||||
Via.getManager().addEnableListener(() -> init(getDataFolder()));
|
||||
Via.getManager().addEnableListener(() -> init(new File(getDataFolder(), "config.yml")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
@@ -53,6 +53,7 @@ public class LecternInteractListener extends ViaBukkitListener {
|
||||
// Open a book with the text of the lectern's writable book
|
||||
ItemStack newBook = new ItemStack(Material.WRITTEN_BOOK);
|
||||
BookMeta newBookMeta = (BookMeta) newBook.getItemMeta();
|
||||
//noinspection deprecation
|
||||
newBookMeta.setPages(meta.getPages());
|
||||
newBookMeta.setAuthor("an upsidedown person");
|
||||
newBookMeta.setTitle("buk");
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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 @@
|
||||
name: ViaBackwards
|
||||
version: ${version}
|
||||
description: Allow older Minecraft versions to connect to a newer server version.
|
||||
description: ${description}
|
||||
main: com.viaversion.viabackwards.BukkitPlugin
|
||||
api-version: 1.13
|
||||
folia-supported: true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
dependencies {
|
||||
implementation(projects.viabackwardsCommon)
|
||||
compileOnlyApi(projects.viabackwardsCommon)
|
||||
compileOnly(libs.bungee)
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,14 +20,15 @@ package com.viaversion.viabackwards;
|
||||
|
||||
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class BungeePlugin extends Plugin implements ViaBackwardsPlatform {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
Via.getManager().addEnableListener(() -> this.init(getDataFolder()));
|
||||
Via.getManager().addEnableListener(() -> this.init(new File(getDataFolder(), "config.yml")));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
@@ -28,7 +28,7 @@ public final class ViaBackwards {
|
||||
private static ViaBackwardsConfig config;
|
||||
|
||||
public static void init(ViaBackwardsPlatform platform, ViaBackwardsConfig config) {
|
||||
Preconditions.checkArgument(platform != null, "ViaBackwards is already initialized");
|
||||
Preconditions.checkArgument(ViaBackwards.platform == null, "ViaBackwards is already initialized");
|
||||
|
||||
ViaBackwards.platform = platform;
|
||||
ViaBackwards.config = config;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,8 +38,8 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
super.reloadConfig();
|
||||
public void reload() {
|
||||
super.reload();
|
||||
loadFields();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
@@ -27,7 +27,7 @@ import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class BackwardsProtocol<CU extends ClientboundPacketType, CM extends ClientboundPacketType, SM extends ServerboundPacketType, SU extends ServerboundPacketType>
|
||||
extends AbstractProtocol<CU, CM, SM, SU> {
|
||||
extends AbstractProtocol<CU, CM, SM, SU> {
|
||||
|
||||
protected BackwardsProtocol() {
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,7 +17,9 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.api;
|
||||
|
||||
public interface ViaBackwardsConfig {
|
||||
import com.viaversion.viaversion.api.configuration.Config;
|
||||
|
||||
public interface ViaBackwardsConfig extends Config {
|
||||
|
||||
/**
|
||||
* Mimics name and level of a custom enchant through the item's lore.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
@@ -51,6 +51,7 @@ import com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.Protocol1_19_
|
||||
import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.Protocol1_19_3To1_19_4;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.Protocol1_19_4To1_20;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.Protocol1_19To1_19_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.Protocol1_20_2To1_20_3;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.Protocol1_20To1_20_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_9_1_2to1_9_3_4.Protocol1_9_1_2To1_9_3_4;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||
@@ -66,14 +67,15 @@ import java.util.logging.Logger;
|
||||
|
||||
public interface ViaBackwardsPlatform {
|
||||
|
||||
String MINIMUM_VV_VERSION = "4.8.1";
|
||||
String MINIMUM_VV_VERSION = "4.9.3";
|
||||
|
||||
/**
|
||||
* Initialize ViaBackwards.
|
||||
*/
|
||||
default void init(File dataFolder) {
|
||||
ViaBackwardsConfig config = new ViaBackwardsConfig(new File(dataFolder, "config.yml"));
|
||||
config.reloadConfig();
|
||||
default void init(final File configFile) {
|
||||
ViaBackwardsConfig config = new ViaBackwardsConfig(configFile);
|
||||
config.reload();
|
||||
Via.getManager().getConfigurationProvider().register(config);
|
||||
|
||||
ViaBackwards.init(this, config);
|
||||
|
||||
@@ -133,6 +135,7 @@ public interface ViaBackwardsPlatform {
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_19_4To1_20(), ProtocolVersion.v1_19_4, ProtocolVersion.v1_20);
|
||||
protocolManager.registerProtocol(new Protocol1_20To1_20_2(), ProtocolVersion.v1_20, ProtocolVersion.v1_20_2);
|
||||
protocolManager.registerProtocol(new Protocol1_20_2To1_20_3(), ProtocolVersion.v1_20_2, ProtocolVersion.v1_20_3);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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) 2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,7 +17,7 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.api.data;
|
||||
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class MappedItem {
|
||||
@@ -32,7 +32,7 @@ public class MappedItem {
|
||||
|
||||
public MappedItem(final int id, final String name, @Nullable final Integer customModelData) {
|
||||
this.id = id;
|
||||
this.jsonName = ChatRewriter.legacyTextToJsonString("§f" + name, true);
|
||||
this.jsonName = ComponentUtil.legacyToJsonString("§f" + name, true);
|
||||
this.customModelData = customModelData;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,9 +21,10 @@ import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viaversion.libs.gson.JsonIOException;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.gson.JsonSyntaxException;
|
||||
import com.viaversion.viaversion.libs.opennbt.NBTIO;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.io.NBTIO;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.io.TagReader;
|
||||
import com.viaversion.viaversion.util.GsonUtil;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
@@ -35,6 +36,8 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class VBMappingDataLoader {
|
||||
|
||||
private static final TagReader<CompoundTag> TAG_READER = NBTIO.reader(CompoundTag.class).named();
|
||||
|
||||
public static @Nullable CompoundTag loadNBT(final String name) {
|
||||
final InputStream resource = getResource(name);
|
||||
if (resource == null) {
|
||||
@@ -42,7 +45,7 @@ public final class VBMappingDataLoader {
|
||||
}
|
||||
|
||||
try (final InputStream stream = resource) {
|
||||
return NBTIO.readTag(stream);
|
||||
return TAG_READER.read(stream);
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -65,7 +68,7 @@ public final class VBMappingDataLoader {
|
||||
|
||||
ViaBackwards.getPlatform().getLogger().info("Loading " + name + " from plugin folder");
|
||||
try {
|
||||
final CompoundTag fileData = NBTIO.readFile(file, false, false);
|
||||
final CompoundTag fileData = TAG_READER.read(file.toPath(), false);
|
||||
return mergeTags(packedData, fileData);
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
+29
-18
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,10 @@
|
||||
|
||||
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 com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import java.util.Locale;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class EntityData {
|
||||
private final int id;
|
||||
private final int replacementId;
|
||||
private final String key;
|
||||
private NameVisibility nameVisibility = NameVisibility.NONE;
|
||||
private ComponentType componentType = ComponentType.NONE;
|
||||
private MetaCreator defaultMeta;
|
||||
|
||||
public EntityData(BackwardsProtocol<?, ?, ?, ?> protocol, EntityType type, int replacementId) {
|
||||
@@ -45,12 +45,17 @@ public class EntityData {
|
||||
}
|
||||
|
||||
public EntityData jsonName() {
|
||||
this.nameVisibility = NameVisibility.JSON;
|
||||
this.componentType = ComponentType.JSON;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityData tagName() {
|
||||
this.componentType = ComponentType.TAG;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityData plainName() {
|
||||
this.nameVisibility = NameVisibility.PLAIN;
|
||||
this.componentType = ComponentType.PLAIN;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -70,17 +75,22 @@ public class EntityData {
|
||||
/**
|
||||
* @return custom mobname, can be either a String or a JsonElement
|
||||
*/
|
||||
public @Nullable Object mobName() {
|
||||
if (nameVisibility == NameVisibility.NONE) {
|
||||
public @Nullable Object entityName() {
|
||||
if (componentType == ComponentType.NONE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String name = protocol.getMappingData().mappedEntityName(key);
|
||||
final 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 null;
|
||||
}
|
||||
return nameVisibility == NameVisibility.JSON ? ChatRewriter.legacyTextToJson(name) : name;
|
||||
|
||||
if (componentType == ComponentType.JSON) {
|
||||
return ComponentUtil.legacyToJson(name);
|
||||
} else if (componentType == ComponentType.TAG) {
|
||||
return new StringTag(name);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public int replacementId() {
|
||||
@@ -102,11 +112,11 @@ public class EntityData {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EntityData{" +
|
||||
"id=" + id +
|
||||
", mobName='" + key + '\'' +
|
||||
", replacementId=" + replacementId +
|
||||
", defaultMeta=" + defaultMeta +
|
||||
'}';
|
||||
"id=" + id +
|
||||
", mobName='" + key + '\'' +
|
||||
", replacementId=" + replacementId +
|
||||
", defaultMeta=" + defaultMeta +
|
||||
'}';
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
@@ -115,9 +125,10 @@ public class EntityData {
|
||||
void createMeta(WrappedMetadata storage);
|
||||
}
|
||||
|
||||
private enum NameVisibility {
|
||||
private enum ComponentType {
|
||||
PLAIN,
|
||||
JSON,
|
||||
TAG,
|
||||
NONE
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,7 +43,7 @@ public class EntityPositionHandler {
|
||||
|
||||
public void cacheEntityPosition(PacketWrapper wrapper, boolean create, boolean relative) throws Exception {
|
||||
cacheEntityPosition(wrapper,
|
||||
wrapper.get(Type.DOUBLE, 0), wrapper.get(Type.DOUBLE, 1), wrapper.get(Type.DOUBLE, 2), create, relative);
|
||||
wrapper.get(Type.DOUBLE, 0), wrapper.get(Type.DOUBLE, 1), wrapper.get(Type.DOUBLE, 2), create, relative);
|
||||
}
|
||||
|
||||
public void cacheEntityPosition(PacketWrapper wrapper, double x, double y, double z, boolean create, boolean relative) throws Exception {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
|
||||
+15
-16
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,10 +21,9 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ShortTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@@ -57,10 +56,10 @@ public class EnchantmentRewriter {
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) return;
|
||||
|
||||
if (tag.get("Enchantments") instanceof ListTag) {
|
||||
if (tag.getListTag("Enchantments") != null) {
|
||||
rewriteEnchantmentsToClient(tag, false);
|
||||
}
|
||||
if (tag.get("StoredEnchantments") instanceof ListTag) {
|
||||
if (tag.getListTag("StoredEnchantments") != null) {
|
||||
rewriteEnchantmentsToClient(tag, true);
|
||||
}
|
||||
}
|
||||
@@ -79,17 +78,16 @@ public class EnchantmentRewriter {
|
||||
|
||||
public void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) {
|
||||
String key = storedEnchant ? "StoredEnchantments" : "Enchantments";
|
||||
ListTag enchantments = tag.get(key);
|
||||
ListTag enchantments = tag.getListTag(key);
|
||||
List<Tag> loreToAdd = new ArrayList<>();
|
||||
boolean changed = false;
|
||||
|
||||
Iterator<Tag> iterator = enchantments.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
CompoundTag enchantmentEntry = (CompoundTag) iterator.next();
|
||||
Tag idTag = enchantmentEntry.get("id");
|
||||
if (!(idTag instanceof StringTag)) continue;
|
||||
StringTag idTag = enchantmentEntry.getStringTag("id");
|
||||
|
||||
String enchantmentId = ((StringTag) idTag).getValue();
|
||||
String enchantmentId = idTag.getValue();
|
||||
String remappedName = enchantmentMappings.get(enchantmentId);
|
||||
if (remappedName != null) {
|
||||
if (!changed) {
|
||||
@@ -100,10 +98,11 @@ public class EnchantmentRewriter {
|
||||
|
||||
iterator.remove();
|
||||
|
||||
int level = ((NumberTag) enchantmentEntry.get("lvl")).asInt();
|
||||
NumberTag levelTag = enchantmentEntry.getNumberTag("lvl");
|
||||
int level = levelTag != null ? levelTag.asInt() : 1;
|
||||
String loreValue = remappedName + " " + getRomanNumber(level);
|
||||
if (jsonFormat) {
|
||||
loreValue = ChatRewriter.legacyTextToJsonString(loreValue);
|
||||
loreValue = ComponentUtil.legacyToJsonString(loreValue);
|
||||
}
|
||||
|
||||
loreToAdd.add(new StringTag(loreValue));
|
||||
@@ -112,19 +111,19 @@ public class EnchantmentRewriter {
|
||||
|
||||
if (!loreToAdd.isEmpty()) {
|
||||
// Add dummy enchant for the glow effect if there are no actual enchantments left
|
||||
if (!storedEnchant && enchantments.size() == 0) {
|
||||
if (!storedEnchant && enchantments.isEmpty()) {
|
||||
CompoundTag dummyEnchantment = new CompoundTag();
|
||||
dummyEnchantment.put("id", new StringTag());
|
||||
dummyEnchantment.put("lvl", new ShortTag((short) 0));
|
||||
dummyEnchantment.putString("id", "");
|
||||
dummyEnchantment.putShort("lvl", (short) 0);
|
||||
enchantments.add(dummyEnchantment);
|
||||
}
|
||||
|
||||
CompoundTag display = tag.get("display");
|
||||
CompoundTag display = tag.getCompoundTag("display");
|
||||
if (display == null) {
|
||||
tag.put("display", display = new CompoundTag());
|
||||
}
|
||||
|
||||
ListTag loreTag = display.get("Lore");
|
||||
ListTag loreTag = display.getListTag("Lore");
|
||||
if (loreTag == null) {
|
||||
display.put("Lore", loreTag = new ListTag(StringTag.class));
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
|
||||
+14
-12
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.Int2IntMapMappings;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.data.entity.TrackedEntity;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
@@ -35,7 +36,6 @@ import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.rewriter.meta.MetaHandlerEvent;
|
||||
import java.util.List;
|
||||
@@ -76,21 +76,22 @@ public abstract class EntityRewriterBase<C extends ClientboundPacketType, T exte
|
||||
|
||||
// Set the mapped entity name if there is no custom name set already
|
||||
final EntityData entityData = entityDataForType(entity.entityType());
|
||||
if (entityData != null && entityData.mobName() != null) {
|
||||
final Object displayNameObject;
|
||||
if (entityData != null && (displayNameObject = entityData.entityName()) != null) {
|
||||
final Metadata displayName = getMeta(displayNameIndex, metadataList);
|
||||
if (initialMetadata) {
|
||||
if (displayName == null) {
|
||||
// Add it as new metadata
|
||||
metadataList.add(new Metadata(displayNameIndex, displayNameMetaType, entityData.mobName()));
|
||||
metadataList.add(new Metadata(displayNameIndex, displayNameMetaType, displayNameObject));
|
||||
addDisplayVisibilityMeta(metadataList);
|
||||
} else if (displayName.getValue() == null || displayName.getValue().toString().isEmpty()) {
|
||||
// Overwrite the existing null/empty display name
|
||||
displayName.setValue(entityData.mobName());
|
||||
displayName.setValue(displayNameObject);
|
||||
addDisplayVisibilityMeta(metadataList);
|
||||
}
|
||||
} else if (displayName != null && (displayName.getValue() == null || displayName.getValue().toString().isEmpty())) {
|
||||
// Overwrite null/empty display name
|
||||
displayName.setValue(entityData.mobName());
|
||||
displayName.setValue(displayNameObject);
|
||||
addDisplayVisibilityMeta(metadataList);
|
||||
}
|
||||
}
|
||||
@@ -176,12 +177,12 @@ public abstract class EntityRewriterBase<C extends ClientboundPacketType, T exte
|
||||
}
|
||||
|
||||
public void registerMetaTypeHandler(
|
||||
@Nullable MetaType itemType,
|
||||
@Nullable MetaType blockStateType,
|
||||
@Nullable MetaType optionalBlockStateType,
|
||||
@Nullable MetaType particleType,
|
||||
@Nullable MetaType componentType,
|
||||
@Nullable MetaType optionalComponentType
|
||||
@Nullable MetaType itemType,
|
||||
@Nullable MetaType blockStateType,
|
||||
@Nullable MetaType optionalBlockStateType,
|
||||
@Nullable MetaType particleType,
|
||||
@Nullable MetaType componentType,
|
||||
@Nullable MetaType optionalComponentType
|
||||
) {
|
||||
filter().handler((event, meta) -> {
|
||||
MetaType type = meta.metaType();
|
||||
@@ -198,6 +199,7 @@ public abstract class EntityRewriterBase<C extends ClientboundPacketType, T exte
|
||||
} else if (type == particleType) {
|
||||
rewriteParticle(meta.value());
|
||||
} else if (type == optionalComponentType || type == componentType) {
|
||||
|
||||
JsonElement text = meta.value();
|
||||
if (text != null) {
|
||||
protocol.getTranslatableRewriter().processText(text);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,16 +29,13 @@ 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;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class ItemRewriter<C extends ClientboundPacketType, S extends ServerboundPacketType,
|
||||
T extends BackwardsProtocol<C, ?, ?, S>> extends ItemRewriterBase<C, S, T> {
|
||||
|
||||
public ItemRewriter(T protocol) {
|
||||
super(protocol, true);
|
||||
}
|
||||
T extends BackwardsProtocol<C, ?, ?, S>> extends ItemRewriterBase<C, S, T> {
|
||||
|
||||
public ItemRewriter(T protocol, Type<Item> itemType, Type<Item[]> itemArrayType) {
|
||||
super(protocol, itemType, itemArrayType, true);
|
||||
@@ -50,25 +47,23 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
||||
return null;
|
||||
}
|
||||
|
||||
CompoundTag display = item.tag() != null ? item.tag().get("display") : null;
|
||||
CompoundTag display = item.tag() != null ? item.tag().getCompoundTag("display") : null;
|
||||
if (protocol.getTranslatableRewriter() != null && display != null) {
|
||||
// Handle name and lore components
|
||||
Tag name = display.get("Name");
|
||||
if (name instanceof StringTag) {
|
||||
StringTag nameStringTag = (StringTag) name;
|
||||
String newValue = protocol.getTranslatableRewriter().processText(nameStringTag.getValue()).toString();
|
||||
StringTag name = display.getStringTag("Name");
|
||||
if (name != null) {
|
||||
String newValue = protocol.getTranslatableRewriter().processText(name.getValue()).toString();
|
||||
if (!newValue.equals(name.getValue())) {
|
||||
saveStringTag(display, nameStringTag, "Name");
|
||||
saveStringTag(display, name, "Name");
|
||||
}
|
||||
|
||||
nameStringTag.setValue(newValue);
|
||||
name.setValue(newValue);
|
||||
}
|
||||
|
||||
Tag lore = display.get("Lore");
|
||||
if (lore instanceof ListTag) {
|
||||
ListTag loreListTag = (ListTag) lore;
|
||||
ListTag lore = display.getListTag("Lore");
|
||||
if (lore != null) {
|
||||
boolean changed = false;
|
||||
for (Tag loreEntryTag : loreListTag) {
|
||||
for (Tag loreEntryTag : lore) {
|
||||
if (!(loreEntryTag instanceof StringTag)) {
|
||||
continue;
|
||||
}
|
||||
@@ -78,7 +73,7 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
||||
if (!changed && !newValue.equals(loreEntry.getValue())) {
|
||||
// Backup original lore before doing any modifications
|
||||
changed = true;
|
||||
saveListTag(display, loreListTag, "Lore");
|
||||
saveListTag(display, lore, "Lore");
|
||||
}
|
||||
|
||||
loreEntry.setValue(newValue);
|
||||
@@ -97,12 +92,12 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
||||
}
|
||||
|
||||
// Save original id, set remapped id
|
||||
item.tag().put(nbtTagName + "|id", new IntTag(item.identifier()));
|
||||
item.tag().putInt(nbtTagName + "|id", item.identifier());
|
||||
item.setIdentifier(data.getId());
|
||||
|
||||
// Add custom model data
|
||||
if (data.customModelData() != null && !item.tag().contains("CustomModelData")) {
|
||||
item.tag().put("CustomModelData", new IntTag(data.customModelData()));
|
||||
item.tag().putInt("CustomModelData", data.customModelData());
|
||||
}
|
||||
|
||||
// Set custom name - only done if there is no original one
|
||||
@@ -122,16 +117,16 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
||||
|
||||
super.handleItemToServer(item);
|
||||
if (item.tag() != null) {
|
||||
IntTag originalId = item.tag().remove(nbtTagName + "|id");
|
||||
if (originalId != null) {
|
||||
item.setIdentifier(originalId.asInt());
|
||||
Tag originalId = item.tag().remove(nbtTagName + "|id");
|
||||
if (originalId instanceof IntTag) {
|
||||
item.setIdentifier(((NumberTag) originalId).asInt());
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAdvancements(C packetType, Type<Item> type) {
|
||||
public void registerAdvancements(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
@@ -156,7 +151,7 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
||||
translatableRewriter.processText(description);
|
||||
}
|
||||
|
||||
handleItemToClient(wrapper.passthrough(type)); // Icon
|
||||
handleItemToClient(wrapper.passthrough(getItemType())); // Icon
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0) {
|
||||
@@ -177,4 +172,48 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAdvancements1_20_3(final C packetType) {
|
||||
// Insert translatable rewriter
|
||||
protocol.registerClientbound(packetType, 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 Tag title = wrapper.passthrough(Type.TAG);
|
||||
final Tag description = wrapper.passthrough(Type.TAG);
|
||||
final TranslatableRewriter<C> translatableRewriter = protocol.getTranslatableRewriter();
|
||||
if (translatableRewriter != null) {
|
||||
translatableRewriter.processTag(title);
|
||||
translatableRewriter.processTag(description);
|
||||
}
|
||||
|
||||
handleItemToClient(wrapper.passthrough(Type.ITEM1_20_2)); // Icon
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
final int flags = wrapper.passthrough(Type.INT);
|
||||
if ((flags & 1) != 0) {
|
||||
wrapper.passthrough(Type.STRING); // Background texture
|
||||
}
|
||||
wrapper.passthrough(Type.FLOAT); // X
|
||||
wrapper.passthrough(Type.FLOAT); // Y
|
||||
}
|
||||
|
||||
final int requirements = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int array = 0; array < requirements; array++) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY);
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Send telemetry
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+12
-16
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,16 +30,12 @@ import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class ItemRewriterBase<C extends ClientboundPacketType, S extends ServerboundPacketType,
|
||||
T extends BackwardsProtocol<C, ?, ?, S>> extends ItemRewriter<C, S, T> {
|
||||
T extends BackwardsProtocol<C, ?, ?, S>> extends ItemRewriter<C, S, T> {
|
||||
|
||||
protected final String nbtTagName;
|
||||
protected final boolean jsonNameFormat;
|
||||
|
||||
protected ItemRewriterBase(T protocol, boolean jsonNameFormat) {
|
||||
this(protocol, Type.FLAT_VAR_INT_ITEM, Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, jsonNameFormat);
|
||||
}
|
||||
|
||||
public ItemRewriterBase(T protocol, Type<Item> itemType, Type<Item[]> itemArrayType, boolean jsonNameFormat) {
|
||||
protected ItemRewriterBase(T protocol, Type<Item> itemType, Type<Item[]> itemArrayType, boolean jsonNameFormat) {
|
||||
super(protocol, itemType, itemArrayType);
|
||||
this.jsonNameFormat = jsonNameFormat;
|
||||
nbtTagName = "VB|" + protocol.getClass().getSimpleName();
|
||||
@@ -62,7 +58,7 @@ public abstract class ItemRewriterBase<C extends ClientboundPacketType, S extend
|
||||
// Multiple places might try to backup data
|
||||
String backupName = nbtTagName + "|o" + name;
|
||||
if (!displayTag.contains(backupName)) {
|
||||
displayTag.put(backupName, new StringTag(original.getValue()));
|
||||
displayTag.putString(backupName, original.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +69,7 @@ public abstract class ItemRewriterBase<C extends ClientboundPacketType, S extend
|
||||
// Clone all tag entries
|
||||
ListTag listTag = new ListTag();
|
||||
for (Tag tag : original.getValue()) {
|
||||
listTag.add(tag.clone());
|
||||
listTag.add(tag.copy());
|
||||
}
|
||||
|
||||
displayTag.put(backupName, listTag);
|
||||
@@ -83,7 +79,7 @@ public abstract class ItemRewriterBase<C extends ClientboundPacketType, S extend
|
||||
protected void restoreDisplayTag(Item item) {
|
||||
if (item.tag() == null) return;
|
||||
|
||||
CompoundTag display = item.tag().get("display");
|
||||
CompoundTag display = item.tag().getCompoundTag("display");
|
||||
if (display != null) {
|
||||
// Remove custom name / restore original name
|
||||
if (display.remove(nbtTagName + "|customName") != null) {
|
||||
@@ -98,16 +94,16 @@ public abstract class ItemRewriterBase<C extends ClientboundPacketType, S extend
|
||||
}
|
||||
|
||||
protected void restoreStringTag(CompoundTag tag, String tagName) {
|
||||
StringTag original = tag.remove(nbtTagName + "|o" + tagName);
|
||||
if (original != null) {
|
||||
tag.put(tagName, new StringTag(original.getValue()));
|
||||
Tag original = tag.remove(nbtTagName + "|o" + tagName);
|
||||
if (original instanceof StringTag) {
|
||||
tag.putString(tagName, ((StringTag) original).getValue());
|
||||
}
|
||||
}
|
||||
|
||||
protected void restoreListTag(CompoundTag tag, String tagName) {
|
||||
ListTag original = tag.remove(nbtTagName + "|o" + tagName);
|
||||
if (original != null) {
|
||||
tag.put(tagName, new ListTag(original.getValue()));
|
||||
Tag original = tag.remove(nbtTagName + "|o" + tagName);
|
||||
if (original instanceof ListTag) {
|
||||
tag.put(tagName, new ListTag(((ListTag) original).getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+80
-58
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,6 +30,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
@@ -37,20 +38,18 @@ import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.gson.JsonPrimitive;
|
||||
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;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S extends ServerboundPacketType,
|
||||
T extends BackwardsProtocol<C, ?, ?, S>> extends ItemRewriterBase<C, S, T> {
|
||||
T extends BackwardsProtocol<C, ?, ?, S>> extends ItemRewriterBase<C, S, T> {
|
||||
|
||||
private static final Map<String, Int2ObjectMap<MappedLegacyBlockItem>> LEGACY_MAPPINGS = new HashMap<>();
|
||||
protected final Int2ObjectMap<MappedLegacyBlockItem> replacementData;
|
||||
protected final Int2ObjectMap<MappedLegacyBlockItem> replacementData; // Raw id -> mapped data
|
||||
|
||||
static {
|
||||
JsonObject jsonObject = VBMappingDataLoader.loadFromDataDir("legacy-mappings.json");
|
||||
@@ -58,40 +57,55 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
||||
Int2ObjectMap<MappedLegacyBlockItem> mappings = new Int2ObjectOpenHashMap<>(8);
|
||||
LEGACY_MAPPINGS.put(entry.getKey(), mappings);
|
||||
for (Map.Entry<String, JsonElement> dataEntry : entry.getValue().getAsJsonObject().entrySet()) {
|
||||
JsonObject object = dataEntry.getValue().getAsJsonObject();
|
||||
int id = object.getAsJsonPrimitive("id").getAsInt();
|
||||
JsonPrimitive jsonData = object.getAsJsonPrimitive("data");
|
||||
short data = jsonData != null ? jsonData.getAsShort() : 0;
|
||||
String name = object.getAsJsonPrimitive("name").getAsString();
|
||||
JsonPrimitive blockField = object.getAsJsonPrimitive("block");
|
||||
boolean block = blockField != null && blockField.getAsBoolean();
|
||||
addMapping(dataEntry.getKey(), dataEntry.getValue().getAsJsonObject(), mappings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dataEntry.getKey().indexOf('-') != -1) {
|
||||
// Range of ids
|
||||
String[] split = dataEntry.getKey().split("-", 2);
|
||||
int from = Integer.parseInt(split[0]);
|
||||
int to = Integer.parseInt(split[1]);
|
||||
private static void addMapping(String key, JsonObject object, Int2ObjectMap<MappedLegacyBlockItem> mappings) {
|
||||
int id = object.getAsJsonPrimitive("id").getAsInt();
|
||||
JsonPrimitive jsonData = object.getAsJsonPrimitive("data");
|
||||
short data = jsonData != null ? jsonData.getAsShort() : 0;
|
||||
String name = object.getAsJsonPrimitive("name").getAsString();
|
||||
JsonPrimitive blockField = object.getAsJsonPrimitive("block");
|
||||
boolean block = blockField != null && blockField.getAsBoolean();
|
||||
|
||||
// Special block color handling
|
||||
if (name.contains("%color%")) {
|
||||
for (int i = from; i <= to; i++) {
|
||||
mappings.put(i, new MappedLegacyBlockItem(id, data, name.replace("%color%", BlockColors.get(i - from)), block));
|
||||
}
|
||||
} else {
|
||||
MappedLegacyBlockItem mappedBlockItem = new MappedLegacyBlockItem(id, data, name, block);
|
||||
for (int i = from; i <= to; i++) {
|
||||
mappings.put(i, mappedBlockItem);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mappings.put(Integer.parseInt(dataEntry.getKey()), new MappedLegacyBlockItem(id, data, name, block));
|
||||
}
|
||||
if (key.indexOf('-') == -1) {
|
||||
int unmappedId;
|
||||
int dataSeparatorIndex = key.indexOf(':');
|
||||
if (dataSeparatorIndex != -1) {
|
||||
// Include data
|
||||
short unmappedData = Short.parseShort(key.substring(dataSeparatorIndex + 1));
|
||||
unmappedId = Integer.parseInt(key.substring(0, dataSeparatorIndex));
|
||||
unmappedId = (unmappedId << 4) | (unmappedData & 15);
|
||||
} else {
|
||||
unmappedId = Integer.parseInt(key) << 4;
|
||||
}
|
||||
|
||||
mappings.put(unmappedId, new MappedLegacyBlockItem(id, data, name, block));
|
||||
return;
|
||||
}
|
||||
|
||||
// Range of ids
|
||||
String[] split = key.split("-", 2);
|
||||
int from = Integer.parseInt(split[0]);
|
||||
int to = Integer.parseInt(split[1]);
|
||||
|
||||
// Special block color handling
|
||||
if (name.contains("%color%")) {
|
||||
for (int i = from; i <= to; i++) {
|
||||
mappings.put(i << 4, new MappedLegacyBlockItem(id, data, name.replace("%color%", BlockColors.get(i - from)), block));
|
||||
}
|
||||
} else {
|
||||
MappedLegacyBlockItem mappedBlockItem = new MappedLegacyBlockItem(id, data, name, block);
|
||||
for (int i = from; i <= to; i++) {
|
||||
mappings.put(i << 4, mappedBlockItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected LegacyBlockItemRewriter(T protocol) {
|
||||
super(protocol, false);
|
||||
super(protocol, Type.ITEM1_8, Type.ITEM1_8_SHORT_ARRAY, false);
|
||||
replacementData = LEGACY_MAPPINGS.get(protocol.getClass().getSimpleName().split("To")[1].replace("_", "."));
|
||||
}
|
||||
|
||||
@@ -99,7 +113,7 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
||||
public @Nullable Item handleItemToClient(@Nullable Item item) {
|
||||
if (item == null) return null;
|
||||
|
||||
MappedLegacyBlockItem data = replacementData.get(item.identifier());
|
||||
MappedLegacyBlockItem data = getMappedBlockItem(item.identifier(), item.data());
|
||||
if (data == null) {
|
||||
// Just rewrite the id
|
||||
return super.handleItemToClient(item);
|
||||
@@ -118,21 +132,22 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
||||
item.setTag(new CompoundTag());
|
||||
}
|
||||
|
||||
CompoundTag display = item.tag().get("display");
|
||||
CompoundTag display = item.tag().getCompoundTag("display");
|
||||
if (display == null) {
|
||||
item.tag().put("display", display = new CompoundTag());
|
||||
}
|
||||
|
||||
StringTag nameTag = display.get("Name");
|
||||
StringTag nameTag = display.getStringTag("Name");
|
||||
if (nameTag == null) {
|
||||
display.put("Name", nameTag = new StringTag(data.getName()));
|
||||
nameTag = new StringTag(data.getName());
|
||||
display.put("Name", nameTag);
|
||||
display.put(nbtTagName + "|customName", new ByteTag());
|
||||
}
|
||||
|
||||
// Handle colors
|
||||
String value = nameTag.getValue();
|
||||
if (value.contains("%vb_color%")) {
|
||||
display.put("Name", new StringTag(value.replace("%vb_color%", BlockColors.get(originalData))));
|
||||
display.putString("Name", value.replace("%vb_color%", BlockColors.get(originalData)));
|
||||
}
|
||||
}
|
||||
return item;
|
||||
@@ -149,7 +164,7 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
||||
}
|
||||
|
||||
public @Nullable Block handleBlock(int blockId, int data) {
|
||||
MappedLegacyBlockItem settings = replacementData.get(blockId);
|
||||
MappedLegacyBlockItem settings = getMappedBlockItem(blockId, data);
|
||||
if (settings == null || !settings.isBlock()) return null;
|
||||
|
||||
Block block = settings.getBlock();
|
||||
@@ -160,21 +175,30 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
||||
return block;
|
||||
}
|
||||
|
||||
private @Nullable MappedLegacyBlockItem getMappedBlockItem(int id, int data) {
|
||||
MappedLegacyBlockItem mapping = replacementData.get((id << 4) | (data & 15));
|
||||
return mapping != null || data == 0 ? mapping : replacementData.get(id << 4);
|
||||
}
|
||||
|
||||
private @Nullable MappedLegacyBlockItem getMappedBlockItem(int rawId) {
|
||||
MappedLegacyBlockItem mapping = replacementData.get(rawId);
|
||||
return mapping != null ? mapping : replacementData.get(rawId & ~15);
|
||||
}
|
||||
|
||||
protected void handleChunk(Chunk chunk) {
|
||||
// Map Block Entities
|
||||
Map<Pos, CompoundTag> tags = new HashMap<>();
|
||||
for (CompoundTag tag : chunk.getBlockEntities()) {
|
||||
Tag xTag;
|
||||
Tag yTag;
|
||||
Tag zTag;
|
||||
if ((xTag = tag.get("x")) == null || (yTag = tag.get("y")) == null || (zTag = tag.get("z")) == null) {
|
||||
NumberTag xTag;
|
||||
NumberTag yTag;
|
||||
NumberTag zTag;
|
||||
if ((xTag = tag.getNumberTag("x")) == null
|
||||
|| (yTag = tag.getNumberTag("y")) == null
|
||||
|| (zTag = tag.getNumberTag("z")) == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Pos pos = new Pos(
|
||||
((NumberTag) xTag).asInt() & 0xF,
|
||||
((NumberTag) yTag).asInt(),
|
||||
((NumberTag) zTag).asInt() & 0xF);
|
||||
Pos pos = new Pos(xTag.asInt() & 0xF, yTag.asInt(), zTag.asInt() & 0xF);
|
||||
tags.put(pos, tag);
|
||||
|
||||
// Handle given Block Entities
|
||||
@@ -184,9 +208,8 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
||||
if (section == null) continue;
|
||||
|
||||
int block = section.palette(PaletteType.BLOCKS).idAt(pos.getX(), pos.getY() & 0xF, pos.getZ());
|
||||
int btype = block >> 4;
|
||||
|
||||
MappedLegacyBlockItem settings = replacementData.get(btype);
|
||||
MappedLegacyBlockItem settings = getMappedBlockItem(block);
|
||||
if (settings != null && settings.hasBlockEntityHandler()) {
|
||||
settings.getBlockEntityHandler().handleOrNewCompoundTag(block, tag);
|
||||
}
|
||||
@@ -215,7 +238,7 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
||||
// We already know that is has a handler
|
||||
if (hasBlockEntityHandler) continue;
|
||||
|
||||
MappedLegacyBlockItem settings = replacementData.get(btype);
|
||||
MappedLegacyBlockItem settings = getMappedBlockItem(block);
|
||||
if (settings != null && settings.hasBlockEntityHandler()) {
|
||||
hasBlockEntityHandler = true;
|
||||
}
|
||||
@@ -228,10 +251,8 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
||||
for (int y = 0; y < 16; y++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int block = palette.idAt(x, y, z);
|
||||
int btype = block >> 4;
|
||||
int meta = block & 15;
|
||||
|
||||
MappedLegacyBlockItem settings = replacementData.get(btype);
|
||||
MappedLegacyBlockItem settings = getMappedBlockItem(block);
|
||||
if (settings == null || !settings.hasBlockEntityHandler()) continue;
|
||||
|
||||
Pos pos = new Pos(x, (y + (i << 4)), z);
|
||||
@@ -240,9 +261,9 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
||||
if (tags.containsKey(pos)) continue;
|
||||
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.put("x", new IntTag(x + (chunk.getX() << 4)));
|
||||
tag.put("y", new IntTag(y + (i << 4)));
|
||||
tag.put("z", new IntTag(z + (chunk.getZ() << 4)));
|
||||
tag.putInt("x", x + (chunk.getX() << 4));
|
||||
tag.putInt("y", y + (i << 4));
|
||||
tag.putInt("z", z + (chunk.getZ() << 4));
|
||||
|
||||
settings.getBlockEntityHandler().handleOrNewCompoundTag(block, tag);
|
||||
chunk.getBlockEntities().add(tag);
|
||||
@@ -254,9 +275,10 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
||||
|
||||
protected CompoundTag getNamedTag(String text) {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.put("display", new CompoundTag());
|
||||
CompoundTag displayTag = new CompoundTag();
|
||||
tag.put("display", displayTag);
|
||||
text = "§r" + text;
|
||||
((CompoundTag) tag.get("display")).put("Name", new StringTag(jsonNameFormat ? ChatRewriter.legacyTextToJsonString(text) : text));
|
||||
displayTag.putString("Name", jsonNameFormat ? ComponentUtil.legacyToJsonString(text) : text);
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
+39
-28
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,6 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ShortTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import java.util.ArrayList;
|
||||
@@ -48,18 +47,24 @@ public class LegacyEnchantmentRewriter {
|
||||
|
||||
public void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) {
|
||||
String key = storedEnchant ? "StoredEnchantments" : "ench";
|
||||
ListTag enchantments = tag.get(key);
|
||||
ListTag enchantments = tag.getListTag(key);
|
||||
ListTag remappedEnchantments = new ListTag(CompoundTag.class);
|
||||
List<Tag> lore = new ArrayList<>();
|
||||
for (Tag enchantmentEntry : enchantments.clone()) {
|
||||
Tag idTag = ((CompoundTag) enchantmentEntry).get("id");
|
||||
for (Tag enchantmentEntry : enchantments.copy()) {
|
||||
if (!(enchantmentEntry instanceof CompoundTag)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CompoundTag entryTag = (CompoundTag) enchantmentEntry;
|
||||
NumberTag idTag = entryTag.getNumberTag("id");
|
||||
if (idTag == null) continue;
|
||||
|
||||
short newId = ((NumberTag) idTag).asShort();
|
||||
short newId = idTag.asShort();
|
||||
String enchantmentName = enchantmentMappings.get(newId);
|
||||
if (enchantmentName != null) {
|
||||
enchantments.remove(enchantmentEntry);
|
||||
short level = ((NumberTag) ((CompoundTag) enchantmentEntry).get("lvl")).asShort();
|
||||
NumberTag levelTag = entryTag.getNumberTag("lvl");
|
||||
short level = levelTag != null ? levelTag.asShort() : 1;
|
||||
if (hideLevelForEnchants != null && hideLevelForEnchants.contains(newId)) {
|
||||
lore.add(new StringTag(enchantmentName));
|
||||
} else {
|
||||
@@ -69,33 +74,32 @@ public class LegacyEnchantmentRewriter {
|
||||
}
|
||||
}
|
||||
if (!lore.isEmpty()) {
|
||||
if (!storedEnchant && enchantments.size() == 0) {
|
||||
if (!storedEnchant && enchantments.isEmpty()) {
|
||||
CompoundTag dummyEnchantment = new CompoundTag();
|
||||
dummyEnchantment.put("id", new ShortTag((short) 0));
|
||||
dummyEnchantment.put("lvl", new ShortTag((short) 0));
|
||||
dummyEnchantment.putShort("id", (short) 0);
|
||||
dummyEnchantment.putShort("lvl", (short) 0);
|
||||
enchantments.add(dummyEnchantment);
|
||||
|
||||
tag.put(nbtTagName + "|dummyEnchant", new ByteTag());
|
||||
|
||||
IntTag hideFlags = tag.get("HideFlags");
|
||||
NumberTag hideFlags = tag.getNumberTag("HideFlags");
|
||||
if (hideFlags == null) {
|
||||
hideFlags = new IntTag();
|
||||
} else {
|
||||
tag.put(nbtTagName + "|oldHideFlags", new IntTag(hideFlags.asByte()));
|
||||
tag.putInt(nbtTagName + "|oldHideFlags", hideFlags.asByte());
|
||||
}
|
||||
|
||||
int flags = hideFlags.asByte() | 1;
|
||||
hideFlags.setValue(flags);
|
||||
tag.put("HideFlags", hideFlags);
|
||||
tag.putInt("HideFlags", flags);
|
||||
}
|
||||
|
||||
tag.put(nbtTagName + "|" + key, remappedEnchantments);
|
||||
|
||||
CompoundTag display = tag.get("display");
|
||||
CompoundTag display = tag.getCompoundTag("display");
|
||||
if (display == null) {
|
||||
tag.put("display", display = new CompoundTag());
|
||||
}
|
||||
ListTag loreTag = display.get("Lore");
|
||||
ListTag loreTag = display.getListTag("Lore");
|
||||
if (loreTag == null) {
|
||||
display.put("Lore", loreTag = new ListTag(StringTag.class));
|
||||
}
|
||||
@@ -108,38 +112,45 @@ public class LegacyEnchantmentRewriter {
|
||||
public void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnchant) {
|
||||
String key = storedEnchant ? "StoredEnchantments" : "ench";
|
||||
ListTag remappedEnchantments = tag.remove(nbtTagName + "|" + key);
|
||||
ListTag enchantments = tag.get(key);
|
||||
ListTag enchantments = tag.getListTag(key);
|
||||
if (enchantments == null) {
|
||||
enchantments = new ListTag(CompoundTag.class);
|
||||
}
|
||||
|
||||
if (!storedEnchant && tag.remove(nbtTagName + "|dummyEnchant") != null) {
|
||||
for (Tag enchantment : enchantments.clone()) {
|
||||
short id = ((NumberTag) ((CompoundTag) enchantment).get("id")).asShort();
|
||||
short level = ((NumberTag) ((CompoundTag) enchantment).get("lvl")).asShort();
|
||||
for (Tag enchantment : enchantments.copy()) {
|
||||
if (!(enchantment instanceof CompoundTag)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CompoundTag entryTag = (CompoundTag) enchantment;
|
||||
NumberTag idTag = entryTag.getNumberTag("id");
|
||||
NumberTag levelTag = entryTag.getNumberTag("lvl");
|
||||
short id = idTag != null ? idTag.asShort() : 0;
|
||||
short level = levelTag != null ? levelTag.asShort() : 0;
|
||||
if (id == 0 && level == 0) {
|
||||
enchantments.remove(enchantment);
|
||||
}
|
||||
}
|
||||
|
||||
IntTag hideFlags = tag.remove(nbtTagName + "|oldHideFlags");
|
||||
if (hideFlags != null) {
|
||||
tag.put("HideFlags", new IntTag(hideFlags.asByte()));
|
||||
Tag hideFlags = tag.remove(nbtTagName + "|oldHideFlags");
|
||||
if (hideFlags instanceof IntTag) {
|
||||
tag.putInt("HideFlags", ((IntTag) hideFlags).asByte());
|
||||
} else {
|
||||
tag.remove("HideFlags");
|
||||
}
|
||||
}
|
||||
|
||||
CompoundTag display = tag.get("display");
|
||||
CompoundTag display = tag.getCompoundTag("display");
|
||||
// A few null checks just to be safe, though they shouldn't actually be
|
||||
ListTag lore = display != null ? display.get("Lore") : null;
|
||||
for (Tag enchantment : remappedEnchantments.clone()) {
|
||||
ListTag lore = display != null ? display.getListTag("Lore") : null;
|
||||
for (Tag enchantment : remappedEnchantments.copy()) {
|
||||
enchantments.add(enchantment);
|
||||
if (lore != null && lore.size() != 0) {
|
||||
if (lore != null && !lore.isEmpty()) {
|
||||
lore.remove(lore.get(0));
|
||||
}
|
||||
}
|
||||
if (lore != null && lore.size() == 0) {
|
||||
if (lore != null && lore.isEmpty()) {
|
||||
display.remove("Lore");
|
||||
if (display.isEmpty()) {
|
||||
tag.remove("display");
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,6 +22,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityData;
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityObjectData;
|
||||
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.ObjectType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
@@ -32,7 +33,6 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,9 +37,7 @@ public final class MapColorRewriter {
|
||||
wrapper.passthrough(Type.BYTE); // X
|
||||
wrapper.passthrough(Type.BYTE); // Z
|
||||
wrapper.passthrough(Type.BYTE); // Direction
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.COMPONENT); // Display Name
|
||||
}
|
||||
wrapper.passthrough(Type.OPTIONAL_COMPONENT); // Display Name
|
||||
}
|
||||
|
||||
short columns = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
-79
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,9 +21,6 @@ import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.VBMappingDataLoader;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
@@ -34,101 +31,43 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
public class TranslatableRewriter<C extends ClientboundPacketType> extends ComponentRewriter<C> {
|
||||
|
||||
private static final Map<String, Map<String, String>> TRANSLATABLES = new HashMap<>();
|
||||
private final Map<String, String> newTranslatables;
|
||||
private final Map<String, String> translatables;
|
||||
|
||||
public static void loadTranslatables() {
|
||||
JsonObject jsonObject = VBMappingDataLoader.loadFromDataDir("translation-mappings.json");
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
|
||||
Map<String, String> versionMappings = new HashMap<>();
|
||||
final JsonObject jsonObject = VBMappingDataLoader.loadFromDataDir("translation-mappings.json");
|
||||
for (final Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
|
||||
final Map<String, String> versionMappings = new HashMap<>();
|
||||
TRANSLATABLES.put(entry.getKey(), versionMappings);
|
||||
for (Map.Entry<String, JsonElement> translationEntry : entry.getValue().getAsJsonObject().entrySet()) {
|
||||
for (final Map.Entry<String, JsonElement> translationEntry : entry.getValue().getAsJsonObject().entrySet()) {
|
||||
versionMappings.put(translationEntry.getKey(), translationEntry.getValue().getAsString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TranslatableRewriter(BackwardsProtocol<C, ?, ?, ?> protocol) {
|
||||
this(protocol, protocol.getClass().getSimpleName().split("To")[1].replace("_", "."));
|
||||
public TranslatableRewriter(final BackwardsProtocol<C, ?, ?, ?> protocol, final ReadType type) {
|
||||
this(protocol, type, protocol.getClass().getSimpleName().split("To")[1].replace("_", "."));
|
||||
}
|
||||
|
||||
public TranslatableRewriter(BackwardsProtocol<C, ?, ?, ?> protocol, String sectionIdentifier) {
|
||||
super(protocol);
|
||||
final Map<String, String> newTranslatables = TRANSLATABLES.get(sectionIdentifier);
|
||||
if (newTranslatables == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Error loading " + sectionIdentifier + " translatables!");
|
||||
this.newTranslatables = new HashMap<>();
|
||||
public TranslatableRewriter(final BackwardsProtocol<C, ?, ?, ?> protocol, final ReadType type, final String sectionIdentifier) {
|
||||
super(protocol, type);
|
||||
final Map<String, String> translatableMappings = TRANSLATABLES.get(sectionIdentifier);
|
||||
if (translatableMappings == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing " + sectionIdentifier + " translatables!");
|
||||
this.translatables = new HashMap<>();
|
||||
} else {
|
||||
this.newTranslatables = newTranslatables;
|
||||
this.translatables = translatableMappings;
|
||||
}
|
||||
}
|
||||
|
||||
public void registerPing() {
|
||||
protocol.registerClientbound(State.LOGIN, 0x00, 0x00, wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
|
||||
public void registerDisconnect(C packetType) {
|
||||
protocol.registerClientbound(packetType, wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
|
||||
public void registerLegacyOpenWindow(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // Id
|
||||
map(Type.STRING); // Window Type
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerOpenWindow(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Id
|
||||
map(Type.VAR_INT); // Window Type
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerTabList(C packetType) {
|
||||
protocol.registerClientbound(packetType, wrapper -> {
|
||||
processText(wrapper.passthrough(Type.COMPONENT));
|
||||
processText(wrapper.passthrough(Type.COMPONENT));
|
||||
});
|
||||
}
|
||||
|
||||
public void registerCombatKill(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.INT);
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerCombatKill1_20(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Duration
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject root, String translate) {
|
||||
String newTranslate = mappedTranslationKey(translate);
|
||||
protected void handleTranslate(final JsonObject root, final String translate) {
|
||||
final String newTranslate = mappedTranslationKey(translate);
|
||||
if (newTranslate != null) {
|
||||
root.addProperty("translate", newTranslate);
|
||||
}
|
||||
}
|
||||
|
||||
public @Nullable String mappedTranslationKey(final String translationKey) {
|
||||
return newTranslatables.get(translationKey);
|
||||
return translatables.get(translationKey);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
-5
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,11 +26,11 @@ import com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets.EntityPac
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets.PlayerPackets1_11;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_10To1_11 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
||||
|
||||
@@ -57,10 +57,10 @@ public class Protocol1_10To1_11 extends BackwardsProtocol<ClientboundPackets1_9_
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
user.put(new ClientWorld());
|
||||
}
|
||||
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_11Types.EntityType.PLAYER));
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_11.EntityType.PLAYER));
|
||||
|
||||
if (!user.has(WindowTracker.class)) {
|
||||
user.put(new WindowTracker());
|
||||
|
||||
+43
-51
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
@@ -28,24 +28,19 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
|
||||
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_11to1_10.EntityIdRewriter;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_3_4Type;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -64,23 +59,20 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot ID
|
||||
map(Type.ITEM); // 2 - Slot Value
|
||||
map(Type.ITEM1_8); // 2 - Slot Value
|
||||
|
||||
handler(itemToClientHandler(Type.ITEM));
|
||||
handler(itemToClientHandler(Type.ITEM1_8));
|
||||
|
||||
// Handle Llama
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
if (isLlama(wrapper.user())) {
|
||||
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
|
||||
if (!horse.isPresent())
|
||||
return;
|
||||
ChestedHorseStorage storage = horse.get();
|
||||
int currentSlot = wrapper.get(Type.SHORT, 0);
|
||||
wrapper.set(Type.SHORT, 0, ((Integer) (currentSlot = getNewSlotId(storage, currentSlot))).shortValue());
|
||||
wrapper.set(Type.ITEM, 0, getNewItem(storage, currentSlot, wrapper.get(Type.ITEM, 0)));
|
||||
}
|
||||
handler(wrapper -> {
|
||||
if (isLlama(wrapper.user())) {
|
||||
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
|
||||
if (!horse.isPresent())
|
||||
return;
|
||||
ChestedHorseStorage storage = horse.get();
|
||||
int currentSlot = wrapper.get(Type.SHORT, 0);
|
||||
wrapper.set(Type.SHORT, 0, ((Integer) (currentSlot = getNewSlotId(storage, currentSlot))).shortValue());
|
||||
wrapper.set(Type.ITEM1_8, 0, getNewItem(storage, currentSlot, wrapper.get(Type.ITEM1_8, 0)));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -90,10 +82,10 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.ITEM_ARRAY); // 1 - Window Values
|
||||
map(Type.ITEM1_8_SHORT_ARRAY); // 1 - Window Values
|
||||
|
||||
handler(wrapper -> {
|
||||
Item[] stacks = wrapper.get(Type.ITEM_ARRAY, 0);
|
||||
Item[] stacks = wrapper.get(Type.ITEM1_8_SHORT_ARRAY, 0);
|
||||
for (int i = 0; i < stacks.length; i++)
|
||||
stacks[i] = handleItemToClient(stacks[i]);
|
||||
|
||||
@@ -108,32 +100,32 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
stacks[getNewSlotId(storage, i)] = stacks[i];
|
||||
stacks[i] = getNewItem(storage, i, stacks[i]);
|
||||
}
|
||||
wrapper.set(Type.ITEM_ARRAY, 0, stacks);
|
||||
wrapper.set(Type.ITEM1_8_SHORT_ARRAY, 0, stacks);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT);
|
||||
|
||||
// Plugin message Packet -> Trading
|
||||
// Plugin message -> Trading
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.STRING); // 0 - Channel
|
||||
|
||||
handler(wrapper -> {
|
||||
if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) {
|
||||
if (wrapper.get(Type.STRING, 0).equals("MC|TrList")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Input Item
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
|
||||
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Input Item
|
||||
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Output Item
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||
if (secondItem) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Second Item
|
||||
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Second Item
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
@@ -153,9 +145,9 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
map(Type.BYTE); // 2 - Button
|
||||
map(Type.SHORT); // 3 - Action number
|
||||
map(Type.VAR_INT); // 4 - Mode
|
||||
map(Type.ITEM); // 5 - Clicked Item
|
||||
map(Type.ITEM1_8); // 5 - Clicked Item
|
||||
|
||||
handler(itemToServerHandler(Type.ITEM));
|
||||
handler(itemToServerHandler(Type.ITEM1_8));
|
||||
|
||||
// Llama slot
|
||||
handler(wrapper -> {
|
||||
@@ -173,24 +165,24 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
}
|
||||
});
|
||||
|
||||
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
|
||||
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); // Use the 1.10 Chunk type since nothing changed.
|
||||
ChunkType1_9_3 type = ChunkType1_9_3.forEnvironment(clientWorld.getEnvironment()); // Use the 1.10 Chunk type since nothing changed.
|
||||
Chunk chunk = wrapper.passthrough(type);
|
||||
|
||||
handleChunk(chunk);
|
||||
|
||||
// only patch it for signs for now
|
||||
for (CompoundTag tag : chunk.getBlockEntities()) {
|
||||
Tag idTag = tag.get("id");
|
||||
if (!(idTag instanceof StringTag)) continue;
|
||||
StringTag idTag = tag.getStringTag("id");
|
||||
if (idTag == null) continue;
|
||||
|
||||
String id = (String) idTag.getValue();
|
||||
String id = idTag.getValue();
|
||||
if (id.equals("minecraft:sign")) {
|
||||
((StringTag) idTag).setValue("Sign");
|
||||
idTag.setValue("Sign");
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -198,7 +190,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.BLOCK_CHANGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.POSITION); // 0 - Block Position
|
||||
map(Type.POSITION1_8); // 0 - Block Position
|
||||
map(Type.VAR_INT); // 1 - Block
|
||||
|
||||
handler(wrapper -> {
|
||||
@@ -226,9 +218,9 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
map(Type.POSITION1_8); // 0 - Position
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Action
|
||||
map(Type.NBT); // 2 - NBT
|
||||
map(Type.NAMED_COMPOUND_TAG); // 2 - NBT
|
||||
|
||||
handler(wrapper -> {
|
||||
// Remove on shulkerbox decleration
|
||||
@@ -237,7 +229,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
}
|
||||
// Handler Spawners
|
||||
if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 1) {
|
||||
CompoundTag tag = wrapper.get(Type.NBT, 0);
|
||||
CompoundTag tag = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||
EntityIdRewriter.toClientSpawner(tag, true);
|
||||
}
|
||||
});
|
||||
@@ -299,7 +291,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
});
|
||||
|
||||
protocol.getEntityRewriter().filter().handler((event, meta) -> {
|
||||
if (meta.metaType().type().equals(Type.ITEM)) // Is Item
|
||||
if (meta.metaType().type().equals(Type.ITEM1_8)) // Is Item
|
||||
meta.setValue(handleItemToClient((Item) meta.getValue()));
|
||||
});
|
||||
}
|
||||
@@ -307,7 +299,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
// Handle spawner block entity (map to itself with custom handler)
|
||||
MappedLegacyBlockItem data = replacementData.computeIfAbsent(52, s -> new MappedLegacyBlockItem(52, (short) -1, null, false));
|
||||
MappedLegacyBlockItem data = replacementData.computeIfAbsent(52 << 4, s -> new MappedLegacyBlockItem(52, (short) -1, null, false));
|
||||
data.setBlockEntityHandler((b, tag) -> {
|
||||
EntityIdRewriter.toClientSpawner(tag, true);
|
||||
return tag;
|
||||
@@ -331,10 +323,10 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
// Rewrite spawn eggs (id checks are done in the method itself)
|
||||
EntityIdRewriter.toClientItem(item, true);
|
||||
|
||||
if (tag.get("ench") instanceof ListTag) {
|
||||
if (tag.getListTag("ench") != null) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToClient(tag, false);
|
||||
}
|
||||
if (tag.get("StoredEnchantments") instanceof ListTag) {
|
||||
if (tag.getListTag("StoredEnchantments") != null) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToClient(tag, true);
|
||||
}
|
||||
return item;
|
||||
@@ -351,10 +343,10 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
// Rewrite spawn eggs (id checks are done in the method itself)
|
||||
EntityIdRewriter.toServerItem(item, true);
|
||||
|
||||
if (tag.contains(nbtTagName + "|ench")) {
|
||||
if (tag.getListTag(nbtTagName + "|ench") != null) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToServer(tag, false);
|
||||
}
|
||||
if (tag.contains(nbtTagName + "|StoredEnchantments")) {
|
||||
if (tag.getListTag(nbtTagName + "|StoredEnchantments") != null) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToServer(tag, true);
|
||||
}
|
||||
return item;
|
||||
@@ -365,7 +357,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
if (tracker.getInventory() != null && tracker.getInventory().equals("EntityHorse")) {
|
||||
EntityTracker entTracker = user.getEntityTracker(Protocol1_10To1_11.class);
|
||||
StoredEntityData entityData = entTracker.entityData(tracker.getEntityId());
|
||||
return entityData != null && entityData.type().is(Entity1_11Types.EntityType.LIAMA);
|
||||
return entityData != null && entityData.type().is(EntityTypes1_11.EntityType.LIAMA);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
+47
-47
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,9 @@ import com.viaversion.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_1
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.ChestedHorseStorage;
|
||||
import com.viaversion.viabackwards.utils.Block;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
@@ -50,7 +50,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT);
|
||||
map(Type.POSITION);
|
||||
map(Type.POSITION1_8);
|
||||
map(Type.INT);
|
||||
handler(wrapper -> {
|
||||
int type = wrapper.get(Type.INT, 0);
|
||||
@@ -84,12 +84,12 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
// Track Entity
|
||||
handler(getObjectTrackerHandler());
|
||||
handler(getObjectRewriter(id -> Entity1_11Types.ObjectType.findById(id).orElse(null)));
|
||||
handler(getObjectRewriter(id -> EntityTypes1_11.ObjectType.findById(id).orElse(null)));
|
||||
|
||||
// Handle FallingBlock blocks
|
||||
handler(wrapper -> {
|
||||
Optional<Entity1_12Types.ObjectType> type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||
if (type.isPresent() && type.get() == Entity1_12Types.ObjectType.FALLING_BLOCK) {
|
||||
Optional<EntityTypes1_12.ObjectType> type = EntityTypes1_12.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||
if (type.isPresent() && type.get() == EntityTypes1_12.ObjectType.FALLING_BLOCK) {
|
||||
int objectData = wrapper.get(Type.INT, 0);
|
||||
int objType = objectData & 4095;
|
||||
int data = objectData >> 12 & 15;
|
||||
@@ -104,8 +104,8 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, Entity1_11Types.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, Entity1_11Types.EntityType.WEATHER);
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, EntityTypes1_11.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, EntityTypes1_11.EntityType.WEATHER);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
@@ -151,8 +151,8 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_PAINTING, Entity1_11Types.EntityType.PAINTING);
|
||||
registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, Entity1_11Types.EntityType.PLAYER);
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_PAINTING, EntityTypes1_11.EntityType.PAINTING);
|
||||
registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, EntityTypes1_11.EntityType.PLAYER);
|
||||
registerRespawn(ClientboundPackets1_9_3.RESPAWN);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketHandlers() {
|
||||
@@ -167,7 +167,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Types1_9.METADATA_LIST); // 7 - Metadata list
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_9.METADATA_LIST, Entity1_11Types.EntityType.PLAYER));
|
||||
handler(getTrackerAndMetaHandler(Types1_9.METADATA_LIST, EntityTypes1_11.EntityType.PLAYER));
|
||||
handler(wrapper -> {
|
||||
// Sub 1.11 clients will cry if the list is empty
|
||||
List<Metadata> metadata = wrapper.get(Types1_9.METADATA_LIST, 0);
|
||||
@@ -204,37 +204,37 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
// Guardian
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.ELDER_GUARDIAN, Entity1_11Types.EntityType.GUARDIAN);
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.ELDER_GUARDIAN, EntityTypes1_11.EntityType.GUARDIAN);
|
||||
// Skeletons
|
||||
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)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.WITHER_SKELETON, EntityTypes1_11.EntityType.SKELETON).spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(1)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.STRAY, EntityTypes1_11.EntityType.SKELETON).plainName().spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(2)));
|
||||
// Zombies
|
||||
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));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.HUSK, EntityTypes1_11.EntityType.ZOMBIE).plainName().spawnMetadata(storage -> handleZombieType(storage, 6));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.ZOMBIE_VILLAGER, EntityTypes1_11.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.
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.DONKEY, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.MULE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(2)));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.SKELETON_HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(4)));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.ZOMBIE_HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(3)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.HORSE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(0))); // Nob able to ride the horse without having the MetaType sent.
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.DONKEY, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.MULE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(2)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.SKELETON_HORSE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(4)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.ZOMBIE_HORSE, EntityTypes1_11.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).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);
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.EVOCATION_FANGS, EntityTypes1_11.EntityType.SHULKER);
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.EVOCATION_ILLAGER, EntityTypes1_11.EntityType.VILLAGER).plainName();
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.VEX, EntityTypes1_11.EntityType.BAT).plainName();
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.VINDICATION_ILLAGER, EntityTypes1_11.EntityType.VILLAGER).plainName().spawnMetadata(storage -> storage.add(new Metadata(13, MetaType1_9.VarInt, 4))); // Base Profession
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.LIAMA, EntityTypes1_11.EntityType.HORSE).plainName().spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.LIAMA_SPIT, EntityTypes1_11.EntityType.SNOWBALL);
|
||||
|
||||
mapObjectType(Entity1_11Types.ObjectType.LIAMA_SPIT, Entity1_11Types.ObjectType.SNOWBALL, -1);
|
||||
mapObjectType(EntityTypes1_11.ObjectType.LIAMA_SPIT, EntityTypes1_11.ObjectType.SNOWBALL, -1);
|
||||
// Replace with endertorchthingies
|
||||
mapObjectType(Entity1_11Types.ObjectType.EVOCATION_FANGS, Entity1_11Types.ObjectType.FALLING_BLOCK, 198 | 1 << 12);
|
||||
mapObjectType(EntityTypes1_11.ObjectType.EVOCATION_FANGS, EntityTypes1_11.ObjectType.FALLING_BLOCK, 198 | 1 << 12);
|
||||
|
||||
// Handle ElderGuardian & target metadata
|
||||
filter().filterFamily(Entity1_11Types.EntityType.GUARDIAN).index(12).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_11.EntityType.GUARDIAN).index(12).handler((event, meta) -> {
|
||||
boolean b = (boolean) meta.getValue();
|
||||
int bitmask = b ? 0x02 : 0;
|
||||
|
||||
if (event.entityType() == Entity1_11Types.EntityType.ELDER_GUARDIAN) {
|
||||
if (event.entityType() == EntityTypes1_11.EntityType.ELDER_GUARDIAN) {
|
||||
bitmask |= 0x04;
|
||||
}
|
||||
|
||||
@@ -242,12 +242,12 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
});
|
||||
|
||||
// Handle skeleton swing
|
||||
filter().filterFamily(Entity1_11Types.EntityType.ABSTRACT_SKELETON).index(12).toIndex(13);
|
||||
filter().type(EntityTypes1_11.EntityType.ABSTRACT_SKELETON).index(12).toIndex(13);
|
||||
|
||||
/*
|
||||
ZOMBIE CHANGES
|
||||
*/
|
||||
filter().filterFamily(Entity1_11Types.EntityType.ZOMBIE).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_11.EntityType.ZOMBIE).handler((event, meta) -> {
|
||||
switch (meta.id()) {
|
||||
case 13:
|
||||
event.cancel();
|
||||
@@ -267,18 +267,18 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
});
|
||||
|
||||
// Handle Evocation Illager
|
||||
filter().type(Entity1_11Types.EntityType.EVOCATION_ILLAGER).index(12).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_11.EntityType.EVOCATION_ILLAGER).index(12).handler((event, meta) -> {
|
||||
event.setIndex(13);
|
||||
meta.setTypeAndValue(MetaType1_9.VarInt, ((Byte) meta.getValue()).intValue()); // Change the profession for the states
|
||||
});
|
||||
|
||||
// Handle Vex (Remove this field completely since the position is not updated correctly when idling for bats. Sad ):
|
||||
filter().type(Entity1_11Types.EntityType.VEX).index(12).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_11.EntityType.VEX).index(12).handler((event, meta) -> {
|
||||
meta.setValue((byte) 0x00);
|
||||
});
|
||||
|
||||
// Handle VindicationIllager
|
||||
filter().type(Entity1_11Types.EntityType.VINDICATION_ILLAGER).index(12).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_11.EntityType.VINDICATION_ILLAGER).index(12).handler((event, meta) -> {
|
||||
event.setIndex(13);
|
||||
meta.setTypeAndValue(MetaType1_9.VarInt, ((Number) meta.getValue()).intValue() == 1 ? 2 : 4);
|
||||
});
|
||||
@@ -288,7 +288,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
*/
|
||||
|
||||
// Handle horse flags
|
||||
filter().filterFamily(Entity1_11Types.EntityType.ABSTRACT_HORSE).index(13).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_11.EntityType.ABSTRACT_HORSE).index(13).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
byte b = (byte) meta.getValue();
|
||||
if (data.has(ChestedHorseStorage.class) && data.get(ChestedHorseStorage.class).isChested()) {
|
||||
@@ -298,7 +298,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
});
|
||||
|
||||
// Create chested horse storage
|
||||
filter().filterFamily(Entity1_11Types.EntityType.CHESTED_HORSE).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_11.EntityType.CHESTED_HORSE).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
if (!data.has(ChestedHorseStorage.class)) {
|
||||
data.put(new ChestedHorseStorage());
|
||||
@@ -306,10 +306,10 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
});
|
||||
|
||||
// Handle horse armor
|
||||
filter().type(Entity1_11Types.EntityType.HORSE).index(16).toIndex(17);
|
||||
filter().type(EntityTypes1_11.EntityType.HORSE).index(16).toIndex(17);
|
||||
|
||||
// Handle chested horse
|
||||
filter().filterFamily(Entity1_11Types.EntityType.CHESTED_HORSE).index(15).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_11.EntityType.CHESTED_HORSE).index(15).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
ChestedHorseStorage storage = data.get(ChestedHorseStorage.class);
|
||||
boolean b = (boolean) meta.getValue();
|
||||
@@ -318,7 +318,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
});
|
||||
|
||||
// Get rid of Liama metadata
|
||||
filter().type(Entity1_11Types.EntityType.LIAMA).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_11.EntityType.LIAMA).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
ChestedHorseStorage storage = data.get(ChestedHorseStorage.class);
|
||||
|
||||
@@ -341,17 +341,17 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
});
|
||||
|
||||
// Handle Horse (Correct owner)
|
||||
filter().filterFamily(Entity1_11Types.EntityType.ABSTRACT_HORSE).index(14).toIndex(16);
|
||||
filter().type(EntityTypes1_11.EntityType.ABSTRACT_HORSE).index(14).toIndex(16);
|
||||
|
||||
// Handle villager - Change non-existing profession
|
||||
filter().type(Entity1_11Types.EntityType.VILLAGER).index(13).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_11.EntityType.VILLAGER).index(13).handler((event, meta) -> {
|
||||
if ((int) meta.getValue() == 5) {
|
||||
meta.setValue(0);
|
||||
}
|
||||
});
|
||||
|
||||
// handle new Shulker color meta
|
||||
filter().type(Entity1_11Types.EntityType.SHULKER).cancel(15);
|
||||
filter().type(EntityTypes1_11.EntityType.SHULKER).cancel(15);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -393,11 +393,11 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return Entity1_11Types.getTypeFromId(typeId, false);
|
||||
return EntityTypes1_11.getTypeFromId(typeId, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityType getObjectTypeFromId(int typeId) {
|
||||
return Entity1_11Types.getTypeFromId(typeId, true);
|
||||
return EntityTypes1_11.getTypeFromId(typeId, true);
|
||||
}
|
||||
}
|
||||
+5
-6
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
@@ -25,10 +25,9 @@ import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
|
||||
public class PlayerPackets1_11 {
|
||||
private static final ValueTransformer<Short, Float> TO_NEW_FLOAT = new ValueTransformer<Short, Float>(Type.FLOAT) {
|
||||
@@ -53,8 +52,8 @@ public class PlayerPackets1_11 {
|
||||
wrapper.clearPacket();
|
||||
wrapper.setPacketType(ClientboundPackets1_9_3.CHAT_MESSAGE);
|
||||
|
||||
// https://bugs.mojang.com/browse/MC-119145to
|
||||
String legacy = LegacyComponentSerializer.legacySection().serialize(GsonComponentSerializer.gson().deserialize(message.toString()));
|
||||
// https://bugs.mojang.com/browse/MC-119145
|
||||
String legacy = ComponentUtil.jsonToLegacy(message);
|
||||
message = new JsonObject();
|
||||
message.getAsJsonObject().addProperty("text", legacy);
|
||||
|
||||
@@ -81,7 +80,7 @@ public class PlayerPackets1_11 {
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.PLAYER_BLOCK_PLACEMENT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.POSITION); // 0 - Location
|
||||
map(Type.POSITION1_8); // 0 - Location
|
||||
map(Type.VAR_INT); // 1 - Face
|
||||
map(Type.VAR_INT); // 2 - Hand
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
-5
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,7 +26,8 @@ import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.ChatPac
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.EntityPackets1_12;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.SoundPackets1_12;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
@@ -34,7 +35,6 @@ import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPacke
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
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> {
|
||||
@@ -71,10 +71,10 @@ public class Protocol1_11_1To1_12 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
user.put(new ClientWorld());
|
||||
}
|
||||
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_12Types.EntityType.PLAYER));
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_12.EntityType.PLAYER));
|
||||
|
||||
user.put(new ShoulderTracker(user));
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
-6
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
|
||||
public class ShoulderTracker extends StoredObject {
|
||||
private int entityId;
|
||||
@@ -74,17 +75,15 @@ public class ShoulderTracker extends StoredObject {
|
||||
}
|
||||
|
||||
private String getName(String current) {
|
||||
if (current.startsWith("minecraft:")) {
|
||||
current = current.substring(10);
|
||||
}
|
||||
current = Key.stripMinecraftNamespace(current);
|
||||
|
||||
String[] array = current.split("_");
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
for (String s : array) {
|
||||
builder.append(s.substring(0, 1).toUpperCase())
|
||||
.append(s.substring(1))
|
||||
.append(" ");
|
||||
.append(s.substring(1))
|
||||
.append(" ");
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
|
||||
+20
-21
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,11 +22,13 @@ import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.MapColorMapping;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.LongArrayTag;
|
||||
@@ -34,11 +36,8 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_3_4Type;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPackets1_12, ServerboundPackets1_9_3, Protocol1_11_1To1_12> {
|
||||
@@ -81,9 +80,9 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
}
|
||||
});
|
||||
|
||||
registerSetSlot(ClientboundPackets1_12.SET_SLOT, Type.ITEM);
|
||||
registerWindowItems(ClientboundPackets1_12.WINDOW_ITEMS, Type.ITEM_ARRAY);
|
||||
registerEntityEquipment(ClientboundPackets1_12.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
registerSetSlot(ClientboundPackets1_12.SET_SLOT);
|
||||
registerWindowItems(ClientboundPackets1_12.WINDOW_ITEMS);
|
||||
registerEntityEquipment(ClientboundPackets1_12.ENTITY_EQUIPMENT);
|
||||
|
||||
// Plugin message Packet -> Trading
|
||||
protocol.registerClientbound(ClientboundPackets1_12.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||
@@ -92,17 +91,17 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
map(Type.STRING); // 0 - Channel
|
||||
|
||||
handler(wrapper -> {
|
||||
if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) {
|
||||
if (wrapper.get(Type.STRING, 0).equals("MC|TrList")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Input Item
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
|
||||
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Input Item
|
||||
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Output Item
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||
if (secondItem)
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Second Item
|
||||
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Second Item
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
wrapper.passthrough(Type.INT); // Number of tools uses
|
||||
@@ -121,7 +120,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
map(Type.BYTE); // 2 - Button
|
||||
map(Type.SHORT); // 3 - Action number
|
||||
map(Type.VAR_INT); // 4 - Mode
|
||||
map(Type.ITEM); // 5 - Clicked Item
|
||||
map(Type.ITEM1_8); // 5 - Clicked Item
|
||||
|
||||
handler(wrapper -> {
|
||||
if (wrapper.get(Type.VAR_INT, 0) == 1) { // Shift click
|
||||
@@ -129,7 +128,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
// Previously clients grab the item from the clicked slot *before* it has
|
||||
// been moved however now they grab the slot item *after* it has been moved
|
||||
// and send that in the packet.
|
||||
wrapper.set(Type.ITEM, 0, null); // Set null item (probably will work)
|
||||
wrapper.set(Type.ITEM1_8, 0, null); // Set null item (probably will work)
|
||||
|
||||
// Apologize (may happen in some cases, maybe if inventory is full?)
|
||||
PacketWrapper confirm = wrapper.create(ServerboundPackets1_12.WINDOW_CONFIRMATION);
|
||||
@@ -143,18 +142,18 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
return;
|
||||
|
||||
}
|
||||
Item item = wrapper.get(Type.ITEM, 0);
|
||||
Item item = wrapper.get(Type.ITEM1_8, 0);
|
||||
handleItemToServer(item);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
|
||||
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.CHUNK_DATA, wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); // Use the 1.9.4 Chunk type since nothing changed.
|
||||
ChunkType1_9_3 type = ChunkType1_9_3.forEnvironment(clientWorld.getEnvironment()); // Use the 1.9.4 Chunk type since nothing changed.
|
||||
Chunk chunk = wrapper.passthrough(type);
|
||||
|
||||
handleChunk(chunk);
|
||||
@@ -163,7 +162,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
protocol.registerClientbound(ClientboundPackets1_12.BLOCK_CHANGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.POSITION); // 0 - Block Position
|
||||
map(Type.POSITION1_8); // 0 - Block Position
|
||||
map(Type.VAR_INT); // 1 - Block
|
||||
|
||||
handler(wrapper -> {
|
||||
@@ -191,9 +190,9 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
protocol.registerClientbound(ClientboundPackets1_12.BLOCK_ENTITY_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
map(Type.POSITION1_8); // 0 - Position
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Action
|
||||
map(Type.NBT); // 2 - NBT
|
||||
map(Type.NAMED_COMPOUND_TAG); // 2 - NBT
|
||||
|
||||
handler(wrapper -> {
|
||||
// Remove bed color
|
||||
@@ -204,7 +203,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
});
|
||||
|
||||
protocol.getEntityRewriter().filter().handler((event, meta) -> {
|
||||
if (meta.metaType().type().equals(Type.ITEM)) // Is Item
|
||||
if (meta.metaType().type().equals(Type.ITEM1_8)) // Is Item
|
||||
meta.setValue(handleItemToClient((Item) meta.getValue()));
|
||||
});
|
||||
|
||||
@@ -277,7 +276,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
// Restore the removed long array tags
|
||||
for (Map.Entry<String, Tag> entry : backupTag) {
|
||||
if (entry.getValue() instanceof CompoundTag) {
|
||||
CompoundTag nestedTag = compoundTag.get(entry.getKey());
|
||||
CompoundTag nestedTag = compoundTag.getCompoundTag(entry.getKey());
|
||||
handleNbtToServer(nestedTag, (CompoundTag) entry.getValue());
|
||||
} else {
|
||||
compoundTag.put(entry.getKey(), fromIntArrayTag((IntArrayTag) entry.getValue()));
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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.rewriter.ComponentRewriter;
|
||||
|
||||
public class ChatPackets1_12 extends RewriterBase<Protocol1_11_1To1_12> {
|
||||
|
||||
public static final ComponentRewriter<ClientboundPackets1_12> COMPONENT_REWRITER = new ComponentRewriter<ClientboundPackets1_12>() {
|
||||
public static final ComponentRewriter<ClientboundPackets1_12> COMPONENT_REWRITER = new ComponentRewriter<ClientboundPackets1_12>(null, ComponentRewriter.ReadType.JSON) {
|
||||
@Override
|
||||
public void processText(JsonElement element) {
|
||||
super.processText(element);
|
||||
|
||||
+28
-29
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
@@ -24,11 +24,10 @@ import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.ParrotStor
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.ShoulderTracker;
|
||||
import com.viaversion.viabackwards.utils.Block;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_12;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
@@ -62,12 +61,12 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
// Track Entity
|
||||
handler(getObjectTrackerHandler());
|
||||
handler(getObjectRewriter(id -> Entity1_12Types.ObjectType.findById(id).orElse(null)));
|
||||
handler(getObjectRewriter(id -> EntityTypes1_12.ObjectType.findById(id).orElse(null)));
|
||||
|
||||
// Handle FallingBlock blocks
|
||||
handler(wrapper -> {
|
||||
Optional<Entity1_12Types.ObjectType> type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||
if (type.isPresent() && type.get() == Entity1_12Types.ObjectType.FALLING_BLOCK) {
|
||||
Optional<EntityTypes1_12.ObjectType> type = EntityTypes1_12.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||
if (type.isPresent() && type.get() == EntityTypes1_12.ObjectType.FALLING_BLOCK) {
|
||||
int objectData = wrapper.get(Type.INT, 0);
|
||||
int objType = objectData & 4095;
|
||||
int data = objectData >> 12 & 15;
|
||||
@@ -83,8 +82,8 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_12.SPAWN_EXPERIENCE_ORB, Entity1_12Types.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_12.SPAWN_GLOBAL_ENTITY, Entity1_12Types.EntityType.WEATHER);
|
||||
registerTracker(ClientboundPackets1_12.SPAWN_EXPERIENCE_ORB, EntityTypes1_12.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_12.SPAWN_GLOBAL_ENTITY, EntityTypes1_12.EntityType.WEATHER);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SPAWN_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
@@ -111,7 +110,7 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_12.SPAWN_PAINTING, Entity1_12Types.EntityType.PAINTING);
|
||||
registerTracker(ClientboundPackets1_12.SPAWN_PAINTING, EntityTypes1_12.EntityType.PAINTING);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SPAWN_PLAYER, new PacketHandlers() {
|
||||
@Override
|
||||
@@ -125,7 +124,7 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Types1_12.METADATA_LIST); // 7 - Metadata list
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_12.METADATA_LIST, Entity1_12Types.EntityType.PLAYER));
|
||||
handler(getTrackerAndMetaHandler(Types1_12.METADATA_LIST, EntityTypes1_12.EntityType.PLAYER));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -136,7 +135,7 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
|
||||
handler(getTrackerHandler(Entity1_12Types.EntityType.PLAYER, Type.INT));
|
||||
handler(getTrackerHandler(EntityTypes1_12.EntityType.PLAYER, Type.INT));
|
||||
|
||||
handler(getDimensionHandler(1));
|
||||
|
||||
@@ -204,8 +203,8 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
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();
|
||||
mapEntityTypeWithData(EntityTypes1_12.EntityType.PARROT, EntityTypes1_12.EntityType.BAT).plainName().spawnMetadata(storage -> storage.add(new Metadata(12, MetaType1_12.Byte, (byte) 0x00)));
|
||||
mapEntityTypeWithData(EntityTypes1_12.EntityType.ILLUSION_ILLAGER, EntityTypes1_12.EntityType.EVOCATION_ILLAGER).plainName();
|
||||
|
||||
filter().handler((event, meta) -> {
|
||||
if (meta.metaType() == MetaType1_12.Chat) {
|
||||
@@ -214,10 +213,10 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
});
|
||||
|
||||
// Handle Illager
|
||||
filter().filterFamily(Entity1_12Types.EntityType.EVOCATION_ILLAGER).cancel(12);
|
||||
filter().filterFamily(Entity1_12Types.EntityType.EVOCATION_ILLAGER).index(13).toIndex(12);
|
||||
filter().type(EntityTypes1_12.EntityType.EVOCATION_ILLAGER).cancel(12);
|
||||
filter().type(EntityTypes1_12.EntityType.EVOCATION_ILLAGER).index(13).toIndex(12);
|
||||
|
||||
filter().type(Entity1_12Types.EntityType.ILLUSION_ILLAGER).index(0).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_12.EntityType.ILLUSION_ILLAGER).index(0).handler((event, meta) -> {
|
||||
byte mask = (byte) meta.getValue();
|
||||
|
||||
if ((mask & 0x20) == 0x20) {
|
||||
@@ -228,15 +227,15 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
});
|
||||
|
||||
// Create Parrot storage
|
||||
filter().filterFamily(Entity1_12Types.EntityType.PARROT).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_12.EntityType.PARROT).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
if (!data.has(ParrotStorage.class)) {
|
||||
data.put(new ParrotStorage());
|
||||
}
|
||||
});
|
||||
// Parrot remove animal metadata
|
||||
filter().type(Entity1_12Types.EntityType.PARROT).cancel(12); // Is baby
|
||||
filter().type(Entity1_12Types.EntityType.PARROT).index(13).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_12.EntityType.PARROT).cancel(12); // Is baby
|
||||
filter().type(EntityTypes1_12.EntityType.PARROT).index(13).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
ParrotStorage storage = data.get(ParrotStorage.class);
|
||||
boolean isSitting = (((byte) meta.getValue()) & 0x01) == 0x01;
|
||||
@@ -260,19 +259,19 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
event.cancel();
|
||||
}
|
||||
}); // Flags (Is sitting etc, might be useful in the future
|
||||
filter().type(Entity1_12Types.EntityType.PARROT).cancel(14); // Owner
|
||||
filter().type(Entity1_12Types.EntityType.PARROT).cancel(15); // Variant
|
||||
filter().type(EntityTypes1_12.EntityType.PARROT).cancel(14); // Owner
|
||||
filter().type(EntityTypes1_12.EntityType.PARROT).cancel(15); // Variant
|
||||
|
||||
// Left shoulder entity data
|
||||
filter().type(Entity1_12Types.EntityType.PLAYER).index(15).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_12.EntityType.PLAYER).index(15).handler((event, meta) -> {
|
||||
CompoundTag tag = (CompoundTag) meta.getValue();
|
||||
ShoulderTracker tracker = event.user().get(ShoulderTracker.class);
|
||||
|
||||
if (tag.isEmpty() && tracker.getLeftShoulder() != null) {
|
||||
tracker.setLeftShoulder(null);
|
||||
tracker.update();
|
||||
} else if (tag.contains("id") && event.entityId() == tracker.getEntityId()) {
|
||||
String id = (String) tag.get("id").getValue();
|
||||
} else if (tag.getStringTag("id") != null && event.entityId() == tracker.getEntityId()) {
|
||||
String id = tag.getStringTag("id").getValue();
|
||||
if (tracker.getLeftShoulder() == null || !tracker.getLeftShoulder().equals(id)) {
|
||||
tracker.setLeftShoulder(id);
|
||||
tracker.update();
|
||||
@@ -283,15 +282,15 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
});
|
||||
|
||||
// Right shoulder entity data
|
||||
filter().type(Entity1_12Types.EntityType.PLAYER).index(16).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_12.EntityType.PLAYER).index(16).handler((event, meta) -> {
|
||||
CompoundTag tag = (CompoundTag) event.meta().getValue();
|
||||
ShoulderTracker tracker = event.user().get(ShoulderTracker.class);
|
||||
|
||||
if (tag.isEmpty() && tracker.getRightShoulder() != null) {
|
||||
tracker.setRightShoulder(null);
|
||||
tracker.update();
|
||||
} else if (tag.contains("id") && event.entityId() == tracker.getEntityId()) {
|
||||
String id = (String) tag.get("id").getValue();
|
||||
} else if (tag.getStringTag("id") != null && event.entityId() == tracker.getEntityId()) {
|
||||
String id = tag.getStringTag("id").getValue();
|
||||
if (tracker.getRightShoulder() == null || !tracker.getRightShoulder().equals(id)) {
|
||||
tracker.setRightShoulder(id);
|
||||
tracker.update();
|
||||
@@ -304,11 +303,11 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return Entity1_12Types.getTypeFromId(typeId, false);
|
||||
return EntityTypes1_12.getTypeFromId(typeId, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityType getObjectTypeFromId(final int typeId) {
|
||||
return Entity1_12Types.getTypeFromId(typeId, true);
|
||||
return EntityTypes1_12.getTypeFromId(typeId, true);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
-5
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,11 +22,11 @@ import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets.EntityPackets1_11_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets.ItemPackets1_11_1;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_11To1_11_1 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
||||
|
||||
@@ -47,10 +47,10 @@ public class Protocol1_11To1_11_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
user.put(new ClientWorld());
|
||||
}
|
||||
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_11Types.EntityType.PLAYER));
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_11.EntityType.PLAYER));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+12
-12
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,8 +20,8 @@ package com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets;
|
||||
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
||||
@@ -50,12 +50,12 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<ClientboundPackets
|
||||
|
||||
// Track Entity
|
||||
handler(getObjectTrackerHandler());
|
||||
handler(getObjectRewriter(id -> Entity1_11Types.ObjectType.findById(id).orElse(null)));
|
||||
handler(getObjectRewriter(id -> EntityTypes1_11.ObjectType.findById(id).orElse(null)));
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, Entity1_11Types.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, Entity1_11Types.EntityType.WEATHER);
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, EntityTypes1_11.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, EntityTypes1_11.EntityType.WEATHER);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
@@ -82,8 +82,8 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<ClientboundPackets
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_PAINTING, Entity1_11Types.EntityType.PAINTING);
|
||||
registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, Entity1_11Types.EntityType.PLAYER);
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_PAINTING, EntityTypes1_11.EntityType.PAINTING);
|
||||
registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, EntityTypes1_11.EntityType.PLAYER);
|
||||
registerRespawn(ClientboundPackets1_9_3.RESPAWN);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketHandlers() {
|
||||
@@ -98,7 +98,7 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<ClientboundPackets
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Types1_9.METADATA_LIST); // 7 - Metadata list
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_9.METADATA_LIST, Entity1_11Types.EntityType.PLAYER));
|
||||
handler(getTrackerAndMetaHandler(Types1_9.METADATA_LIST, EntityTypes1_11.EntityType.PLAYER));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -109,19 +109,19 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<ClientboundPackets
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
// Handle non-existing firework metadata (index 7 entity id for boosting)
|
||||
filter().type(Entity1_11Types.EntityType.FIREWORK).cancel(7);
|
||||
filter().type(EntityTypes1_11.EntityType.FIREWORK).cancel(7);
|
||||
|
||||
// Handle non-existing pig metadata (index 14 - boost time)
|
||||
filter().type(Entity1_11Types.EntityType.PIG).cancel(14);
|
||||
filter().type(EntityTypes1_11.EntityType.PIG).cancel(14);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return Entity1_11Types.getTypeFromId(typeId, false);
|
||||
return EntityTypes1_11.getTypeFromId(typeId, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityType getObjectTypeFromId(final int typeId) {
|
||||
return Entity1_11Types.getTypeFromId(typeId, true);
|
||||
return EntityTypes1_11.getTypeFromId(typeId, true);
|
||||
}
|
||||
}
|
||||
+15
-16
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
@@ -25,7 +25,6 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
|
||||
@@ -39,9 +38,9 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<ClientboundPacket
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM);
|
||||
registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS, Type.ITEM_ARRAY);
|
||||
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
registerSetSlot(ClientboundPackets1_9_3.SET_SLOT);
|
||||
registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS);
|
||||
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT);
|
||||
|
||||
// Plugin message Packet -> Trading
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||
@@ -50,17 +49,17 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<ClientboundPacket
|
||||
map(Type.STRING); // 0 - Channel
|
||||
|
||||
handler(wrapper -> {
|
||||
if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) {
|
||||
if (wrapper.get(Type.STRING, 0).equals("MC|TrList")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Input Item
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
|
||||
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Input Item
|
||||
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Output Item
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||
if (secondItem) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Second Item
|
||||
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Second Item
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
@@ -72,12 +71,12 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<ClientboundPacket
|
||||
}
|
||||
});
|
||||
|
||||
registerClickWindow(ServerboundPackets1_9_3.CLICK_WINDOW, Type.ITEM);
|
||||
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
|
||||
registerClickWindow(ServerboundPackets1_9_3.CLICK_WINDOW);
|
||||
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION);
|
||||
|
||||
// Handle item metadata
|
||||
protocol.getEntityRewriter().filter().handler((event, meta) -> {
|
||||
if (meta.metaType().type().equals(Type.ITEM)) { // Is Item
|
||||
if (meta.metaType().type().equals(Type.ITEM1_8)) { // Is Item
|
||||
meta.setValue(handleItemToClient((Item) meta.getValue()));
|
||||
}
|
||||
});
|
||||
@@ -97,10 +96,10 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<ClientboundPacket
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) return item;
|
||||
|
||||
if (tag.get("ench") instanceof ListTag) {
|
||||
if (tag.getListTag("ench") != null) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToClient(tag, false);
|
||||
}
|
||||
if (tag.get("StoredEnchantments") instanceof ListTag) {
|
||||
if (tag.getListTag("StoredEnchantments") != null) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToClient(tag, true);
|
||||
}
|
||||
return item;
|
||||
@@ -114,10 +113,10 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<ClientboundPacket
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) return item;
|
||||
|
||||
if (tag.contains(nbtTagName + "|ench")) {
|
||||
if (tag.getListTag(nbtTagName + "|ench") != null) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToServer(tag, false);
|
||||
}
|
||||
if (tag.contains(nbtTagName + "|StoredEnchantments")) {
|
||||
if (tag.getListTag(nbtTagName + "|StoredEnchantments") != null) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToServer(tag, true);
|
||||
}
|
||||
return item;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
|
||||
+14
-20
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,24 +29,24 @@ import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets.PlayerP
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets.SoundPackets1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.NoteBlockStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.PlayerPositionStorage1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.TabCompleteStorage;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.gson.JsonParser;
|
||||
import com.viaversion.viaversion.libs.kyori.adventure.text.Component;
|
||||
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_13, ClientboundPackets1_12_1, ServerboundPackets1_13, ServerboundPackets1_12_1> {
|
||||
@@ -54,7 +54,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings();
|
||||
private final EntityPackets1_13 entityRewriter = new EntityPackets1_13(this);
|
||||
private final BlockItemPackets1_13 blockItemPackets = new BlockItemPackets1_13(this);
|
||||
private final TranslatableRewriter<ClientboundPackets1_13> translatableRewriter = new TranslatableRewriter<ClientboundPackets1_13>(this) {
|
||||
private final TranslatableRewriter<ClientboundPackets1_13> translatableRewriter = new TranslatableRewriter<ClientboundPackets1_13>(this, ComponentRewriter.ReadType.JSON) {
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject root, String translate) {
|
||||
String mappedKey = mappedTranslationKey(translate);
|
||||
@@ -63,7 +63,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
}
|
||||
}
|
||||
};
|
||||
private final TranslatableRewriter<ClientboundPackets1_13> translatableToLegacyRewriter = new TranslatableRewriter<ClientboundPackets1_13>(this) {
|
||||
private final TranslatableRewriter<ClientboundPackets1_13> translatableToLegacyRewriter = new TranslatableRewriter<ClientboundPackets1_13>(this, ComponentRewriter.ReadType.JSON) {
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject root, String translate) {
|
||||
String mappedKey = mappedTranslationKey(translate);
|
||||
@@ -89,7 +89,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
translatableRewriter.registerBossBar(ClientboundPackets1_13.BOSSBAR);
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT_MESSAGE);
|
||||
translatableRewriter.registerLegacyOpenWindow(ClientboundPackets1_13.OPEN_WINDOW);
|
||||
translatableRewriter.registerDisconnect(ClientboundPackets1_13.DISCONNECT);
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_13.DISCONNECT);
|
||||
translatableRewriter.registerCombatEvent(ClientboundPackets1_13.COMBAT_EVENT);
|
||||
translatableRewriter.registerTitle(ClientboundPackets1_13.TITLE);
|
||||
translatableRewriter.registerTabList(ClientboundPackets1_13.TAB_LIST);
|
||||
@@ -114,10 +114,10 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
user.put(new ClientWorld());
|
||||
}
|
||||
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_13Types.EntityType.PLAYER));
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_13.EntityType.PLAYER));
|
||||
|
||||
user.put(new BackwardsBlockStorage());
|
||||
user.put(new TabCompleteStorage());
|
||||
@@ -125,6 +125,8 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
if (ViaBackwards.getConfig().isFix1_13FacePlayer() && !user.has(PlayerPositionStorage1_13.class)) {
|
||||
user.put(new PlayerPositionStorage1_13());
|
||||
}
|
||||
|
||||
user.put(new NoteBlockStorage());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -166,14 +168,6 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
}
|
||||
|
||||
translatableToLegacyRewriter.processText(value);
|
||||
|
||||
try {
|
||||
Component component = ChatRewriter.HOVER_GSON_SERIALIZER.deserializeFromTree(value);
|
||||
return LegacyComponentSerializer.legacySection().serialize(component);
|
||||
} catch (Exception e) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Error converting json text to legacy: " + value);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
return ComponentUtil.jsonToLegacy(value);
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,10 +20,9 @@ package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_h
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
|
||||
public class BannerHandler implements BackwardsBlockEntityHandler {
|
||||
@@ -34,28 +33,29 @@ public class BannerHandler implements BackwardsBlockEntityHandler {
|
||||
private static final int BANNER_STOP = 7109;
|
||||
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
public CompoundTag transform(int blockId, CompoundTag tag) {
|
||||
// Normal banners
|
||||
if (blockId >= BANNER_START && blockId <= BANNER_STOP) {
|
||||
int color = (blockId - BANNER_START) >> 4;
|
||||
tag.put("Base", new IntTag((15 - color)));
|
||||
tag.putInt("Base", 15 - color);
|
||||
}
|
||||
// Wall banners
|
||||
else if (blockId >= WALL_BANNER_START && blockId <= WALL_BANNER_STOP) {
|
||||
int color = (blockId - WALL_BANNER_START) >> 2;
|
||||
tag.put("Base", new IntTag((15 - color)));
|
||||
tag.putInt("Base", 15 - color);
|
||||
} else {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag);
|
||||
}
|
||||
|
||||
// Invert colors
|
||||
Tag patternsTag = tag.get("Patterns");
|
||||
if (patternsTag instanceof ListTag) {
|
||||
for (Tag pattern : (ListTag) patternsTag) {
|
||||
ListTag patternsTag = tag.getListTag("Patterns");
|
||||
if (patternsTag != null) {
|
||||
for (Tag pattern : patternsTag) {
|
||||
if (!(pattern instanceof CompoundTag)) continue;
|
||||
|
||||
IntTag c = ((CompoundTag) pattern).get("Color");
|
||||
c.setValue(15 - c.asInt()); // Invert color id
|
||||
CompoundTag patternTag = (CompoundTag) pattern;
|
||||
NumberTag colorTag = patternTag.getNumberTag("Color");
|
||||
patternTag.putInt("Color", 15 - colorTag.asInt()); // Invert color id
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-5
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,18 +19,16 @@
|
||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
|
||||
public class BedHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
public CompoundTag transform(int blockId, CompoundTag tag) {
|
||||
int offset = blockId - 748;
|
||||
int color = offset >> 4;
|
||||
|
||||
tag.put("color", new IntTag(color));
|
||||
tag.putInt("color", color);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
+4
-7
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,12 +19,9 @@
|
||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
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.util.Pair;
|
||||
|
||||
public class FlowerPotHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||
@@ -72,11 +69,11 @@ public class FlowerPotHandler implements BackwardsBlockEntityProvider.BackwardsB
|
||||
|
||||
// TODO THIS IS NEVER CALLED BECAUSE ITS NO LONGER A BLOCK ENTITY :(
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
public CompoundTag transform(int blockId, CompoundTag tag) {
|
||||
Pair<String, Byte> item = getOrDefault(blockId);
|
||||
|
||||
tag.put("Item", new StringTag(item.key()));
|
||||
tag.put("Data", new IntTag(item.value()));
|
||||
tag.putString("Item", item.key());
|
||||
tag.putInt("Data", item.value());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
+13
-13
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,23 +20,23 @@ package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_h
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||
|
||||
private final Map<String, Integer> pistonIds = new HashMap<>();
|
||||
private final Object2IntMap<String> pistonIds = new Object2IntOpenHashMap<>();
|
||||
|
||||
public PistonHandler() {
|
||||
pistonIds.defaultReturnValue(-1);
|
||||
if (Via.getConfig().isServersideBlockConnections()) {
|
||||
Map<String, Integer> keyToId = ConnectionData.getKeyToId();
|
||||
for (Map.Entry<String, Integer> entry : keyToId.entrySet()) {
|
||||
@@ -76,30 +76,30 @@ public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBloc
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
CompoundTag blockState = tag.get("blockState");
|
||||
public CompoundTag transform(int blockId, CompoundTag tag) {
|
||||
CompoundTag blockState = tag.getCompoundTag("blockState");
|
||||
if (blockState == null) return tag;
|
||||
|
||||
String dataFromTag = getDataFromTag(blockState);
|
||||
if (dataFromTag == null) return tag;
|
||||
|
||||
Integer id = pistonIds.get(dataFromTag);
|
||||
if (id == null) {
|
||||
int id = pistonIds.getInt(dataFromTag);
|
||||
if (id == -1) {
|
||||
//TODO see why this could be null and if this is bad
|
||||
return tag;
|
||||
}
|
||||
|
||||
tag.put("blockId", new IntTag(id >> 4));
|
||||
tag.put("blockData", new IntTag(id & 15));
|
||||
tag.putInt("blockId", id >> 4);
|
||||
tag.putInt("blockData", id & 15);
|
||||
return tag;
|
||||
}
|
||||
|
||||
// The type hasn't actually been updated in the blockstorage, so we need to construct it
|
||||
private String getDataFromTag(CompoundTag tag) {
|
||||
StringTag name = tag.get("Name");
|
||||
StringTag name = tag.getStringTag("Name");
|
||||
if (name == null) return null;
|
||||
|
||||
CompoundTag properties = tag.get("Properties");
|
||||
CompoundTag properties = tag.getCompoundTag("Properties");
|
||||
if (properties == null) return name.getValue();
|
||||
|
||||
StringJoiner joiner = new StringJoiner(",", name.getValue() + "[", "]");
|
||||
|
||||
+4
-6
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,21 +19,19 @@
|
||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
|
||||
public class SkullHandler implements BackwardsBlockEntityHandler {
|
||||
private static final int SKULL_START = 5447;
|
||||
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
public CompoundTag transform(int blockId, CompoundTag tag) {
|
||||
int diff = blockId - SKULL_START;
|
||||
int pos = diff % 20;
|
||||
byte type = (byte) Math.floor(diff / 20f);
|
||||
|
||||
// Set type
|
||||
tag.put("SkullType", new ByteTag(type));
|
||||
tag.putByte("SkullType", type);
|
||||
|
||||
// Remove wall skulls
|
||||
if (pos < 4) {
|
||||
@@ -41,7 +39,7 @@ public class SkullHandler implements BackwardsBlockEntityHandler {
|
||||
}
|
||||
|
||||
// Add rotation for normal skulls
|
||||
tag.put("Rot", new ByteTag((byte) ((pos - 4) & 255)));
|
||||
tag.putByte("Rot", (byte) ((pos - 4) & 255));
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
+7
-11
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,22 +20,18 @@ package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_h
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.EntityNameRewrites;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
|
||||
public class SpawnerHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
Tag dataTag = tag.get("SpawnData");
|
||||
if (dataTag instanceof CompoundTag) {
|
||||
CompoundTag data = (CompoundTag) dataTag;
|
||||
Tag idTag = data.get("id");
|
||||
if (idTag instanceof StringTag) {
|
||||
StringTag s = (StringTag) idTag;
|
||||
s.setValue(EntityNameRewrites.rewrite(s.getValue()));
|
||||
public CompoundTag transform(int blockId, CompoundTag tag) {
|
||||
CompoundTag dataTag = tag.getCompoundTag("SpawnData");
|
||||
if (dataTag != null) {
|
||||
StringTag idTag = dataTag.getStringTag("id");
|
||||
if (idTag != null) {
|
||||
idTag.setValue(EntityNameRewrites.rewrite(idTag.getValue()));
|
||||
}
|
||||
}
|
||||
return tag;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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_12_2to1_13.data;
|
||||
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -42,15 +43,11 @@ public class EntityNameRewrites {
|
||||
|
||||
|
||||
private static void reg(String past, String future) {
|
||||
ENTITY_NAMES.put("minecraft:" + future, "minecraft:" + past);
|
||||
ENTITY_NAMES.put(Key.namespaced(future), Key.namespaced(past));
|
||||
}
|
||||
|
||||
public static String rewrite(String entName) {
|
||||
String entityName = ENTITY_NAMES.get(entName);
|
||||
if (entityName != null) {
|
||||
return entityName;
|
||||
}
|
||||
entityName = ENTITY_NAMES.get("minecraft:" + entName);
|
||||
String entityName = ENTITY_NAMES.get(Key.namespaced(entName));
|
||||
if (entityName != null) {
|
||||
return entityName;
|
||||
} else
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
-5
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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_12_2to1_13.data;
|
||||
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.NamedSoundRewriter;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -37,9 +38,6 @@ public class NamedSoundMapping {
|
||||
}
|
||||
|
||||
public static String getOldId(String sound1_13) {
|
||||
if (sound1_13.startsWith("minecraft:")) {
|
||||
sound1_13 = sound1_13.substring(10);
|
||||
}
|
||||
return SOUNDS.get(sound1_13);
|
||||
return SOUNDS.get(Key.stripMinecraftNamespace(sound1_13));
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
|
||||
+88
-88
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,10 +19,10 @@
|
||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
import java.util.List;
|
||||
|
||||
public class ParticleMapping {
|
||||
@@ -36,7 +36,7 @@ public class ParticleMapping {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData> data) {
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData<?>> data) {
|
||||
return rewrite((int) data.get(0).getValue());
|
||||
}
|
||||
|
||||
@@ -55,94 +55,94 @@ public class ParticleMapping {
|
||||
};
|
||||
|
||||
particles = new ParticleData[]{
|
||||
rewrite(16), // (0->16) minecraft:ambient_entity_effect -> mobSpellAmbient
|
||||
rewrite(20), // (1->20) minecraft:angry_villager -> angryVillager
|
||||
rewrite(35), // (2->35) minecraft:barrier -> barrier
|
||||
rewrite(37, blockHandler),
|
||||
// (3->37) minecraft:block -> blockcrack
|
||||
rewrite(4), // (4->4) minecraft:bubble -> bubble
|
||||
rewrite(29), // (5->29) minecraft:cloud -> cloud
|
||||
rewrite(9), // (6->9) minecraft:crit -> crit
|
||||
rewrite(44), // (7->44) minecraft:damage_indicator -> damageIndicator
|
||||
rewrite(42), // (8->42) minecraft:dragon_breath -> dragonbreath
|
||||
rewrite(19), // (9->19) minecraft:dripping_lava -> dripLava
|
||||
rewrite(18), // (10->18) minecraft:dripping_water -> dripWater
|
||||
rewrite(30, new ParticleHandler() {
|
||||
@Override
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception {
|
||||
float r = wrapper.read(Type.FLOAT);
|
||||
float g = wrapper.read(Type.FLOAT);
|
||||
float b = wrapper.read(Type.FLOAT);
|
||||
float scale = wrapper.read(Type.FLOAT);
|
||||
rewrite(16), // (0->16) minecraft:ambient_entity_effect -> mobSpellAmbient
|
||||
rewrite(20), // (1->20) minecraft:angry_villager -> angryVillager
|
||||
rewrite(35), // (2->35) minecraft:barrier -> barrier
|
||||
rewrite(37, blockHandler),
|
||||
// (3->37) minecraft:block -> blockcrack
|
||||
rewrite(4), // (4->4) minecraft:bubble -> bubble
|
||||
rewrite(29), // (5->29) minecraft:cloud -> cloud
|
||||
rewrite(9), // (6->9) minecraft:crit -> crit
|
||||
rewrite(44), // (7->44) minecraft:damage_indicator -> damageIndicator
|
||||
rewrite(42), // (8->42) minecraft:dragon_breath -> dragonbreath
|
||||
rewrite(19), // (9->19) minecraft:dripping_lava -> dripLava
|
||||
rewrite(18), // (10->18) minecraft:dripping_water -> dripWater
|
||||
rewrite(30, new ParticleHandler() {
|
||||
@Override
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception {
|
||||
float r = wrapper.read(Type.FLOAT);
|
||||
float g = wrapper.read(Type.FLOAT);
|
||||
float b = wrapper.read(Type.FLOAT);
|
||||
float scale = wrapper.read(Type.FLOAT);
|
||||
|
||||
wrapper.set(Type.FLOAT, 3, r); // 5 - Offset X index=3
|
||||
wrapper.set(Type.FLOAT, 4, g); // 6 - Offset Y index=4
|
||||
wrapper.set(Type.FLOAT, 5, b); // 7 - Offset Z index=5
|
||||
wrapper.set(Type.FLOAT, 6, scale); // 8 - Particle Data index=6
|
||||
wrapper.set(Type.INT, 1, 0); // 9 - Particle Count index=1 enable rgb particle
|
||||
wrapper.set(Type.FLOAT, 3, r); // 5 - Offset X index=3
|
||||
wrapper.set(Type.FLOAT, 4, g); // 6 - Offset Y index=4
|
||||
wrapper.set(Type.FLOAT, 5, b); // 7 - Offset Z index=5
|
||||
wrapper.set(Type.FLOAT, 6, scale); // 8 - Particle Data index=6
|
||||
wrapper.set(Type.INT, 1, 0); // 9 - Particle Count index=1 enable rgb particle
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData> data) {
|
||||
return null;
|
||||
}
|
||||
}), // (11->30) minecraft:dust -> reddust
|
||||
rewrite(13), // (12->13) minecraft:effect -> spell
|
||||
rewrite(41), // (13->41) minecraft:elder_guardian -> mobappearance
|
||||
rewrite(10), // (14->10) minecraft:enchanted_hit -> magicCrit
|
||||
rewrite(25), // (15->25) minecraft:enchant -> enchantmenttable
|
||||
rewrite(43), // (16->43) minecraft:end_rod -> endRod
|
||||
rewrite(15), // (17->15) minecraft:entity_effect -> mobSpell
|
||||
rewrite(2), // (18->2) minecraft:explosion_emitter -> hugeexplosion
|
||||
rewrite(1), // (19->1) minecraft:explosion -> largeexplode
|
||||
rewrite(46, blockHandler),
|
||||
// (20->46) minecraft:falling_dust -> fallingdust
|
||||
rewrite(3), // (21->3) minecraft:firework -> fireworksSpark
|
||||
rewrite(6), // (22->6) minecraft:fishing -> wake
|
||||
rewrite(26), // (23->26) minecraft:flame -> flame
|
||||
rewrite(21), // (24->21) minecraft:happy_villager -> happyVillager
|
||||
rewrite(34), // (25->34) minecraft:heart -> heart
|
||||
rewrite(14), // (26->14) minecraft:instant_effect -> instantSpell
|
||||
rewrite(36, new ParticleHandler() {
|
||||
@Override
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception {
|
||||
return rewrite(protocol, wrapper.read(Type.FLAT_ITEM));
|
||||
}
|
||||
@Override
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData<?>> data) {
|
||||
return null;
|
||||
}
|
||||
}), // (11->30) minecraft:dust -> reddust
|
||||
rewrite(13), // (12->13) minecraft:effect -> spell
|
||||
rewrite(41), // (13->41) minecraft:elder_guardian -> mobappearance
|
||||
rewrite(10), // (14->10) minecraft:enchanted_hit -> magicCrit
|
||||
rewrite(25), // (15->25) minecraft:enchant -> enchantmenttable
|
||||
rewrite(43), // (16->43) minecraft:end_rod -> endRod
|
||||
rewrite(15), // (17->15) minecraft:entity_effect -> mobSpell
|
||||
rewrite(2), // (18->2) minecraft:explosion_emitter -> hugeexplosion
|
||||
rewrite(1), // (19->1) minecraft:explosion -> largeexplode
|
||||
rewrite(46, blockHandler),
|
||||
// (20->46) minecraft:falling_dust -> fallingdust
|
||||
rewrite(3), // (21->3) minecraft:firework -> fireworksSpark
|
||||
rewrite(6), // (22->6) minecraft:fishing -> wake
|
||||
rewrite(26), // (23->26) minecraft:flame -> flame
|
||||
rewrite(21), // (24->21) minecraft:happy_villager -> happyVillager
|
||||
rewrite(34), // (25->34) minecraft:heart -> heart
|
||||
rewrite(14), // (26->14) minecraft:instant_effect -> instantSpell
|
||||
rewrite(36, new ParticleHandler() {
|
||||
@Override
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception {
|
||||
return rewrite(protocol, wrapper.read(Type.ITEM1_13));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData> data) {
|
||||
return rewrite(protocol, (Item) data.get(0).getValue());
|
||||
}
|
||||
@Override
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData<?>> data) {
|
||||
return rewrite(protocol, (Item) data.get(0).getValue());
|
||||
}
|
||||
|
||||
private int[] rewrite(Protocol1_12_2To1_13 protocol, Item newItem) {
|
||||
Item item = protocol.getItemRewriter().handleItemToClient(newItem);
|
||||
return new int[]{item.identifier(), item.data()};
|
||||
}
|
||||
}), // (27->36) minecraft:item -> iconcrack
|
||||
rewrite(33), // (28->33) minecraft:item_slime -> slime
|
||||
rewrite(31), // (29->31) minecraft:item_snowball -> snowballpoof
|
||||
rewrite(12), // (30->12) minecraft:large_smoke -> largesmoke
|
||||
rewrite(27), // (31->27) minecraft:lava -> lava
|
||||
rewrite(22), // (32->22) minecraft:mycelium -> townaura
|
||||
rewrite(23), // (33->23) minecraft:note -> note
|
||||
rewrite(0), // (34->0) minecraft:poof -> explode
|
||||
rewrite(24), // (35->24) minecraft:portal -> portal
|
||||
rewrite(39), // (36->39) minecraft:rain -> droplet
|
||||
rewrite(11), // (37->11) minecraft:smoke -> smoke
|
||||
rewrite(48), // (38->48) minecraft:spit -> spit
|
||||
rewrite(12), // (39->-1) minecraft:squid_ink -> squid_ink -> large_smoke
|
||||
rewrite(45), // (40->45) minecraft:sweep_attack -> sweepAttack
|
||||
rewrite(47), // (41->47) minecraft:totem_of_undying -> totem
|
||||
rewrite(7), // (42->7) minecraft:underwater -> suspended
|
||||
rewrite(5), // (43->5) minecraft:splash -> splash
|
||||
rewrite(17), // (44->17) minecraft:witch -> witchMagic
|
||||
rewrite(4), // (45->4) minecraft:bubble_pop -> bubble
|
||||
rewrite(4), // (46->4) minecraft:current_down -> bubble
|
||||
rewrite(4), // (47->4) minecraft:bubble_column_up -> bubble
|
||||
rewrite(18), // (48->-1) minecraft:nautilus -> nautilus -> dripWater
|
||||
rewrite(18), // (49->18) minecraft:dolphin -> dripWater
|
||||
private int[] rewrite(Protocol1_12_2To1_13 protocol, Item newItem) {
|
||||
Item item = protocol.getItemRewriter().handleItemToClient(newItem);
|
||||
return new int[]{item.identifier(), item.data()};
|
||||
}
|
||||
}), // (27->36) minecraft:item -> iconcrack
|
||||
rewrite(33), // (28->33) minecraft:item_slime -> slime
|
||||
rewrite(31), // (29->31) minecraft:item_snowball -> snowballpoof
|
||||
rewrite(12), // (30->12) minecraft:large_smoke -> largesmoke
|
||||
rewrite(27), // (31->27) minecraft:lava -> lava
|
||||
rewrite(22), // (32->22) minecraft:mycelium -> townaura
|
||||
rewrite(23), // (33->23) minecraft:note -> note
|
||||
rewrite(0), // (34->0) minecraft:poof -> explode
|
||||
rewrite(24), // (35->24) minecraft:portal -> portal
|
||||
rewrite(39), // (36->39) minecraft:rain -> droplet
|
||||
rewrite(11), // (37->11) minecraft:smoke -> smoke
|
||||
rewrite(48), // (38->48) minecraft:spit -> spit
|
||||
rewrite(12), // (39->-1) minecraft:squid_ink -> squid_ink -> large_smoke
|
||||
rewrite(45), // (40->45) minecraft:sweep_attack -> sweepAttack
|
||||
rewrite(47), // (41->47) minecraft:totem_of_undying -> totem
|
||||
rewrite(7), // (42->7) minecraft:underwater -> suspended
|
||||
rewrite(5), // (43->5) minecraft:splash -> splash
|
||||
rewrite(17), // (44->17) minecraft:witch -> witchMagic
|
||||
rewrite(4), // (45->4) minecraft:bubble_pop -> bubble
|
||||
rewrite(4), // (46->4) minecraft:current_down -> bubble
|
||||
rewrite(4), // (47->4) minecraft:bubble_column_up -> bubble
|
||||
rewrite(18), // (48->-1) minecraft:nautilus -> nautilus -> dripWater
|
||||
rewrite(18), // (49->18) minecraft:dolphin -> dripWater
|
||||
};
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ public class ParticleMapping {
|
||||
|
||||
int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception;
|
||||
|
||||
int[] rewrite(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData> data);
|
||||
int[] rewrite(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData<?>> data);
|
||||
|
||||
default boolean isBlockHandler() {
|
||||
return false;
|
||||
@@ -187,7 +187,7 @@ public class ParticleMapping {
|
||||
return handler.rewrite(protocol, wrapper);
|
||||
}
|
||||
|
||||
public int[] rewriteMeta(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData> data) {
|
||||
public int[] rewriteMeta(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData<?>> data) {
|
||||
if (handler == null) return null;
|
||||
return handler.rewrite(protocol, data);
|
||||
}
|
||||
|
||||
+168
-144
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
@@ -25,9 +25,11 @@ import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2T
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.FlowerPotHandler;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.NoteBlockStorage;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
@@ -37,26 +39,24 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.conversion.ConverterRegistry;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
|
||||
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;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ShortTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.BlockIdData;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_3_4Type;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -70,22 +70,22 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
private final String extraNbtTag;
|
||||
|
||||
public BlockItemPackets1_13(Protocol1_12_2To1_13 protocol) {
|
||||
super(protocol);
|
||||
super(protocol, null, null);
|
||||
extraNbtTag = "VB|" + protocol.getClass().getSimpleName() + "|2";
|
||||
}
|
||||
|
||||
public static boolean isDamageable(int id) {
|
||||
return id >= 256 && id <= 259 // iron shovel, pickaxe, axe, flint and steel
|
||||
|| id == 261 // bow
|
||||
|| id >= 267 && id <= 279 // iron sword, wooden+stone+diamond swords, shovels, pickaxes, axes
|
||||
|| id >= 283 && id <= 286 // gold sword, shovel, pickaxe, axe
|
||||
|| id >= 290 && id <= 294 // hoes
|
||||
|| id >= 298 && id <= 317 // armors
|
||||
|| id == 346 // fishing rod
|
||||
|| id == 359 // shears
|
||||
|| id == 398 // carrot on a stick
|
||||
|| id == 442 // shield
|
||||
|| id == 443; // elytra
|
||||
|| id == 261 // bow
|
||||
|| id >= 267 && id <= 279 // iron sword, wooden+stone+diamond swords, shovels, pickaxes, axes
|
||||
|| id >= 283 && id <= 286 // gold sword, shovel, pickaxe, axe
|
||||
|| id >= 290 && id <= 294 // hoes
|
||||
|| id >= 298 && id <= 317 // armors
|
||||
|| id == 346 // fishing rod
|
||||
|| id == 359 // shears
|
||||
|| id == 398 // carrot on a stick
|
||||
|| id == 442 // shield
|
||||
|| id == 443; // elytra
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,7 +109,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ACTION, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.POSITION); // Location
|
||||
map(Type.POSITION1_8); // Location
|
||||
map(Type.UNSIGNED_BYTE); // Action Id
|
||||
map(Type.UNSIGNED_BYTE); // Action param
|
||||
map(Type.VAR_INT); // Block Id - /!\ NOT BLOCK STATE ID
|
||||
@@ -137,6 +137,17 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
else if (blockId >= 483 && blockId <= 498)
|
||||
blockId = blockId - 483 + 219;
|
||||
|
||||
if (blockId == 25) { // Note block
|
||||
final NoteBlockStorage noteBlockStorage = wrapper.user().get(NoteBlockStorage.class);
|
||||
|
||||
final Position position = wrapper.get(Type.POSITION1_8, 0);
|
||||
final Pair<Integer, Integer> update = noteBlockStorage.getNoteBlockUpdate(position);
|
||||
if (update != null) { // Use values from block state update
|
||||
wrapper.set(Type.UNSIGNED_BYTE, 0, update.key().shortValue());
|
||||
wrapper.set(Type.UNSIGNED_BYTE, 1, update.value().shortValue());
|
||||
}
|
||||
}
|
||||
|
||||
wrapper.set(Type.VAR_INT, 0, blockId);
|
||||
});
|
||||
}
|
||||
@@ -145,9 +156,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ENTITY_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
map(Type.POSITION1_8); // 0 - Position
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Action
|
||||
map(Type.NBT); // 2 - NBT Data
|
||||
map(Type.NAMED_COMPOUND_TAG); // 2 - NBT Data
|
||||
|
||||
handler(wrapper -> {
|
||||
BackwardsBlockEntityProvider provider = Via.getManager().getProviders().get(BackwardsBlockEntityProvider.class);
|
||||
@@ -157,12 +168,12 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
wrapper.cancel();
|
||||
}
|
||||
|
||||
wrapper.set(Type.NBT, 0,
|
||||
provider.transform(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.POSITION, 0),
|
||||
wrapper.get(Type.NBT, 0)
|
||||
));
|
||||
wrapper.set(Type.NAMED_COMPOUND_TAG, 0,
|
||||
provider.transform(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.POSITION1_8, 0),
|
||||
wrapper.get(Type.NAMED_COMPOUND_TAG, 0)
|
||||
));
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -176,7 +187,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
blockStorage.getBlocks().entrySet().removeIf(entry -> {
|
||||
Position position = entry.getKey();
|
||||
return position.x() >= chunkMinX && position.z() >= chunkMinZ
|
||||
&& position.x() <= chunkMaxX && position.z() <= chunkMaxZ;
|
||||
&& position.x() <= chunkMaxX && position.z() <= chunkMaxZ;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -184,11 +195,16 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_CHANGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
map(Type.POSITION1_8); // 0 - Position
|
||||
|
||||
handler(wrapper -> {
|
||||
int blockState = wrapper.read(Type.VAR_INT);
|
||||
Position position = wrapper.get(Type.POSITION, 0);
|
||||
Position position = wrapper.get(Type.POSITION1_8, 0);
|
||||
|
||||
// Note block special treatment
|
||||
if (blockState >= 249 && blockState <= 748) { // Note block states id range
|
||||
wrapper.user().get(NoteBlockStorage.class).storeNoteBlockUpdate(position, blockState);
|
||||
}
|
||||
|
||||
// Store blocks
|
||||
BackwardsBlockStorage storage = wrapper.user().get(BackwardsBlockStorage.class);
|
||||
@@ -217,9 +233,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
int chunkZ = wrapper.get(Type.INT, 1);
|
||||
int block = record.getBlockId();
|
||||
Position position = new Position(
|
||||
record.getSectionX() + (chunkX * 16),
|
||||
record.getY(),
|
||||
record.getSectionZ() + (chunkZ * 16));
|
||||
record.getSectionX() + (chunkX * 16),
|
||||
record.getY(),
|
||||
record.getSectionZ() + (chunkZ * 16));
|
||||
|
||||
// Store if needed
|
||||
storage.checkAndStore(position, block);
|
||||
@@ -238,9 +254,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
map(Type.FLAT_ITEM_ARRAY, Type.ITEM_ARRAY);
|
||||
map(Type.ITEM1_13_SHORT_ARRAY, Type.ITEM1_8_SHORT_ARRAY);
|
||||
|
||||
handler(itemArrayToClientHandler(Type.ITEM_ARRAY));
|
||||
handler(itemArrayToClientHandler(Type.ITEM1_8_SHORT_ARRAY));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -249,32 +265,32 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
map(Type.SHORT);
|
||||
map(Type.FLAT_ITEM, Type.ITEM);
|
||||
map(Type.ITEM1_13, Type.ITEM1_8);
|
||||
|
||||
handler(itemToClientHandler(Type.ITEM));
|
||||
handler(itemToClientHandler(Type.ITEM1_8));
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
Chunk1_9_3_4Type type_old = new Chunk1_9_3_4Type(clientWorld);
|
||||
Chunk1_13Type type = new Chunk1_13Type(clientWorld);
|
||||
ChunkType1_9_3 type_old = ChunkType1_9_3.forEnvironment(clientWorld.getEnvironment());
|
||||
ChunkType1_13 type = ChunkType1_13.forEnvironment(clientWorld.getEnvironment());
|
||||
Chunk chunk = wrapper.read(type);
|
||||
|
||||
// Handle Block Entities before block rewrite
|
||||
BackwardsBlockEntityProvider provider = Via.getManager().getProviders().get(BackwardsBlockEntityProvider.class);
|
||||
BackwardsBlockStorage storage = wrapper.user().get(BackwardsBlockStorage.class);
|
||||
for (CompoundTag tag : chunk.getBlockEntities()) {
|
||||
Tag idTag = tag.get("id");
|
||||
StringTag idTag = tag.getStringTag("id");
|
||||
if (idTag == null) continue;
|
||||
|
||||
String id = (String) idTag.getValue();
|
||||
String id = idTag.getValue();
|
||||
|
||||
// Ignore if we don't handle it
|
||||
if (!provider.isHandled(id)) continue;
|
||||
|
||||
int sectionIndex = ((NumberTag) tag.get("y")).asInt() >> 4;
|
||||
int sectionIndex = tag.getNumberTag("y").asInt() >> 4;
|
||||
if (sectionIndex < 0 || sectionIndex > 15) {
|
||||
// 1.17 chunks
|
||||
continue;
|
||||
@@ -282,9 +298,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
|
||||
ChunkSection section = chunk.getSections()[sectionIndex];
|
||||
|
||||
int x = ((NumberTag) tag.get("x")).asInt();
|
||||
int y = ((NumberTag) tag.get("y")).asInt();
|
||||
int z = ((NumberTag) tag.get("z")).asInt();
|
||||
int x = tag.getNumberTag("x").asInt();
|
||||
int y = tag.getNumberTag("y").asInt();
|
||||
int z = tag.getNumberTag("z").asInt();
|
||||
Position position = new Position(x, (short) y, z);
|
||||
|
||||
int block = section.palette(PaletteType.BLOCKS).idAt(x & 0xF, y & 0xF, z & 0xF);
|
||||
@@ -310,9 +326,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
// Check if the block is a flower
|
||||
if (FlowerPotHandler.isFlowah(block)) {
|
||||
Position pos = new Position(
|
||||
(x + (chunk.getX() << 4)),
|
||||
(short) (y + (i << 4)),
|
||||
(z + (chunk.getZ() << 4))
|
||||
(x + (chunk.getX() << 4)),
|
||||
(short) (y + (i << 4)),
|
||||
(z + (chunk.getZ() << 4))
|
||||
);
|
||||
// Store block
|
||||
storage.checkAndStore(pos, block);
|
||||
@@ -371,7 +387,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // Effect Id
|
||||
map(Type.POSITION); // Location
|
||||
map(Type.POSITION1_8); // Location
|
||||
map(Type.INT); // Data
|
||||
handler(wrapper -> {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
@@ -401,9 +417,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
byte x = wrapper.read(Type.BYTE);
|
||||
byte z = wrapper.read(Type.BYTE);
|
||||
byte direction = wrapper.read(Type.BYTE);
|
||||
if (wrapper.read(Type.BOOLEAN)) {
|
||||
wrapper.read(Type.COMPONENT);
|
||||
}
|
||||
wrapper.read(Type.OPTIONAL_COMPONENT);
|
||||
if (type > 9) {
|
||||
wrapper.set(Type.VAR_INT, 1, wrapper.get(Type.VAR_INT, 1) - 1);
|
||||
continue;
|
||||
@@ -421,9 +435,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.VAR_INT);
|
||||
map(Type.FLAT_ITEM, Type.ITEM);
|
||||
map(Type.ITEM1_13, Type.ITEM1_8);
|
||||
|
||||
handler(itemToClientHandler(Type.ITEM));
|
||||
handler(itemToClientHandler(Type.ITEM1_8));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -449,9 +463,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.SHORT);
|
||||
map(Type.ITEM, Type.FLAT_ITEM);
|
||||
map(Type.ITEM1_8, Type.ITEM1_13);
|
||||
|
||||
handler(itemToServerHandler(Type.FLAT_ITEM));
|
||||
handler(itemToServerHandler(Type.ITEM1_13));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -463,9 +477,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
map(Type.BYTE);
|
||||
map(Type.SHORT);
|
||||
map(Type.VAR_INT);
|
||||
map(Type.ITEM, Type.FLAT_ITEM);
|
||||
map(Type.ITEM1_8, Type.ITEM1_13);
|
||||
|
||||
handler(itemToServerHandler(Type.FLAT_ITEM));
|
||||
handler(itemToServerHandler(Type.ITEM1_13));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -492,7 +506,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
|
||||
// Use tag to get original ID and data
|
||||
Tag originalIdTag;
|
||||
if (tag != null && (originalIdTag = tag.remove(extraNbtTag)) != null) {
|
||||
if (tag != null && (originalIdTag = tag.remove(extraNbtTag)) instanceof NumberTag) {
|
||||
rawId = ((NumberTag) originalIdTag).asInt();
|
||||
gotRawIdFromTag = true;
|
||||
}
|
||||
@@ -529,15 +543,15 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
if (tag != null) {
|
||||
if (isDamageable(item.identifier())) {
|
||||
Tag damageTag = tag.remove("Damage");
|
||||
if (!gotRawIdFromTag && damageTag instanceof IntTag) {
|
||||
item.setData((short) (int) damageTag.getValue());
|
||||
if (!gotRawIdFromTag && damageTag instanceof NumberTag) {
|
||||
item.setData(((NumberTag) damageTag).asShort());
|
||||
}
|
||||
}
|
||||
|
||||
if (item.identifier() == 358) { // map
|
||||
Tag mapTag = tag.remove("map");
|
||||
if (!gotRawIdFromTag && mapTag instanceof IntTag) {
|
||||
item.setData((short) (int) mapTag.getValue());
|
||||
if (!gotRawIdFromTag && mapTag instanceof NumberTag) {
|
||||
item.setData(((NumberTag) mapTag).asShort());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -545,11 +559,11 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
invertShieldAndBannerId(item, tag);
|
||||
|
||||
// Display Name now uses JSON
|
||||
CompoundTag display = tag.get("display");
|
||||
CompoundTag display = tag.getCompoundTag("display");
|
||||
if (display != null) {
|
||||
StringTag name = display.get("Name");
|
||||
StringTag name = display.getStringTag("Name");
|
||||
if (name != null) {
|
||||
display.put(extraNbtTag + "|Name", new StringTag(name.getValue()));
|
||||
display.putString(extraNbtTag + "|Name", name.getValue());
|
||||
name.setValue(protocol.jsonToLegacy(name.getValue()));
|
||||
}
|
||||
}
|
||||
@@ -572,7 +586,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
}
|
||||
if (!tag.contains("EntityTag")) {
|
||||
CompoundTag entityTag = new CompoundTag();
|
||||
entityTag.put("id", new StringTag(eggEntityId.get()));
|
||||
entityTag.putString("id", eggEntityId.get());
|
||||
tag.put("EntityTag", entityTag);
|
||||
}
|
||||
return 0x17f0000; // 383 << 16;
|
||||
@@ -583,16 +597,15 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
|
||||
private void rewriteCanPlaceToClient(CompoundTag tag, String tagName) {
|
||||
// The tag was manually created incorrectly so ignore rewriting it
|
||||
if (!(tag.get(tagName) instanceof ListTag)) return;
|
||||
ListTag blockTag = tag.get(tagName);
|
||||
ListTag blockTag = tag.getListTag(tagName);
|
||||
if (blockTag == null) return;
|
||||
|
||||
ListTag newCanPlaceOn = new ListTag(StringTag.class);
|
||||
tag.put(extraNbtTag + "|" + tagName, ConverterRegistry.convertToTag(ConverterRegistry.convertToValue(blockTag)));
|
||||
tag.put(extraNbtTag + "|" + tagName, blockTag.copy());
|
||||
for (Tag oldTag : blockTag) {
|
||||
Object value = oldTag.getValue();
|
||||
String[] newValues = value instanceof String ?
|
||||
BlockIdData.fallbackReverseMapping.get(((String) value).replace("minecraft:", "")) : null;
|
||||
BlockIdData.fallbackReverseMapping.get(Key.stripMinecraftNamespace((String) value)) : null;
|
||||
if (newValues != null) {
|
||||
for (String newValue : newValues) {
|
||||
newCanPlaceOn.add(new StringTag(newValue));
|
||||
@@ -607,22 +620,26 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
//TODO un-ugly all of this
|
||||
private void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnch) {
|
||||
String key = storedEnch ? "StoredEnchantments" : "Enchantments";
|
||||
ListTag enchantments = tag.get(key);
|
||||
ListTag enchantments = tag.getListTag(key);
|
||||
if (enchantments == null) return;
|
||||
|
||||
ListTag noMapped = new ListTag(CompoundTag.class);
|
||||
ListTag newEnchantments = new ListTag(CompoundTag.class);
|
||||
List<Tag> lore = new ArrayList<>();
|
||||
boolean hasValidEnchants = false;
|
||||
for (Tag enchantmentEntryTag : enchantments.clone()) {
|
||||
CompoundTag enchantmentEntry = (CompoundTag) enchantmentEntryTag;
|
||||
Tag idTag = enchantmentEntry.get("id");
|
||||
if (!(idTag instanceof StringTag)) {
|
||||
for (Tag enchantmentEntryTag : enchantments.copy()) {
|
||||
if (!(enchantmentEntryTag instanceof CompoundTag)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String newId = (String) idTag.getValue();
|
||||
NumberTag levelTag = enchantmentEntry.get("lvl");
|
||||
CompoundTag enchantmentEntry = (CompoundTag) enchantmentEntryTag;
|
||||
StringTag idTag = enchantmentEntry.getStringTag("id");
|
||||
if (idTag == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String newId = idTag.getValue();
|
||||
NumberTag levelTag = enchantmentEntry.getNumberTag("lvl");
|
||||
if (levelTag == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -667,51 +684,50 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
}
|
||||
|
||||
CompoundTag newEntry = new CompoundTag();
|
||||
newEntry.put("id", new ShortTag(oldId));
|
||||
newEntry.put("lvl", new ShortTag(level));
|
||||
newEntry.putShort("id", oldId);
|
||||
newEntry.putShort("lvl", level);
|
||||
newEnchantments.add(newEntry);
|
||||
}
|
||||
}
|
||||
|
||||
// Put here to hide empty enchantment from 1.14 rewrites
|
||||
if (!storedEnch && !hasValidEnchants) {
|
||||
IntTag hideFlags = tag.get("HideFlags");
|
||||
NumberTag hideFlags = tag.getNumberTag("HideFlags");
|
||||
if (hideFlags == null) {
|
||||
hideFlags = new IntTag();
|
||||
tag.put(extraNbtTag + "|DummyEnchant", new ByteTag());
|
||||
} else {
|
||||
tag.put(extraNbtTag + "|OldHideFlags", new IntTag(hideFlags.asByte()));
|
||||
tag.putInt(extraNbtTag + "|OldHideFlags", hideFlags.asByte());
|
||||
}
|
||||
|
||||
if (newEnchantments.size() == 0) {
|
||||
if (newEnchantments.isEmpty()) {
|
||||
CompoundTag enchEntry = new CompoundTag();
|
||||
enchEntry.put("id", new ShortTag((short) 0));
|
||||
enchEntry.put("lvl", new ShortTag((short) 0));
|
||||
enchEntry.putShort("id", (short) 0);
|
||||
enchEntry.putShort("lvl", (short) 0);
|
||||
newEnchantments.add(enchEntry);
|
||||
}
|
||||
|
||||
int value = hideFlags.asByte() | 1;
|
||||
hideFlags.setValue(value);
|
||||
tag.put("HideFlags", hideFlags);
|
||||
tag.putInt("HideFlags", value);
|
||||
}
|
||||
|
||||
if (noMapped.size() != 0) {
|
||||
if (!noMapped.isEmpty()) {
|
||||
tag.put(extraNbtTag + "|" + key, noMapped);
|
||||
|
||||
if (!lore.isEmpty()) {
|
||||
CompoundTag display = tag.get("display");
|
||||
CompoundTag display = tag.getCompoundTag("display");
|
||||
if (display == null) {
|
||||
tag.put("display", display = new CompoundTag());
|
||||
}
|
||||
|
||||
ListTag loreTag = display.get("Lore");
|
||||
ListTag loreTag = display.getListTag("Lore");
|
||||
if (loreTag == null) {
|
||||
display.put("Lore", loreTag = new ListTag(StringTag.class));
|
||||
tag.put(extraNbtTag + "|DummyLore", new ByteTag());
|
||||
} else if (loreTag.size() != 0) {
|
||||
} else if (!loreTag.isEmpty()) {
|
||||
ListTag oldLore = new ListTag(StringTag.class);
|
||||
for (Tag value : loreTag) {
|
||||
oldLore.add(value.clone());
|
||||
oldLore.add(value.copy());
|
||||
}
|
||||
tag.put(extraNbtTag + "|OldLore", oldLore);
|
||||
|
||||
@@ -739,11 +755,11 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
// NBT Additions
|
||||
if (isDamageable(item.identifier())) {
|
||||
if (tag == null) item.setTag(tag = new CompoundTag());
|
||||
tag.put("Damage", new IntTag(item.data()));
|
||||
tag.putInt("Damage", item.data());
|
||||
}
|
||||
if (item.identifier() == 358) { // map
|
||||
if (tag == null) item.setTag(tag = new CompoundTag());
|
||||
tag.put("map", new IntTag(item.data()));
|
||||
tag.putInt("map", item.data());
|
||||
}
|
||||
|
||||
// NBT Changes
|
||||
@@ -752,13 +768,12 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
invertShieldAndBannerId(item, tag);
|
||||
|
||||
// Display Name now uses JSON
|
||||
Tag display = tag.get("display");
|
||||
if (display instanceof CompoundTag) {
|
||||
CompoundTag displayTag = (CompoundTag) display;
|
||||
StringTag name = displayTag.get("Name");
|
||||
CompoundTag display = tag.getCompoundTag("display");
|
||||
if (display != null) {
|
||||
StringTag name = display.getStringTag("Name");
|
||||
if (name != null) {
|
||||
StringTag via = displayTag.remove(extraNbtTag + "|Name");
|
||||
name.setValue(via != null ? via.getValue() : ChatRewriter.legacyTextToJsonString(name.getValue()));
|
||||
Tag via = display.remove(extraNbtTag + "|Name");
|
||||
name.setValue(via instanceof StringTag ? ((StringTag) via).getValue() : ComponentUtil.legacyToJsonString(name.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -771,9 +786,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
|
||||
// Handle SpawnEggs
|
||||
if (item.identifier() == 383) {
|
||||
CompoundTag entityTag = tag.get("EntityTag");
|
||||
CompoundTag entityTag = tag.getCompoundTag("EntityTag");
|
||||
StringTag identifier;
|
||||
if (entityTag != null && (identifier = entityTag.get("id")) != null) {
|
||||
if (entityTag != null && (identifier = entityTag.getStringTag("id")) != null) {
|
||||
rawId = SpawnEggRewriter.getSpawnEggId(identifier.getValue());
|
||||
if (rawId == -1) {
|
||||
rawId = 25100288; // Bat fallback
|
||||
@@ -807,8 +822,10 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
int newId = -1;
|
||||
if (protocol.getMappingData().getItemMappings().inverse().getNewId(rawId) == -1) {
|
||||
if (!isDamageable(item.identifier()) && item.identifier() != 358) { // Map
|
||||
if (tag == null) item.setTag(tag = new CompoundTag());
|
||||
tag.put(extraNbtTag, new IntTag(originalId)); // Data will be lost, saving original id
|
||||
if (tag == null) {
|
||||
item.setTag(tag = new CompoundTag());
|
||||
}
|
||||
tag.putInt(extraNbtTag, originalId); // Data will be lost, saving original id
|
||||
}
|
||||
|
||||
if (item.identifier() == 229) { // purple shulker box
|
||||
@@ -835,15 +852,16 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
}
|
||||
|
||||
private void rewriteCanPlaceToServer(CompoundTag tag, String tagName) {
|
||||
if (!(tag.get(tagName) instanceof ListTag)) return;
|
||||
if (tag.getListTag(tagName) == null) return;
|
||||
|
||||
ListTag blockTag = tag.remove(extraNbtTag + "|" + tagName);
|
||||
if (blockTag != null) {
|
||||
tag.put(tagName, ConverterRegistry.convertToTag(ConverterRegistry.convertToValue(blockTag)));
|
||||
} else if ((blockTag = tag.get(tagName)) != null) {
|
||||
tag.put(tagName, blockTag.copy());
|
||||
} else if ((blockTag = tag.getListTag(tagName)) != null) {
|
||||
ListTag newCanPlaceOn = new ListTag(StringTag.class);
|
||||
for (Tag oldTag : blockTag) {
|
||||
Object value = oldTag.getValue();
|
||||
String oldId = value.toString().replace("minecraft:", "");
|
||||
String oldId = Key.stripMinecraftNamespace(value.toString());
|
||||
int key = Ints.tryParse(oldId);
|
||||
String numberConverted = BlockIdData.numberIdToString.get(key);
|
||||
if (numberConverted != null) {
|
||||
@@ -866,15 +884,15 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
|
||||
private void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnch) {
|
||||
String key = storedEnch ? "StoredEnchantments" : "Enchantments";
|
||||
ListTag enchantments = tag.get(storedEnch ? key : "ench");
|
||||
ListTag enchantments = tag.getListTag(storedEnch ? key : "ench");
|
||||
if (enchantments == null) return;
|
||||
|
||||
ListTag newEnchantments = new ListTag(CompoundTag.class);
|
||||
boolean dummyEnchant = false;
|
||||
if (!storedEnch) {
|
||||
IntTag hideFlags = tag.remove(extraNbtTag + "|OldHideFlags");
|
||||
if (hideFlags != null) {
|
||||
tag.put("HideFlags", new IntTag(hideFlags.asByte()));
|
||||
Tag hideFlags = tag.remove(extraNbtTag + "|OldHideFlags");
|
||||
if (hideFlags instanceof IntTag) {
|
||||
tag.putInt("HideFlags", ((NumberTag) hideFlags).asByte());
|
||||
dummyEnchant = true;
|
||||
} else if (tag.remove(extraNbtTag + "|DummyEnchant") != null) {
|
||||
tag.remove("HideFlags");
|
||||
@@ -883,42 +901,50 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
}
|
||||
|
||||
for (Tag enchEntry : enchantments) {
|
||||
CompoundTag enchantmentEntry = new CompoundTag();
|
||||
short oldId = ((NumberTag) ((CompoundTag) enchEntry).get("id")).asShort();
|
||||
short level = ((NumberTag) ((CompoundTag) enchEntry).get("lvl")).asShort();
|
||||
if (dummyEnchant && oldId == 0 && level == 0) {
|
||||
continue; //Skip dummy enchatment
|
||||
if (!(enchEntry instanceof CompoundTag)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CompoundTag entryTag = (CompoundTag) enchEntry;
|
||||
NumberTag idTag = entryTag.getNumberTag("id");
|
||||
NumberTag levelTag = entryTag.getNumberTag("lvl");
|
||||
CompoundTag enchantmentEntry = new CompoundTag();
|
||||
short oldId = idTag != null ? idTag.asShort() : 0;
|
||||
short level = levelTag != null ? levelTag.asShort() : 0;
|
||||
if (dummyEnchant && oldId == 0 && level == 0) {
|
||||
continue; // Skip dummy enchatment
|
||||
}
|
||||
|
||||
String newId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().get(oldId);
|
||||
if (newId == null) {
|
||||
newId = "viaversion:legacy/" + oldId;
|
||||
}
|
||||
enchantmentEntry.put("id", new StringTag(newId));
|
||||
enchantmentEntry.putString("id", newId);
|
||||
|
||||
enchantmentEntry.put("lvl", new ShortTag(level));
|
||||
enchantmentEntry.putShort("lvl", level);
|
||||
newEnchantments.add(enchantmentEntry);
|
||||
}
|
||||
|
||||
ListTag noMapped = tag.remove(extraNbtTag + "|Enchantments");
|
||||
if (noMapped != null) {
|
||||
for (Tag value : noMapped) {
|
||||
Tag noMapped = tag.remove(extraNbtTag + "|Enchantments");
|
||||
if (noMapped instanceof ListTag) {
|
||||
for (Tag value : ((ListTag) noMapped)) {
|
||||
newEnchantments.add(value);
|
||||
}
|
||||
}
|
||||
|
||||
CompoundTag display = tag.get("display");
|
||||
CompoundTag display = tag.getCompoundTag("display");
|
||||
if (display == null) {
|
||||
tag.put("display", display = new CompoundTag());
|
||||
}
|
||||
|
||||
ListTag oldLore = tag.remove(extraNbtTag + "|OldLore");
|
||||
if (oldLore != null) {
|
||||
ListTag lore = display.get("Lore");
|
||||
Tag oldLore = tag.remove(extraNbtTag + "|OldLore");
|
||||
if (oldLore instanceof ListTag) {
|
||||
ListTag lore = display.getListTag("Lore");
|
||||
if (lore == null) {
|
||||
tag.put("Lore", lore = new ListTag());
|
||||
}
|
||||
|
||||
lore.setValue(oldLore.getValue());
|
||||
lore.setValue(((ListTag) oldLore).getValue());
|
||||
} else if (tag.remove(extraNbtTag + "|DummyLore") != null) {
|
||||
display.remove("Lore");
|
||||
if (display.isEmpty()) {
|
||||
@@ -935,24 +961,22 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
private void invertShieldAndBannerId(Item item, CompoundTag tag) {
|
||||
if (item.identifier() != 442 && item.identifier() != 425) return;
|
||||
|
||||
Tag blockEntityTag = tag.get("BlockEntityTag");
|
||||
if (!(blockEntityTag instanceof CompoundTag)) return;
|
||||
CompoundTag blockEntityTag = tag.getCompoundTag("BlockEntityTag");
|
||||
if (blockEntityTag == null) return;
|
||||
|
||||
CompoundTag blockEntityCompoundTag = (CompoundTag) blockEntityTag;
|
||||
Tag base = blockEntityCompoundTag.get("Base");
|
||||
if (base instanceof IntTag) {
|
||||
IntTag baseTag = (IntTag) base;
|
||||
baseTag.setValue(15 - baseTag.asInt()); // invert color id
|
||||
NumberTag base = blockEntityTag.getNumberTag("Base");
|
||||
if (base != null) {
|
||||
blockEntityTag.putInt("Base", 15 - base.asInt()); // Invert color id
|
||||
}
|
||||
|
||||
Tag patterns = blockEntityCompoundTag.get("Patterns");
|
||||
if (patterns instanceof ListTag) {
|
||||
ListTag patternsTag = (ListTag) patterns;
|
||||
for (Tag pattern : patternsTag) {
|
||||
ListTag patterns = blockEntityTag.getListTag("Patterns");
|
||||
if (patterns != null) {
|
||||
for (Tag pattern : patterns) {
|
||||
if (!(pattern instanceof CompoundTag)) continue;
|
||||
|
||||
IntTag colorTag = ((CompoundTag) pattern).get("Color");
|
||||
colorTag.setValue(15 - colorTag.asInt()); // Invert color id
|
||||
CompoundTag patternTag = (CompoundTag) pattern;
|
||||
NumberTag colorTag = patternTag.getNumberTag("Color");
|
||||
patternTag.putInt("Color", 15 - colorTag.asInt()); // Invert color id
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -966,21 +990,21 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
|
||||
// Remove the flowerpot
|
||||
PacketWrapper blockUpdateRemove = PacketWrapper.create(ClientboundPackets1_12_1.BLOCK_CHANGE, user);
|
||||
blockUpdateRemove.write(Type.POSITION, position);
|
||||
blockUpdateRemove.write(Type.POSITION1_8, position);
|
||||
blockUpdateRemove.write(Type.VAR_INT, 0);
|
||||
blockUpdateRemove.scheduleSend(Protocol1_12_2To1_13.class);
|
||||
|
||||
// Create the flowerpot
|
||||
PacketWrapper blockCreate = PacketWrapper.create(ClientboundPackets1_12_1.BLOCK_CHANGE, user);
|
||||
blockCreate.write(Type.POSITION, position);
|
||||
blockCreate.write(Type.POSITION1_8, position);
|
||||
blockCreate.write(Type.VAR_INT, Protocol1_12_2To1_13.MAPPINGS.getNewBlockStateId(blockState));
|
||||
blockCreate.scheduleSend(Protocol1_12_2To1_13.class);
|
||||
|
||||
// Send a block entity update
|
||||
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_12_1.BLOCK_ENTITY_DATA, user);
|
||||
wrapper.write(Type.POSITION, position);
|
||||
wrapper.write(Type.POSITION1_8, position);
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) 5);
|
||||
wrapper.write(Type.NBT, nbt);
|
||||
wrapper.write(Type.NAMED_COMPOUND_TAG, nbt);
|
||||
wrapper.scheduleSend(Protocol1_12_2To1_13.class);
|
||||
|
||||
}
|
||||
|
||||
+46
-42
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
@@ -25,16 +25,17 @@ import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.EntityType
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.PaintingMapping;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.ParticleMapping;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.NoteBlockStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.PlayerPositionStorage1_13;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
|
||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
|
||||
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_12;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_12;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
@@ -88,16 +89,16 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
handler(getObjectTrackerHandler());
|
||||
|
||||
handler(wrapper -> {
|
||||
Optional<Entity1_13Types.ObjectType> optionalType = Entity1_13Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||
Optional<EntityTypes1_13.ObjectType> optionalType = EntityTypes1_13.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||
if (!optionalType.isPresent()) return;
|
||||
|
||||
Entity1_13Types.ObjectType type = optionalType.get();
|
||||
if (type == Entity1_13Types.ObjectType.FALLING_BLOCK) {
|
||||
EntityTypes1_13.ObjectType type = optionalType.get();
|
||||
if (type == EntityTypes1_13.ObjectType.FALLING_BLOCK) {
|
||||
int blockState = wrapper.get(Type.INT, 0);
|
||||
int combined = Protocol1_12_2To1_13.MAPPINGS.getNewBlockStateId(blockState);
|
||||
combined = ((combined >> 4) & 0xFFF) | ((combined & 0xF) << 12);
|
||||
wrapper.set(Type.INT, 0, combined);
|
||||
} else if (type == Entity1_13Types.ObjectType.ITEM_FRAME) {
|
||||
} else if (type == EntityTypes1_13.ObjectType.ITEM_FRAME) {
|
||||
int data = wrapper.get(Type.INT, 0);
|
||||
switch (data) {
|
||||
case 3:
|
||||
@@ -111,15 +112,15 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
break;
|
||||
}
|
||||
wrapper.set(Type.INT, 0, data);
|
||||
} else if (type == Entity1_13Types.ObjectType.TRIDENT) {
|
||||
wrapper.set(Type.BYTE, 0, (byte) Entity1_13Types.ObjectType.TIPPED_ARROW.getId());
|
||||
} else if (type == EntityTypes1_13.ObjectType.TRIDENT) {
|
||||
wrapper.set(Type.BYTE, 0, (byte) EntityTypes1_13.ObjectType.TIPPED_ARROW.getId());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_13.SPAWN_EXPERIENCE_ORB, Entity1_13Types.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_13.SPAWN_GLOBAL_ENTITY, Entity1_13Types.EntityType.LIGHTNING_BOLT);
|
||||
registerTracker(ClientboundPackets1_13.SPAWN_EXPERIENCE_ORB, EntityTypes1_13.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_13.SPAWN_GLOBAL_ENTITY, EntityTypes1_13.EntityType.LIGHTNING_BOLT);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
@@ -140,7 +141,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
handler(wrapper -> {
|
||||
int type = wrapper.get(Type.VAR_INT, 1);
|
||||
EntityType entityType = Entity1_13Types.getTypeFromId(type, false);
|
||||
EntityType entityType = EntityTypes1_13.getTypeFromId(type, false);
|
||||
tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), entityType);
|
||||
|
||||
int oldId = EntityTypeMapping.getOldId(type);
|
||||
@@ -170,7 +171,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
map(Type.BYTE);
|
||||
map(Types1_13.METADATA_LIST, Types1_12.METADATA_LIST);
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_12.METADATA_LIST, Entity1_13Types.EntityType.PLAYER));
|
||||
handler(getTrackerAndMetaHandler(Types1_12.METADATA_LIST, EntityTypes1_13.EntityType.PLAYER));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -180,7 +181,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
map(Type.VAR_INT);
|
||||
map(Type.UUID);
|
||||
|
||||
handler(getTrackerHandler(Entity1_13Types.EntityType.PAINTING, Type.VAR_INT));
|
||||
handler(getTrackerHandler(EntityTypes1_13.EntityType.PAINTING, Type.VAR_INT));
|
||||
handler(wrapper -> {
|
||||
int motive = wrapper.read(Type.VAR_INT);
|
||||
String title = PaintingMapping.getStringId(motive);
|
||||
@@ -189,7 +190,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
registerJoinGame(ClientboundPackets1_13.JOIN_GAME, Entity1_13Types.EntityType.PLAYER);
|
||||
registerJoinGame(ClientboundPackets1_13.JOIN_GAME, EntityTypes1_13.EntityType.PLAYER);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
@@ -197,7 +198,10 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
map(Type.INT); // 0 - Dimension ID
|
||||
|
||||
handler(getDimensionHandler(0));
|
||||
handler(wrapper -> wrapper.user().get(BackwardsBlockStorage.class).clear());
|
||||
handler(wrapper -> {
|
||||
wrapper.user().get(BackwardsBlockStorage.class).clear();
|
||||
wrapper.user().get(NoteBlockStorage.class).clear();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -227,8 +231,8 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
//TODO properly cache and calculate head position?
|
||||
EntityPositionHandler.writeFacingDegrees(positionAndLook, positionStorage.getX(),
|
||||
anchor == 1 ? positionStorage.getY() + 1.62 : positionStorage.getY(),
|
||||
positionStorage.getZ(), x, y, z);
|
||||
anchor == 1 ? positionStorage.getY() + 1.62 : positionStorage.getY(),
|
||||
positionStorage.getZ(), x, y, z);
|
||||
|
||||
positionAndLook.write(Type.BYTE, (byte) 7); // bitfield, 0=absolute, 1=relative - x,y,z relative, yaw,pitch absolute
|
||||
positionAndLook.write(Type.VAR_INT, -1);
|
||||
@@ -254,25 +258,25 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
// Rewrite new Entity 'drowned'
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.DROWNED, Entity1_13Types.EntityType.ZOMBIE_VILLAGER).plainName();
|
||||
mapEntityTypeWithData(EntityTypes1_13.EntityType.DROWNED, EntityTypes1_13.EntityType.ZOMBIE_VILLAGER).plainName();
|
||||
|
||||
// Fishy
|
||||
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();
|
||||
mapEntityTypeWithData(EntityTypes1_13.EntityType.COD, EntityTypes1_13.EntityType.SQUID).plainName();
|
||||
mapEntityTypeWithData(EntityTypes1_13.EntityType.SALMON, EntityTypes1_13.EntityType.SQUID).plainName();
|
||||
mapEntityTypeWithData(EntityTypes1_13.EntityType.PUFFERFISH, EntityTypes1_13.EntityType.SQUID).plainName();
|
||||
mapEntityTypeWithData(EntityTypes1_13.EntityType.TROPICAL_FISH, EntityTypes1_13.EntityType.SQUID).plainName();
|
||||
|
||||
// Phantom
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.PHANTOM, Entity1_13Types.EntityType.PARROT).plainName().spawnMetadata(storage -> {
|
||||
mapEntityTypeWithData(EntityTypes1_13.EntityType.PHANTOM, EntityTypes1_13.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).plainName();
|
||||
mapEntityTypeWithData(EntityTypes1_13.EntityType.DOLPHIN, EntityTypes1_13.EntityType.SQUID).plainName();
|
||||
|
||||
// Turtle
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.TURTLE, Entity1_13Types.EntityType.OCELOT).plainName();
|
||||
mapEntityTypeWithData(EntityTypes1_13.EntityType.TURTLE, EntityTypes1_13.EntityType.OCELOT).plainName();
|
||||
|
||||
// Rewrite Meta types
|
||||
filter().handler((event, meta) -> {
|
||||
@@ -297,36 +301,36 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
});
|
||||
|
||||
// Handle zombie metadata
|
||||
filter().filterFamily(Entity1_13Types.EntityType.ZOMBIE).removeIndex(15);
|
||||
filter().type(EntityTypes1_13.EntityType.ZOMBIE).removeIndex(15);
|
||||
|
||||
// Handle turtle metadata (Remove them all for now)
|
||||
filter().type(Entity1_13Types.EntityType.TURTLE).cancel(13); // Home pos
|
||||
filter().type(Entity1_13Types.EntityType.TURTLE).cancel(14); // Has egg
|
||||
filter().type(Entity1_13Types.EntityType.TURTLE).cancel(15); // Laying egg
|
||||
filter().type(Entity1_13Types.EntityType.TURTLE).cancel(16); // Travel pos
|
||||
filter().type(Entity1_13Types.EntityType.TURTLE).cancel(17); // Going home
|
||||
filter().type(Entity1_13Types.EntityType.TURTLE).cancel(18); // Traveling
|
||||
filter().type(EntityTypes1_13.EntityType.TURTLE).cancel(13); // Home pos
|
||||
filter().type(EntityTypes1_13.EntityType.TURTLE).cancel(14); // Has egg
|
||||
filter().type(EntityTypes1_13.EntityType.TURTLE).cancel(15); // Laying egg
|
||||
filter().type(EntityTypes1_13.EntityType.TURTLE).cancel(16); // Travel pos
|
||||
filter().type(EntityTypes1_13.EntityType.TURTLE).cancel(17); // Going home
|
||||
filter().type(EntityTypes1_13.EntityType.TURTLE).cancel(18); // Traveling
|
||||
|
||||
// Remove additional fish meta
|
||||
filter().filterFamily(Entity1_13Types.EntityType.ABSTRACT_FISHES).cancel(12);
|
||||
filter().filterFamily(Entity1_13Types.EntityType.ABSTRACT_FISHES).cancel(13);
|
||||
filter().type(EntityTypes1_13.EntityType.ABSTRACT_FISHES).cancel(12);
|
||||
filter().type(EntityTypes1_13.EntityType.ABSTRACT_FISHES).cancel(13);
|
||||
|
||||
// Remove phantom size
|
||||
filter().type(Entity1_13Types.EntityType.PHANTOM).cancel(12);
|
||||
filter().type(EntityTypes1_13.EntityType.PHANTOM).cancel(12);
|
||||
|
||||
// Remove boat splash timer
|
||||
filter().type(Entity1_13Types.EntityType.BOAT).cancel(12);
|
||||
filter().type(EntityTypes1_13.EntityType.BOAT).cancel(12);
|
||||
|
||||
// Remove Trident special loyalty level
|
||||
filter().type(Entity1_13Types.EntityType.TRIDENT).cancel(7);
|
||||
filter().type(EntityTypes1_13.EntityType.TRIDENT).cancel(7);
|
||||
|
||||
// Handle new wolf colors
|
||||
filter().type(Entity1_13Types.EntityType.WOLF).index(17).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_13.EntityType.WOLF).index(17).handler((event, meta) -> {
|
||||
meta.setValue(15 - (int) meta.getValue());
|
||||
});
|
||||
|
||||
// Rewrite AreaEffectCloud
|
||||
filter().type(Entity1_13Types.EntityType.AREA_EFFECT_CLOUD).index(9).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_13.EntityType.AREA_EFFECT_CLOUD).index(9).handler((event, meta) -> {
|
||||
Particle particle = (Particle) meta.getValue();
|
||||
|
||||
ParticleMapping.ParticleData data = ParticleMapping.getMapping(particle.getId());
|
||||
@@ -354,12 +358,12 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return Entity1_13Types.getTypeFromId(typeId, false);
|
||||
return EntityTypes1_13.getTypeFromId(typeId, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityType getObjectTypeFromId(final int typeId) {
|
||||
return Entity1_13Types.getTypeFromId(typeId, true);
|
||||
return EntityTypes1_13.getTypeFromId(typeId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+18
-23
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
@@ -61,12 +61,10 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
public void register() {
|
||||
handler(packetWrapper -> {
|
||||
packetWrapper.cancel();
|
||||
packetWrapper.create(0x02, new PacketHandler() { // Plugin response
|
||||
@Override
|
||||
public void handle(PacketWrapper newWrapper) throws Exception {
|
||||
newWrapper.write(Type.VAR_INT, packetWrapper.read(Type.VAR_INT)); // Packet id
|
||||
newWrapper.write(Type.BOOLEAN, false); // Success
|
||||
}
|
||||
// Plugin response
|
||||
packetWrapper.create(0x02, wrapper -> {
|
||||
wrapper.write(Type.VAR_INT, packetWrapper.read(Type.VAR_INT)); // Packet id
|
||||
wrapper.write(Type.BOOLEAN, false); // Success
|
||||
}).sendToServer(Protocol1_12_2To1_13.class);
|
||||
});
|
||||
}
|
||||
@@ -81,17 +79,17 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
//Input Item
|
||||
Item input = wrapper.read(Type.FLAT_ITEM);
|
||||
wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(input));
|
||||
Item input = wrapper.read(Type.ITEM1_13);
|
||||
wrapper.write(Type.ITEM1_8, protocol.getItemRewriter().handleItemToClient(input));
|
||||
//Output Item
|
||||
Item output = wrapper.read(Type.FLAT_ITEM);
|
||||
wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(output));
|
||||
Item output = wrapper.read(Type.ITEM1_13);
|
||||
wrapper.write(Type.ITEM1_8, protocol.getItemRewriter().handleItemToClient(output));
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); //Has second item
|
||||
if (secondItem) {
|
||||
//Second Item
|
||||
Item second = wrapper.read(Type.FLAT_ITEM);
|
||||
wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(second));
|
||||
Item second = wrapper.read(Type.ITEM1_13);
|
||||
wrapper.write(Type.ITEM1_8, protocol.getItemRewriter().handleItemToClient(second));
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); //Trade disabled
|
||||
@@ -319,10 +317,7 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
for (int i = 0; i < count; i++) {
|
||||
String match = wrapper.read(Type.STRING);
|
||||
wrapper.write(Type.STRING, (start == 0 && !storage.isLastAssumeCommand() ? "/" : "") + match);
|
||||
// Ignore tooltip
|
||||
if (wrapper.read(Type.BOOLEAN)) {
|
||||
wrapper.read(Type.STRING);
|
||||
}
|
||||
wrapper.read(Type.OPTIONAL_COMPONENT); // Remove tooltip
|
||||
}
|
||||
});
|
||||
|
||||
@@ -332,7 +327,7 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
|
||||
String command = wrapper.read(Type.STRING);
|
||||
boolean assumeCommand = wrapper.read(Type.BOOLEAN);
|
||||
wrapper.read(Type.OPTIONAL_POSITION);
|
||||
wrapper.read(Type.OPTIONAL_POSITION1_8);
|
||||
|
||||
if (!assumeCommand && !command.startsWith("/")) {
|
||||
// Complete usernames for non-commands
|
||||
@@ -382,8 +377,8 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
case "MC|BSign":
|
||||
case "MC|BEdit":
|
||||
wrapper.setPacketType(ServerboundPackets1_13.EDIT_BOOK);
|
||||
Item book = wrapper.read(Type.ITEM);
|
||||
wrapper.write(Type.FLAT_ITEM, protocol.getItemRewriter().handleItemToServer(book));
|
||||
Item book = wrapper.read(Type.ITEM1_8);
|
||||
wrapper.write(Type.ITEM1_13, protocol.getItemRewriter().handleItemToServer(book));
|
||||
boolean signing = channel.equals("MC|BSign");
|
||||
wrapper.write(Type.BOOLEAN, signing);
|
||||
break;
|
||||
@@ -395,7 +390,7 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
if (type == 0) {
|
||||
//Information from https://wiki.vg/index.php?title=Plugin_channels&oldid=14089
|
||||
//The Notchain client only uses this for command block minecarts and uses MC|AutoCmd for blocks, but the Notchian server still accepts it for either.
|
||||
//Maybe older versions used this and we need to implement this? The issues is that we would have to save the command block types
|
||||
//Maybe older versions used this and we need to implement this? The issue is that we would have to save the command block types
|
||||
wrapper.setPacketType(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK);
|
||||
wrapper.cancel();
|
||||
ViaBackwards.getPlatform().getLogger().warning("Client send MC|AdvCmd custom payload to update command block, weird!");
|
||||
@@ -416,7 +411,7 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
int y = wrapper.read(Type.INT);
|
||||
int z = wrapper.read(Type.INT);
|
||||
|
||||
wrapper.write(Type.POSITION, new Position(x, (short) y, z));
|
||||
wrapper.write(Type.POSITION1_8, new Position(x, (short) y, z));
|
||||
|
||||
wrapper.passthrough(Type.STRING); //Command
|
||||
|
||||
@@ -439,7 +434,7 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
int x = wrapper.read(Type.INT);
|
||||
int y = wrapper.read(Type.INT);
|
||||
int z = wrapper.read(Type.INT);
|
||||
wrapper.write(Type.POSITION, new Position(x, (short) y, z));
|
||||
wrapper.write(Type.POSITION1_8, new Position(x, (short) y, z));
|
||||
wrapper.write(Type.VAR_INT, wrapper.read(Type.BYTE) - 1);
|
||||
String mode = wrapper.read(Type.STRING);
|
||||
int modeId = mode.equals("SAVE") ? 0 : mode.equals("LOAD") ? 1 : mode.equals("CORNER") ? 2 : 3;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
-12
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,9 +29,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
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;
|
||||
|
||||
@@ -65,12 +63,12 @@ public class BackwardsBlockEntityProvider implements Provider {
|
||||
* @param tag The block entity tag
|
||||
*/
|
||||
public CompoundTag transform(UserConnection user, Position position, CompoundTag tag) throws Exception {
|
||||
final Tag idTag = tag.get("id");
|
||||
if (!(idTag instanceof StringTag)) {
|
||||
final StringTag idTag = tag.getStringTag("id");
|
||||
if (idTag == null) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
String id = (String) idTag.getValue();
|
||||
String id = idTag.getValue();
|
||||
BackwardsBlockEntityHandler handler = handlers.get(id);
|
||||
if (handler == null) {
|
||||
return tag;
|
||||
@@ -82,7 +80,7 @@ public class BackwardsBlockEntityProvider implements Provider {
|
||||
return tag;
|
||||
}
|
||||
|
||||
return handler.transform(user, blockId, tag);
|
||||
return handler.transform(blockId, tag);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,15 +92,17 @@ public class BackwardsBlockEntityProvider implements Provider {
|
||||
*/
|
||||
public CompoundTag transform(UserConnection user, Position position, String id) throws Exception {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.put("id", new StringTag(id));
|
||||
tag.put("x", new IntTag(Math.toIntExact(position.x())));
|
||||
tag.put("y", new IntTag(Math.toIntExact(position.y())));
|
||||
tag.put("z", new IntTag(Math.toIntExact(position.z())));
|
||||
tag.putString("id", id);
|
||||
tag.putInt("x", Math.toIntExact(position.x()));
|
||||
tag.putInt("y", Math.toIntExact(position.y()));
|
||||
tag.putInt("z", Math.toIntExact(position.z()));
|
||||
|
||||
return this.transform(user, position, tag);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface BackwardsBlockEntityHandler {
|
||||
CompoundTag transform(UserConnection user, int blockId, CompoundTag tag);
|
||||
|
||||
CompoundTag transform(int blockId, CompoundTag tag);
|
||||
}
|
||||
}
|
||||
+3
-6
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
@@ -24,6 +24,7 @@ import com.viaversion.viaversion.libs.fastutil.ints.IntOpenHashSet;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.IntSet;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class BackwardsBlockStorage implements StorableObject {
|
||||
// This BlockStorage is very exclusive (;
|
||||
@@ -77,11 +78,7 @@ public class BackwardsBlockStorage implements StorableObject {
|
||||
blocks.put(position, block);
|
||||
}
|
||||
|
||||
public boolean isWelcome(int block) {
|
||||
return WHITELIST.contains(block);
|
||||
}
|
||||
|
||||
public Integer get(Position position) {
|
||||
public @Nullable Integer get(Position position) {
|
||||
return blocks.get(position);
|
||||
}
|
||||
|
||||
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2024 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/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
|
||||
public class NoteBlockStorage implements StorableObject {
|
||||
|
||||
private static final int MAX_NOTE_ID = 24;
|
||||
|
||||
private final Object2IntMap<Position> noteBlockUpdates = new Object2IntOpenHashMap<>();
|
||||
|
||||
public void storeNoteBlockUpdate(final Position position, final int blockStateId) {
|
||||
noteBlockUpdates.put(position, blockStateId);
|
||||
}
|
||||
|
||||
public Pair<Integer, Integer> getNoteBlockUpdate(final Position position) {
|
||||
if (!noteBlockUpdates.containsKey(position)) {
|
||||
return null;
|
||||
}
|
||||
int relativeBlockState = noteBlockUpdates.removeInt(position) - 249;
|
||||
relativeBlockState = relativeBlockState / 2; // Get rid of powered state
|
||||
|
||||
return new Pair<>(relativeBlockState / MAX_NOTE_ID + 1, relativeBlockState % MAX_NOTE_ID + 1);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
noteBlockUpdates.clear();
|
||||
}
|
||||
|
||||
}
|
||||
+1
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,4 @@ package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage;
|
||||
import com.viaversion.viabackwards.api.entities.storage.PlayerPositionStorage;
|
||||
|
||||
public class PlayerPositionStorage1_13 extends PlayerPositionStorage {
|
||||
|
||||
public PlayerPositionStorage1_13() {
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
@@ -42,7 +42,7 @@ public class Protocol1_13_1To1_13_2 extends BackwardsProtocol<ClientboundPackets
|
||||
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM);
|
||||
map(Type.ITEM1_13, Type.ITEM1_13_2);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -61,8 +61,8 @@ public class Protocol1_13_1To1_13_2 extends BackwardsProtocol<ClientboundPackets
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.COMPONENT); // Title
|
||||
wrapper.passthrough(Type.COMPONENT); // Description
|
||||
Item icon = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||
wrapper.write(Type.FLAT_ITEM, icon);
|
||||
Item icon = wrapper.read(Type.ITEM1_13_2);
|
||||
wrapper.write(Type.ITEM1_13, icon);
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
|
||||
+15
-15
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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 {
|
||||
public void register() {
|
||||
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
|
||||
map(Type.ITEM1_13_2, Type.ITEM1_13); // 2 - Slot Value
|
||||
}
|
||||
});
|
||||
|
||||
@@ -39,7 +39,7 @@ public class InventoryPackets1_13_2 {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.FLAT_VAR_INT_ITEM_ARRAY, Type.FLAT_ITEM_ARRAY); // 1 - Window Values
|
||||
map(Type.ITEM1_13_2_SHORT_ARRAY, Type.ITEM1_13_SHORT_ARRAY); // 1 - Window Values
|
||||
}
|
||||
});
|
||||
|
||||
@@ -55,13 +55,13 @@ public class InventoryPackets1_13_2 {
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
// Input Item
|
||||
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM));
|
||||
wrapper.write(Type.ITEM1_13, wrapper.read(Type.ITEM1_13_2));
|
||||
// Output Item
|
||||
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM));
|
||||
wrapper.write(Type.ITEM1_13, wrapper.read(Type.ITEM1_13_2));
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||
if (secondItem) {
|
||||
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM));
|
||||
wrapper.write(Type.ITEM1_13, wrapper.read(Type.ITEM1_13_2));
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
@@ -78,7 +78,7 @@ public class InventoryPackets1_13_2 {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.VAR_INT); // 1 - Slot ID
|
||||
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 2 - Item
|
||||
map(Type.ITEM1_13_2, Type.ITEM1_13); // 2 - Item
|
||||
}
|
||||
});
|
||||
|
||||
@@ -91,22 +91,22 @@ public class InventoryPackets1_13_2 {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i1 = 0; i1 < ingredientsNo; i1++) {
|
||||
wrapper.write(Type.FLAT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT));
|
||||
wrapper.write(Type.ITEM1_13_ARRAY, wrapper.read(Type.ITEM1_13_2_ARRAY));
|
||||
}
|
||||
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM));
|
||||
wrapper.write(Type.ITEM1_13, wrapper.read(Type.ITEM1_13_2));
|
||||
} else if (type.equals("crafting_shaped")) {
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
for (int i1 = 0; i1 < ingredientsNo; i1++) {
|
||||
wrapper.write(Type.FLAT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT));
|
||||
wrapper.write(Type.ITEM1_13_ARRAY, wrapper.read(Type.ITEM1_13_2_ARRAY));
|
||||
}
|
||||
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM));
|
||||
wrapper.write(Type.ITEM1_13, wrapper.read(Type.ITEM1_13_2));
|
||||
} else if (type.equals("smelting")) {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
// Ingredient start
|
||||
wrapper.write(Type.FLAT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT));
|
||||
wrapper.write(Type.ITEM1_13_ARRAY, wrapper.read(Type.ITEM1_13_2_ARRAY));
|
||||
// Ingredient end
|
||||
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM));
|
||||
wrapper.write(Type.ITEM1_13, wrapper.read(Type.ITEM1_13_2));
|
||||
wrapper.passthrough(Type.FLOAT); // EXP
|
||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class InventoryPackets1_13_2 {
|
||||
map(Type.BYTE); // 2 - Button
|
||||
map(Type.SHORT); // 3 - Action number
|
||||
map(Type.VAR_INT); // 4 - Mode
|
||||
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 5 - Clicked Item
|
||||
map(Type.ITEM1_13, Type.ITEM1_13_2); // 5 - Clicked Item
|
||||
}
|
||||
});
|
||||
|
||||
@@ -129,7 +129,7 @@ public class InventoryPackets1_13_2 {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.SHORT); // 0 - Slot
|
||||
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 1 - Clicked Item
|
||||
map(Type.ITEM1_13, Type.ITEM1_13_2); // 1 - Clicked Item
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
@@ -42,7 +42,7 @@ public class WorldPackets1_13_2 {
|
||||
handler(wrapper -> {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
if (id == 27) {
|
||||
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM));
|
||||
wrapper.write(Type.ITEM1_13, wrapper.read(Type.ITEM1_13_2));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+10
-9
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
@@ -28,7 +28,8 @@ import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.packets.SoundPa
|
||||
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.minecraft.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
@@ -36,7 +37,7 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPacke
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
|
||||
public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_14, ClientboundPackets1_13, ServerboundPackets1_14, ServerboundPackets1_13> {
|
||||
@@ -44,7 +45,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);
|
||||
private final EntityPackets1_14 entityRewriter = new EntityPackets1_14(this);
|
||||
private final BlockItemPackets1_14 blockItemPackets = new BlockItemPackets1_14(this);
|
||||
private final TranslatableRewriter<ClientboundPackets1_14> translatableRewriter = new TranslatableRewriter<>(this);
|
||||
private final TranslatableRewriter<ClientboundPackets1_14> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
|
||||
|
||||
public Protocol1_13_2To1_14() {
|
||||
super(ClientboundPackets1_14.class, ClientboundPackets1_13.class, ServerboundPackets1_14.class, ServerboundPackets1_13.class);
|
||||
@@ -57,7 +58,7 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
translatableRewriter.registerBossBar(ClientboundPackets1_14.BOSSBAR);
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_14.CHAT_MESSAGE);
|
||||
translatableRewriter.registerCombatEvent(ClientboundPackets1_14.COMBAT_EVENT);
|
||||
translatableRewriter.registerDisconnect(ClientboundPackets1_14.DISCONNECT);
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_14.DISCONNECT);
|
||||
translatableRewriter.registerTabList(ClientboundPackets1_14.TAB_LIST);
|
||||
translatableRewriter.registerTitle(ClientboundPackets1_14.TITLE);
|
||||
translatableRewriter.registerPing();
|
||||
@@ -163,16 +164,16 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
user.put(new ClientWorld());
|
||||
}
|
||||
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_14Types.PLAYER));
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_14.PLAYER));
|
||||
|
||||
if (!user.has(ChunkLightStorage.class)) {
|
||||
user.put(new ChunkLightStorage(user));
|
||||
user.put(new ChunkLightStorage());
|
||||
}
|
||||
|
||||
user.put(new DifficultyStorage(user));
|
||||
user.put(new DifficultyStorage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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
|
||||
|
||||
+49
-48
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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.rewriters.EnchantmentRewriter;
|
||||
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;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.Environment;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
@@ -30,12 +31,14 @@ import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionLight;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionLightImpl;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_14;
|
||||
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;
|
||||
@@ -44,16 +47,14 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||
import com.viaversion.viaversion.rewriter.RecipeRewriter;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -63,12 +64,12 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
private EnchantmentRewriter enchantmentRewriter;
|
||||
|
||||
public BlockItemPackets1_14(Protocol1_13_2To1_14 protocol) {
|
||||
super(protocol);
|
||||
super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_SHORT_ARRAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerServerbound(ServerboundPackets1_13.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||
protocol.registerServerbound(ServerboundPackets1_13.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.ITEM1_13_2)));
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.OPEN_WINDOW, wrapper -> {
|
||||
int windowId = wrapper.read(Type.VAR_INT);
|
||||
@@ -146,7 +147,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
if (title.isJsonObject() && (object = title.getAsJsonObject()).has("translate")) {
|
||||
// Don't rewrite other 9x3 translatable containers
|
||||
if (type != 2 || object.getAsJsonPrimitive("translate").getAsString().equals("container.barrel")) {
|
||||
title = ChatRewriter.legacyTextToJson(containerTitle);
|
||||
title = ComponentUtil.legacyToJson(containerTitle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,12 +167,12 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
wrapper.passthrough(Type.INT); // Entity id
|
||||
});
|
||||
|
||||
BlockRewriter<ClientboundPackets1_14> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION);
|
||||
BlockRewriter<ClientboundPackets1_14> blockRewriter = BlockRewriter.legacy(protocol);
|
||||
|
||||
registerSetCooldown(ClientboundPackets1_14.COOLDOWN);
|
||||
registerWindowItems(ClientboundPackets1_14.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||
registerSetSlot(ClientboundPackets1_14.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||
registerAdvancements(ClientboundPackets1_14.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||
registerWindowItems(ClientboundPackets1_14.WINDOW_ITEMS);
|
||||
registerSetSlot(ClientboundPackets1_14.SET_SLOT);
|
||||
registerAdvancements(ClientboundPackets1_14.ADVANCEMENTS);
|
||||
|
||||
// Trade List -> Plugin Message
|
||||
protocol.registerClientbound(ClientboundPackets1_14.TRADE_LIST, ClientboundPackets1_13.PLUGIN_MESSAGE, wrapper -> {
|
||||
@@ -183,22 +184,22 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
// Input Item
|
||||
Item input = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||
Item input = wrapper.read(Type.ITEM1_13_2);
|
||||
input = handleItemToClient(input);
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, input);
|
||||
wrapper.write(Type.ITEM1_13_2, input);
|
||||
|
||||
|
||||
// Output Item
|
||||
Item output = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||
Item output = wrapper.read(Type.ITEM1_13_2);
|
||||
output = handleItemToClient(output);
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, output);
|
||||
wrapper.write(Type.ITEM1_13_2, output);
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||
if (secondItem) {
|
||||
// Second Item
|
||||
Item second = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||
Item second = wrapper.read(Type.ITEM1_13_2);
|
||||
second = handleItemToClient(second);
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, second);
|
||||
wrapper.write(Type.ITEM1_13_2, second);
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
@@ -225,21 +226,21 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.VAR_INT); // 1 - Slot ID
|
||||
map(Type.FLAT_VAR_INT_ITEM); // 2 - Item
|
||||
map(Type.ITEM1_13_2); // 2 - Item
|
||||
|
||||
handler(itemToClientHandler(Type.FLAT_VAR_INT_ITEM));
|
||||
handler(itemToClientHandler(Type.ITEM1_13_2));
|
||||
|
||||
handler(wrapper -> {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
EntityType entityType = wrapper.user().getEntityTracker(Protocol1_13_2To1_14.class).entityType(entityId);
|
||||
if (entityType == null) return;
|
||||
|
||||
if (entityType.isOrHasParent(Entity1_14Types.ABSTRACT_HORSE)) {
|
||||
if (entityType.isOrHasParent(EntityTypes1_14.ABSTRACT_HORSE)) {
|
||||
wrapper.setPacketType(ClientboundPackets1_13.ENTITY_METADATA);
|
||||
wrapper.resetReader();
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.read(Type.VAR_INT);
|
||||
Item item = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||
Item item = wrapper.read(Type.ITEM1_13_2);
|
||||
int armorType = item == null || item.identifier() == 0 ? 0 : item.identifier() - 726;
|
||||
if (armorType < 0 || armorType > 3) {
|
||||
wrapper.cancel();
|
||||
@@ -261,22 +262,22 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
for (int i = 0; i < size; i++) {
|
||||
String type = wrapper.read(Type.STRING);
|
||||
String id = wrapper.read(Type.STRING); // Recipe Identifier
|
||||
type = type.replace("minecraft:", "");
|
||||
type = Key.stripMinecraftNamespace(type);
|
||||
if (removedTypes.contains(type)) {
|
||||
switch (type) {
|
||||
case "blasting":
|
||||
case "smoking":
|
||||
case "campfire_cooking":
|
||||
wrapper.read(Type.STRING); // Group
|
||||
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||
wrapper.read(Type.ITEM1_13_2_ARRAY); // Ingredients
|
||||
wrapper.read(Type.ITEM1_13_2);
|
||||
wrapper.read(Type.FLOAT); // EXP
|
||||
wrapper.read(Type.VAR_INT); // Cooking time
|
||||
break;
|
||||
case "stonecutting":
|
||||
wrapper.read(Type.STRING); // Group?
|
||||
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
wrapper.read(Type.FLAT_VAR_INT_ITEM); // Result
|
||||
wrapper.read(Type.ITEM1_13_2_ARRAY); // Ingredients
|
||||
wrapper.read(Type.ITEM1_13_2); // Result
|
||||
break;
|
||||
}
|
||||
deleted++;
|
||||
@@ -292,14 +293,14 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
});
|
||||
|
||||
|
||||
registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW);
|
||||
registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.BLOCK_BREAK_ANIMATION, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.POSITION1_14, Type.POSITION);
|
||||
map(Type.POSITION1_14, Type.POSITION1_8);
|
||||
map(Type.BYTE);
|
||||
}
|
||||
});
|
||||
@@ -307,14 +308,14 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
protocol.registerClientbound(ClientboundPackets1_14.BLOCK_ENTITY_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.POSITION1_14, Type.POSITION);
|
||||
map(Type.POSITION1_14, Type.POSITION1_8);
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.BLOCK_ACTION, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.POSITION1_14, Type.POSITION); // Location
|
||||
map(Type.POSITION1_14, Type.POSITION1_8); // Location
|
||||
map(Type.UNSIGNED_BYTE); // Action id
|
||||
map(Type.UNSIGNED_BYTE); // Action param
|
||||
map(Type.VAR_INT); // Block id - /!\ NOT BLOCK STATE
|
||||
@@ -332,7 +333,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
protocol.registerClientbound(ClientboundPackets1_14.BLOCK_CHANGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.POSITION1_14, Type.POSITION);
|
||||
map(Type.POSITION1_14, Type.POSITION1_8);
|
||||
map(Type.VAR_INT);
|
||||
handler(wrapper -> {
|
||||
int id = wrapper.get(Type.VAR_INT, 0);
|
||||
@@ -366,8 +367,8 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.CHUNK_DATA, wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
Chunk chunk = wrapper.read(new Chunk1_14Type());
|
||||
wrapper.write(new Chunk1_13Type(clientWorld), chunk);
|
||||
Chunk chunk = wrapper.read(ChunkType1_14.TYPE);
|
||||
wrapper.write(ChunkType1_13.forEnvironment(clientWorld.getEnvironment()), chunk);
|
||||
|
||||
ChunkLightStorage.ChunkLight chunkLight = wrapper.user().get(ChunkLightStorage.class).getStoredLight(chunk.getX(), chunk.getZ());
|
||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||
@@ -382,10 +383,10 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
sectionLight.setSkyLight(ChunkLightStorage.FULL_LIGHT);
|
||||
}
|
||||
} else {
|
||||
byte[] blockLight = chunkLight.getBlockLight()[i];
|
||||
byte[] blockLight = chunkLight.blockLight()[i];
|
||||
sectionLight.setBlockLight(blockLight != null ? blockLight : ChunkLightStorage.FULL_LIGHT);
|
||||
if (clientWorld.getEnvironment() == Environment.NORMAL) {
|
||||
byte[] skyLight = chunkLight.getSkyLight()[i];
|
||||
byte[] skyLight = chunkLight.skyLight()[i];
|
||||
sectionLight.setSkyLight(skyLight != null ? skyLight : ChunkLightStorage.FULL_LIGHT);
|
||||
}
|
||||
}
|
||||
@@ -421,7 +422,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // Effect Id
|
||||
map(Type.POSITION1_14, Type.POSITION); // Location
|
||||
map(Type.POSITION1_14, Type.POSITION1_8); // Location
|
||||
map(Type.INT); // Data
|
||||
handler(wrapper -> {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
@@ -435,7 +436,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
}
|
||||
});
|
||||
|
||||
registerSpawnParticle(ClientboundPackets1_14.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.FLOAT);
|
||||
registerSpawnParticle(ClientboundPackets1_14.SPAWN_PARTICLE, Type.FLOAT);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.MAP_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
@@ -443,14 +444,14 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
map(Type.VAR_INT);
|
||||
map(Type.BYTE);
|
||||
map(Type.BOOLEAN);
|
||||
map(Type.BOOLEAN, Type.NOTHING); // Locked
|
||||
read(Type.BOOLEAN); // Locked
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_POSITION, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.POSITION1_14, Type.POSITION);
|
||||
map(Type.POSITION1_14, Type.POSITION1_8);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -471,8 +472,8 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
// Lore now uses JSON
|
||||
CompoundTag tag = item.tag();
|
||||
CompoundTag display;
|
||||
if (tag != null && (display = tag.get("display")) != null) {
|
||||
ListTag lore = display.get("Lore");
|
||||
if (tag != null && (display = tag.getCompoundTag("display")) != null) {
|
||||
ListTag lore = display.getListTag("Lore");
|
||||
if (lore != null) {
|
||||
saveListTag(display, lore, "Lore");
|
||||
|
||||
@@ -482,7 +483,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
StringTag loreEntryTag = (StringTag) loreEntry;
|
||||
String value = loreEntryTag.getValue();
|
||||
if (value != null && !value.isEmpty()) {
|
||||
loreEntryTag.setValue(ChatRewriter.jsonToLegacyText(value));
|
||||
loreEntryTag.setValue(ComponentUtil.jsonToLegacy(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -499,14 +500,14 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
// Lore now uses JSON
|
||||
CompoundTag tag = item.tag();
|
||||
CompoundTag display;
|
||||
if (tag != null && (display = tag.get("display")) != null) {
|
||||
if (tag != null && (display = tag.getCompoundTag("display")) != null) {
|
||||
// Transform to json if no backup tag is found (else process that in the super method)
|
||||
ListTag lore = display.get("Lore");
|
||||
ListTag lore = display.getListTag("Lore");
|
||||
if (lore != null && !hasBackupTag(display, "Lore")) {
|
||||
for (Tag loreEntry : lore) {
|
||||
if (loreEntry instanceof StringTag) {
|
||||
StringTag loreEntryTag = (StringTag) loreEntry;
|
||||
loreEntryTag.setValue(ChatRewriter.legacyTextToJsonString(loreEntryTag.getValue()));
|
||||
loreEntryTag.setValue(ComponentUtil.legacyToJsonString(loreEntryTag.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+61
-61
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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 +26,21 @@ import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLi
|
||||
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.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.api.minecraft.VillagerData;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import com.viaversion.viaversion.rewriter.meta.MetaHandler;
|
||||
|
||||
public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_14, Protocol1_13_2To1_14> {
|
||||
@@ -57,8 +57,8 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
super.addTrackedEntity(wrapper, entityId, type);
|
||||
|
||||
// Cache the position for every newly tracked entity
|
||||
if (type == Entity1_14Types.PAINTING) {
|
||||
final Position position = wrapper.get(Type.POSITION, 0);
|
||||
if (type == EntityTypes1_14.PAINTING) {
|
||||
final Position position = wrapper.get(Type.POSITION1_8, 0);
|
||||
positionHandler.cacheEntityPosition(wrapper, position.x(), position.y(), position.z(), true, false);
|
||||
} else if (wrapper.getId() != ClientboundPackets1_14.JOIN_GAME.getId()) { // ignore join game
|
||||
positionHandler.cacheEntityPosition(wrapper, true, false);
|
||||
@@ -77,14 +77,14 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
EntityTracker tracker = tracker(wrapper.user());
|
||||
EntityType entityType = tracker.entityType(entityId);
|
||||
if (entityType != Entity1_14Types.PLAYER) return;
|
||||
if (entityType != EntityTypes1_14.PLAYER) return;
|
||||
|
||||
// Remove equipment, else the client will see ghost items
|
||||
for (int i = 0; i <= 5; i++) {
|
||||
PacketWrapper equipmentPacket = wrapper.create(ClientboundPackets1_13.ENTITY_EQUIPMENT);
|
||||
equipmentPacket.write(Type.VAR_INT, entityId);
|
||||
equipmentPacket.write(Type.VAR_INT, i);
|
||||
equipmentPacket.write(Type.FLAT_VAR_INT_ITEM, null);
|
||||
equipmentPacket.write(Type.ITEM1_13_2, null);
|
||||
equipmentPacket.send(Protocol1_13_2To1_14.class);
|
||||
}
|
||||
});
|
||||
@@ -139,10 +139,10 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
handler(wrapper -> {
|
||||
int id = wrapper.get(Type.BYTE, 0);
|
||||
int mappedId = newEntityId(id);
|
||||
Entity1_13Types.EntityType entityType = Entity1_13Types.getTypeFromId(mappedId, false);
|
||||
Entity1_13Types.ObjectType objectType;
|
||||
if (entityType.isOrHasParent(Entity1_13Types.EntityType.MINECART_ABSTRACT)) {
|
||||
objectType = Entity1_13Types.ObjectType.MINECART;
|
||||
EntityTypes1_13.EntityType entityType = EntityTypes1_13.getTypeFromId(mappedId, false);
|
||||
EntityTypes1_13.ObjectType objectType;
|
||||
if (entityType.isOrHasParent(EntityTypes1_13.EntityType.MINECART_ABSTRACT)) {
|
||||
objectType = EntityTypes1_13.ObjectType.MINECART;
|
||||
int data = 0;
|
||||
switch (entityType) {
|
||||
case CHEST_MINECART:
|
||||
@@ -167,7 +167,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
if (data != 0)
|
||||
wrapper.set(Type.INT, 0, data);
|
||||
} else {
|
||||
objectType = Entity1_13Types.ObjectType.fromEntityType(entityType).orElse(null);
|
||||
objectType = EntityTypes1_13.ObjectType.fromEntityType(entityType).orElse(null);
|
||||
}
|
||||
|
||||
if (objectType == null) return;
|
||||
@@ -175,11 +175,11 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
wrapper.set(Type.BYTE, 0, (byte) objectType.getId());
|
||||
|
||||
int data = wrapper.get(Type.INT, 0);
|
||||
if (objectType == Entity1_13Types.ObjectType.FALLING_BLOCK) {
|
||||
if (objectType == EntityTypes1_13.ObjectType.FALLING_BLOCK) {
|
||||
int blockState = wrapper.get(Type.INT, 0);
|
||||
int combined = protocol.getMappingData().getNewBlockStateId(blockState);
|
||||
wrapper.set(Type.INT, 0, combined);
|
||||
} else if (entityType.isOrHasParent(Entity1_13Types.EntityType.ABSTRACT_ARROW)) {
|
||||
} else if (entityType.isOrHasParent(EntityTypes1_13.EntityType.ABSTRACT_ARROW)) {
|
||||
wrapper.set(Type.INT, 0, data + 1);
|
||||
}
|
||||
});
|
||||
@@ -205,7 +205,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
handler(wrapper -> {
|
||||
int type = wrapper.get(Type.VAR_INT, 1);
|
||||
EntityType entityType = Entity1_14Types.getTypeFromId(type);
|
||||
EntityType entityType = EntityTypes1_14.getTypeFromId(type);
|
||||
addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), entityType);
|
||||
|
||||
int oldId = newEntityId(type);
|
||||
@@ -234,7 +234,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
map(Type.DOUBLE); // Needs to be mapped for the position cache
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
handler(wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), Entity1_14Types.EXPERIENCE_ORB));
|
||||
handler(wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), EntityTypes1_14.EXPERIENCE_ORB));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -246,7 +246,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
map(Type.DOUBLE); // Needs to be mapped for the position cache
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
handler(wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), Entity1_14Types.LIGHTNING_BOLT));
|
||||
handler(wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), EntityTypes1_14.LIGHTNING_BOLT));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -256,11 +256,11 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
map(Type.VAR_INT);
|
||||
map(Type.UUID);
|
||||
map(Type.VAR_INT);
|
||||
map(Type.POSITION1_14, Type.POSITION);
|
||||
map(Type.POSITION1_14, Type.POSITION1_8);
|
||||
map(Type.BYTE);
|
||||
|
||||
// Track entity
|
||||
handler(wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), Entity1_14Types.PAINTING));
|
||||
handler(wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), EntityTypes1_14.PAINTING));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -276,7 +276,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Types1_14.METADATA_LIST, Types1_13_2.METADATA_LIST); // 7 - Metadata
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_13_2.METADATA_LIST, Entity1_14Types.PLAYER));
|
||||
handler(getTrackerAndMetaHandler(Types1_13_2.METADATA_LIST, EntityTypes1_14.PLAYER));
|
||||
handler(wrapper -> positionHandler.cacheEntityPosition(wrapper, true, false));
|
||||
}
|
||||
});
|
||||
@@ -291,7 +291,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
|
||||
handler(getTrackerHandler(Entity1_14Types.PLAYER, Type.INT));
|
||||
handler(getTrackerHandler(EntityTypes1_14.PLAYER, Type.INT));
|
||||
handler(getDimensionHandler(1));
|
||||
handler(wrapper -> {
|
||||
short difficulty = wrapper.user().get(DifficultyStorage.class).getDifficulty();
|
||||
@@ -331,15 +331,15 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
mapTypes(Entity1_14Types.values(), Entity1_13Types.EntityType.class);
|
||||
mapTypes(EntityTypes1_14.values(), EntityTypes1_13.EntityType.class);
|
||||
|
||||
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();
|
||||
mapEntityTypeWithData(EntityTypes1_14.CAT, EntityTypes1_14.OCELOT).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_14.TRADER_LLAMA, EntityTypes1_14.LLAMA).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_14.FOX, EntityTypes1_14.WOLF).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_14.PANDA, EntityTypes1_14.POLAR_BEAR).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_14.PILLAGER, EntityTypes1_14.VILLAGER).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_14.WANDERING_TRADER, EntityTypes1_14.VILLAGER).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_14.RAVAGER, EntityTypes1_14.COW).jsonName();
|
||||
|
||||
filter().handler((event, meta) -> {
|
||||
int typeId = meta.metaType().typeId();
|
||||
@@ -349,30 +349,30 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
});
|
||||
|
||||
registerMetaTypeHandler(Types1_13_2.META_TYPES.itemType, Types1_13_2.META_TYPES.blockStateType, null, null,
|
||||
Types1_13_2.META_TYPES.componentType, Types1_13_2.META_TYPES.optionalComponentType);
|
||||
Types1_13_2.META_TYPES.componentType, Types1_13_2.META_TYPES.optionalComponentType);
|
||||
|
||||
filter().type(Entity1_14Types.PILLAGER).cancel(15);
|
||||
filter().type(EntityTypes1_14.PILLAGER).cancel(15);
|
||||
|
||||
filter().type(Entity1_14Types.FOX).cancel(15);
|
||||
filter().type(Entity1_14Types.FOX).cancel(16);
|
||||
filter().type(Entity1_14Types.FOX).cancel(17);
|
||||
filter().type(Entity1_14Types.FOX).cancel(18);
|
||||
filter().type(EntityTypes1_14.FOX).cancel(15);
|
||||
filter().type(EntityTypes1_14.FOX).cancel(16);
|
||||
filter().type(EntityTypes1_14.FOX).cancel(17);
|
||||
filter().type(EntityTypes1_14.FOX).cancel(18);
|
||||
|
||||
filter().type(Entity1_14Types.PANDA).cancel(15);
|
||||
filter().type(Entity1_14Types.PANDA).cancel(16);
|
||||
filter().type(Entity1_14Types.PANDA).cancel(17);
|
||||
filter().type(Entity1_14Types.PANDA).cancel(18);
|
||||
filter().type(Entity1_14Types.PANDA).cancel(19);
|
||||
filter().type(Entity1_14Types.PANDA).cancel(20);
|
||||
filter().type(EntityTypes1_14.PANDA).cancel(15);
|
||||
filter().type(EntityTypes1_14.PANDA).cancel(16);
|
||||
filter().type(EntityTypes1_14.PANDA).cancel(17);
|
||||
filter().type(EntityTypes1_14.PANDA).cancel(18);
|
||||
filter().type(EntityTypes1_14.PANDA).cancel(19);
|
||||
filter().type(EntityTypes1_14.PANDA).cancel(20);
|
||||
|
||||
filter().type(Entity1_14Types.CAT).cancel(18);
|
||||
filter().type(Entity1_14Types.CAT).cancel(19);
|
||||
filter().type(Entity1_14Types.CAT).cancel(20);
|
||||
filter().type(EntityTypes1_14.CAT).cancel(18);
|
||||
filter().type(EntityTypes1_14.CAT).cancel(19);
|
||||
filter().type(EntityTypes1_14.CAT).cancel(20);
|
||||
|
||||
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) {
|
||||
if (type.isOrHasParent(EntityTypes1_14.ABSTRACT_ILLAGER_BASE) || type == EntityTypes1_14.RAVAGER || type == EntityTypes1_14.WITCH) {
|
||||
int index = event.index();
|
||||
if (index == 14) {
|
||||
event.cancel();
|
||||
@@ -382,11 +382,11 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
filter().type(Entity1_14Types.AREA_EFFECT_CLOUD).index(10).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_14.AREA_EFFECT_CLOUD).index(10).handler((event, meta) -> {
|
||||
rewriteParticle((Particle) meta.getValue());
|
||||
});
|
||||
|
||||
filter().type(Entity1_14Types.FIREWORK_ROCKET).index(8).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_14.FIREWORK_ROCKET).index(8).handler((event, meta) -> {
|
||||
meta.setMetaType(Types1_13_2.META_TYPES.varIntType);
|
||||
Integer value = (Integer) meta.getValue();
|
||||
if (value == null) {
|
||||
@@ -394,9 +394,9 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
filter().filterFamily(Entity1_14Types.ABSTRACT_ARROW).removeIndex(9);
|
||||
filter().type(EntityTypes1_14.ABSTRACT_ARROW).removeIndex(9);
|
||||
|
||||
filter().type(Entity1_14Types.VILLAGER).cancel(15); // Head shake timer
|
||||
filter().type(EntityTypes1_14.VILLAGER).cancel(15); // Head shake timer
|
||||
|
||||
MetaHandler villagerDataHandler = (event, meta) -> {
|
||||
VillagerData villagerData = (VillagerData) meta.getValue();
|
||||
@@ -406,27 +406,27 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
};
|
||||
|
||||
filter().type(Entity1_14Types.ZOMBIE_VILLAGER).index(18).handler(villagerDataHandler);
|
||||
filter().type(Entity1_14Types.VILLAGER).index(16).handler(villagerDataHandler);
|
||||
filter().type(EntityTypes1_14.ZOMBIE_VILLAGER).index(18).handler(villagerDataHandler);
|
||||
filter().type(EntityTypes1_14.VILLAGER).index(16).handler(villagerDataHandler);
|
||||
|
||||
// Holding arms up - from bitfield into own boolean
|
||||
filter().filterFamily(Entity1_14Types.ABSTRACT_SKELETON).index(13).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_14.ABSTRACT_SKELETON).index(13).handler((event, meta) -> {
|
||||
byte value = (byte) meta.getValue();
|
||||
if ((value & 4) != 0) {
|
||||
event.createExtraMeta(new Metadata(14, Types1_13_2.META_TYPES.booleanType, true));
|
||||
}
|
||||
});
|
||||
filter().filterFamily(Entity1_14Types.ZOMBIE).index(13).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_14.ZOMBIE).index(13).handler((event, meta) -> {
|
||||
byte value = (byte) meta.getValue();
|
||||
if ((value & 4) != 0) {
|
||||
event.createExtraMeta(new Metadata(16, Types1_13_2.META_TYPES.booleanType, true));
|
||||
}
|
||||
});
|
||||
|
||||
filter().filterFamily(Entity1_14Types.ZOMBIE).addIndex(16);
|
||||
filter().type(EntityTypes1_14.ZOMBIE).addIndex(16);
|
||||
|
||||
// Remove bed location
|
||||
filter().filterFamily(Entity1_14Types.LIVINGENTITY).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_14.LIVINGENTITY).handler((event, meta) -> {
|
||||
int index = event.index();
|
||||
if (index == 12) {
|
||||
Position position = (Position) meta.getValue();
|
||||
@@ -434,7 +434,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
// Use bed
|
||||
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_13.USE_BED, null, event.user());
|
||||
wrapper.write(Type.VAR_INT, event.entityId());
|
||||
wrapper.write(Type.POSITION, position);
|
||||
wrapper.write(Type.POSITION1_8, position);
|
||||
|
||||
try {
|
||||
wrapper.scheduleSend(Protocol1_13_2To1_14.class);
|
||||
@@ -452,12 +452,12 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
// Pose
|
||||
filter().removeIndex(6);
|
||||
|
||||
filter().type(Entity1_14Types.OCELOT).index(13).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_14.OCELOT).index(13).handler((event, meta) -> {
|
||||
event.setIndex(15);
|
||||
meta.setTypeAndValue(Types1_13_2.META_TYPES.varIntType, 0);
|
||||
});
|
||||
|
||||
filter().type(Entity1_14Types.CAT).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_14.CAT).handler((event, meta) -> {
|
||||
if (event.index() == 15) {
|
||||
meta.setValue(1);
|
||||
} else if (event.index() == 13) {
|
||||
@@ -501,6 +501,6 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return Entity1_14Types.getTypeFromId(typeId);
|
||||
return EntityTypes1_14.getTypeFromId(typeId);
|
||||
}
|
||||
}
|
||||
+9
-9
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 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,7 +38,7 @@ public class PlayerPackets1_14 extends RewriterBase<Protocol1_13_2To1_14> {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
map(Type.BOOLEAN, Type.NOTHING); // Locked
|
||||
read(Type.BOOLEAN); // Locked
|
||||
handler(wrapper -> {
|
||||
byte difficulty = wrapper.get(Type.UNSIGNED_BYTE, 0).byteValue();
|
||||
wrapper.user().get(DifficultyStorage.class).setDifficulty(difficulty);
|
||||
@@ -49,21 +49,21 @@ public class PlayerPackets1_14 extends RewriterBase<Protocol1_13_2To1_14> {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.OPEN_SIGN_EDITOR, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.POSITION1_14, Type.POSITION);
|
||||
map(Type.POSITION1_14, Type.POSITION1_8);
|
||||
}
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_13.QUERY_BLOCK_NBT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.POSITION, Type.POSITION1_14);
|
||||
map(Type.POSITION1_8, Type.POSITION1_14);
|
||||
}
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_13.PLAYER_DIGGING, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Action
|
||||
map(Type.POSITION, Type.POSITION1_14); // Position
|
||||
map(Type.POSITION1_8, Type.POSITION1_14); // Position
|
||||
}
|
||||
});
|
||||
|
||||
@@ -94,24 +94,24 @@ public class PlayerPackets1_14 extends RewriterBase<Protocol1_13_2To1_14> {
|
||||
protocol.registerServerbound(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.POSITION, Type.POSITION1_14);
|
||||
map(Type.POSITION1_8, Type.POSITION1_14);
|
||||
}
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_13.UPDATE_STRUCTURE_BLOCK, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.POSITION, Type.POSITION1_14);
|
||||
map(Type.POSITION1_8, Type.POSITION1_14);
|
||||
}
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_13.UPDATE_SIGN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.POSITION, Type.POSITION1_14);
|
||||
map(Type.POSITION1_8, Type.POSITION1_14);
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_13.PLAYER_BLOCK_PLACEMENT, wrapper -> {
|
||||
Position position = wrapper.read(Type.POSITION);
|
||||
Position position = wrapper.read(Type.POSITION1_8);
|
||||
int face = wrapper.read(Type.VAR_INT);
|
||||
int hand = wrapper.read(Type.VAR_INT);
|
||||
float x = wrapper.read(Type.FLOAT);
|
||||
|
||||
Loaded 100 of 226 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user