Generator changes
This commit is contained in:
parent
8f08c310aa
commit
84e26e1f5c
3 changed files with 24 additions and 5 deletions
|
@ -10,7 +10,7 @@ import net.minecraft.util.registry.BuiltinRegistries;
|
|||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BuiltinBiomes;
|
||||
import net.minecraft.world.biome.BiomeKeys;
|
||||
import ru.betterend.world.biome.BiomeDefinition;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
import ru.betterend.world.generator.BiomePicker;
|
||||
|
@ -19,19 +19,30 @@ public class BiomeRegistry {
|
|||
private static final Map<EndBiome, RegistryKey<Biome>> KEYS = Maps.newHashMap();
|
||||
public static final HashMap<Biome, EndBiome> MUTABLE = Maps.newHashMap();
|
||||
|
||||
public static final EndBiome END = registerBiome(BuiltinBiomes.PLAINS);
|
||||
public static final EndBiome END = registerBiome(BiomeKeys.THE_END);
|
||||
public static final EndBiome END_BARRENS = registerBiome(BiomeKeys.END_BARRENS);
|
||||
public static final EndBiome END_HIGHLANDS = registerBiome(BiomeKeys.END_HIGHLANDS);
|
||||
public static final EndBiome END_MIDLANDS = registerBiome(BiomeKeys.END_MIDLANDS);
|
||||
public static final EndBiome SMALL_END_ISLANDS = registerBiome(BiomeKeys.SMALL_END_ISLANDS);
|
||||
public static final EndBiome TEST = registerBiome(new EndBiome(new BiomeDefinition("test").setFogColor(255, 0, 0)));
|
||||
|
||||
public static void register() {}
|
||||
|
||||
private static EndBiome registerBiome(Biome biome) {
|
||||
public static EndBiome registerBiome(RegistryKey<Biome> key) {
|
||||
EndBiome endBiome = new EndBiome(BuiltinRegistries.BIOME.get(key));
|
||||
BiomePicker.addBiome(endBiome);
|
||||
makeLink(endBiome);
|
||||
return endBiome;
|
||||
}
|
||||
|
||||
public static EndBiome registerBiome(Biome biome) {
|
||||
EndBiome endBiome = new EndBiome(biome);
|
||||
BiomePicker.addBiome(endBiome);
|
||||
makeLink(endBiome);
|
||||
return endBiome;
|
||||
}
|
||||
|
||||
private static EndBiome registerBiome(EndBiome biome) {
|
||||
public static EndBiome registerBiome(EndBiome biome) {
|
||||
BiomePicker.addBiome(biome);
|
||||
registerBiomeDirect(biome);
|
||||
return biome;
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.util.Identifier;
|
|||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryLookupCodec;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BiomeKeys;
|
||||
import net.minecraft.world.biome.source.BiomeSource;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.registry.BiomeRegistry;
|
||||
|
@ -25,12 +26,14 @@ public class BetterEndBiomeSource extends BiomeSource {
|
|||
private BiomeMap map;
|
||||
private final long seed;
|
||||
private final Registry<Biome> biomeRegistry;
|
||||
private final Biome centerBiome;
|
||||
|
||||
public BetterEndBiomeSource(Registry<Biome> biomeRegistry, long seed) {
|
||||
super(Collections.emptyList());
|
||||
this.seed = seed;
|
||||
this.map = new BiomeMap(seed, 50);
|
||||
this.biomeRegistry = biomeRegistry;
|
||||
this.centerBiome = biomeRegistry.getOrThrow(BiomeKeys.THE_END);
|
||||
|
||||
BiomeRegistry.MUTABLE.clear();
|
||||
for (EndBiome biome : BiomePicker.getBiomes())
|
||||
|
@ -39,6 +42,10 @@ public class BetterEndBiomeSource extends BiomeSource {
|
|||
|
||||
@Override
|
||||
public Biome getBiomeForNoiseGen(int biomeX, int biomeY, int biomeZ) {
|
||||
long i = biomeX >> 2;
|
||||
long j = biomeZ >> 2;
|
||||
if (i * i + j * j <= 4096L) return this.centerBiome;
|
||||
|
||||
EndBiome netherBiome = map.getBiome(biomeX << 2, biomeZ << 2);
|
||||
if (biomeX == 0 && biomeZ == 0) {
|
||||
map.clearCache();
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Random;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import ru.betterend.registry.BiomeRegistry;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
|
||||
public class BiomePicker {
|
||||
|
@ -21,7 +22,7 @@ public class BiomePicker {
|
|||
for (EndBiome biome: BIOMES)
|
||||
if (biome.canGenerate(chance))
|
||||
return biome;
|
||||
return null;
|
||||
return BiomeRegistry.END;
|
||||
}
|
||||
|
||||
public static List<EndBiome> getBiomes() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue