use of com.seedfinding.mcfeature.structure.OldStructure in project SeedcrackerX by 19MisterX98.
the class TimeMachine method pokeLifting.
protected boolean pokeLifting() {
if (!this.structureSeeds.isEmpty() || this.dataStorage.getLiftingBits() < 40F)
return false;
List<UniformStructure.Data<?>> dataList = new ArrayList<>();
for (DataStorage.Entry<Feature.Data<?>> e : this.dataStorage.baseSeedData) {
if (e.data.feature instanceof OldStructure || e.data.feature instanceof Shipwreck) {
dataList.add((UniformStructure.Data<?>) e.data);
}
}
List<Feature.Data<?>> cache = new ArrayList<>();
for (DataStorage.Entry<Feature.Data<?>> entry : this.dataStorage.baseSeedData) {
if (!(entry.data.feature instanceof Decorator) || entry.data.feature.getVersion().isOlderThan(MCVersion.v1_18)) {
if (!(entry.data.feature instanceof PillagerOutpost)) {
cache.add(entry.data);
}
}
}
Log.warn("tmachine.startLifting", dataList.size());
// You could first lift on 1L<<18 with %2 since that would be a smaller range
// Then lift on 1<<19 with those 1<<18 fixed with % 4 and for nextInt(24)
// You can even do %8 on 1<<20 (however we included shipwreck so only nextInt(20) so 1<<19 is the max here
Stream<Long> lowerBitsStream = LongStream.range(0, 1L << 19).boxed().filter(lowerBits -> {
ChunkRand rand = new ChunkRand();
for (UniformStructure.Data<?> data : dataList) {
rand.setRegionSeed(lowerBits, data.regionX, data.regionZ, data.feature.getSalt(), Config.get().getVersion());
if (rand.nextInt(((UniformStructure<?>) data.feature).getOffset()) % 4 != data.offsetX % 4 || rand.nextInt(((UniformStructure<?>) data.feature).getOffset()) % 4 != data.offsetZ % 4) {
return false;
}
}
return true;
});
Stream<Long> seedStream = lowerBitsStream.flatMap(lowerBits -> LongStream.range(0, 1L << (48 - 19)).boxed().map(upperBits -> (upperBits << 19) | lowerBits));
Stream<Long> strutureSeedStream = seedStream.filter(seed -> {
ChunkRand rand = new ChunkRand();
for (Feature.Data<?> data : cache) {
if (!data.testStart(seed, rand)) {
return false;
}
}
return true;
});
this.structureSeeds = strutureSeedStream.parallel().collect(Collectors.toSet());
if (!this.structureSeeds.isEmpty()) {
Log.warn("tmachine.structureSeedSearchFinished");
} else {
Log.error("finishedSearchNoResult");
}
return !this.structureSeeds.isEmpty();
}
Aggregations