From 7988274d616a19d487d52739547edaa440806941 Mon Sep 17 00:00:00 2001
From: ZacSharp <68165024+ZacSharp@users.noreply.github.com>
Date: Tue, 12 Jan 2021 23:59:11 +0100
Subject: [PATCH 01/13] =?UTF-8?q?=E2=9C=A8=20add=20buildSkipBlocks=20setti?=
=?UTF-8?q?ng?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/java/baritone/api/Settings.java | 9 +++++++++
src/main/java/baritone/process/BuilderProcess.java | 3 +++
2 files changed, 12 insertions(+)
diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java
index 69b7e552..2de53e60 100644
--- a/src/api/java/baritone/api/Settings.java
+++ b/src/api/java/baritone/api/Settings.java
@@ -206,6 +206,15 @@ public final class Settings {
)));
+ /**
+ * A list of blocks to be treated as correct.
+ *
+ * If a schematic asks for any block on this list at a certain position, it will be treated as correct, regardless of what it currently is.
+ */
+ public final Setting> buildSkipBlocks = new Setting<>(new ArrayList<>(Arrays.asList(
+
+ )));
+
/**
* A list of blocks to become air
*
diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java
index 00d3831c..1d08a0f1 100644
--- a/src/main/java/baritone/process/BuilderProcess.java
+++ b/src/main/java/baritone/process/BuilderProcess.java
@@ -794,6 +794,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
if (!(current.getBlock() instanceof BlockAir) && Baritone.settings().buildIgnoreExisting.value && !itemVerify) {
return true;
}
+ if (Baritone.settings().buildSkipBlocks.value.contains(desired.getBlock())) {
+ return true;
+ }
return current.equals(desired);
}
From dba186347c192c12eeb764e55be8751143d1728d Mon Sep 17 00:00:00 2001
From: ZacSharp <68165024+ZacSharp@users.noreply.github.com>
Date: Wed, 13 Jan 2021 22:45:59 +0100
Subject: [PATCH 02/13] remove likely useless code breaking buildSkipBlocks
---
src/api/java/baritone/api/schematic/FillSchematic.java | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/api/java/baritone/api/schematic/FillSchematic.java b/src/api/java/baritone/api/schematic/FillSchematic.java
index de9ccf97..edb1d611 100644
--- a/src/api/java/baritone/api/schematic/FillSchematic.java
+++ b/src/api/java/baritone/api/schematic/FillSchematic.java
@@ -44,8 +44,6 @@ public class FillSchematic extends AbstractSchematic {
public IBlockState desiredState(int x, int y, int z, IBlockState current, List approxPlaceable) {
if (bom.matches(current)) {
return current;
- } else if (current.getBlock() != Blocks.AIR) {
- return Blocks.AIR.getDefaultState();
}
for (IBlockState placeable : approxPlaceable) {
if (bom.matches(placeable)) {
From 5e4f31f39e337bd70fe01c9b15b74a527cd318b3 Mon Sep 17 00:00:00 2001
From: ZacSharp <68165024+ZacSharp@users.noreply.github.com>
Date: Sat, 16 Jan 2021 02:05:59 +0100
Subject: [PATCH 03/13] proper place/break costs for skipped blocks
---
src/main/java/baritone/process/BuilderProcess.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java
index 1d08a0f1..9e76b04b 100644
--- a/src/main/java/baritone/process/BuilderProcess.java
+++ b/src/main/java/baritone/process/BuilderProcess.java
@@ -794,7 +794,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
if (!(current.getBlock() instanceof BlockAir) && Baritone.settings().buildIgnoreExisting.value && !itemVerify) {
return true;
}
- if (Baritone.settings().buildSkipBlocks.value.contains(desired.getBlock())) {
+ if (Baritone.settings().buildSkipBlocks.value.contains(desired.getBlock()) && !itemVerify) {
return true;
}
return current.equals(desired);
@@ -834,7 +834,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
return COST_INF;
}
IBlockState sch = getSchematic(x, y, z, current);
- if (sch != null) {
+ if (sch != null && !Baritone.settings().buildSkipBlocks.value.contains(sch.getBlock())) {
// TODO this can return true even when allowPlace is off.... is that an issue?
if (sch.getBlock() == Blocks.AIR) {
// we want this to be air, but they're asking if they can place here
@@ -868,7 +868,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
return COST_INF;
}
IBlockState sch = getSchematic(x, y, z, current);
- if (sch != null) {
+ if (sch != null && !Baritone.settings().buildSkipBlocks.value.contains(sch.getBlock())) {
if (sch.getBlock() == Blocks.AIR) {
// it should be air
// regardless of current contents, we can break it
From d375d1abc97b77a12c2d61408b9fd351d2b29595 Mon Sep 17 00:00:00 2001
From: ZacSharp <68165024+ZacSharp@users.noreply.github.com>
Date: Sun, 17 Jan 2021 00:16:34 +0100
Subject: [PATCH 04/13] Add setting parser for mappings
---
.../java/baritone/api/utils/SettingsUtil.java | 31 +++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/src/api/java/baritone/api/utils/SettingsUtil.java b/src/api/java/baritone/api/utils/SettingsUtil.java
index f9cb7136..48c8ee4d 100644
--- a/src/api/java/baritone/api/utils/SettingsUtil.java
+++ b/src/api/java/baritone/api/utils/SettingsUtil.java
@@ -35,6 +35,7 @@ import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -261,6 +262,36 @@ public class SettingsUtil {
public boolean accepts(Type type) {
return List.class.isAssignableFrom(TypeUtils.resolveBaseClass(type));
}
+ },
+ MAPPING() {
+ @Override
+ public Object parse(ParserContext context, String raw) {
+ Type keyType = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0];
+ Type valueType = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[1];
+ Parser keyParser = Parser.getParser(keyType);
+ Parser valueParser = Parser.getParser(valueType);
+
+ return Stream.of(raw.split(",(?=[^,]*->)"))
+ .map(s -> s.split("->"))
+ .collect(Collectors.toMap(s -> keyParser.parse(context, s[0]), s -> valueParser.parse(context, s[1])));
+ }
+
+ @Override
+ public String toString(ParserContext context, Object value) {
+ Type keyType = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0];
+ Type valueType = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[1];
+ Parser keyParser = Parser.getParser(keyType);
+ Parser valueParser = Parser.getParser(valueType);
+
+ return ((Map,?>) value).entrySet().stream()
+ .map(o -> keyParser.toString(context, o.getKey()) + "->" + valueParser.toString(context, o.getValue()))
+ .collect(Collectors.joining(","));
+ }
+
+ @Override
+ public boolean accepts(Type type) {
+ return Map.class.isAssignableFrom(TypeUtils.resolveBaseClass(type));
+ }
};
private final Class> cla$$;
From 13547781d2088b63c1fab6803e3ddb75b1b0865c Mon Sep 17 00:00:00 2001
From: ZacSharp <68165024+ZacSharp@users.noreply.github.com>
Date: Sun, 17 Jan 2021 00:53:50 +0100
Subject: [PATCH 05/13] add buildValidSubstitutes setting to builder
---
src/api/java/baritone/api/Settings.java | 7 +++++++
src/main/java/baritone/process/BuilderProcess.java | 3 +++
2 files changed, 10 insertions(+)
diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java
index 2de53e60..1b9b173a 100644
--- a/src/api/java/baritone/api/Settings.java
+++ b/src/api/java/baritone/api/Settings.java
@@ -215,6 +215,13 @@ public final class Settings {
)));
+ /**
+ * A mapping of blocks to blocks treated as correct in their position
+ *
+ * If a schematic asks for a block on this mapping, all blocks on the mapped list will be accepted at that location as well
+ */
+ public final Setting