mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-14 12:10:30 +00:00
Correctly check for success or consume
No, I don't really know what the difference is either :). Closes #518.
This commit is contained in:
parent
99581e1f40
commit
e8e9294fdf
@ -238,7 +238,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
|||||||
cancelResult = hitEntity.applyPlayerInteraction( turtlePlayer, hitPos, Hand.MAIN_HAND );
|
cancelResult = hitEntity.applyPlayerInteraction( turtlePlayer, hitPos, Hand.MAIN_HAND );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( cancelResult == ActionResultType.SUCCESS )
|
if( cancelResult.isSuccessOrConsume() )
|
||||||
{
|
{
|
||||||
placed = true;
|
placed = true;
|
||||||
}
|
}
|
||||||
@ -246,7 +246,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
|||||||
{
|
{
|
||||||
// See EntityPlayer.interactOn
|
// See EntityPlayer.interactOn
|
||||||
cancelResult = ForgeHooks.onInteractEntity( turtlePlayer, hitEntity, Hand.MAIN_HAND );
|
cancelResult = ForgeHooks.onInteractEntity( turtlePlayer, hitEntity, Hand.MAIN_HAND );
|
||||||
if( cancelResult == ActionResultType.SUCCESS )
|
if( cancelResult.isSuccessOrConsume() )
|
||||||
{
|
{
|
||||||
placed = true;
|
placed = true;
|
||||||
}
|
}
|
||||||
@ -353,17 +353,15 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
|||||||
TileEntity existingTile = turtle.getWorld().getTileEntity( position );
|
TileEntity existingTile = turtle.getWorld().getTileEntity( position );
|
||||||
|
|
||||||
// See PlayerInteractionManager.processRightClickBlock
|
// See PlayerInteractionManager.processRightClickBlock
|
||||||
// TODO: ^ Check we're still consistent.
|
|
||||||
PlayerInteractEvent.RightClickBlock event = ForgeHooks.onRightClickBlock( turtlePlayer, Hand.MAIN_HAND, position, side );
|
PlayerInteractEvent.RightClickBlock event = ForgeHooks.onRightClickBlock( turtlePlayer, Hand.MAIN_HAND, position, side );
|
||||||
if( !event.isCanceled() )
|
if( !event.isCanceled() )
|
||||||
{
|
{
|
||||||
if( item.onItemUseFirst( stack, context ) == ActionResultType.SUCCESS )
|
if( item.onItemUseFirst( stack, context ).isSuccessOrConsume() )
|
||||||
{
|
{
|
||||||
placed = true;
|
placed = true;
|
||||||
turtlePlayer.loadInventory( stackCopy );
|
turtlePlayer.loadInventory( stackCopy );
|
||||||
}
|
}
|
||||||
else if( event.getUseItem() != Event.Result.DENY &&
|
else if( event.getUseItem() != Event.Result.DENY && stackCopy.onItemUse( context ).isSuccessOrConsume() )
|
||||||
stackCopy.onItemUse( context ) == ActionResultType.SUCCESS )
|
|
||||||
{
|
{
|
||||||
placed = true;
|
placed = true;
|
||||||
turtlePlayer.loadInventory( stackCopy );
|
turtlePlayer.loadInventory( stackCopy );
|
||||||
@ -373,14 +371,14 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
|||||||
if( !placed && (item instanceof BucketItem || item instanceof BoatItem || item instanceof LilyPadItem || item instanceof GlassBottleItem) )
|
if( !placed && (item instanceof BucketItem || item instanceof BoatItem || item instanceof LilyPadItem || item instanceof GlassBottleItem) )
|
||||||
{
|
{
|
||||||
ActionResultType actionResult = ForgeHooks.onItemRightClick( turtlePlayer, Hand.MAIN_HAND );
|
ActionResultType actionResult = ForgeHooks.onItemRightClick( turtlePlayer, Hand.MAIN_HAND );
|
||||||
if( actionResult == ActionResultType.SUCCESS )
|
if( actionResult != null && actionResult.isSuccessOrConsume() )
|
||||||
{
|
{
|
||||||
placed = true;
|
placed = true;
|
||||||
}
|
}
|
||||||
else if( actionResult == null )
|
else if( actionResult == null )
|
||||||
{
|
{
|
||||||
ActionResult<ItemStack> result = stackCopy.useItemRightClick( turtle.getWorld(), turtlePlayer, Hand.MAIN_HAND );
|
ActionResult<ItemStack> result = stackCopy.useItemRightClick( turtle.getWorld(), turtlePlayer, Hand.MAIN_HAND );
|
||||||
if( result.getType() == ActionResultType.SUCCESS && !ItemStack.areItemStacksEqual( stack, result.getResult() ) )
|
if( result.getType().isSuccessOrConsume() && !ItemStack.areItemStacksEqual( stack, result.getResult() ) )
|
||||||
{
|
{
|
||||||
placed = true;
|
placed = true;
|
||||||
turtlePlayer.loadInventory( result.getResult() );
|
turtlePlayer.loadInventory( result.getResult() );
|
||||||
|
Loading…
Reference in New Issue
Block a user