From f997b02b8f35eaf7348aeed7ad278b08a97d902b Mon Sep 17 00:00:00 2001 From: svitoos Date: Sat, 14 Sep 2019 02:29:43 +0300 Subject: [PATCH] Fix the use of the item on the entity --- .../turtle/core/TurtlePlaceCommand.java | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java index f8fa6f275..38d3646f4 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java @@ -227,35 +227,21 @@ public class TurtlePlaceCommand implements ITurtleCommand // Place on the entity boolean placed = false; - ActionResult cancelResult = null; // ForgeHooks.onInteractEntityAt( turtlePlayer, hitEntity, hitPos, Hand.MAIN_HAND); - if( cancelResult == null ) - { - cancelResult = hitEntity.interactAt( turtlePlayer, hitPos, Hand.MAIN_HAND ); - } - + ActionResult cancelResult = hitEntity.interactAt( turtlePlayer, hitPos, Hand.MAIN_HAND ); if( cancelResult == ActionResult.SUCCESS ) { placed = true; } else { - // See PlayerEntity.interactOn - // cancelResult = ForgeHooks.onInteractEntity( turtlePlayer, hitEntity, Hand.MAIN_HAND); - if( cancelResult == ActionResult.SUCCESS ) + if( hitEntity.interact( turtlePlayer, Hand.MAIN_HAND ) ) { placed = true; } - else if( cancelResult == null ) + else if( hitEntity instanceof LivingEntity ) { - if( hitEntity.interact( turtlePlayer, Hand.MAIN_HAND ) ) - { - placed = true; - } - else if( hitEntity instanceof LivingEntity ) - { - placed = stackCopy.useOnEntity( turtlePlayer, (LivingEntity) hitEntity, Hand.MAIN_HAND ); - if( placed ) turtlePlayer.loadInventory( stackCopy ); - } + placed = stackCopy.useOnEntity( turtlePlayer, (LivingEntity) hitEntity, Hand.MAIN_HAND ); + if( placed ) turtlePlayer.loadInventory( stackCopy ); } }