mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-14 19:15:08 -05:00
Replaced 1.20.3 -> 1.20.2 component converter of ViaVersion
This commit is contained in:
parent
702ed7235f
commit
4d39a0441a
2 changed files with 54 additions and 3 deletions
|
@ -56,7 +56,7 @@ dependencies {
|
|||
include "com.viaversion:viaversion-common:4.9.2"
|
||||
include "com.viaversion:viabackwards-common:4.9.2-20231208.084014-2"
|
||||
include "com.viaversion:viarewind-common:3.0.5"
|
||||
include("net.raphimc:ViaLegacy:2.2.21") {
|
||||
include("net.raphimc:ViaLegacy:2.2.22-SNAPSHOT") {
|
||||
exclude group: "net.lenni0451.mcstructs", module: "text"
|
||||
}
|
||||
include "net.raphimc:ViaAprilFools:2.0.10"
|
||||
|
@ -88,10 +88,10 @@ dependencies {
|
|||
include("net.lenni0451:MCPing:1.3.0") {
|
||||
exclude group: "com.google.code.gson", module: "gson"
|
||||
}
|
||||
include("net.raphimc.netminecraft:all:2.3.7") {
|
||||
include("net.raphimc.netminecraft:all:2.3.8-SNAPSHOT") {
|
||||
exclude group: "com.google.code.gson", module: "gson"
|
||||
}
|
||||
include("net.raphimc:MinecraftAuth:3.0.0") {
|
||||
include("net.raphimc:MinecraftAuth:3.0.1-SNAPSHOT") {
|
||||
exclude group: "com.google.code.gson", module: "gson"
|
||||
exclude group: "org.slf4j", module: "slf4j-api"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* This file is part of ViaProxy - https://github.com/RaphiMC/ViaProxy
|
||||
* Copyright (C) 2023 RK_01/RaphiMC 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 net.raphimc.viaproxy.injection.mixins;
|
||||
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonNull;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.Protocol1_20_3To1_20_2;
|
||||
import net.lenni0451.mcstructs.text.ATextComponent;
|
||||
import net.lenni0451.mcstructs.text.serializer.TextComponentCodec;
|
||||
import net.lenni0451.mcstructs.text.serializer.TextComponentSerializer;
|
||||
import net.raphimc.vialegacy.api.util.converter.JsonConverter;
|
||||
import net.raphimc.vialegacy.api.util.converter.NbtConverter;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
|
||||
@Mixin(Protocol1_20_3To1_20_2.class)
|
||||
public abstract class MixinProtocol1_20_3To1_20_2 {
|
||||
|
||||
@Overwrite
|
||||
public static JsonElement tagComponentToJson(final Tag tag) {
|
||||
final ATextComponent textComponent = TextComponentCodec.V1_20_3.deserializeNbtTree(NbtConverter.viaToMcStructs(tag));
|
||||
if (textComponent == null) return JsonNull.INSTANCE;
|
||||
|
||||
return JsonConverter.gsonToVia(TextComponentSerializer.V1_19_4.serializeJson(textComponent));
|
||||
}
|
||||
|
||||
@Overwrite
|
||||
public static Tag jsonComponentToTag(final JsonElement component) {
|
||||
final ATextComponent textComponent = TextComponentSerializer.V1_19_4.deserialize(JsonConverter.viaToGson(component));
|
||||
if (textComponent == null) return null;
|
||||
|
||||
return NbtConverter.mcStructsToVia(TextComponentCodec.V1_20_3.serializeNbt(textComponent));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue