mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 00:15:35 +00:00
update platform biome delegate logic
This commit is contained in:
parent
73af05bf09
commit
c90ca076ab
@ -18,6 +18,7 @@
|
||||
package com.dfsek.terra.mod.config;
|
||||
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
@ -31,7 +32,7 @@ import com.dfsek.terra.mod.util.MinecraftUtil;
|
||||
public class ProtoPlatformBiome implements PlatformBiome {
|
||||
private final Identifier identifier;
|
||||
|
||||
private RegistryKey<Biome> delegate;
|
||||
private RegistryEntry<Biome> delegate;
|
||||
|
||||
public ProtoPlatformBiome(Identifier identifier) {
|
||||
this.identifier = identifier;
|
||||
@ -46,11 +47,11 @@ public class ProtoPlatformBiome implements PlatformBiome {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public RegistryKey<Biome> getDelegate() {
|
||||
public RegistryEntry<Biome> getDelegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public void setDelegate(RegistryKey<Biome> delegate) {
|
||||
public void setDelegate(RegistryEntry<Biome> delegate) {
|
||||
this.delegate = Objects.requireNonNull(delegate);
|
||||
}
|
||||
}
|
||||
|
@ -35,10 +35,7 @@ public final class Codecs {
|
||||
id)))));
|
||||
|
||||
public static final Codec<TerraBiomeSource> TERRA_BIOME_SOURCE = RecordCodecBuilder
|
||||
.create(instance -> instance.group(RegistryOps.getEntryCodec(RegistryKeys.BIOME)
|
||||
.fieldOf("biome_registry")
|
||||
.stable()
|
||||
.forGetter(TerraBiomeSource::getBiomeRegistry),
|
||||
.create(instance -> instance.group(
|
||||
CONFIG_PACK.fieldOf("pack")
|
||||
.stable()
|
||||
.forGetter(TerraBiomeSource::getPack))
|
||||
|
@ -38,16 +38,14 @@ import com.dfsek.terra.mod.util.SeedHack;
|
||||
public class TerraBiomeSource extends BiomeSource {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TerraBiomeSource.class);
|
||||
private final Registry<net.minecraft.world.biome.Biome> biomeRegistry;
|
||||
private ConfigPack pack;
|
||||
|
||||
public TerraBiomeSource(Registry<net.minecraft.world.biome.Biome> biomes, ConfigPack pack) {
|
||||
public TerraBiomeSource(ConfigPack pack) {
|
||||
super(StreamSupport
|
||||
.stream(pack.getBiomeProvider()
|
||||
.getBiomes()
|
||||
.spliterator(), false)
|
||||
.map(b -> biomes.entryOf(((ProtoPlatformBiome) b.getPlatformBiome()).getDelegate())));
|
||||
this.biomeRegistry = biomes;
|
||||
.map(b -> ((ProtoPlatformBiome) b.getPlatformBiome()).getDelegate()));
|
||||
this.pack = pack;
|
||||
|
||||
LOGGER.debug("Biomes: " + getBiomes());
|
||||
@ -60,22 +58,16 @@ public class TerraBiomeSource extends BiomeSource {
|
||||
|
||||
@Override
|
||||
public RegistryEntry<Biome> getBiome(int biomeX, int biomeY, int biomeZ, MultiNoiseSampler noiseSampler) {
|
||||
return biomeRegistry
|
||||
.entryOf(((ProtoPlatformBiome) pack
|
||||
return ((ProtoPlatformBiome) pack
|
||||
.getBiomeProvider()
|
||||
.getBiome(biomeX << 2, biomeY << 2, biomeZ << 2, SeedHack.getSeed(noiseSampler))
|
||||
.getPlatformBiome()).getDelegate()
|
||||
);
|
||||
.getPlatformBiome()).getDelegate();
|
||||
}
|
||||
|
||||
public BiomeProvider getProvider() {
|
||||
return pack.getBiomeProvider();
|
||||
}
|
||||
|
||||
public Registry<net.minecraft.world.biome.Biome> getBiomeRegistry() {
|
||||
return biomeRegistry;
|
||||
}
|
||||
|
||||
public ConfigPack getPack() {
|
||||
return pack;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class PresetUtil {
|
||||
|
||||
PRESETS.add(generatorID);
|
||||
|
||||
TerraBiomeSource biomeSource = new TerraBiomeSource(biomeRegistry, pack);
|
||||
TerraBiomeSource biomeSource = new TerraBiomeSource(pack);
|
||||
ChunkGenerator generator = new MinecraftChunkGeneratorWrapper(biomeSource, pack, overworld);
|
||||
|
||||
DimensionOptions dimensionOptions = new DimensionOptions(overworldDimensionType, generator);
|
||||
|
@ -54,7 +54,7 @@ public final class BiomeUtil {
|
||||
|
||||
|
||||
if(pack.getContext().get(PreLoadCompatibilityOptions.class).useVanillaBiomes()) {
|
||||
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(vanilla);
|
||||
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(registry.getEntry(vanilla).orElseThrow());
|
||||
} else {
|
||||
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
||||
|
||||
@ -65,14 +65,12 @@ public final class BiomeUtil {
|
||||
|
||||
if(registry.containsId(identifier)) {
|
||||
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(MinecraftUtil.getEntry(registry, identifier)
|
||||
.orElseThrow()
|
||||
.getKey()
|
||||
.orElseThrow());
|
||||
} else {
|
||||
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(Registry.registerReference(registry,
|
||||
MinecraftUtil.registerKey(identifier)
|
||||
.getValue(),
|
||||
minecraftBiome).getKey().orElseThrow());
|
||||
minecraftBiome));
|
||||
}
|
||||
|
||||
Map<RegistryKey<net.minecraft.world.biome.Biome>, VillagerType> villagerMap = VillagerTypeAccessor.getBiomeTypeToIdMap();
|
||||
|
Loading…
x
Reference in New Issue
Block a user