mirror of https://github.com/cabaletta/baritone
tweaks
This commit is contained in:
parent
56d109bf0a
commit
14bc65468a
|
@ -17,12 +17,13 @@
|
||||||
|
|
||||||
package baritone.utils;
|
package baritone.utils;
|
||||||
|
|
||||||
import java.util.OptionalInt;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
|
import java.util.OptionalInt;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class MapArtSchematic extends Schematic {
|
public class MapArtSchematic extends Schematic {
|
||||||
private final int[][] heightMap;
|
private final int[][] heightMap;
|
||||||
|
|
||||||
|
@ -34,7 +35,7 @@ public class MapArtSchematic extends Schematic {
|
||||||
for (int z = 0; z < lengthZ; z++) {
|
for (int z = 0; z < lengthZ; z++) {
|
||||||
IBlockState[] column = states[x][z];
|
IBlockState[] column = states[x][z];
|
||||||
|
|
||||||
OptionalInt lowestBlockY = getLowest(column, block -> block != Blocks.AIR);
|
OptionalInt lowestBlockY = lastIndexMatching(column, block -> block != Blocks.AIR);
|
||||||
if (lowestBlockY.isPresent()) {
|
if (lowestBlockY.isPresent()) {
|
||||||
heightMap[x][z] = lowestBlockY.getAsInt();
|
heightMap[x][z] = lowestBlockY.getAsInt();
|
||||||
} else {
|
} else {
|
||||||
|
@ -47,7 +48,7 @@ public class MapArtSchematic extends Schematic {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> OptionalInt getLowest(T[] arr, Predicate<T> predicate) {
|
private static <T> OptionalInt lastIndexMatching(T[] arr, Predicate<T> predicate) {
|
||||||
for (int y = arr.length - 1; y >= 0; y--) {
|
for (int y = arr.length - 1; y >= 0; y--) {
|
||||||
if (predicate.test(arr[y])) {
|
if (predicate.test(arr[y])) {
|
||||||
return OptionalInt.of(y);
|
return OptionalInt.of(y);
|
||||||
|
|
Loading…
Reference in New Issue