From c67fbec533b524a7f67c1477ce13da998beaf4e8 Mon Sep 17 00:00:00 2001 From: wdog5 Date: Tue, 15 Oct 2024 21:17:26 +0800 Subject: [PATCH] Fix interactions --- .../server/level/MixinServerPlayerGameMode.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/banner-server/src/main/java/com/mohistmc/banner/mixin/server/level/MixinServerPlayerGameMode.java b/banner-server/src/main/java/com/mohistmc/banner/mixin/server/level/MixinServerPlayerGameMode.java index d0f03f155..9783a1191 100644 --- a/banner-server/src/main/java/com/mohistmc/banner/mixin/server/level/MixinServerPlayerGameMode.java +++ b/banner-server/src/main/java/com/mohistmc/banner/mixin/server/level/MixinServerPlayerGameMode.java @@ -19,6 +19,7 @@ import net.minecraft.server.players.PlayerList; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.player.Player; @@ -431,10 +432,18 @@ public InteractionResult useItemOn(ServerPlayer player, Level level, ItemStack s boolean bl2 = player.isSecondaryUseActive() && bl; ItemStack itemStack = stack.copy(); if (!bl2) { - enuminteractionresult = blockState.useWithoutItem(level, player, hitResult); - if (enuminteractionresult.consumesAction()) { + ItemInteractionResult result = blockState.useItemOn(player.getItemInHand(hand), level, player, hand, hitResult); + if (result.consumesAction()) { CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger(player, blockPos, itemStack); - return enuminteractionresult; + return result.result(); + } + + if (result == ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION && hand == InteractionHand.MAIN_HAND) { + enuminteractionresult = blockState.useWithoutItem(level, player, hitResult); + if (enuminteractionresult.consumesAction()) { + CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger(player, blockPos, itemStack); + return enuminteractionresult; + } } }