Skip to content

Commit

Permalink
Fix interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
wdog5734 committed Oct 15, 2024
1 parent 329ec04 commit c67fbec
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit c67fbec

Please sign in to comment.