Search in sources :

Example 1 with Shipwreck

use of com.seedfinding.mcfeature.structure.Shipwreck 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();
}
Also used : OldStructure(com.seedfinding.mcfeature.structure.OldStructure) WorldSeed(com.seedfinding.mccore.rand.seed.WorldSeed) MCVersion(com.seedfinding.mccore.version.MCVersion) Xoroshiro128PlusPlusRandom(net.minecraft.util.math.random.Xoroshiro128PlusPlusRandom) StructureSeed(com.seedfinding.mccore.rand.seed.StructureSeed) ChunkRandom(net.minecraft.util.math.random.ChunkRandom) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) OverworldBiomeSource(com.seedfinding.mcbiome.source.OverworldBiomeSource) Shipwreck(com.seedfinding.mcfeature.structure.Shipwreck) Decorator(kaptainwutax.seedcrackerX.cracker.decorator.Decorator) Config(kaptainwutax.seedcrackerX.config.Config) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ChunkRand(com.seedfinding.mccore.rand.ChunkRand) BiomeData(kaptainwutax.seedcrackerX.cracker.BiomeData) PillarSeed(com.seedfinding.mccore.rand.seed.PillarSeed) ExecutorService(java.util.concurrent.ExecutorService) OldStructure(com.seedfinding.mcfeature.structure.OldStructure) LongStream(java.util.stream.LongStream) Database(kaptainwutax.seedcrackerX.util.Database) SeedCracker(kaptainwutax.seedcrackerX.SeedCracker) Set(java.util.Set) PillagerOutpost(com.seedfinding.mcfeature.structure.PillagerOutpost) Collectors(java.util.stream.Collectors) Feature(com.seedfinding.mcfeature.Feature) Executors(java.util.concurrent.Executors) UniformStructure(com.seedfinding.mcfeature.structure.UniformStructure) List(java.util.List) Stream(java.util.stream.Stream) Log(kaptainwutax.seedcrackerX.util.Log) LCG(com.seedfinding.mcseed.lcg.LCG) MinecraftClient(net.minecraft.client.MinecraftClient) Text(net.minecraft.text.Text) PillagerOutpost(com.seedfinding.mcfeature.structure.PillagerOutpost) ArrayList(java.util.ArrayList) BiomeData(kaptainwutax.seedcrackerX.cracker.BiomeData) UniformStructure(com.seedfinding.mcfeature.structure.UniformStructure) Feature(com.seedfinding.mcfeature.Feature) ChunkRand(com.seedfinding.mccore.rand.ChunkRand) Shipwreck(com.seedfinding.mcfeature.structure.Shipwreck) Decorator(kaptainwutax.seedcrackerX.cracker.decorator.Decorator)

Aggregations

OverworldBiomeSource (com.seedfinding.mcbiome.source.OverworldBiomeSource)1 ChunkRand (com.seedfinding.mccore.rand.ChunkRand)1 PillarSeed (com.seedfinding.mccore.rand.seed.PillarSeed)1 StructureSeed (com.seedfinding.mccore.rand.seed.StructureSeed)1 WorldSeed (com.seedfinding.mccore.rand.seed.WorldSeed)1 MCVersion (com.seedfinding.mccore.version.MCVersion)1 Feature (com.seedfinding.mcfeature.Feature)1 OldStructure (com.seedfinding.mcfeature.structure.OldStructure)1 PillagerOutpost (com.seedfinding.mcfeature.structure.PillagerOutpost)1 Shipwreck (com.seedfinding.mcfeature.structure.Shipwreck)1 UniformStructure (com.seedfinding.mcfeature.structure.UniformStructure)1 LCG (com.seedfinding.mcseed.lcg.LCG)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors (java.util.concurrent.Executors)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Collectors (java.util.stream.Collectors)1