From 34fc6c2eaacf4c03b3f6b0ae0743df0477906142 Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Wed, 30 Oct 2024 20:55:50 +0100 Subject: [PATCH] Fixed sword blocking fix version range --- .../MixinBlockItemPacketRewriter1_21_2.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/java/net/raphimc/viaproxy/injection/mixins/MixinBlockItemPacketRewriter1_21_2.java diff --git a/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinBlockItemPacketRewriter1_21_2.java b/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinBlockItemPacketRewriter1_21_2.java new file mode 100644 index 0000000..f4e988b --- /dev/null +++ b/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinBlockItemPacketRewriter1_21_2.java @@ -0,0 +1,39 @@ +/* + * This file is part of ViaProxy - https://github.com/RaphiMC/ViaProxy + * Copyright (C) 2021-2024 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 . + */ +package net.raphimc.viaproxy.injection.mixins; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import com.viaversion.viaversion.protocols.v1_21to1_21_2.rewriter.BlockItemPacketRewriter1_21_2; +import net.raphimc.vialegacy.api.LegacyProtocolVersion; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(value = BlockItemPacketRewriter1_21_2.class, remap = false) +public abstract class MixinBlockItemPacketRewriter1_21_2 { + + @Redirect(method = "appendItemDataFixComponents", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;olderThanOrEqualTo(Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;)Z")) + private boolean changeSwordFixVersionRange(ProtocolVersion instance, ProtocolVersion other) { + if (other == ProtocolVersion.v1_8) { + return instance.betweenInclusive(LegacyProtocolVersion.b1_8tob1_8_1, ProtocolVersion.v1_8); + } else { + return instance.olderThanOrEqualTo(other); + } + } + +}