From 6759917a2fbab523edd4532ebbd1f575ffcac24b Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 19 Dec 2019 11:58:47 -0600 Subject: [PATCH] Additional clean up --- .../baritone/api/schematic/FillSchematic.java | 3 ++ .../utils/schematic/FillSchematic.java | 26 ++------------ .../utils/schematic/MapArtSchematic.java | 34 +++---------------- 3 files changed, 11 insertions(+), 52 deletions(-) diff --git a/src/api/java/baritone/api/schematic/FillSchematic.java b/src/api/java/baritone/api/schematic/FillSchematic.java index aaaeb5dd..fbf16fb4 100644 --- a/src/api/java/baritone/api/schematic/FillSchematic.java +++ b/src/api/java/baritone/api/schematic/FillSchematic.java @@ -38,6 +38,9 @@ public class FillSchematic extends AbstractSchematic { @Override public IBlockState desiredState(int x, int y, int z, IBlockState current, List approxPlaceable) { + // TODO: is this even necessary??? + // Builder will already handle logic that requires breaking blocks before replacing them, and non-api Fill Schematic + // is used for clear area and doesn't have any issues. if (bom.matches(current)) { return current; } else if (current.getBlock() != Blocks.AIR) { diff --git a/src/main/java/baritone/utils/schematic/FillSchematic.java b/src/main/java/baritone/utils/schematic/FillSchematic.java index 2e67b121..67e5c734 100644 --- a/src/main/java/baritone/utils/schematic/FillSchematic.java +++ b/src/main/java/baritone/utils/schematic/FillSchematic.java @@ -17,22 +17,17 @@ package baritone.utils.schematic; -import baritone.api.schematic.ISchematic; +import baritone.api.schematic.AbstractSchematic; import net.minecraft.block.state.IBlockState; import java.util.List; -public class FillSchematic implements ISchematic { +public class FillSchematic extends AbstractSchematic { - private final int widthX; - private final int heightY; - private final int lengthZ; private final IBlockState state; public FillSchematic(int widthX, int heightY, int lengthZ, IBlockState state) { - this.widthX = widthX; - this.heightY = heightY; - this.lengthZ = lengthZ; + super(widthX, heightY, lengthZ); this.state = state; } @@ -40,19 +35,4 @@ public class FillSchematic implements ISchematic { public IBlockState desiredState(int x, int y, int z, IBlockState current, List approxPlaceable) { return state; } - - @Override - public int widthX() { - return widthX; - } - - @Override - public int heightY() { - return heightY; - } - - @Override - public int lengthZ() { - return lengthZ; - } } diff --git a/src/main/java/baritone/utils/schematic/MapArtSchematic.java b/src/main/java/baritone/utils/schematic/MapArtSchematic.java index ec477b57..a6bd2021 100644 --- a/src/main/java/baritone/utils/schematic/MapArtSchematic.java +++ b/src/main/java/baritone/utils/schematic/MapArtSchematic.java @@ -17,23 +17,20 @@ package baritone.utils.schematic; -import baritone.api.schematic.AbstractSchematic; import baritone.api.schematic.ISchematic; +import baritone.api.schematic.MaskSchematic; import net.minecraft.block.BlockAir; import net.minecraft.block.state.IBlockState; -import java.util.List; import java.util.OptionalInt; import java.util.function.Predicate; -public class MapArtSchematic extends AbstractSchematic { +public class MapArtSchematic extends MaskSchematic { - private final ISchematic child; private final int[][] heightMap; public MapArtSchematic(ISchematic schematic) { - super(schematic.widthX(), schematic.heightY(), schematic.lengthZ()); - this.child = schematic; + super(schematic); heightMap = new int[schematic.widthX()][schematic.lengthZ()]; @@ -63,28 +60,7 @@ public class MapArtSchematic extends AbstractSchematic { } @Override - public boolean inSchematic(int x, int y, int z, IBlockState currentState) { - // in map art, we only care about coordinates in or above the art - return this.child.inSchematic(x, y, z, currentState) && y >= heightMap[x][z]; - } - - @Override - public IBlockState desiredState(int x, int y, int z, IBlockState current, List approxPlaceable) { - return this.child.desiredState(x, y, z, current, approxPlaceable); - } - - @Override - public int widthX() { - return this.child.widthX(); - } - - @Override - public int heightY() { - return this.child.heightY(); - } - - @Override - public int lengthZ() { - return this.child.lengthZ(); + protected boolean partOfMask(int x, int y, int z, IBlockState currentState) { + return y >= heightMap[x][z]; } }