From b55add2a9b7db334d49f36fcaa75e7a74a298857 Mon Sep 17 00:00:00 2001 From: Michael Zangl Date: Sat, 9 May 2020 23:07:58 +0200 Subject: [PATCH] Fix #192: Whitelist wheat, grass, ... when jumping up sidewards. --- .../minecraft/minebot/ai/path/MovePathFinder.java | 4 ++-- .../minecraft/minebot/ai/path/world/BlockSets.java | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Minebot/src/main/java/net/famzangl/minecraft/minebot/ai/path/MovePathFinder.java b/Minebot/src/main/java/net/famzangl/minecraft/minebot/ai/path/MovePathFinder.java index 448e877..1af55cb 100644 --- a/Minebot/src/main/java/net/famzangl/minecraft/minebot/ai/path/MovePathFinder.java +++ b/Minebot/src/main/java/net/famzangl/minecraft/minebot/ai/path/MovePathFinder.java @@ -220,8 +220,8 @@ private boolean isAllowedPosition(int cx, int cy, int cz) { } protected boolean checkGroundBlock(int currentNode, int cx, int cy, int cz) { - if (getY(currentNode) < cy) { - // Moving up + if (getY(currentNode) < cy && cx == getX(currentNode) && cz == getZ(currentNode)) { + // Moving straight up - this needs to place a block return allowedGroundForUpwardsBlocks.isAt(world, cx, cy - 1, cz); } else { return allowedGroundBlocks.isAt(world, cx, cy - 1, cz); diff --git a/Minebot/src/main/java/net/famzangl/minecraft/minebot/ai/path/world/BlockSets.java b/Minebot/src/main/java/net/famzangl/minecraft/minebot/ai/path/world/BlockSets.java index ff188dd..b3cec52 100644 --- a/Minebot/src/main/java/net/famzangl/minecraft/minebot/ai/path/world/BlockSets.java +++ b/Minebot/src/main/java/net/famzangl/minecraft/minebot/ai/path/world/BlockSets.java @@ -383,7 +383,7 @@ public class BlockSets { * Flowers and stuff like that */ private static final BlockSet explicitFootWalkableBlocks = BlockSet.builder().add( - Blocks.TALL_GRASS, + Blocks.GRASS, Blocks.CORNFLOWER, Blocks.CHORUS_FLOWER, Blocks.SUNFLOWER, @@ -434,14 +434,14 @@ public class BlockSets { public static final BlockSet HEAD_CAN_WALK_THROUGH = BlockSet.builder().add( Blocks.KELP_PLANT, Blocks.CHORUS_PLANT, + Blocks.TALL_GRASS, Blocks.SUGAR_CANE).add(AIR).add(TORCH).build(); public static final BlockSet FEET_CAN_WALK_THROUGH = BlockSet.builder().add(explicitFootWalkableBlocks).add(HEAD_CAN_WALK_THROUGH).build(); private static final BlockSet explicitSafeSideBlocks = BlockSet.builder().add( Blocks.ANVIL, - Blocks.CACTUS, - Blocks.SUGAR_CANE, + Blocks.CACTUS, Blocks.COBWEB, Blocks.GLASS_PANE, Blocks.ENCHANTING_TABLE, @@ -456,7 +456,7 @@ public class BlockSets { Blocks.STONE_BUTTON, Blocks.DRAGON_EGG, Blocks.TURTLE_EGG, - Blocks.FLOWER_POT).add(WALL).add(FENCE).add(FENCE_GATE).add(BED).add(WOODEN_PRESSURE_PLATE).add(WOODEN_BUTTON).build(); + Blocks.FLOWER_POT).add(FEET_CAN_WALK_THROUGH).add(WALL).add(FENCE).add(FENCE_GATE).add(BED).add(WOODEN_PRESSURE_PLATE).add(WOODEN_BUTTON).build(); /** * Blocks we can just walk over/next to without problems. @@ -488,7 +488,9 @@ public class BlockSets { Blocks.EMERALD_ORE, Blocks.OBSERVER, // FIXME: Not a cube. - Blocks.FARMLAND, Blocks.FURNACE, Blocks.GLASS, Blocks.GLOWSTONE, + Blocks.FARMLAND, + + Blocks.FURNACE, Blocks.GLASS, Blocks.GLOWSTONE, Blocks.GRASS_BLOCK, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.CLAY, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE,