2017-05-07 00:18:59 +00:00
|
|
|
/*
|
2017-05-01 13:32:39 +00:00
|
|
|
* This file is part of ComputerCraft - http://www.computercraft.info
|
2017-05-13 18:20:39 +00:00
|
|
|
* Copyright Daniel Ratcliffe, 2011-2017. Do not distribute without permission.
|
2017-05-01 13:32:39 +00:00
|
|
|
* Send enquiries to dratcliffe@gmail.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
package dan200.computercraft.shared.turtle.core;
|
|
|
|
|
|
|
|
import dan200.computercraft.api.turtle.ITurtleAccess;
|
|
|
|
import dan200.computercraft.api.turtle.ITurtleCommand;
|
|
|
|
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
|
|
|
import dan200.computercraft.shared.util.InventoryUtil;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
2017-05-06 23:07:42 +00:00
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
|
2017-05-01 13:32:39 +00:00
|
|
|
public class TurtleCompareToCommand implements ITurtleCommand
|
|
|
|
{
|
|
|
|
private final int m_slot;
|
|
|
|
|
|
|
|
public TurtleCompareToCommand( int slot )
|
|
|
|
{
|
|
|
|
m_slot = slot;
|
|
|
|
}
|
|
|
|
|
2017-05-06 23:07:42 +00:00
|
|
|
@Nonnull
|
2017-05-01 13:32:39 +00:00
|
|
|
@Override
|
2017-05-06 23:07:42 +00:00
|
|
|
public TurtleCommandResult execute( @Nonnull ITurtleAccess turtle )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
ItemStack selectedStack = turtle.getInventory().getStackInSlot( turtle.getSelectedSlot() );
|
|
|
|
ItemStack stack = turtle.getInventory().getStackInSlot( m_slot );
|
|
|
|
if( InventoryUtil.areItemsStackable( selectedStack, stack ) )
|
|
|
|
{
|
|
|
|
return TurtleCommandResult.success();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return TurtleCommandResult.failure();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|