From 9bd1fa63ea4aa12ab6fca2ce860547bb1177d108 Mon Sep 17 00:00:00 2001 From: Mrbysco Date: Sun, 28 Apr 2024 22:12:22 +0200 Subject: [PATCH] Reduce drill placement code size --- .../mod/items/DrillItem.java | 24 +++---------------- 1 file changed, 3 insertions(+), 21 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 f87d8fea7..0499be6fb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/DrillItem.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/DrillItem.java @@ -124,27 +124,9 @@ public class DrillItem extends ItemEnergy { if (!equip.isEmpty() && equip != stack) { ItemStack toPlaceStack = equip; -// WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, toPlaceStack); - - //tryPlaceItemIntoWorld could throw an Exception - try { - //Places the Block into the World - 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()); - } - } - } - //Notify the Player and log the Exception - catch (Exception e) { - 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); - - return InteractionResult.sidedSuccess(level.isClientSide); + //Places the Block into the World + BlockHitResult result = new BlockHitResult(context.getClickLocation(), context.getClickedFace(), context.getClickedPos(), context.isInside()); + return toPlaceStack.useOn(new UseOnContext(level, player, hand, toPlaceStack, result)); } } }