mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-07-07 20:42:53 +00:00
Merge pull request #520 from SquidDev-CC/ComputerCraft/hotfix/turtle-world-border
Prevent turtles moving beyond the world border
This commit is contained in:
commit
5ae38a3f18
@ -541,10 +541,11 @@ public class TurtleBrain implements ITurtleAccess
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !world.isBlockLoaded( pos ) )
|
// Ensure the chunk is loaded
|
||||||
{
|
if( !world.isBlockLoaded( pos ) ) return false;
|
||||||
return false;
|
|
||||||
}
|
// Ensure we're inside the world border
|
||||||
|
if( !world.getWorldBorder().contains( pos ) ) return false;
|
||||||
|
|
||||||
oldOwner.notifyMoveStart();
|
oldOwner.notifyMoveStart();
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@ import dan200.computercraft.api.turtle.TurtleCommandResult;
|
|||||||
import dan200.computercraft.shared.util.WorldUtil;
|
import dan200.computercraft.shared.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@ -170,6 +170,10 @@ public class TurtleMoveCommand implements ITurtleCommand
|
|||||||
{
|
{
|
||||||
return TurtleCommandResult.failure( "Cannot leave loaded world" );
|
return TurtleCommandResult.failure( "Cannot leave loaded world" );
|
||||||
}
|
}
|
||||||
|
if( !world.getWorldBorder().contains( position ) )
|
||||||
|
{
|
||||||
|
return TurtleCommandResult.failure( "Cannot pass the world border" );
|
||||||
|
}
|
||||||
return TurtleCommandResult.success();
|
return TurtleCommandResult.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user