From 4b526f724281d970ebb297b8e1c4cba5ad625f80 Mon Sep 17 00:00:00 2001 From: aUniqueUser Date: Tue, 25 Feb 2020 21:13:20 -0500 Subject: [PATCH 1/6] Custom Tunneling --- .../command/defaults/TunnelCommand.java | 64 +++++++++++++++---- 1 file changed, 52 insertions(+), 12 deletions(-) diff --git a/src/main/java/baritone/command/defaults/TunnelCommand.java b/src/main/java/baritone/command/defaults/TunnelCommand.java index 991a7ff8..3a24ca3a 100644 --- a/src/main/java/baritone/command/defaults/TunnelCommand.java +++ b/src/main/java/baritone/command/defaults/TunnelCommand.java @@ -18,11 +18,13 @@ package baritone.command.defaults; import baritone.api.IBaritone; +import baritone.api.command.Command; +import baritone.api.command.argument.IArgConsumer; +import baritone.api.command.exception.CommandException; import baritone.api.pathing.goals.Goal; import baritone.api.pathing.goals.GoalStrictDirection; -import baritone.api.command.Command; -import baritone.api.command.exception.CommandException; -import baritone.api.command.argument.IArgConsumer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import java.util.Arrays; import java.util.List; @@ -36,13 +38,50 @@ public class TunnelCommand extends Command { @Override public void execute(String label, IArgConsumer args) throws CommandException { - args.requireMax(0); - Goal goal = new GoalStrictDirection( - ctx.playerFeet(), - ctx.player().getHorizontalFacing() - ); - baritone.getCustomGoalProcess().setGoalAndPath(goal); - logDirect(String.format("Goal: %s", goal.toString())); + args.requireMax(3); + if (args.hasExactly(3)) { + boolean cont = true; + int depth = Integer.parseInt(args.peekString(0))-1; + int height = Integer.parseInt(args.peekString(1))-1; + int width = Integer.parseInt(args.peekString(2))-1; + + if (width < 1 || height < 2) { + logDirect("Width must at least be 1 block, Height must at least be 2 blocks"); + cont = false; + } + + if (cont) { + BlockPos corner1 = null, corner2 = null; + EnumFacing enumfacing = ctx.player().getHorizontalFacing(); + int addition = ((width % 2 == 0) ? 0 : 1); + switch (enumfacing) { + case EAST: + corner1 = new BlockPos(ctx.playerFeet().x, ctx.playerFeet().y, ctx.playerFeet().z - width / 2); + corner2 = new BlockPos(ctx.playerFeet().x + depth, ctx.playerFeet().y + height, ctx.playerFeet().z + width / 2 + addition); + break; + case WEST: + corner1 = new BlockPos(ctx.playerFeet().x, ctx.playerFeet().y, ctx.playerFeet().z + width / 2 + addition); + corner2 = new BlockPos(ctx.playerFeet().x - depth, ctx.playerFeet().y + height, ctx.playerFeet().z - width / 2); + break; + case NORTH: + corner1 = new BlockPos(ctx.playerFeet().x - width / 2, ctx.playerFeet().y, ctx.playerFeet().z); + corner2 = new BlockPos(ctx.playerFeet().x + width / 2 + addition, ctx.playerFeet().y + height, ctx.playerFeet().z - depth); + break; + case SOUTH: + corner1 = new BlockPos(ctx.playerFeet().x + width / 2 + addition, ctx.playerFeet().y, ctx.playerFeet().z); + corner2 = new BlockPos(ctx.playerFeet().x - width / 2, ctx.playerFeet().y + height, ctx.playerFeet().z + depth); + break; + } + baritone.getBuilderProcess().clearArea(corner1, corner2); + } + } else { + Goal goal = new GoalStrictDirection( + ctx.playerFeet(), + ctx.player().getHorizontalFacing() + ); + baritone.getCustomGoalProcess().setGoalAndPath(goal); + logDirect(String.format("Goal: %s", goal.toString())); + } } @Override @@ -61,7 +100,8 @@ public class TunnelCommand extends Command { "The tunnel command sets a goal that tells Baritone to mine completely straight in the direction that you're facing.", "", "Usage:", - "> tunnel" + "> tunnel - No arguments, mines in a 1x2 radius.", + "> tunnel depth/height/width - Tunnels in a user defined depth, height and width." ); } -} +} \ No newline at end of file From 3c2838df9eb584dc75acbb0af42bd0dbb3512590 Mon Sep 17 00:00:00 2001 From: aUniqueUser Date: Tue, 25 Feb 2020 21:22:35 -0500 Subject: [PATCH 2/6] lol --- src/main/java/baritone/command/defaults/TunnelCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/command/defaults/TunnelCommand.java b/src/main/java/baritone/command/defaults/TunnelCommand.java index 3a24ca3a..2831675b 100644 --- a/src/main/java/baritone/command/defaults/TunnelCommand.java +++ b/src/main/java/baritone/command/defaults/TunnelCommand.java @@ -41,7 +41,7 @@ public class TunnelCommand extends Command { args.requireMax(3); if (args.hasExactly(3)) { boolean cont = true; - int depth = Integer.parseInt(args.peekString(0))-1; + int depth = Integer.parseInt(args.peekString(0)); int height = Integer.parseInt(args.peekString(1))-1; int width = Integer.parseInt(args.peekString(2))-1; From acd9bcceeba16fac47f19a2bcf47a074fd246a46 Mon Sep 17 00:00:00 2001 From: aUniqueUser Date: Tue, 25 Feb 2020 21:47:35 -0500 Subject: [PATCH 3/6] Codacy --- src/main/java/baritone/command/defaults/TunnelCommand.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/command/defaults/TunnelCommand.java b/src/main/java/baritone/command/defaults/TunnelCommand.java index 2831675b..3972a325 100644 --- a/src/main/java/baritone/command/defaults/TunnelCommand.java +++ b/src/main/java/baritone/command/defaults/TunnelCommand.java @@ -51,7 +51,8 @@ public class TunnelCommand extends Command { } if (cont) { - BlockPos corner1 = null, corner2 = null; + BlockPos corner1; + BlockPos corner2; EnumFacing enumfacing = ctx.player().getHorizontalFacing(); int addition = ((width % 2 == 0) ? 0 : 1); switch (enumfacing) { @@ -71,6 +72,8 @@ public class TunnelCommand extends Command { corner1 = new BlockPos(ctx.playerFeet().x + width / 2 + addition, ctx.playerFeet().y, ctx.playerFeet().z); corner2 = new BlockPos(ctx.playerFeet().x - width / 2, ctx.playerFeet().y + height, ctx.playerFeet().z + depth); break; + default: + throw new IllegalStateException("Unexpected value: " + enumfacing); } baritone.getBuilderProcess().clearArea(corner1, corner2); } From 6f136a90a28db9527fbbec7cd5db90194d9d6df9 Mon Sep 17 00:00:00 2001 From: CDAGaming Date: Wed, 26 Feb 2020 07:55:21 -0600 Subject: [PATCH 4/6] [Change] Adjustments --- .../command/defaults/TunnelCommand.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/baritone/command/defaults/TunnelCommand.java b/src/main/java/baritone/command/defaults/TunnelCommand.java index 3972a325..6121679a 100644 --- a/src/main/java/baritone/command/defaults/TunnelCommand.java +++ b/src/main/java/baritone/command/defaults/TunnelCommand.java @@ -41,21 +41,21 @@ public class TunnelCommand extends Command { args.requireMax(3); if (args.hasExactly(3)) { boolean cont = true; - int depth = Integer.parseInt(args.peekString(0)); - int height = Integer.parseInt(args.peekString(1))-1; - int width = Integer.parseInt(args.peekString(2))-1; + int depth = Integer.parseInt(args.getArgs().get(0).getValue()); + int height = Integer.parseInt(args.getArgs().get(1).getValue()); + int width = Integer.parseInt(args.getArgs().get(2).getValue()); - if (width < 1 || height < 2) { - logDirect("Width must at least be 1 block, Height must at least be 2 blocks"); + if (width < 1 || height < 2 || depth < 1) { + logDirect("Width and depth must at least be 1 block; Height must at least be 2 blocks"); cont = false; } if (cont) { BlockPos corner1; BlockPos corner2; - EnumFacing enumfacing = ctx.player().getHorizontalFacing(); + EnumFacing enumFacing = ctx.player().getHorizontalFacing(); int addition = ((width % 2 == 0) ? 0 : 1); - switch (enumfacing) { + switch (enumFacing) { case EAST: corner1 = new BlockPos(ctx.playerFeet().x, ctx.playerFeet().y, ctx.playerFeet().z - width / 2); corner2 = new BlockPos(ctx.playerFeet().x + depth, ctx.playerFeet().y + height, ctx.playerFeet().z + width / 2 + addition); @@ -73,8 +73,9 @@ public class TunnelCommand extends Command { corner2 = new BlockPos(ctx.playerFeet().x - width / 2, ctx.playerFeet().y + height, ctx.playerFeet().z + depth); break; default: - throw new IllegalStateException("Unexpected value: " + enumfacing); + throw new IllegalStateException("Unexpected value: " + enumFacing); } + logDirect(String.format("Creating a tunnel %s block(s) deep, %s block(s) wide, and %s block(s) high", depth, width, height)); baritone.getBuilderProcess().clearArea(corner1, corner2); } } else { @@ -107,4 +108,4 @@ public class TunnelCommand extends Command { "> tunnel depth/height/width - Tunnels in a user defined depth, height and width." ); } -} \ No newline at end of file +} From e3b91c884a8e3664a72a4c5c36518d6e6b099b09 Mon Sep 17 00:00:00 2001 From: aUniqueUser Date: Wed, 26 Feb 2020 12:30:07 -0500 Subject: [PATCH 5/6] More logical argument order --- .../baritone/command/defaults/TunnelCommand.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/command/defaults/TunnelCommand.java b/src/main/java/baritone/command/defaults/TunnelCommand.java index 6121679a..e404f23b 100644 --- a/src/main/java/baritone/command/defaults/TunnelCommand.java +++ b/src/main/java/baritone/command/defaults/TunnelCommand.java @@ -41,16 +41,18 @@ public class TunnelCommand extends Command { args.requireMax(3); if (args.hasExactly(3)) { boolean cont = true; - int depth = Integer.parseInt(args.getArgs().get(0).getValue()); - int height = Integer.parseInt(args.getArgs().get(1).getValue()); - int width = Integer.parseInt(args.getArgs().get(2).getValue()); + int height = Integer.parseInt(args.getArgs().get(0).getValue()); + int width = Integer.parseInt(args.getArgs().get(1).getValue()); + int depth = Integer.parseInt(args.getArgs().get(2).getValue()); - if (width < 1 || height < 2 || depth < 1) { - logDirect("Width and depth must at least be 1 block; Height must at least be 2 blocks"); + if (width < 1 || height < 2 || depth < 1 || height > 255) { + logDirect("Width and depth must at least be 1 block; Height must at least be 2 blocks, and cannot be greater than the build limit."); cont = false; } if (cont) { + height--; + width--; BlockPos corner1; BlockPos corner2; EnumFacing enumFacing = ctx.player().getHorizontalFacing(); @@ -75,7 +77,7 @@ public class TunnelCommand extends Command { default: throw new IllegalStateException("Unexpected value: " + enumFacing); } - logDirect(String.format("Creating a tunnel %s block(s) deep, %s block(s) wide, and %s block(s) high", depth, width, height)); + logDirect(String.format("Creating a tunnel %s block(s) high, %s block(s) wide, and %s block(s) deep", height+1, width+1, depth)); baritone.getBuilderProcess().clearArea(corner1, corner2); } } else { From 628ec0f2b570248a372d7240e5e4198e0354225a Mon Sep 17 00:00:00 2001 From: aUniqueUser Date: Wed, 26 Feb 2020 13:04:10 -0500 Subject: [PATCH 6/6] updated longDesc --- src/main/java/baritone/command/defaults/TunnelCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/command/defaults/TunnelCommand.java b/src/main/java/baritone/command/defaults/TunnelCommand.java index e404f23b..d346e9df 100644 --- a/src/main/java/baritone/command/defaults/TunnelCommand.java +++ b/src/main/java/baritone/command/defaults/TunnelCommand.java @@ -107,7 +107,7 @@ public class TunnelCommand extends Command { "", "Usage:", "> tunnel - No arguments, mines in a 1x2 radius.", - "> tunnel depth/height/width - Tunnels in a user defined depth, height and width." + "> tunnel height/width/depth - Tunnels in a user defined height, width and depth." ); } }