Skip to content

Commit

Permalink
Fix a minor bug in fill that might lead the bot into lava / other obs…
Browse files Browse the repository at this point in the history
…tracles.
  • Loading branch information
michaelzangl committed May 17, 2020
1 parent f4326ab commit a3bc692
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.famzangl.minecraft.minebot.ai.command.AICommandParameter.BlockFilter;
import net.famzangl.minecraft.minebot.ai.path.world.BlockSet;
import net.famzangl.minecraft.minebot.ai.path.world.BlockSets;
import net.famzangl.minecraft.minebot.ai.path.world.WorldData;
import net.famzangl.minecraft.minebot.ai.task.WaitTask;
import net.famzangl.minecraft.minebot.ai.utils.BlockCuboid;
import net.famzangl.minecraft.minebot.build.blockbuild.AbstractBuildTask;
Expand Down Expand Up @@ -49,11 +50,11 @@ public boolean matches(BlockState block) {

}

private final BlockCuboid fillCuboid;
private final BlockCuboid<WorldData> fillCuboid;
private int currentFillLayer;
private final BlockState blockToPlace;

public FillAreaPathfinder(BlockCuboid cuboid,
public FillAreaPathfinder(BlockCuboid<WorldData> cuboid,
BlockState blockToPlace) {
fillCuboid = cuboid;
this.blockToPlace = blockToPlace;
Expand Down Expand Up @@ -123,7 +124,11 @@ private boolean generatePlaceBlockTask(BlockPos currentPos) {
BlockPos placeAtPos = currentPos.subtract(pos);
if (placeAtPos.getY() == currentFillLayer
&& fillCuboid.contains(world, placeAtPos)
&& BlockSets.AIR.isAt(world, placeAtPos)) {
&& BlockSets.AIR.isAt(world, placeAtPos)
&& BlockSets.AIR.isAt(world, placeAtPos.up())
&& BlockSets.AIR.isAt(world, placeAtPos.up(2))
&& BlockSets.safeSideAround(world, placeAtPos.up())
&& BlockSets.safeSideAround(world, placeAtPos.up(2))) {
addTask(new BlockBuildTask(placeAtPos, blockToPlace)
.getPlaceBlockTask(pos));
return true;
Expand Down

0 comments on commit a3bc692

Please sign in to comment.