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