More biome builder functions (generation settings, music)
This commit is contained in:
parent
14ab0c878b
commit
c7c11d0b4c
7 changed files with 73 additions and 7 deletions
|
@ -8,19 +8,25 @@ import net.minecraft.util.Mth;
|
|||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.level.biome.AmbientAdditionsSettings;
|
||||
import net.minecraft.world.level.biome.AmbientMoodSettings;
|
||||
import net.minecraft.world.level.biome.AmbientParticleSettings;
|
||||
import net.minecraft.world.level.biome.Biome.BiomeBuilder;
|
||||
import net.minecraft.world.level.biome.Biome.BiomeCategory;
|
||||
import net.minecraft.world.level.biome.Biome.Precipitation;
|
||||
import net.minecraft.world.level.biome.BiomeGenerationSettings;
|
||||
import net.minecraft.world.level.biome.BiomeSpecialEffects;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import ru.bclib.util.ColorUtil;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
import ru.bclib.world.features.BCLFeature;
|
||||
|
||||
public class BCLBiomeBuilder {
|
||||
private static final BCLBiomeBuilder INSTANCE = new BCLBiomeBuilder();
|
||||
|
||||
private BiomeGenerationSettings.Builder generationSettings;
|
||||
private BiomeSpecialEffects.Builder effectsBuilder;
|
||||
private MobSpawnSettings.Builder spawnSettings;
|
||||
private Precipitation precipitation;
|
||||
|
@ -39,10 +45,12 @@ public class BCLBiomeBuilder {
|
|||
INSTANCE.biomeID = biomeID;
|
||||
INSTANCE.precipitation = Precipitation.NONE;
|
||||
INSTANCE.category = BiomeCategory.NONE;
|
||||
INSTANCE.generationSettings = null;
|
||||
INSTANCE.effectsBuilder = null;
|
||||
INSTANCE.spawnSettings = null;
|
||||
INSTANCE.temperature = 1.0F;
|
||||
INSTANCE.fogDensity = 1.0F;
|
||||
INSTANCE.downfall = 1.0F;
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
|
@ -339,6 +347,28 @@ public class BCLBiomeBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets biome mood sound. Can be used for biome environment.
|
||||
* @param mood {@link SoundEvent} to use as a mood.
|
||||
* @param tickDelay delay between sound events in ticks.
|
||||
* @param blockSearchExtent block search radius (for area available for sound).
|
||||
* @param soundPositionOffset offset in sound.
|
||||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder mood(SoundEvent mood, int tickDelay, int blockSearchExtent, float soundPositionOffset) {
|
||||
getEffects().ambientMoodSound(new AmbientMoodSettings(mood, tickDelay, blockSearchExtent, soundPositionOffset));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets biome mood sound. Can be used for biome environment.
|
||||
* @param mood {@link SoundEvent} to use as a mood.
|
||||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder mood(SoundEvent mood) {
|
||||
return mood(mood, 6000, 8, 2.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets biome additionsl ambient sounds.
|
||||
* @param additions {@link SoundEvent} to use.
|
||||
|
@ -359,6 +389,26 @@ public class BCLBiomeBuilder {
|
|||
return additions(additions, 0.0111F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds new feature to the biome.
|
||||
* @param decoration {@link Decoration} feature step.
|
||||
* @param feature {@link PlacedFeature}.
|
||||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder feature(Decoration decoration, PlacedFeature feature) {
|
||||
getGeneration().addFeature(decoration, feature);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds new feature to the biome.
|
||||
* @param feature {@link BCLFeature}.
|
||||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder feature(BCLFeature feature) {
|
||||
return feature(feature.getDecoration(), feature.getPlacedFeature());
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalize biome creation.
|
||||
* @return created {@link BCLBiome} instance.
|
||||
|
@ -378,6 +428,10 @@ public class BCLBiomeBuilder {
|
|||
builder.specialEffects(effectsBuilder.build());
|
||||
}
|
||||
|
||||
if (generationSettings != null) {
|
||||
builder.generationSettings(generationSettings.build());
|
||||
}
|
||||
|
||||
return new BCLBiome(biomeID, builder.build()).setFogDensity(fogDensity);
|
||||
}
|
||||
|
||||
|
@ -404,4 +458,16 @@ public class BCLBiomeBuilder {
|
|||
}
|
||||
return spawnSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or create {@link BiomeGenerationSettings.Builder} for biome features and generation.
|
||||
* For internal usage only.
|
||||
* @return new or same {@link BiomeGenerationSettings.Builder} instance.
|
||||
*/
|
||||
private BiomeGenerationSettings.Builder getGeneration() {
|
||||
if (generationSettings == null) {
|
||||
generationSettings = new BiomeGenerationSettings.Builder();
|
||||
}
|
||||
return generationSettings;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -412,7 +412,7 @@ public class BiomeAPI {
|
|||
*
|
||||
*/
|
||||
public static void addBiomeFeature(Biome biome, BCLFeature feature) {
|
||||
addBiomeFeature(biome, feature.getPlacedFeature(), feature.getFeatureStep());
|
||||
addBiomeFeature(biome, feature.getPlacedFeature(), feature.getDecoration());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -434,7 +434,7 @@ public class BiomeAPI {
|
|||
*/
|
||||
public static void addBiomeFeatures(Biome biome, BCLFeature... features) {
|
||||
for (BCLFeature feature: features) {
|
||||
addBiomeFeature(biome, feature.getPlacedFeature(), feature.getFeatureStep());
|
||||
addBiomeFeature(biome, feature.getPlacedFeature(), feature.getDecoration());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import ru.bclib.api.biomes.BiomeAPI;
|
||||
import ru.bclib.api.BonemealAPI;
|
||||
import ru.bclib.api.biomes.BiomeAPI;
|
||||
import ru.bclib.util.BlocksHelper;
|
||||
import ru.bclib.util.MHelper;
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import ru.bclib.api.biomes.BiomeAPI;
|
||||
import ru.bclib.api.LifeCycleAPI;
|
||||
import ru.bclib.api.biomes.BiomeAPI;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
|
|
@ -217,7 +217,7 @@ public class BCLBiomeDef {
|
|||
|
||||
public BCLBiomeDef addFeature(BCLFeature feature) {
|
||||
FeatureInfo info = new FeatureInfo();
|
||||
info.featureStep = feature.getFeatureStep();
|
||||
info.featureStep = feature.getDecoration();
|
||||
info.feature = feature.getPlacedFeature();
|
||||
features.add(info);
|
||||
return this;
|
||||
|
|
|
@ -58,7 +58,7 @@ public class BCLFeature {
|
|||
* Get feature decoration step.
|
||||
* @return {@link Decoration}.
|
||||
*/
|
||||
public Decoration getFeatureStep() {
|
||||
public Decoration getDecoration() {
|
||||
return featureStep;
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -19,8 +19,8 @@ import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConf
|
|||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||
import ru.bclib.api.biomes.BiomeAPI;
|
||||
import ru.bclib.api.TagAPI;
|
||||
import ru.bclib.api.biomes.BiomeAPI;
|
||||
import ru.bclib.util.BlocksHelper;
|
||||
import ru.bclib.world.processors.DestructionStructureProcessor;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue