Search in sources :

Example 1 with PillagerOutpost

use of com.seedfinding.mcfeature.structure.PillagerOutpost 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)

Example 2 with PillagerOutpost

use of com.seedfinding.mcfeature.structure.PillagerOutpost in project SeedcrackerX by 19MisterX98.

the class TimeMachine method pokeStructures.

protected boolean pokeStructures() {
    if (this.pillarSeeds == null || !this.structureSeeds.isEmpty() || this.dataStorage.getBaseBits() < this.dataStorage.getWantedBits())
        return false;
    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);
            }
        }
    }
    for (int pillarSeed : this.pillarSeeds) {
        Log.debug("====================================");
        Log.warn("tmachine.lookingForStructureSeeds", pillarSeed);
        AtomicInteger completion = new AtomicInteger();
        ProgressListener progressListener = new ProgressListener();
        for (int threadId = 0; threadId < 4; threadId++) {
            int fThreadId = threadId;
            SERVICE.submit(() -> {
                ChunkRand rand = new ChunkRand();
                long lower = (long) fThreadId * (1L << 30);
                long upper = (long) (fThreadId + 1) * (1L << 30);
                for (long partialWorldSeed = lower; partialWorldSeed < upper && !this.shouldTerminate; partialWorldSeed++) {
                    if ((partialWorldSeed & ((1 << 27) - 1)) == 0) {
                        progressListener.addPercent(3.125F, true);
                    }
                    long seed = this.timeMachine(partialWorldSeed, pillarSeed);
                    boolean matches = true;
                    for (Feature.Data<?> baseSeedDatum : cache) {
                        if (!baseSeedDatum.testStart(seed, rand)) {
                            matches = false;
                            break;
                        }
                    }
                    if (matches) {
                        this.structureSeeds.add(seed);
                        Log.printSeed("foundStructureSeed", seed);
                    }
                }
                completion.getAndIncrement();
            });
        }
        while (completion.get() != 4) {
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (this.shouldTerminate) {
                return false;
            }
        }
        progressListener.addPercent(0.0F, true);
    }
    if (!this.structureSeeds.isEmpty()) {
        Log.warn("tmachine.structureSeedSearchFinished");
    } else {
        Log.error("finishedSearchNoResult");
    }
    return true;
}
Also used : PillagerOutpost(com.seedfinding.mcfeature.structure.PillagerOutpost) ArrayList(java.util.ArrayList) BiomeData(kaptainwutax.seedcrackerX.cracker.BiomeData) Feature(com.seedfinding.mcfeature.Feature) ChunkRand(com.seedfinding.mccore.rand.ChunkRand) Decorator(kaptainwutax.seedcrackerX.cracker.decorator.Decorator) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Example 3 with PillagerOutpost

use of com.seedfinding.mcfeature.structure.PillagerOutpost in project SeedcrackerX by 19MisterX98.

the class TimeMachine method pokeStructureReduce.

protected boolean pokeStructureReduce() {
    if (shouldTerminate)
        return false;
    if (!this.worldSeeds.isEmpty() || this.structureSeeds.size() < 2)
        return false;
    if (Config.get().getVersion().isOlderThan(MCVersion.v1_13))
        return false;
    Set<Long> result = new HashSet<>();
    Log.debug("====================================");
    Log.warn("tmachine.reduceSeeds", this.structureSeeds.size());
    if (this.pillarSeeds != null) {
        structureSeeds.forEach(seed -> {
            if (this.pillarSeeds.contains((int) PillarSeed.fromStructureSeed(seed))) {
                result.add(seed);
            }
        });
    }
    if (result.size() != 1) {
        this.dataStorage.baseSeedData.dump();
        this.dataStorage.baseSeedData.getBaseSet().removeIf(dataEntry -> !dataEntry.data.feature.getVersion().equals(Config.get().getVersion()));
        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)) {
                // todo remove this when libs are updated
                if (!(entry.data.feature instanceof PillagerOutpost)) {
                    cache.add(entry.data);
                }
            }
        }
        ChunkRand rand = new ChunkRand();
        for (Long seed : this.structureSeeds) {
            boolean matches = true;
            for (Feature.Data<?> baseSeedDatum : cache) {
                if (!baseSeedDatum.testStart(seed, rand)) {
                    matches = false;
                    break;
                }
            }
            if (matches) {
                result.add(seed);
            }
        }
    }
    if (!result.isEmpty() && this.structureSeeds.size() > result.size()) {
        if (result.size() < 10) {
            result.forEach(seed -> Log.printSeed("foundStructureSeed", seed));
        } else {
            Log.warn("tmachine.succeedReducing", result.size());
        }
        this.structureSeeds = result;
        return true;
    } else {
        Log.warn("tmachine.failedReducing");
    }
    return false;
}
Also used : PillagerOutpost(com.seedfinding.mcfeature.structure.PillagerOutpost) ArrayList(java.util.ArrayList) BiomeData(kaptainwutax.seedcrackerX.cracker.BiomeData) Feature(com.seedfinding.mcfeature.Feature) ChunkRand(com.seedfinding.mccore.rand.ChunkRand) Decorator(kaptainwutax.seedcrackerX.cracker.decorator.Decorator) HashSet(java.util.HashSet)

Aggregations

ChunkRand (com.seedfinding.mccore.rand.ChunkRand)3 Feature (com.seedfinding.mcfeature.Feature)3 PillagerOutpost (com.seedfinding.mcfeature.structure.PillagerOutpost)3 ArrayList (java.util.ArrayList)3 BiomeData (kaptainwutax.seedcrackerX.cracker.BiomeData)3 Decorator (kaptainwutax.seedcrackerX.cracker.decorator.Decorator)3 HashSet (java.util.HashSet)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 OverworldBiomeSource (com.seedfinding.mcbiome.source.OverworldBiomeSource)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 OldStructure (com.seedfinding.mcfeature.structure.OldStructure)1 Shipwreck (com.seedfinding.mcfeature.structure.Shipwreck)1 UniformStructure (com.seedfinding.mcfeature.structure.UniformStructure)1 LCG (com.seedfinding.mcseed.lcg.LCG)1 List (java.util.List)1 Set (java.util.Set)1 ExecutorService (java.util.concurrent.ExecutorService)1