From 7e7fd0d8e20fc5502993d2e4c75796db1e33c65f Mon Sep 17 00:00:00 2001 From: Mrbysco Date: Sun, 28 Apr 2024 22:07:31 +0200 Subject: [PATCH] Fix the block placing drill upgrade --- .../actuallyadditions/mod/items/DrillItem.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/DrillItem.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/DrillItem.java index c9bf7c02e..c8340d2ef 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/DrillItem.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/DrillItem.java @@ -111,6 +111,7 @@ public class DrillItem extends ItemEnergy { @Nonnull @Override public InteractionResult useOn(UseOnContext context) { + Level level = context.getLevel(); Player player = context.getPlayer(); InteractionHand hand = context.getHand(); @@ -121,16 +122,17 @@ public class DrillItem extends ItemEnergy { if (slot >= 0 && slot < 9) { // TODO: validate... old = PlayerInventory.getHotbarSize(); new = 9 ItemStack equip = player.getInventory().getItem(slot); if (!equip.isEmpty() && equip != stack) { - ItemStack toPlaceStack = equip.copy(); + ItemStack toPlaceStack = equip; - WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, toPlaceStack); +// WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, toPlaceStack); //tryPlaceItemIntoWorld could throw an Exception try { //Places the Block into the World - if (toPlaceStack.useOn(context) != InteractionResult.FAIL) { + BlockHitResult result = new BlockHitResult(context.getClickLocation(), context.getClickedFace(), context.getClickedPos(), context.isInside()); + if (toPlaceStack.useOn(new UseOnContext(level, player, hand, toPlaceStack, result)) != InteractionResult.FAIL) { if (!player.isCreative()) { - WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, toPlaceStack.copy()); +// WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, toPlaceStack.copy()); } } } @@ -139,8 +141,8 @@ public class DrillItem extends ItemEnergy { ActuallyAdditions.LOGGER.error("Player " + player.getName() + " who should place a Block using a Drill at " + player.getX() + ", " + player.getY() + ", " + player.getZ() + " in World " + context.getLevel().dimension() + " threw an Exception! Don't let that happen again!"); } - player.getInventory().setItem(slot, player.getItemInHand(hand)); - WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, stack); +// player.getInventory().setItem(slot, player.getItemInHand(hand)); +// WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, stack); return InteractionResult.SUCCESS; }