From bd345ae041d789673f01986baa90e657cbc3d70d Mon Sep 17 00:00:00 2001 From: Xennex <55858288+Xephorix@users.noreply.github.com> Date: Mon, 7 Oct 2019 09:50:10 -0600 Subject: [PATCH 01/15] Update USAGE.md added a few commands to the list of "fun / interesting / important ones that you might want to look at" --- USAGE.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/USAGE.md b/USAGE.md index 25fef11e8..76da07cb4 100644 --- a/USAGE.md +++ b/USAGE.md @@ -65,6 +65,8 @@ There are about a hundred settings, but here are some fun / interesting / import - `worldExploringChunkOffset` - `acceptableThrowawayItems` - `blocksToAvoidBreaking` +- `mineScanDroppedItems` +- `allowDiagonalAscend` From 4b526f724281d970ebb297b8e1c4cba5ad625f80 Mon Sep 17 00:00:00 2001 From: aUniqueUser Date: Tue, 25 Feb 2020 21:13:20 -0500 Subject: [PATCH 02/15] 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 991a7ff81..3a24ca3ab 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 03/15] 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 3a24ca3ab..2831675b9 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 04/15] 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 2831675b9..3972a3254 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 05/15] [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 3972a3254..6121679ae 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 06/15] 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 6121679ae..e404f23b4 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 07/15] 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 e404f23b4..d346e9df7 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." ); } } From f1f4adf8a6c04f262458813c872af33365d74500 Mon Sep 17 00:00:00 2001 From: Bella Who Date: Thu, 27 Feb 2020 17:42:12 -0500 Subject: [PATCH 08/15] Update USAGE.md as per #1332 --- USAGE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/USAGE.md b/USAGE.md index d1592acd5..ce761b8ea 100644 --- a/USAGE.md +++ b/USAGE.md @@ -44,7 +44,7 @@ Some common examples: - `save waypointName` to save a waypoint. `goto waypointName` to go to it. - `build` to build a schematic. `build blah` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420). - `schematica` to build the schematic that is currently open in schematica -- `tunnel` to dig just straight ahead and make a tunnel +- `tunnel height/width/depth` to dig and make a tunnel. If you don't supply numbers then it just digs a 1x2 tunnel. - `farm` to automatically harvest, replant, or bone meal crops - `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120). - `explore x z` to explore the world from the origin of x,z. Leave out x and z to default to player feet. This will continually path towards the closest chunk to the origin that it's never seen before. `explorefilter filter.json` with optional invert can be used to load in a list of chunks to load. From 220fa79057e0458bad7665ef5a9596010610a6ea Mon Sep 17 00:00:00 2001 From: fw4hre0xxq <60912178+fw4hre0xxq@users.noreply.github.com> Date: Thu, 27 Feb 2020 17:14:12 -0800 Subject: [PATCH 09/15] fix #1339 --- src/main/java/baritone/pathing/movement/MovementHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 7e1c567a3..d6f0b9a28 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -302,7 +302,7 @@ public interface MovementHelper extends ActionCosts, Helper { if (block == Blocks.FARMLAND || block == Blocks.GRASS_PATH) { return true; } - if (block == Blocks.ENDER_CHEST || block == Blocks.CHEST) { + if (block == Blocks.ENDER_CHEST || block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST ) { return true; } if (isWater(block)) { From 9fb46946b57c110df8aacb37fad70e27fc886b05 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 27 Feb 2020 18:05:05 -0800 Subject: [PATCH 10/15] fix sprint while paused bug, fixes #1331 --- src/launch/java/baritone/launch/mixins/MixinMinecraft.java | 2 +- src/main/java/baritone/behavior/PathingBehavior.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java index 3de4a0f54..51e9959f3 100644 --- a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java +++ b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java @@ -145,7 +145,7 @@ public class MixinMinecraft { ) private boolean isAllowUserInput(GuiScreen screen) { // allow user input is only the primary baritone - return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().getCurrent() != null && player != null) || screen.allowUserInput; + return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing() && player != null) || screen.allowUserInput; } @Inject( diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 86fd95055..50ca7425f 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -103,7 +103,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, @Override public void onPlayerSprintState(SprintStateEvent event) { - if (current != null) { + if (isPathing()) { event.setState(current.isSprinting()); } } From 17c691b1cfa4f05e97906ff7abf64c7d1e06b692 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 27 Feb 2020 18:06:11 -0800 Subject: [PATCH 11/15] the whole point is its better to do something nonsensical than to crash, so lets continue in that direction --- .../baritone/utils/BlockStateInterfaceAccessWrapper.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/utils/BlockStateInterfaceAccessWrapper.java b/src/main/java/baritone/utils/BlockStateInterfaceAccessWrapper.java index 6ce70193f..6dded1dd5 100644 --- a/src/main/java/baritone/utils/BlockStateInterfaceAccessWrapper.java +++ b/src/main/java/baritone/utils/BlockStateInterfaceAccessWrapper.java @@ -19,6 +19,7 @@ package baritone.utils; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Biomes; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; @@ -44,12 +45,12 @@ public final class BlockStateInterfaceAccessWrapper implements IBlockAccess { @Nullable @Override public TileEntity getTileEntity(BlockPos pos) { - throw new UnsupportedOperationException("getTileEntity not supported by BlockStateInterfaceAccessWrapper"); + return null; } @Override public int getCombinedLight(BlockPos pos, int lightValue) { - throw new UnsupportedOperationException("getCombinedLight not supported by BlockStateInterfaceAccessWrapper"); + return 0; } @Override @@ -65,12 +66,12 @@ public final class BlockStateInterfaceAccessWrapper implements IBlockAccess { @Override public Biome getBiome(BlockPos pos) { - throw new UnsupportedOperationException("getBiome not supported by BlockStateInterfaceAccessWrapper"); + return Biomes.FOREST; } @Override public int getStrongPower(BlockPos pos, EnumFacing direction) { - throw new UnsupportedOperationException("getStrongPower not supported by BlockStateInterfaceAccessWrapper"); + return 0; } @Override From 0ca3c496de110b71aa8031b0bc1d856dcb7b88cf Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 2 Mar 2020 13:40:43 -0600 Subject: [PATCH 12/15] Fix tunnel command usage --- 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 d346e9df7..6f7304a6a 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 height/width/depth - Tunnels in a user defined height, width and depth." + "> tunnel - Tunnels in a user defined height, width and depth." ); } } From 96a8bb90c9444a3e15f91ad8be6f656703d1d6bb Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 2 Mar 2020 13:41:21 -0600 Subject: [PATCH 13/15] Fix tunnel usage in USAGE.md --- USAGE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/USAGE.md b/USAGE.md index ce761b8ea..681298b01 100644 --- a/USAGE.md +++ b/USAGE.md @@ -44,7 +44,7 @@ Some common examples: - `save waypointName` to save a waypoint. `goto waypointName` to go to it. - `build` to build a schematic. `build blah` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420). - `schematica` to build the schematic that is currently open in schematica -- `tunnel height/width/depth` to dig and make a tunnel. If you don't supply numbers then it just digs a 1x2 tunnel. +- `tunnel height width depth` to dig and make a tunnel. If you don't supply numbers then it just digs a 1x2 tunnel. - `farm` to automatically harvest, replant, or bone meal crops - `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120). - `explore x z` to explore the world from the origin of x,z. Leave out x and z to default to player feet. This will continually path towards the closest chunk to the origin that it's never seen before. `explorefilter filter.json` with optional invert can be used to load in a list of chunks to load. From c8856cfea4ffd19fe0909a0446d4aa34813df53c Mon Sep 17 00:00:00 2001 From: Brady Date: Sat, 7 Mar 2020 17:34:27 -0600 Subject: [PATCH 14/15] Fix #1250 --- .../java/baritone/process/BuilderProcess.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 5af434923..17a8f5f94 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -206,7 +206,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil continue; // irrelevant } IBlockState curr = bcc.bsi.get0(x, y, z); - if (curr.getBlock() != Blocks.AIR && !(curr.getBlock() instanceof BlockLiquid) && !valid(curr, desired)) { + if (curr.getBlock() != Blocks.AIR && !(curr.getBlock() instanceof BlockLiquid) && !valid(curr, desired, false)) { BetterBlockPos pos = new BetterBlockPos(x, y, z); Optional rot = RotationUtils.reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance()); if (rot.isPresent()) { @@ -247,7 +247,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil continue; // irrelevant } IBlockState curr = bcc.bsi.get0(x, y, z); - if (MovementHelper.isReplaceable(x, y, z, curr, bcc.bsi) && !valid(curr, desired)) { + if (MovementHelper.isReplaceable(x, y, z, curr, bcc.bsi) && !valid(curr, desired, false)) { if (dy == 1 && bcc.bsi.get0(x, y + 1, z).getBlock() == Blocks.AIR) { continue; } @@ -314,7 +314,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil ); ctx.player().rotationYaw = originalYaw; ctx.player().rotationPitch = originalPitch; - if (valid(wouldBePlaced, desired)) { + if (valid(wouldBePlaced, desired, true)) { return OptionalInt.of(i); } } @@ -457,7 +457,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil outer: for (IBlockState desired : desirableOnHotbar) { for (int i = 0; i < 9; i++) { - if (valid(approxPlaceable.get(i), desired)) { + if (valid(approxPlaceable.get(i), desired, true)) { usefulSlots.add(i); continue outer; } @@ -468,7 +468,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil outer: for (int i = 9; i < 36; i++) { for (IBlockState desired : noValidHotbarOption) { - if (valid(approxPlaceable.get(i), desired)) { + if (valid(approxPlaceable.get(i), desired, true)) { baritone.getInventoryBehavior().attemptToPutOnHotbar(i, usefulSlots::contains); break outer; } @@ -524,7 +524,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (desired != null) { // we care about this position BetterBlockPos pos = new BetterBlockPos(x, y, z); - if (valid(bcc.bsi.get0(x, y, z), desired)) { + if (valid(bcc.bsi.get0(x, y, z), desired, false)) { incorrectPositions.remove(pos); observedCompleted.add(BetterBlockPos.longHash(pos)); } else { @@ -551,7 +551,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil } if (bcc.bsi.worldContainsLoadedChunk(blockX, blockZ)) { // check if its in render distance, not if its in cache // we can directly observe this block, it is in render distance - if (valid(bcc.bsi.get0(blockX, blockY, blockZ), schematic.desiredState(x, y, z, current, this.approxPlaceable))) { + if (valid(bcc.bsi.get0(blockX, blockY, blockZ), schematic.desiredState(x, y, z, current, this.approxPlaceable), false)) { observedCompleted.add(BetterBlockPos.longHash(blockX, blockY, blockZ)); } else { incorrectPositions.add(new BetterBlockPos(blockX, blockY, blockZ)); @@ -769,7 +769,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil return result; } - private boolean valid(IBlockState current, IBlockState desired) { + private boolean valid(IBlockState current, IBlockState desired, boolean itemVerify) { if (desired == null) { return true; } @@ -780,7 +780,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (desired.getBlock() instanceof BlockAir && Baritone.settings().buildIgnoreBlocks.value.contains(current.getBlock())) { return true; } - if (!(current.getBlock() instanceof BlockAir) && Baritone.settings().buildIgnoreExisting.value) { + if (!(current.getBlock() instanceof BlockAir) && Baritone.settings().buildIgnoreExisting.value && !itemVerify) { return true; } return current.equals(desired); @@ -862,7 +862,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil } // it should be a real block // is it already that block? - if (valid(bsi.get0(x, y, z), sch)) { + if (valid(bsi.get0(x, y, z), sch, false)) { return Baritone.settings().breakCorrectBlockPenaltyMultiplier.value; } else { // can break if it's wrong From eda18207738ba8d773607e3c6e8f14f0c7bff490 Mon Sep 17 00:00:00 2001 From: Brady Date: Sat, 7 Mar 2020 20:17:53 -0600 Subject: [PATCH 15/15] Fix Cubecraft Crash (Affects 1.13.2+) --- .../launch/mixins/MixinNetHandlerPlayClient.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/launch/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java b/src/launch/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java index e2cc98427..96e9cc29d 100644 --- a/src/launch/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java +++ b/src/launch/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java @@ -21,6 +21,7 @@ import baritone.api.BaritoneAPI; import baritone.api.IBaritone; import baritone.api.event.events.ChunkEvent; import baritone.api.event.events.type.EventState; +import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.network.play.server.SPacketChunkData; import net.minecraft.network.play.server.SPacketCombatEvent; @@ -45,7 +46,8 @@ public class MixinNetHandlerPlayClient { ) private void preRead(SPacketChunkData packetIn, CallbackInfo ci) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { - if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) { + EntityPlayerSP player = ibaritone.getPlayerContext().player(); + if (player != null && player.connection == (NetHandlerPlayClient) (Object) this) { ibaritone.getGameEventHandler().onChunkEvent( new ChunkEvent( EventState.PRE, @@ -64,7 +66,8 @@ public class MixinNetHandlerPlayClient { ) private void postHandleChunkData(SPacketChunkData packetIn, CallbackInfo ci) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { - if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) { + EntityPlayerSP player = ibaritone.getPlayerContext().player(); + if (player != null && player.connection == (NetHandlerPlayClient) (Object) this) { ibaritone.getGameEventHandler().onChunkEvent( new ChunkEvent( EventState.POST, @@ -86,7 +89,8 @@ public class MixinNetHandlerPlayClient { ) private void onPlayerDeath(SPacketCombatEvent packetIn, CallbackInfo ci) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { - if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) { + EntityPlayerSP player = ibaritone.getPlayerContext().player(); + if (player != null && player.connection == (NetHandlerPlayClient) (Object) this) { ibaritone.getGameEventHandler().onPlayerDeath(); } }