Revert "Merge remote-tracking branch 'origin/master'"
This reverts commit3f57818c35, reversing changes made to4e28f711ed.
This commit is contained in:
@@ -5,82 +5,46 @@ import kaptainwutax.seedcracker.cracker.population.PopulationData;
|
||||
import kaptainwutax.seedcracker.util.Log;
|
||||
import kaptainwutax.seedcracker.util.Rand;
|
||||
import kaptainwutax.seedcracker.util.math.LCG;
|
||||
import net.minecraft.world.gen.ChunkRandom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class TimeMachine {
|
||||
|
||||
|
||||
private LCG inverseLCG = Rand.JAVA_LCG.combine(-2);
|
||||
public int THREAD_COUNT = 4;
|
||||
public ExecutorService SERVICE = Executors.newFixedThreadPool(THREAD_COUNT);
|
||||
|
||||
private boolean isRunning = false;
|
||||
|
||||
public TimeMachine() {
|
||||
|
||||
}
|
||||
|
||||
public List<Long> bruteforceRegion(int pillarSeed, int region, long size, List<StructureData> structureDataList, List<DecoratorData> decoratorDataList) {
|
||||
List<Long> result = new ArrayList<>();
|
||||
Rand rand = new Rand(0L);
|
||||
public List<Long> buildStructureSeeds(int pillarSeed, List<StructureData> structureDataList, List<PopulationData> populationDataList, List<Long> structureSeeds) {
|
||||
ChunkRandom chunkRandom = new ChunkRandom();
|
||||
|
||||
for(long i = 0; i < (1L << 32); i++) {
|
||||
if((i & ((1L << 28) - 1)) == 0) {
|
||||
Log.warn("Progress " + (i * 100.0f) / (1L << 32) + "%...");
|
||||
}
|
||||
|
||||
for(long i = start; i < end; i++) {
|
||||
long structureSeed = this.timeMachine(i, pillarSeed);
|
||||
boolean goodSeed = true;
|
||||
|
||||
for(StructureData structureData: structureDataList) {
|
||||
if(!goodSeed)break;
|
||||
if(!structureData.test(structureSeed, rand))goodSeed = false;
|
||||
chunkRandom.setStructureSeed(structureSeed, structureData.getRegionX(),
|
||||
structureData.getRegionZ(), structureData.getSalt());
|
||||
if(!structureData.test(chunkRandom))goodSeed = false;
|
||||
}
|
||||
|
||||
for(DecoratorData decoratorData : decoratorDataList) {
|
||||
for(PopulationData populationData: populationDataList) {
|
||||
if(!goodSeed)break;
|
||||
if(!decoratorData.test(structureSeed))goodSeed = false;
|
||||
if(!populationData.test(structureSeed))goodSeed = false;
|
||||
}
|
||||
|
||||
if(goodSeed) {
|
||||
result.add(structureSeed);
|
||||
structureSeeds.add(structureSeed);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Set<Long> buildStructureSeeds(int pillarSeed, List<StructureData> structureDataList, List<DecoratorData> decoratorDataList, Set<Long> structureSeeds) {
|
||||
if(this.isRunning) {
|
||||
throw new IllegalStateException("Time Machine is already running");
|
||||
}
|
||||
|
||||
this.isRunning = true;
|
||||
long size = (long)Math.ceil((double)(1L << 32) / THREAD_COUNT);
|
||||
AtomicInteger progress = new AtomicInteger();
|
||||
|
||||
for(int i = 0; i < THREAD_COUNT; i++) {
|
||||
int finalI = i;
|
||||
|
||||
SERVICE.submit(() -> {
|
||||
structureSeeds.addAll(this.bruteforceRegion(pillarSeed, finalI, size, structureDataList, decoratorDataList));
|
||||
Log.warn("Completed thread " + finalI + "!");
|
||||
progress.getAndIncrement();
|
||||
});
|
||||
}
|
||||
|
||||
while(progress.get() < THREAD_COUNT) {
|
||||
try {Thread.sleep(20);}
|
||||
catch(InterruptedException e) {e.printStackTrace();}
|
||||
}
|
||||
|
||||
this.isRunning = false;
|
||||
return structureSeeds;
|
||||
}
|
||||
|
||||
@@ -95,8 +59,4 @@ public class TimeMachine {
|
||||
return currentSeed;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
this.isRunning = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user