mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 00:15:35 +00:00
add BiomeCreationEvent
This commit is contained in:
parent
fa8a6f38cc
commit
1df09f44ea
@ -37,6 +37,7 @@ import com.dfsek.terra.config.lang.LangUtil;
|
||||
import com.dfsek.terra.config.lang.Language;
|
||||
import com.dfsek.terra.config.pack.ConfigPack;
|
||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||
import com.dfsek.terra.fabric.api.BiomeCreationEvent;
|
||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.fabric.generation.PopulatorFeature;
|
||||
import com.dfsek.terra.fabric.generation.TerraBiomeSource;
|
||||
@ -249,7 +250,7 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
.registerLoader(com.dfsek.terra.api.platform.world.Biome.class, (t, o, l) -> biomeFixer.translate((String) o));
|
||||
}
|
||||
|
||||
private Biome createBiome(BiomeBuilder biome) {
|
||||
private Biome createBiome(BiomeBuilder biome, ConfigPack pack) {
|
||||
BiomeTemplate template = biome.getTemplate();
|
||||
Map<String, Integer> colors = template.getColors();
|
||||
|
||||
@ -279,7 +280,7 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
accessor.getFoliageColor().ifPresent(effects::foliageColor);
|
||||
}
|
||||
|
||||
return new Biome.Builder()
|
||||
Biome.Builder builder = new Biome.Builder()
|
||||
.precipitation(vanilla.getPrecipitation())
|
||||
.category(vanilla.getCategory())
|
||||
.depth(vanilla.getDepth())
|
||||
@ -287,16 +288,19 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
.temperature(vanilla.getTemperature())
|
||||
.downfall(vanilla.getDownfall())
|
||||
.effects(effects.build())
|
||||
.spawnSettings(vanilla.getSpawnSettings())
|
||||
.generationSettings(generationSettings.build())
|
||||
.build();
|
||||
.spawnSettings(vanilla.getSpawnSettings());
|
||||
|
||||
eventManager.callEvent(new BiomeCreationEvent(builder, effects, biome, pack));
|
||||
|
||||
builder.generationSettings(generationSettings.build());
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public void packInit() {
|
||||
logger.info("Loading config packs...");
|
||||
registry.loadAll(this);
|
||||
|
||||
registry.forEach(pack -> pack.getBiomeRegistry().forEach((id, biome) -> Registry.register(BuiltinRegistries.BIOME, new Identifier("terra", createBiomeID(pack, id)), createBiome(biome)))); // Register all Terra biomes.
|
||||
registry.forEach(pack -> pack.getBiomeRegistry().forEach((id, biome) -> Registry.register(BuiltinRegistries.BIOME, new Identifier("terra", createBiomeID(pack, id)), createBiome(biome, pack)))); // Register all Terra biomes.
|
||||
|
||||
if(FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
|
||||
registry.forEach(pack -> {
|
||||
@ -331,7 +335,6 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
logger.info("Loaded addons.");
|
||||
|
||||
|
||||
|
||||
Registry.register(Registry.FEATURE, new Identifier("terra", "flora_populator"), POPULATOR_FEATURE);
|
||||
RegistryKey<ConfiguredFeature<?, ?>> floraKey = RegistryKey.of(Registry.CONFIGURED_FEATURE_WORLDGEN, new Identifier("terra", "flora_populator"));
|
||||
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, floraKey.getValue(), POPULATOR_CONFIGURED_FEATURE);
|
||||
|
@ -0,0 +1,42 @@
|
||||
package com.dfsek.terra.fabric.api;
|
||||
|
||||
import com.dfsek.terra.api.event.events.PackEvent;
|
||||
import com.dfsek.terra.config.builder.BiomeBuilder;
|
||||
import com.dfsek.terra.config.pack.ConfigPack;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BiomeEffects;
|
||||
|
||||
/**
|
||||
* Called when a {@link Biome} is created
|
||||
* as a delegate to a {@link BiomeBuilder}.
|
||||
*/
|
||||
public class BiomeCreationEvent implements PackEvent {
|
||||
private final Biome.Builder builder;
|
||||
private final BiomeEffects.Builder effectsBuilder;
|
||||
private final BiomeBuilder terraBiome;
|
||||
private final ConfigPack pack;
|
||||
|
||||
public BiomeCreationEvent(Biome.Builder builder, BiomeEffects.Builder effectsBuilder, BiomeBuilder terraBiome, ConfigPack pack) {
|
||||
this.builder = builder;
|
||||
this.effectsBuilder = effectsBuilder;
|
||||
this.terraBiome = terraBiome;
|
||||
this.pack = pack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPack getPack() {
|
||||
return pack;
|
||||
}
|
||||
|
||||
public BiomeBuilder getTerraBiome() {
|
||||
return terraBiome;
|
||||
}
|
||||
|
||||
public Biome.Builder getBuilder() {
|
||||
return builder;
|
||||
}
|
||||
|
||||
public BiomeEffects.Builder getEffectsBuilder() {
|
||||
return effectsBuilder;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user