Merge pull request #3159 from Entropy5/master

Better buildignoredirection
This commit is contained in:
Leijurv 2021-12-23 11:21:44 -10:00 committed by GitHub
commit 7a96772a9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 12 deletions

View File

@ -56,9 +56,9 @@ For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see de
For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge or Fabric 1.16.5, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.3) and get the `api-forge` or `api-fabric` jar. **For 1.16.5 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.6.3/baritone-api-fabric-1.6.3.jar)**.
For 1.17.1 leijurv is to lazy to actually create a release so you can login to github and download the jars in the `artifacts` zip [here](https://github.com/cabaletta/baritone/actions/runs/1451572684)
For 1.17.1 leijurv is too lazy to actually create a release so you can login to github and download the jars in the `artifacts` zip [here](https://github.com/cabaletta/baritone/actions/runs/1451572684)
For 1.18.1 leijurv is to lazy to actually create a release so you can login to github and download the jars in the `artifacts` zip [here](https://github.com/cabaletta/baritone/actions/runs/1472825778)
For 1.18.1 leijurv is too lazy to actually create a release so you can login to github and download the jars in the `artifacts` zip [here](https://github.com/cabaletta/baritone/actions/runs/1472825778)
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 through 1.16.5. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).

View File

@ -45,12 +45,11 @@ import baritone.utils.schematic.MapArtSchematic;
import baritone.utils.schematic.SelectionSchematic;
import baritone.utils.schematic.SchematicSystem;
import baritone.utils.schematic.schematica.SchematicaHelper;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import net.minecraft.block.BlockAir;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.BlockGlazedTerracotta;
import net.minecraft.block.BlockBone;
import net.minecraft.block.BlockHay;
import net.minecraft.block.*;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemBlock;
@ -835,14 +834,31 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
return result;
}
public static final Set<IProperty<?>> orientationProps =
ImmutableSet.of(BlockRotatedPillar.AXIS, BlockLog.LOG_AXIS, BlockHorizontal.FACING,
BlockStairs.FACING, BlockStairs.HALF, BlockStairs.SHAPE,
BlockPane.NORTH, BlockPane.EAST, BlockPane.SOUTH, BlockPane.WEST, BlockVine.UP,
BlockTrapDoor.OPEN, BlockTrapDoor.HALF
);
private boolean sameWithoutOrientation(IBlockState first, IBlockState second) {
if (first.getBlock() != second.getBlock()) {
return false;
}
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)) {
return false;
}
}
return true;
}
private boolean valid(IBlockState current, IBlockState desired, boolean itemVerify) {
if (desired == null) {
return true;
}
if (Baritone.settings().buildIgnoreDirection.value && current.getBlock() == desired.getBlock() &&
(current.getBlock() instanceof BlockGlazedTerracotta || current.getBlock() instanceof BlockBone || current.getBlock() instanceof BlockHay)) {
return true;
}
if (current.getBlock() instanceof BlockLiquid && Baritone.settings().okIfWater.value) {
return true;
}
@ -861,7 +877,10 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
if (Baritone.settings().buildValidSubstitutes.value.getOrDefault(desired.getBlock(), Collections.emptyList()).contains(current.getBlock()) && !itemVerify) {
return true;
}
return current.equals(desired);
if (current.equals(desired)) {
return true;
}
return Baritone.settings().buildIgnoreDirection.value && sameWithoutOrientation(current, desired);
}
public class BuilderCalculationContext extends CalculationContext {