mirror of https://github.com/cabaletta/baritone
fix stream limit. immutable's in BOML
This commit is contained in:
parent
c04eb066cb
commit
98a748afb3
|
@ -41,8 +41,8 @@ public final class BlockOptionalMeta {
|
|||
private final int meta;
|
||||
private final boolean noMeta;
|
||||
private final Set<IBlockState> blockstates;
|
||||
private final ImmutableSet<Integer> stateHashes;
|
||||
private final ImmutableSet<Integer> stackHashes;
|
||||
private final Set<Integer> stateHashes;
|
||||
private final Set<Integer> stackHashes;
|
||||
private static final Pattern pattern = Pattern.compile("^(.+?)(?::(\\d+))?$");
|
||||
private static final Map<Object, Object> normalizations;
|
||||
|
||||
|
@ -319,4 +319,8 @@ public final class BlockOptionalMeta {
|
|||
public Set<IBlockState> getAllBlockStates() {
|
||||
return blockstates;
|
||||
}
|
||||
|
||||
public Set<Integer> stackHashes() {
|
||||
return stackHashes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package baritone.api.utils;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -28,34 +29,41 @@ import java.util.Set;
|
|||
import java.util.stream.Stream;
|
||||
|
||||
public class BlockOptionalMetaLookup {
|
||||
private final Set<Block> blockSet = new HashSet<>();
|
||||
private final Set<IBlockState> blockStateSet = new HashSet<>();
|
||||
private final Set<Block> blockSet;
|
||||
private final Set<IBlockState> blockStateSet;
|
||||
private final BlockOptionalMeta[] boms;
|
||||
|
||||
public BlockOptionalMetaLookup(BlockOptionalMeta... boms) {
|
||||
this.boms = boms;
|
||||
Set<Block> blocks = new HashSet<>();
|
||||
Set<IBlockState> blockStates = new HashSet<>();
|
||||
Set<Integer> stacks = new HashSet<>();
|
||||
for (BlockOptionalMeta bom : boms) {
|
||||
blockSet.add(bom.getBlock());
|
||||
blockStateSet.addAll(bom.getAllBlockStates());
|
||||
blocks.add(bom.getBlock());
|
||||
blockStates.addAll(bom.getAllBlockStates());
|
||||
stacks.addAll(bom.stackHashes());
|
||||
}
|
||||
this.blockSet = ImmutableSet.copyOf(blocks);
|
||||
this.blockStateSet = ImmutableSet.copyOf(blockStates);
|
||||
}
|
||||
|
||||
public BlockOptionalMetaLookup(Block... blocks) {
|
||||
this.boms = Stream.of(blocks)
|
||||
this(Stream.of(blocks)
|
||||
.map(BlockOptionalMeta::new)
|
||||
.toArray(BlockOptionalMeta[]::new);
|
||||
.toArray(BlockOptionalMeta[]::new));
|
||||
|
||||
}
|
||||
|
||||
public BlockOptionalMetaLookup(List<Block> blocks) {
|
||||
this.boms = blocks.stream()
|
||||
this(blocks.stream()
|
||||
.map(BlockOptionalMeta::new)
|
||||
.toArray(BlockOptionalMeta[]::new);
|
||||
.toArray(BlockOptionalMeta[]::new));
|
||||
}
|
||||
|
||||
public BlockOptionalMetaLookup(String... blocks) {
|
||||
this.boms = Stream.of(blocks)
|
||||
this(Stream.of(blocks)
|
||||
.map(BlockOptionalMeta::new)
|
||||
.toArray(BlockOptionalMeta[]::new);
|
||||
.toArray(BlockOptionalMeta[]::new));
|
||||
}
|
||||
|
||||
public boolean has(Block block) {
|
||||
|
|
|
@ -55,7 +55,11 @@ public enum FasterWorldScanner implements IWorldScanner {
|
|||
|
||||
@Override
|
||||
public List<BlockPos> scanChunk(IPlayerContext ctx, BlockOptionalMetaLookup filter, ChunkPos pos, int max, int yLevelThreshold) {
|
||||
return scanChunkInternal(ctx, filter, pos).limit(max).collect(Collectors.toList());
|
||||
Stream<BlockPos> stream = scanChunkInternal(ctx, filter, pos);
|
||||
if (max >= 0) {
|
||||
stream = stream.limit(max);
|
||||
}
|
||||
return stream.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue