✨ Add buildIgnoreProperties setting
This commit is contained in:
parent
69ffdb7665
commit
ba3ca47f8c
@ -279,6 +279,12 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> buildIgnoreDirection = new Setting<>(false);
|
public final Setting<Boolean> buildIgnoreDirection = new Setting<>(false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of names of block properties the builder will ignore.
|
||||||
|
*/
|
||||||
|
public final Setting<List<String>> buildIgnoreProperties = new Setting<>(new ArrayList<>(Arrays.asList(
|
||||||
|
)));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this setting is true, Baritone will never break a block that is adjacent to an unsupported falling block.
|
* If this setting is true, Baritone will never break a block that is adjacent to an unsupported falling block.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -874,14 +874,21 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
BlockTrapDoor.OPEN, BlockTrapDoor.HALF
|
BlockTrapDoor.OPEN, BlockTrapDoor.HALF
|
||||||
);
|
);
|
||||||
|
|
||||||
private boolean sameWithoutOrientation(IBlockState first, IBlockState second) {
|
private boolean sameBlockstate(IBlockState first, IBlockState second) {
|
||||||
if (first.getBlock() != second.getBlock()) {
|
if (first.getBlock() != second.getBlock()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
boolean ignoreDirection = Baritone.settings().buildIgnoreDirection.value;
|
||||||
|
List<String> ignoredProps = Baritone.settings().buildIgnoreProperties.value;
|
||||||
|
if (!ignoreDirection && ignoredProps.isEmpty()) {
|
||||||
|
return first.equals(second); // early return if no properties are being ignored
|
||||||
|
}
|
||||||
ImmutableMap<IProperty<?>, Comparable<?>> map1 = first.getProperties();
|
ImmutableMap<IProperty<?>, Comparable<?>> map1 = first.getProperties();
|
||||||
ImmutableMap<IProperty<?>, Comparable<?>> map2 = second.getProperties();
|
ImmutableMap<IProperty<?>, Comparable<?>> map2 = second.getProperties();
|
||||||
for (IProperty<?> prop : map1.keySet()) {
|
for (IProperty<?> prop : map1.keySet()) {
|
||||||
if (map1.get(prop) != map2.get(prop) && !orientationProps.contains(prop)) {
|
if (map1.get(prop) != map2.get(prop)
|
||||||
|
&& !(ignoreDirection && orientationProps.contains(prop))
|
||||||
|
&& !ignoredProps.contains(prop.getName())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -913,7 +920,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
if (current.equals(desired)) {
|
if (current.equals(desired)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return Baritone.settings().buildIgnoreDirection.value && sameWithoutOrientation(current, desired);
|
return sameBlockstate(current, desired);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BuilderCalculationContext extends CalculationContext {
|
public class BuilderCalculationContext extends CalculationContext {
|
||||||
|
Loading…
Reference in New Issue
Block a user