diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinSwordItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinSwordItem.java index 6dca780a..e9c60690 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinSwordItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinSwordItem.java @@ -23,9 +23,7 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import net.minecraft.item.SwordItem; -import net.minecraft.item.consume.UseAction; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.world.World; @@ -49,13 +47,4 @@ public abstract class MixinSwordItem extends Item { } } - @Override - public UseAction getUseAction(ItemStack stack) { - if (ProtocolTranslator.getTargetVersion().betweenInclusive(LegacyProtocolVersion.b1_8tob1_8_1, ProtocolVersion.v1_8)) { - return UseAction.BLOCK; - } else { - return super.getUseAction(stack); - } - } - } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinBlockItemPacketRewriter1_21_2.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinBlockItemPacketRewriter1_21_2.java new file mode 100644 index 00000000..edf01ff1 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinBlockItemPacketRewriter1_21_2.java @@ -0,0 +1,41 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus + * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC + * Copyright (C) 2023-2024 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 de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion; + +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); + } + } + +} diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json index 72c54912..86557e71 100644 --- a/src/main/resources/viafabricplus.mixins.json +++ b/src/main/resources/viafabricplus.mixins.json @@ -142,6 +142,7 @@ "fixes.minecraft.item.MixinItemRenderer", "fixes.minecraft.item.MixinItemStack", "fixes.minecraft.item.MixinKnowledgeBookItem", + "fixes.minecraft.item.MixinLeadItem", "fixes.minecraft.item.MixinShovelItem", "fixes.minecraft.item.MixinSwordItem", "fixes.minecraft.network.MixinChatMessageC2SPacket", @@ -184,6 +185,7 @@ "fixes.vialegacy.MixinProtocolc0_30cpeToc0_28_30", "fixes.vialegacy.MixinProtocolr1_7_6_10Tor1_8", "fixes.viaversion.MixinBlockItemPacketRewriter1_20_5", + "fixes.viaversion.MixinBlockItemPacketRewriter1_21_2", "fixes.viaversion.MixinCommandBlockProvider", "fixes.viaversion.MixinCommonBoss", "fixes.viaversion.MixinEntityPacketRewriter1_12", @@ -212,8 +214,7 @@ "fixes.viaversion.MixinWorldPacketRewriter1_19", "viabedrock.MixinJoinPackets", "vialegacy.MixinExtensionProtocolMetadataStorage", - "vialegacy.MixinViaLegacyConfig", - "fixes.minecraft.item.MixinLeadItem" + "vialegacy.MixinViaLegacyConfig" ], "injectors": { "defaultRequire": 1