Skip to content

Commit 51ecc78

Browse files
Allow omitting [block] from /snake
1 parent dc4217e commit 51ecc78

File tree

1 file changed

+13
-25
lines changed

1 file changed

+13
-25
lines changed

fCraft/Commands/BuildingCommands.cs

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2780,32 +2780,20 @@ static void StaticHandler( Player player, CommandReader cmd ) {
27802780

27812781
private static void SnakeHandler(Player player, CommandReader cmd) {
27822782
int length;
2783-
if (!cmd.NextInt(out length)) return;
2783+
if (!cmd.NextInt(out length)) {
2784+
CdSnake.PrintUsage(player);
2785+
return;
2786+
}
27842787
if (length > 100000) {
2785-
player.Message("Snake cannot be more than 100,000 blocks in length");
2788+
player.Message("Snake cannot be more than 100,000 blocks in length");
27862789
return;
27872790
}
27882791

2789-
string sblock = cmd.Next();
2790-
Block newBlock;
2791-
if (sblock == null) {
2792-
if (player.LastUsedBlockType != Block.None) {
2793-
string blockName = Map.GetBlockName(player.World, player.LastUsedBlockType);
2794-
player.Message("No block specified, Using last used block ({0})", blockName);
2795-
newBlock = player.LastUsedBlockType;
2796-
} else {
2797-
player.Message("&WCannot deduce desired block. Click a block or type out the block name.");
2798-
return;
2799-
}
2800-
} else if (!Map.GetBlockByName(player.World, sblock, false, out newBlock)) {
2801-
if (player.LastUsedBlockType != Block.None) {
2802-
string blockName = Map.GetBlockName(player.World, player.LastUsedBlockType);
2803-
player.Message("No block specified, Using last used block ({0})", blockName);
2804-
newBlock = player.LastUsedBlockType;
2805-
} else {
2806-
player.Message("&WCannot deduce desired block. Click a block or type out the block name.");
2807-
return;
2808-
}
2792+
Block block = player.LastUsedBlockType;
2793+
if (cmd.HasNext && !cmd.NextBlock(player, false, out block)) return;
2794+
if (block == Block.None) {
2795+
player.Message("&WCannot deduce desired block. Click a block or type out the block name.");
2796+
return;
28092797
}
28102798
Random dir = new Random();
28112799
Vector3I pos = new Vector3I(player.Position.BlockX, player.Position.BlockY, player.Position.BlockZ);
@@ -2819,13 +2807,13 @@ private static void SnakeHandler(Player player, CommandReader cmd) {
28192807
Vector3I nextZ = pos; nextZ.Z += dir.Next(0, 2) * 2 - 1;
28202808
pos = new Vector3I(nextX.X, nextY.Y, nextZ.Z);
28212809

2822-
DrawOneBlock(player, player.World.Map, newBlock, nextX,
2810+
DrawOneBlock(player, player.World.Map, block, nextX,
28232811
BlockChangeContext.Drawn,
28242812
ref blocksDrawn, ref blocksSkipped, undoState);
2825-
DrawOneBlock(player, player.World.Map, newBlock, nextY,
2813+
DrawOneBlock(player, player.World.Map, block, nextY,
28262814
BlockChangeContext.Drawn,
28272815
ref blocksDrawn, ref blocksSkipped, undoState);
2828-
DrawOneBlock(player, player.World.Map, newBlock, nextZ,
2816+
DrawOneBlock(player, player.World.Map, block, nextZ,
28292817
BlockChangeContext.Drawn,
28302818
ref blocksDrawn, ref blocksSkipped, undoState);
28312819
}

0 commit comments

Comments
 (0)