updated to 1.15 biome logic

This commit is contained in:
Unknown
2019-12-12 18:07:30 -05:00
parent 85ec24e4a2
commit 9b50dcf874
3 changed files with 63 additions and 28 deletions
@@ -1,38 +1,31 @@
package kaptainwutax.seedcracker;
import com.google.common.collect.Lists;
import kaptainwutax.seedcracker.cracker.*;
import kaptainwutax.seedcracker.cracker.population.PopulationData;
import kaptainwutax.seedcracker.finder.FinderQueue;
import kaptainwutax.seedcracker.render.RenderQueue;
import kaptainwutax.seedcracker.util.Rand;
import net.fabricmc.api.ModInitializer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockBox;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MutableIntBoundingBox;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.biome.layer.BiomeLayerSampler;
import net.minecraft.world.biome.layer.BiomeLayers;
import net.minecraft.world.biome.source.BiomeSourceType;
import net.minecraft.world.biome.source.VoronoiBiomeAccessType;
import net.minecraft.world.gen.ChunkRandom;
import net.minecraft.world.gen.chunk.OverworldChunkGeneratorConfig;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.StrongholdFeature;
import net.minecraft.world.level.LevelGeneratorType;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
public class SeedCracker implements ModInitializer {
public static final Logger LOG = LogManager.getLogger("Seed Cracker");
private static final SeedCracker INSTANCE = new SeedCracker();
public static final OverworldChunkGeneratorConfig CHUNK_GEN_CONFIG = new OverworldChunkGeneratorConfig();
public List<Long> worldSeeds = null;
public List<Long> structureSeeds = null;
public List<Integer> pillarSeeds = null;
@@ -46,6 +39,10 @@ public class SeedCracker implements ModInitializer {
public void onInitialize() {
RenderQueue.get().add("hand", FinderQueue.get()::renderFinders);
DecoratorCache.get().initialize();
FakeBiomeSource fakeBiomeSource = new FakeBiomeSource(3698703115574076237L);
System.out.println(VoronoiBiomeAccessType.INSTANCE.getBiome(3698703115574076237L, -176,0, -266, fakeBiomeSource));
/*
System.out.println("FETCHING SEEDS============");
long structureSeed = 29131954246896L;
@@ -89,7 +86,7 @@ public class SeedCracker implements ModInitializer {
}
private void checkWorldSeed(long worldSeed, ChunkPos pos) {
StrongholdFeature.Start start = new StrongholdFeature.Start(Feature.STRONGHOLD, pos.x, pos.z, Biomes.PLAINS, MutableIntBoundingBox.empty(), 0, worldSeed);
StrongholdFeature.Start start = new StrongholdFeature.Start(Feature.STRONGHOLD, pos.x, pos.z, BlockBox.empty(), 0, worldSeed);
}
public static SeedCracker get() {
@@ -142,7 +139,7 @@ public class SeedCracker implements ModInitializer {
});
if(this.structureSeeds.size() > 0) {
LOG.warn("Finished search with " + this.structureSeeds.size() + (this.structureSeeds.size() == 1 ? " seed." : " seeds."));
LOG.warn("Finished search with " + this.structureSeeds + (this.structureSeeds.size() == 1 ? " seed." : " seeds."));
} else {
LOG.error("Finished search with no seeds.");
}
@@ -151,6 +148,8 @@ public class SeedCracker implements ModInitializer {
this.onPopulationData(null);
this.onBiomeData(null);
} else if(this.structureSeeds != null && structureData != null) {
System.out.println(this.structureSeeds);
System.out.println(this.biomeCache);
this.structureSeeds.removeIf(structureSeed -> {
ChunkRandom chunkRandom = new ChunkRandom();
chunkRandom.setStructureSeed(structureSeed, structureData.getRegionX(), structureData.getRegionZ(), structureData.getSalt());
@@ -195,11 +194,11 @@ public class SeedCracker implements ModInitializer {
for (long j = 0; j < (1L << 16); j++) {
long worldSeed = (j << 48) | structureSeed;
boolean goodSeed = true;
BiomeLayerSampler sampler = BiomeLayers.build(worldSeed, LevelGeneratorType.DEFAULT,
BiomeSourceType.VANILLA_LAYERED.getConfig().getGeneratorSettings())[1];
FakeBiomeSource fakeBiomeSource = new FakeBiomeSource(worldSeed);
for(BiomeData data : this.biomeCache) {
if (!data.test(worldSeed, sampler)) {
if (!data.test(worldSeed, fakeBiomeSource)) {
goodSeed = false;
break;
}
@@ -218,16 +217,14 @@ public class SeedCracker implements ModInitializer {
}
} else if(this.worldSeeds != null && biomeData != null) {
this.worldSeeds.removeIf(worldSeed -> {
BiomeLayerSampler sampler = BiomeLayers.build(worldSeed, LevelGeneratorType.DEFAULT,
BiomeSourceType.VANILLA_LAYERED.getConfig().getGeneratorSettings())[1];
return !biomeData.test(worldSeed, sampler);
FakeBiomeSource fakeBiomeSource = new FakeBiomeSource(worldSeed);
return !biomeData.test(worldSeed, fakeBiomeSource);
});
} else if(this.worldSeeds != null) {
this.worldSeeds.removeIf(worldSeed -> {
for(BiomeData data: this.biomeCache) {
BiomeLayerSampler sampler = BiomeLayers.build(worldSeed, LevelGeneratorType.DEFAULT,
BiomeSourceType.VANILLA_LAYERED.getConfig().getGeneratorSettings())[1];
if(!biomeData.test(worldSeed, sampler))return true;
FakeBiomeSource fakeBiomeSource = new FakeBiomeSource(worldSeed);
if(!data.test(worldSeed, fakeBiomeSource))return true;
}
return false;
@@ -285,6 +282,7 @@ public class SeedCracker implements ModInitializer {
writer.close();*/
}
/*
private static List<ChunkPos> initialize(long worldSeed) {
BiomeLayerSampler sampler = BiomeLayers.build(worldSeed, LevelGeneratorType.DEFAULT,
BiomeSourceType.VANILLA_LAYERED.getConfig().getGeneratorSettings())[0];
@@ -321,8 +319,10 @@ public class SeedCracker implements ModInitializer {
}
return startPositions;
}
}./
//CHECK NEW 1.15 SAMPLER
/*
public static BlockPos locateBiome(BiomeLayerSampler sampler, int x, int z, int size, List<Biome> validBiomes, Random rand) {
int int_4 = x - size >> 2;
int int_5 = z - size >> 2;
@@ -347,6 +347,6 @@ public class SeedCracker implements ModInitializer {
}
return pos;
}
}*/
}
@@ -3,7 +3,7 @@ package kaptainwutax.seedcracker.cracker;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.layer.BiomeLayerSampler;
import net.minecraft.world.biome.source.VoronoiBiomeAccessType;
public class BiomeData {
@@ -25,8 +25,8 @@ public class BiomeData {
this(x, z, Registry.BIOME.get(biomeId));
}
public boolean test(long worldSeed, BiomeLayerSampler sampler) {
return sampler.sample(this.x, this.z) == this.biome;
public boolean test(long worldSeed, FakeBiomeSource source) {
return VoronoiBiomeAccessType.INSTANCE.getBiome(worldSeed, this.x,0, this.z, source) == this.biome;
}
@Override
@@ -0,0 +1,35 @@
package kaptainwutax.seedcracker.cracker;
import com.google.common.collect.ImmutableSet;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.biome.layer.BiomeLayers;
import net.minecraft.world.biome.source.BiomeLayerSampler;
import net.minecraft.world.biome.source.BiomeSource;
import net.minecraft.world.gen.chunk.OverworldChunkGeneratorConfig;
import net.minecraft.world.level.LevelGeneratorType;
import java.util.Set;
public class FakeBiomeSource extends BiomeSource {
public static final OverworldChunkGeneratorConfig CHUNK_GEN_CONFIG = new OverworldChunkGeneratorConfig();
private static final Set<Biome> BIOMES;
private final BiomeLayerSampler biomeSampler;
public FakeBiomeSource(long worldSeed) {
super(BIOMES);
this.biomeSampler = BiomeLayers.build(worldSeed, LevelGeneratorType.DEFAULT, CHUNK_GEN_CONFIG);
}
@Override
public Biome getBiomeForNoiseGen(int biomeX, int biomeY, int biomeZ) {
return this.biomeSampler.sample(biomeX, biomeZ);
}
static {
BIOMES = ImmutableSet.<Biome>of(Biomes.OCEAN, Biomes.PLAINS, Biomes.DESERT, Biomes.MOUNTAINS, Biomes.FOREST, Biomes.TAIGA, Biomes.SWAMP, Biomes.RIVER, Biomes.FROZEN_OCEAN, Biomes.FROZEN_RIVER, Biomes.SNOWY_TUNDRA, Biomes.SNOWY_MOUNTAINS, Biomes.MUSHROOM_FIELDS, Biomes.MUSHROOM_FIELD_SHORE, Biomes.BEACH, Biomes.DESERT_HILLS, Biomes.WOODED_HILLS, Biomes.TAIGA_HILLS, Biomes.MOUNTAIN_EDGE, Biomes.JUNGLE, Biomes.JUNGLE_HILLS, Biomes.JUNGLE_EDGE, Biomes.DEEP_OCEAN, Biomes.STONE_SHORE, Biomes.SNOWY_BEACH, Biomes.BIRCH_FOREST, Biomes.BIRCH_FOREST_HILLS, Biomes.DARK_FOREST, Biomes.SNOWY_TAIGA, Biomes.SNOWY_TAIGA_HILLS, Biomes.GIANT_TREE_TAIGA, Biomes.GIANT_TREE_TAIGA_HILLS, Biomes.WOODED_MOUNTAINS, Biomes.SAVANNA, Biomes.SAVANNA_PLATEAU, Biomes.BADLANDS, Biomes.WOODED_BADLANDS_PLATEAU, Biomes.BADLANDS_PLATEAU, Biomes.WARM_OCEAN, Biomes.LUKEWARM_OCEAN, Biomes.COLD_OCEAN, Biomes.DEEP_WARM_OCEAN, Biomes.DEEP_LUKEWARM_OCEAN, Biomes.DEEP_COLD_OCEAN, Biomes.DEEP_FROZEN_OCEAN, Biomes.SUNFLOWER_PLAINS, Biomes.DESERT_LAKES, Biomes.GRAVELLY_MOUNTAINS, Biomes.FLOWER_FOREST, Biomes.TAIGA_MOUNTAINS, Biomes.SWAMP_HILLS, Biomes.ICE_SPIKES, Biomes.MODIFIED_JUNGLE, Biomes.MODIFIED_JUNGLE_EDGE, Biomes.TALL_BIRCH_FOREST, Biomes.TALL_BIRCH_HILLS, Biomes.DARK_FOREST_HILLS, Biomes.SNOWY_TAIGA_MOUNTAINS, Biomes.GIANT_SPRUCE_TAIGA, Biomes.GIANT_SPRUCE_TAIGA_HILLS, Biomes.MODIFIED_GRAVELLY_MOUNTAINS, Biomes.SHATTERED_SAVANNA, Biomes.SHATTERED_SAVANNA_PLATEAU, Biomes.ERODED_BADLANDS, Biomes.MODIFIED_WOODED_BADLANDS_PLATEAU, Biomes.MODIFIED_BADLANDS_PLATEAU);
}
}