Removed deprecated code, sapling refactor
This commit is contained in:
parent
1af5bf2e2d
commit
d6faafd4c0
7 changed files with 122 additions and 671 deletions
|
@ -8,7 +8,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
|
||||||
public abstract class FeatureHangingSaplingBlock extends FeatureSaplingBlockCommon{
|
public abstract class FeatureHangingSaplingBlock extends FeatureSaplingBlock {
|
||||||
private static final VoxelShape SHAPE = Block.box(4, 2, 4, 12, 16, 12);
|
private static final VoxelShape SHAPE = Block.box(4, 2, 4, 12, 16, 12);
|
||||||
public FeatureHangingSaplingBlock() {
|
public FeatureHangingSaplingBlock() {
|
||||||
super();
|
super();
|
||||||
|
|
|
@ -1,22 +1,137 @@
|
||||||
package ru.bclib.blocks;
|
package ru.bclib.blocks;
|
||||||
|
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
|
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
import net.minecraft.world.level.block.SaplingBlock;
|
||||||
|
import net.minecraft.world.level.block.SoundType;
|
||||||
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||||
|
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
|
||||||
|
import net.minecraft.world.level.material.Material;
|
||||||
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import ru.bclib.client.models.BasePatterns;
|
||||||
|
import ru.bclib.client.models.ModelsHelper;
|
||||||
|
import ru.bclib.client.models.PatternsHelper;
|
||||||
|
import ru.bclib.client.render.BCLRenderLayer;
|
||||||
|
import ru.bclib.interfaces.BlockModelProvider;
|
||||||
|
import ru.bclib.interfaces.RenderLayerProvider;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
import java.util.Collections;
|
||||||
public abstract class FeatureSaplingBlock extends FeatureSaplingBlockCommon {
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class FeatureSaplingBlock extends SaplingBlock implements RenderLayerProvider, BlockModelProvider {
|
||||||
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
|
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
|
||||||
|
private final Function<BlockState, Feature<?>> feature;
|
||||||
|
|
||||||
public FeatureSaplingBlock() {
|
public FeatureSaplingBlock(Function<BlockState, Feature<?>> featureSupplier) {
|
||||||
super();
|
this(FabricBlockSettings.of(Material.PLANT)
|
||||||
|
.breakByHand(true)
|
||||||
|
.collidable(false)
|
||||||
|
.instabreak()
|
||||||
|
.sound(SoundType.GRASS)
|
||||||
|
.randomTicks(),
|
||||||
|
featureSupplier
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FeatureSaplingBlock(int light) {
|
public FeatureSaplingBlock(int light, Function<BlockState, Feature<?>> featureSupplier) {
|
||||||
super(light);
|
this(FabricBlockSettings.of(Material.PLANT)
|
||||||
|
.breakByHand(true)
|
||||||
|
.collidable(false)
|
||||||
|
.luminance(light)
|
||||||
|
.instabreak()
|
||||||
|
.sound(SoundType.GRASS)
|
||||||
|
.randomTicks(),
|
||||||
|
featureSupplier
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FeatureSaplingBlock(BlockBehaviour.Properties settings, Function<BlockState, Feature<?>> featureSupplier) {
|
||||||
|
super(null, settings);
|
||||||
|
this.feature = featureSupplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Feature<?> getFeature(BlockState state) {
|
||||||
|
return feature.apply(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
|
return Collections.singletonList(new ItemStack(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
|
||||||
|
if (!canSurvive(state, world, pos)) return Blocks.AIR.defaultBlockState();
|
||||||
|
else return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
|
||||||
|
return random.nextInt(16) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void advanceTree(ServerLevel world, BlockPos pos, BlockState blockState, Random random) {
|
||||||
|
FeaturePlaceContext context = new FeaturePlaceContext(
|
||||||
|
Optional.empty(),
|
||||||
|
world,
|
||||||
|
world.getChunkSource().getGenerator(),
|
||||||
|
random,
|
||||||
|
pos,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
getFeature(blockState).place(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||||
|
this.tick(state, world, pos, random);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||||
|
super.tick(state, world, pos, random);
|
||||||
|
if (isBonemealSuccess(world, random, pos, state)) {
|
||||||
|
performBonemeal(world, random, pos, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BCLRenderLayer getRenderLayer() {
|
||||||
|
return BCLRenderLayer.CUTOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||||
|
return ModelsHelper.createBlockItem(resourceLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||||
|
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_CROSS, resourceLocation);
|
||||||
|
return ModelsHelper.fromPattern(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,130 +0,0 @@
|
||||||
package ru.bclib.blocks;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
|
||||||
import net.minecraft.world.level.block.Blocks;
|
|
||||||
import net.minecraft.world.level.block.SaplingBlock;
|
|
||||||
import net.minecraft.world.level.block.SoundType;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
|
|
||||||
import net.minecraft.world.level.material.Material;
|
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import ru.bclib.client.models.BasePatterns;
|
|
||||||
import ru.bclib.client.models.ModelsHelper;
|
|
||||||
import ru.bclib.client.models.PatternsHelper;
|
|
||||||
import ru.bclib.client.render.BCLRenderLayer;
|
|
||||||
import ru.bclib.interfaces.BlockModelProvider;
|
|
||||||
import ru.bclib.interfaces.RenderLayerProvider;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
abstract class FeatureSaplingBlockCommon extends SaplingBlock implements RenderLayerProvider, BlockModelProvider {
|
|
||||||
public FeatureSaplingBlockCommon() {
|
|
||||||
super(
|
|
||||||
null,
|
|
||||||
FabricBlockSettings.of(Material.PLANT)
|
|
||||||
.breakByHand(true)
|
|
||||||
.collidable(false)
|
|
||||||
.instabreak()
|
|
||||||
.sound(SoundType.GRASS)
|
|
||||||
.randomTicks()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FeatureSaplingBlockCommon(int light) {
|
|
||||||
super(
|
|
||||||
null,
|
|
||||||
FabricBlockSettings.of(Material.PLANT)
|
|
||||||
.breakByHand(true)
|
|
||||||
.collidable(false)
|
|
||||||
.luminance(light)
|
|
||||||
.instabreak()
|
|
||||||
.sound(SoundType.GRASS)
|
|
||||||
.randomTicks()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
/**
|
|
||||||
* Override {@link #getFeature(BlockState)} directly. Will be removed in 5.x
|
|
||||||
*/
|
|
||||||
protected Feature<?> getFeature() { return null; }
|
|
||||||
|
|
||||||
protected Feature<?> getFeature(BlockState state){
|
|
||||||
return getFeature();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
|
||||||
return Collections.singletonList(new ItemStack(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
|
|
||||||
if (!canSurvive(state, world, pos)) return Blocks.AIR.defaultBlockState();
|
|
||||||
else return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
|
|
||||||
return random.nextInt(16) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void advanceTree(ServerLevel world, BlockPos pos, BlockState blockState, Random random) {
|
|
||||||
FeaturePlaceContext context = new FeaturePlaceContext(
|
|
||||||
Optional.empty(),
|
|
||||||
world,
|
|
||||||
world.getChunkSource().getGenerator(),
|
|
||||||
random,
|
|
||||||
pos,
|
|
||||||
null
|
|
||||||
);
|
|
||||||
getFeature(blockState).place(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
|
||||||
this.tick(state, world, pos, random);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
|
||||||
super.tick(state, world, pos, random);
|
|
||||||
if (isBonemealSuccess(world, random, pos, state)) {
|
|
||||||
performBonemeal(world, random, pos, state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BCLRenderLayer getRenderLayer() {
|
|
||||||
return BCLRenderLayer.CUTOUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
|
||||||
return ModelsHelper.createBlockItem(resourceLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
|
||||||
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_CROSS, resourceLocation);
|
|
||||||
return ModelsHelper.fromPattern(pattern);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,61 +0,0 @@
|
||||||
package ru.bclib.blocks.properties;
|
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import net.minecraft.world.level.block.state.properties.Property;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public class StringProperty extends Property<String> {
|
|
||||||
private final Set<String> values;
|
|
||||||
|
|
||||||
public static StringProperty create(String name, String... values) {
|
|
||||||
return new StringProperty(name, values);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected StringProperty(String string, String... values) {
|
|
||||||
super(string, String.class);
|
|
||||||
this.values = Sets.newHashSet(values);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addValue(String name) {
|
|
||||||
values.add(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<String> getPossibleValues() {
|
|
||||||
return Collections.unmodifiableSet(values);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName(String comparable) {
|
|
||||||
return comparable;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<String> getValue(String string) {
|
|
||||||
if (values.contains(string)) {
|
|
||||||
return Optional.of(string);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int generateHashCode() {
|
|
||||||
return super.generateHashCode() + Objects.hashCode(values);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (!(o instanceof StringProperty that)) return false;
|
|
||||||
if (!super.equals(o)) return false;
|
|
||||||
return values.equals(that.values);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,426 +0,0 @@
|
||||||
package ru.bclib.world.biomes;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import net.minecraft.core.Registry;
|
|
||||||
import net.minecraft.core.particles.ParticleOptions;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.sounds.Music;
|
|
||||||
import net.minecraft.sounds.Musics;
|
|
||||||
import net.minecraft.sounds.SoundEvent;
|
|
||||||
import net.minecraft.util.Mth;
|
|
||||||
import net.minecraft.world.entity.EntityType;
|
|
||||||
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;
|
|
||||||
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.Builder;
|
|
||||||
import net.minecraft.world.level.biome.MobSpawnSettings;
|
|
||||||
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.levelgen.GenerationStep.Carving;
|
|
||||||
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
|
|
||||||
import net.minecraft.world.level.levelgen.carver.CarverConfiguration;
|
|
||||||
import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
|
||||||
import ru.bclib.config.IdConfig;
|
|
||||||
import ru.bclib.config.PathConfig;
|
|
||||||
import ru.bclib.util.ColorUtil;
|
|
||||||
import ru.bclib.world.features.BCLFeature;
|
|
||||||
import ru.bclib.world.structures.BCLStructureFeature;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class BCLBiomeDef {
|
|
||||||
public static final int DEF_FOLIAGE_OVERWORLD = ColorUtil.color(110, 143, 64);
|
|
||||||
public static final int DEF_FOLIAGE_NETHER = ColorUtil.color(117, 10, 10);
|
|
||||||
public static final int DEF_FOLIAGE_END = ColorUtil.color(197, 210, 112);
|
|
||||||
|
|
||||||
private final List<ConfiguredStructureFeature<?, ?>> structures = Lists.newArrayList();
|
|
||||||
private final List<FeatureInfo> features = Lists.newArrayList();
|
|
||||||
private final List<CarverInfo> carvers = Lists.newArrayList();
|
|
||||||
private final List<SpawnInfo> mobs = Lists.newArrayList();
|
|
||||||
private final List<SpawnerData> spawns = Lists.newArrayList();
|
|
||||||
private final Map<String, Object> customData = Maps.newHashMap();
|
|
||||||
|
|
||||||
private final ResourceLocation id;
|
|
||||||
|
|
||||||
private AmbientParticleSettings particleConfig;
|
|
||||||
private AmbientAdditionsSettings additions;
|
|
||||||
private AmbientMoodSettings mood;
|
|
||||||
private SoundEvent music;
|
|
||||||
private SoundEvent loop;
|
|
||||||
|
|
||||||
private int foliageColor = DEF_FOLIAGE_OVERWORLD;
|
|
||||||
private int grassColor = DEF_FOLIAGE_OVERWORLD;
|
|
||||||
private int waterFogColor = 329011;
|
|
||||||
private int waterColor = 4159204;
|
|
||||||
private int fogColor = 10518688;
|
|
||||||
private int skyColor = 0;
|
|
||||||
private float fogDensity = 1F;
|
|
||||||
private float terrainHeight = 0.1F;
|
|
||||||
|
|
||||||
private Precipitation precipitation = Precipitation.NONE;
|
|
||||||
private BiomeCategory category = BiomeCategory.NONE;
|
|
||||||
private float temperature = 1F;
|
|
||||||
private float genChance = 1F;
|
|
||||||
private float downfall = 0F;
|
|
||||||
private int edgeSize = 32;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Custom biome definition. Can be extended with new parameters.
|
|
||||||
*
|
|
||||||
* @param id - Biome {@link ResourceLocation} (identifier).
|
|
||||||
*/
|
|
||||||
public BCLBiomeDef(ResourceLocation id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create default definition for The Nether biome.
|
|
||||||
*
|
|
||||||
* @return {@link BCLBiomeDef}.
|
|
||||||
*/
|
|
||||||
public BCLBiomeDef netherBiome() {
|
|
||||||
this.foliageColor = DEF_FOLIAGE_NETHER;
|
|
||||||
this.grassColor = DEF_FOLIAGE_NETHER;
|
|
||||||
this.setCategory(BiomeCategory.NETHER);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create default definition for The End biome.
|
|
||||||
*
|
|
||||||
* @return {@link BCLBiomeDef}.
|
|
||||||
*/
|
|
||||||
public BCLBiomeDef endBiome() {
|
|
||||||
this.foliageColor = DEF_FOLIAGE_END;
|
|
||||||
this.grassColor = DEF_FOLIAGE_END;
|
|
||||||
this.setCategory(BiomeCategory.THEEND);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to load biome settings from config.
|
|
||||||
* @param config - {@link IdConfig}.
|
|
||||||
* @return this {@link BCLBiomeDef}.
|
|
||||||
*/
|
|
||||||
public BCLBiomeDef loadConfigValues(IdConfig config) {
|
|
||||||
this.fogDensity = config.getFloat(id, "fog_density", this.fogDensity);
|
|
||||||
this.genChance = config.getFloat(id, "generation_chance", this.genChance);
|
|
||||||
this.edgeSize = config.getInt(id, "edge_size", this.edgeSize);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to load biome settings from config.
|
|
||||||
* @param config - {@link PathConfig}.
|
|
||||||
* @return this {@link BCLBiomeDef}.
|
|
||||||
*/
|
|
||||||
public BCLBiomeDef loadConfigValues(PathConfig config) {
|
|
||||||
String biomePath = id.getNamespace() + "." + id.getPath();
|
|
||||||
this.fogDensity = config.getFloat(biomePath, "fog_density", this.fogDensity);
|
|
||||||
this.genChance = config.getFloat(biomePath, "generation_chance", this.genChance);
|
|
||||||
this.edgeSize = config.getInt(biomePath, "edge_size", this.edgeSize);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set category of the biome.
|
|
||||||
* @param category - {@link BiomeCategory}.
|
|
||||||
* @return this {@link BCLBiomeDef}.
|
|
||||||
*/
|
|
||||||
public BCLBiomeDef setCategory(BiomeCategory category) {
|
|
||||||
this.category = category;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setPrecipitation(Precipitation precipitation) {
|
|
||||||
this.precipitation = precipitation;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setSurface(Block block) {
|
|
||||||
//TODO: 1.18 add back surface Code
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setSurface(Block block1, Block block2) {
|
|
||||||
//TODO: 1.18 add back surface Code
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setParticles(ParticleOptions particle, float probability) {
|
|
||||||
this.particleConfig = new AmbientParticleSettings(particle, probability);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setGenChance(float genChance) {
|
|
||||||
this.genChance = genChance;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setTerrainHeight(float terrainHeight) {
|
|
||||||
this.terrainHeight = terrainHeight;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setTemperature(float temperature) {
|
|
||||||
this.temperature = temperature;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setDownfall(float downfall) {
|
|
||||||
this.downfall = downfall;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setEdgeSize(int edgeSize) {
|
|
||||||
this.edgeSize = edgeSize;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef addMobSpawn(EntityType<?> type, int weight, int minGroupSize, int maxGroupSize) {
|
|
||||||
ResourceLocation eID = Registry.ENTITY_TYPE.getKey(type);
|
|
||||||
if (eID != Registry.ENTITY_TYPE.getDefaultKey()) {
|
|
||||||
SpawnInfo info = new SpawnInfo();
|
|
||||||
info.type = type;
|
|
||||||
info.weight = weight;
|
|
||||||
info.minGroupSize = minGroupSize;
|
|
||||||
info.maxGroupSize = maxGroupSize;
|
|
||||||
mobs.add(info);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef addMobSpawn(SpawnerData entry) {
|
|
||||||
spawns.add(entry);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef addStructureFeature(ConfiguredStructureFeature<?, ?> feature) {
|
|
||||||
structures.add(feature);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef addStructureFeature(BCLStructureFeature feature) {
|
|
||||||
structures.add(feature.getFeatureConfigured());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef addFeature(BCLFeature feature) {
|
|
||||||
FeatureInfo info = new FeatureInfo();
|
|
||||||
info.featureStep = feature.getDecoration();
|
|
||||||
info.feature = feature.getPlacedFeature();
|
|
||||||
features.add(info);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef addFeature(Decoration featureStep, PlacedFeature feature) {
|
|
||||||
FeatureInfo info = new FeatureInfo();
|
|
||||||
info.featureStep = featureStep;
|
|
||||||
info.feature = feature;
|
|
||||||
features.add(info);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getColor(int r, int g, int b) {
|
|
||||||
r = Mth.clamp(r, 0, 255);
|
|
||||||
g = Mth.clamp(g, 0, 255);
|
|
||||||
b = Mth.clamp(b, 0, 255);
|
|
||||||
return ColorUtil.color(r, g, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setSkyColor(int rgb) {
|
|
||||||
this.skyColor = rgb;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setSkyColor(int r, int g, int b) {
|
|
||||||
return setSkyColor(getColor(r, g, b));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setFogColor(int rgb) {
|
|
||||||
this.fogColor = rgb;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setFogColor(int r, int g, int b) {
|
|
||||||
return setFogColor(getColor(r, g, b));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setFogDensity(float density) {
|
|
||||||
this.fogDensity = density;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setWaterColor(int r, int g, int b) {
|
|
||||||
this.waterColor = getColor(r, g, b);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setWaterFogColor(int r, int g, int b) {
|
|
||||||
this.waterFogColor = getColor(r, g, b);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setWaterAndFogColor(int r, int g, int b) {
|
|
||||||
return setWaterColor(r, g, b).setWaterFogColor(r, g, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setFoliageColor(int r, int g, int b) {
|
|
||||||
this.foliageColor = getColor(r, g, b);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setGrassColor(int r, int g, int b) {
|
|
||||||
this.grassColor = getColor(r, g, b);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setPlantsColor(int r, int g, int b) {
|
|
||||||
return this.setFoliageColor(r, g, b).setGrassColor(r, g, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setLoop(SoundEvent loop) {
|
|
||||||
this.loop = loop;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setMood(SoundEvent mood) {
|
|
||||||
this.mood = new AmbientMoodSettings(mood, 6000, 8, 2.0D);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setAdditions(SoundEvent additions) {
|
|
||||||
this.additions = new AmbientAdditionsSettings(additions, 0.0111);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef setMusic(SoundEvent music) {
|
|
||||||
this.music = music;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void addCustomToBuild(BiomeGenerationSettings.Builder generationSettings){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Biome build() {
|
|
||||||
MobSpawnSettings.Builder spawnSettings = new MobSpawnSettings.Builder();
|
|
||||||
BiomeGenerationSettings.Builder generationSettings = new BiomeGenerationSettings.Builder();
|
|
||||||
Builder effects = new Builder();
|
|
||||||
|
|
||||||
mobs.forEach((spawn) -> {
|
|
||||||
spawnSettings.addSpawn(
|
|
||||||
spawn.type.getCategory(),
|
|
||||||
new MobSpawnSettings.SpawnerData(spawn.type, spawn.weight, spawn.minGroupSize, spawn.maxGroupSize)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
spawns.forEach((entry) -> {
|
|
||||||
spawnSettings.addSpawn(entry.type.getCategory(), entry);
|
|
||||||
});
|
|
||||||
|
|
||||||
//generationSettings.surfaceBuilder(surface == null ? net.minecraft.data.worldgen.SurfaceBuilders.END : surface);
|
|
||||||
|
|
||||||
//TODO: 1.18 Done elsewhere now
|
|
||||||
//structures.forEach((structure) -> generationSettings.addStructureStart(structure));
|
|
||||||
features.forEach((info) -> generationSettings.addFeature(info.featureStep, info.feature));
|
|
||||||
carvers.forEach((info) -> generationSettings.addCarver(info.carverStep, info.carver));
|
|
||||||
|
|
||||||
addCustomToBuild(generationSettings);
|
|
||||||
|
|
||||||
effects.skyColor(skyColor)
|
|
||||||
.waterColor(waterColor)
|
|
||||||
.waterFogColor(waterFogColor)
|
|
||||||
.fogColor(fogColor)
|
|
||||||
.foliageColorOverride(foliageColor)
|
|
||||||
.grassColorOverride(grassColor);
|
|
||||||
if (loop != null) effects.ambientLoopSound(loop);
|
|
||||||
if (mood != null) effects.ambientMoodSound(mood);
|
|
||||||
if (additions != null) effects.ambientAdditionsSound(additions);
|
|
||||||
if (particleConfig != null) effects.ambientParticle(particleConfig);
|
|
||||||
effects.backgroundMusic(music != null ? new Music(music, 600, 2400, true) : Musics.END);
|
|
||||||
|
|
||||||
Biome b = new Biome.BiomeBuilder()
|
|
||||||
.precipitation(precipitation)
|
|
||||||
.biomeCategory(category)
|
|
||||||
//.depth(depth)
|
|
||||||
//.scale(0.2F)
|
|
||||||
.temperature(temperature)
|
|
||||||
.downfall(downfall)
|
|
||||||
.specialEffects(effects.build())
|
|
||||||
.mobSpawnSettings(spawnSettings.build())
|
|
||||||
.generationSettings(generationSettings.build())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
//structures.forEach((structure) -> BiomeAPI.addBiomeStructure(b., structure));
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getTerrainHeight() {
|
|
||||||
return terrainHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class SpawnInfo {
|
|
||||||
EntityType<?> type;
|
|
||||||
int weight;
|
|
||||||
int minGroupSize;
|
|
||||||
int maxGroupSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class FeatureInfo {
|
|
||||||
Decoration featureStep;
|
|
||||||
PlacedFeature feature;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class CarverInfo <C extends CarverConfiguration> {
|
|
||||||
Carving carverStep;
|
|
||||||
ConfiguredWorldCarver<C> carver;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResourceLocation getID() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getFodDensity() {
|
|
||||||
return fogDensity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getGenChance() {
|
|
||||||
return genChance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getEdgeSize() {
|
|
||||||
return edgeSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <C extends CarverConfiguration> BCLBiomeDef addCarver(Carving carverStep, ConfiguredWorldCarver<C> carver) {
|
|
||||||
CarverInfo info = new CarverInfo();
|
|
||||||
info.carverStep = carverStep;
|
|
||||||
info.carver = carver;
|
|
||||||
carvers.add(info);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLBiomeDef addCustomData(String name, Object value) {
|
|
||||||
customData.put(name, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public <T> T getCustomData(String name, Object defaultValue) {
|
|
||||||
return (T) customData.getOrDefault(name, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Map<String, Object> getCustomData() {
|
|
||||||
return customData;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -77,8 +77,6 @@ public class BCLFeature {
|
||||||
PlacementUtils.HEIGHTMAP,
|
PlacementUtils.HEIGHTMAP,
|
||||||
BiomeFilter.biome()
|
BiomeFilter.biome()
|
||||||
);
|
);
|
||||||
//.decorated(BCLDecorators.HEIGHTMAP_SQUARE)
|
|
||||||
//.countRandom(density);
|
|
||||||
return new BCLFeature(id, feature, Decoration.VEGETAL_DECORATION, configured);
|
return new BCLFeature(id, feature, Decoration.VEGETAL_DECORATION, configured);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -129,12 +127,6 @@ public class BCLFeature {
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
BiomeFilter.biome());
|
BiomeFilter.biome());
|
||||||
// .rangeUniform(
|
|
||||||
// VerticalAnchor.absolute(minY),
|
|
||||||
// VerticalAnchor.absolute(maxY)
|
|
||||||
// )
|
|
||||||
// .squared()
|
|
||||||
// .count(veins);
|
|
||||||
return new BCLFeature(
|
return new BCLFeature(
|
||||||
net.minecraft.world.level.levelgen.feature.Feature.ORE,
|
net.minecraft.world.level.levelgen.feature.Feature.ORE,
|
||||||
Registry.register(BuiltinRegistries.PLACED_FEATURE, id, oreFeature),
|
Registry.register(BuiltinRegistries.PLACED_FEATURE, id, oreFeature),
|
||||||
|
@ -153,7 +145,6 @@ public class BCLFeature {
|
||||||
PlacedFeature configured = feature
|
PlacedFeature configured = feature
|
||||||
.configured(FeatureConfiguration.NONE)
|
.configured(FeatureConfiguration.NONE)
|
||||||
.placed(CountPlacement.of(1));
|
.placed(CountPlacement.of(1));
|
||||||
//.decorated(FeatureDecorator.COUNT.configured(new CountConfiguration(1)));
|
|
||||||
return new BCLFeature(id, feature, step, configured);
|
return new BCLFeature(id, feature, step, configured);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +160,6 @@ public class BCLFeature {
|
||||||
PlacedFeature configured = feature
|
PlacedFeature configured = feature
|
||||||
.configured(FeatureConfiguration.NONE)
|
.configured(FeatureConfiguration.NONE)
|
||||||
.placed(RarityFilter.onAverageOnceEvery(chance));
|
.placed(RarityFilter.onAverageOnceEvery(chance));
|
||||||
//.decorated(FeatureDecorator.CHANCE.configured(new ChanceDecoratorConfiguration(chance)));
|
|
||||||
return new BCLFeature(id, feature, step, configured);
|
return new BCLFeature(id, feature, step, configured);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,34 +190,4 @@ public class BCLFeature {
|
||||||
PlacedFeature configured = feature.configured(FeatureConfiguration.NONE).placed();
|
PlacedFeature configured = feature.configured(FeatureConfiguration.NONE).placed();
|
||||||
return new BCLFeature(id, feature, step, configured);
|
return new BCLFeature(id, feature, step, configured);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static BCLFeature makeOreFeature(ResourceLocation id, Block blockOre, Block hostBlock, int veins, int veinSize, int offset, int minY, int maxY) {
|
|
||||||
return makeOreFeature(id, blockOre, hostBlock, veins, veinSize, minY, maxY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static BCLFeature makeRawGenFeature(ResourceLocation id, Feature<NoneFeatureConfiguration> feature, int chance) {
|
|
||||||
return makeChancedFeature(id, Decoration.RAW_GENERATION, feature, chance);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static BCLFeature makeChunkFeature(ResourceLocation id, Feature<NoneFeatureConfiguration> feature) {
|
|
||||||
return makeChunkFeature(id, Decoration.LOCAL_MODIFICATIONS, feature);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static BCLFeature makeChansedFeature(ResourceLocation id, Feature<NoneFeatureConfiguration> feature, int chance) {
|
|
||||||
return makeChancedFeature(id, Decoration.SURFACE_STRUCTURES, feature, chance);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static BCLFeature makeCountRawFeature(ResourceLocation id, Feature<NoneFeatureConfiguration> feature, int chance) {
|
|
||||||
return makeCountFeature(id, Decoration.RAW_GENERATION, feature, chance);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static BCLFeature makeFeatureConfigured(ResourceLocation id, Feature<NoneFeatureConfiguration> feature) {
|
|
||||||
return makeFeatureConfigured(id, Decoration.RAW_GENERATION, feature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,7 @@ import ru.bclib.world.biomes.BCLBiome;
|
||||||
import ru.bclib.world.generator.map.hex.HexBiomeMap;
|
import ru.bclib.world.generator.map.hex.HexBiomeMap;
|
||||||
import ru.bclib.world.generator.map.square.SquareBiomeMap;
|
import ru.bclib.world.generator.map.square.SquareBiomeMap;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class BCLibNetherBiomeSource extends BiomeSource {
|
public class BCLibNetherBiomeSource extends BiomeSource {
|
||||||
public static final Codec<BCLibNetherBiomeSource> CODEC = RecordCodecBuilder.create((instance) -> {
|
public static final Codec<BCLibNetherBiomeSource> CODEC = RecordCodecBuilder.create((instance) -> {
|
||||||
|
@ -46,9 +44,6 @@ public class BCLibNetherBiomeSource extends BiomeSource {
|
||||||
forceLegacyGenerator = val;
|
forceLegacyGenerator = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final List<Consumer<BCLibNetherBiomeSource>> onInit = new LinkedList<>();
|
|
||||||
|
|
||||||
public BCLibNetherBiomeSource(Registry<Biome> biomeRegistry, long seed) {
|
public BCLibNetherBiomeSource(Registry<Biome> biomeRegistry, long seed) {
|
||||||
super(getBiomes(biomeRegistry));
|
super(getBiomes(biomeRegistry));
|
||||||
|
|
||||||
|
@ -87,8 +82,6 @@ public class BCLibNetherBiomeSource extends BiomeSource {
|
||||||
|
|
||||||
this.biomeRegistry = biomeRegistry;
|
this.biomeRegistry = biomeRegistry;
|
||||||
this.seed = seed;
|
this.seed = seed;
|
||||||
|
|
||||||
onInit.forEach(consumer->consumer.accept(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Biome> getBiomes(Registry<Biome> biomeRegistry) {
|
private static List<Biome> getBiomes(Registry<Biome> biomeRegistry) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue