-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main'
- Loading branch information
Showing
7 changed files
with
123 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...rianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinProtocol1_20_2To1_20.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus | ||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD | ||
* 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 de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion; | ||
|
||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; | ||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.Protocol1_20_2To1_20; | ||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2; | ||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(value = Protocol1_20_2To1_20.class, remap = false) | ||
public abstract class MixinProtocol1_20_2To1_20 { | ||
|
||
@Inject(method = "lambda$queueServerboundPacket$11", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/packet/PacketWrapper;setPacketType(Lcom/viaversion/viaversion/api/protocol/packet/PacketType;)V", shift = At.Shift.AFTER), cancellable = true) | ||
private static void dontQueueConfigPackets(ServerboundPackets1_20_2 packetType, PacketWrapper wrapper, CallbackInfo ci) { | ||
if (!DebugSettings.global().queueConfigPackets.getValue()) { | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
...anmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinProtocol1_20_3To1_20_2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus | ||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD | ||
* 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 de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion; | ||
|
||
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(value = Protocol1_20_3To1_20_2.class, remap = false) | ||
public abstract class MixinProtocol1_20_3To1_20_2 { | ||
|
||
/** | ||
* @author RK_01 | ||
* @reason Replace code with a proper conversion | ||
*/ | ||
@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)); | ||
} | ||
|
||
/** | ||
* @author RK_01 | ||
* @reason Replace code with a proper conversion | ||
*/ | ||
@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)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters