1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-12 19:20:29 +00:00

Merge pull request #267 from SquidDev-CC/feature/tutle-tool-changes

Shovel upgrade converts grass to path blocks
This commit is contained in:
Daniel Ratcliffe 2017-05-20 12:16:47 +01:00 committed by GitHub
commit d86aa50bec

View File

@ -5,13 +5,23 @@
*/
package dan200.computercraft.shared.turtle.upgrades;
import dan200.computercraft.api.turtle.ITurtleAccess;
import dan200.computercraft.api.turtle.TurtleCommandResult;
import dan200.computercraft.api.turtle.TurtleSide;
import dan200.computercraft.api.turtle.TurtleVerb;
import dan200.computercraft.shared.turtle.core.TurtlePlaceCommand;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.util.math.BlockPos;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class TurtleShovel extends TurtleTool
{
public TurtleShovel( ResourceLocation id, int legacyId, String adjective, Item item )
@ -41,4 +51,20 @@ public class TurtleShovel extends TurtleTool
}
return false;
}
@Nonnull
@Override
public TurtleCommandResult useTool( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side, @Nonnull TurtleVerb verb, @Nonnull EnumFacing direction )
{
if( verb == TurtleVerb.Dig )
{
ItemStack shovel = m_item.copy();
ItemStack remainder = TurtlePlaceCommand.deploy( shovel, turtle, direction, null, null );
if( remainder != shovel )
{
return TurtleCommandResult.success();
}
}
return super.useTool( turtle, side, verb, direction );
}
}