Skip to content
This repository has been archived by the owner on Jul 1, 2018. It is now read-only.

Commit

Permalink
Use TurtleHooks' block protection for tool host
Browse files Browse the repository at this point in the history
  • Loading branch information
SquidDev committed Feb 7, 2017
1 parent aecd093 commit e3e9ce9
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.squiddev.cctweaks.turtle;

import dan200.computercraft.ComputerCraft;
import dan200.computercraft.api.turtle.ITurtleAccess;
import dan200.computercraft.api.turtle.TurtleCommandResult;
import dan200.computercraft.shared.turtle.core.TurtlePlayer;
Expand All @@ -20,6 +21,7 @@
import org.squiddev.cctweaks.api.IWorldPosition;
import org.squiddev.cctweaks.core.Config;
import org.squiddev.cctweaks.core.McEvents;
import org.squiddev.cctweaks.core.turtle.TurtleHooks;
import org.squiddev.cctweaks.core.utils.FakeNetHandler;
import org.squiddev.cctweaks.core.utils.WorldPosition;

Expand Down Expand Up @@ -86,6 +88,10 @@ public TurtleCommandResult dig(ITurtleAccess turtle, EnumFacing direction, Block
if (block != digBlock || !pos.equals(digPosition)) setState(block, pos);

if (!world.isAirBlock(pos) && !block.getMaterial().isLiquid()) {
if (ComputerCraft.turtlesObeyBlockProtection && !TurtleHooks.isBlockBreakable(world, pos, this)) {
return TurtleCommandResult.failure("Cannot break protected block");
}

if (block == Blocks.bedrock || block.getBlockHardness(world, pos) <= -1) {
return TurtleCommandResult.failure("Unbreakable block detected");
}
Expand Down

0 comments on commit e3e9ce9

Please sign in to comment.