Skip to content

Commit

Permalink
Simplified item interaction fix
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Nov 12, 2023
1 parent 740a439 commit 18b4340
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 126 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;

import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Equipment;
import net.minecraft.item.ItemStack;
import net.raphimc.vialoader.util.VersionEnum;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -28,6 +30,23 @@
@Mixin(Equipment.class)
public interface MixinEquipment {

@Redirect(method = "equipAndSwap", at = @At(value = "INVOKE", target = "Lnet/minecraft/enchantment/EnchantmentHelper;hasBindingCurse(Lnet/minecraft/item/ItemStack;)Z"))
default boolean removeBindingCurseCondition(ItemStack stack) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
return false;
}
return EnchantmentHelper.hasBindingCurse(stack);
}

@Redirect(method = "equipAndSwap", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;areEqual(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Z"))
default boolean simplifyCondition(ItemStack left, ItemStack right) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
return !right.isEmpty();
}

return ItemStack.areEqual(left, right);
}

@Redirect(method = "equipAndSwap", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isCreative()Z"))
default boolean removeCreativeCondition(PlayerEntity instance) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/viafabricplus.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,9 @@
"fixes.minecraft.input.MixinKeyboard",
"fixes.minecraft.input.MixinKeyboardInput",
"fixes.minecraft.input.MixinMouse",
"fixes.minecraft.item.MixinArmorItem",
"fixes.minecraft.item.MixinAxeItem",
"fixes.minecraft.item.MixinBlockItem",
"fixes.minecraft.item.MixinBrushItem",
"fixes.minecraft.item.MixinElytraItem",
"fixes.minecraft.item.MixinEnderPearlItem",
"fixes.minecraft.item.MixinEquipment",
"fixes.minecraft.item.MixinFireworkRocketItem",
Expand Down

0 comments on commit 18b4340

Please sign in to comment.