Merge pull request #3697 from ZacSharp/pr/buildIgnoreProperties

 Add buildIgnoreProperties setting
This commit is contained in:
Leijurv 2022-10-31 12:28:44 -07:00 committed by GitHub
commit 3a945c8c10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -279,6 +279,12 @@ public final class Settings {
*/
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.
* <p>

View File

@ -874,14 +874,21 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
BlockTrapDoor.OPEN, BlockTrapDoor.HALF
);
private boolean sameWithoutOrientation(IBlockState first, IBlockState second) {
private boolean sameBlockstate(IBlockState first, IBlockState second) {
if (first.getBlock() != second.getBlock()) {
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<?>> map2 = second.getProperties();
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;
}
}
@ -913,7 +920,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
if (current.equals(desired)) {
return true;
}
return Baritone.settings().buildIgnoreDirection.value && sameWithoutOrientation(current, desired);
return sameBlockstate(current, desired);
}
public class BuilderCalculationContext extends CalculationContext {