Removed redundant code (moved to BCLib lists)
This commit is contained in:
parent
8a1490f00e
commit
9c1c1edb12
10 changed files with 18 additions and 115 deletions
|
@ -6,17 +6,19 @@ import net.minecraft.world.level.biome.Biome.BiomeCategory;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
import ru.bclib.api.BiomeAPI;
|
||||
import ru.bclib.util.WeightedList;
|
||||
import ru.bclib.world.biomes.BCLBiomeDef;
|
||||
import ru.bclib.world.features.BCLFeature;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.interfaces.ShuffelingListExtended;
|
||||
import ru.betterend.registry.EndSounds;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
import ru.betterend.world.features.terrain.caves.CaveChunkPopulatorFeature;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class EndCaveBiome extends EndBiome {
|
||||
final private ShufflingList<Feature<?>> floorFeatures = new ShufflingList<>();
|
||||
final private ShufflingList<Feature<?>> ceilFeatures = new ShufflingList<>();
|
||||
private WeightedList<Feature<?>> floorFeatures = new WeightedList<Feature<?>>();
|
||||
private WeightedList<Feature<?>> ceilFeatures = new WeightedList<Feature<?>>();
|
||||
|
||||
public EndCaveBiome(BCLBiomeDef definition) {
|
||||
super(makeDef(definition));
|
||||
|
@ -24,8 +26,7 @@ public class EndCaveBiome extends EndBiome {
|
|||
|
||||
private static BCLBiomeDef makeDef(BCLBiomeDef definition) {
|
||||
BCLFeature feature = BCLFeature.makeChunkFeature(
|
||||
BetterEnd.makeID(definition.getID()
|
||||
.getPath() + "_cave_populator"),
|
||||
BetterEnd.makeID(definition.getID().getPath() + "_cave_populator"),
|
||||
new CaveChunkPopulatorFeature(() -> (EndCaveBiome) BiomeAPI.getBiome(definition.getID()))
|
||||
);
|
||||
definition.setCategory(BiomeCategory.NONE).addFeature(feature);
|
||||
|
@ -34,22 +35,20 @@ public class EndCaveBiome extends EndBiome {
|
|||
return definition;
|
||||
}
|
||||
|
||||
public void addFloorFeature(Feature<?> feature, int weight) {
|
||||
public void addFloorFeature(Feature<?> feature, float weight) {
|
||||
floorFeatures.add(feature, weight);
|
||||
}
|
||||
|
||||
public void addCeilFeature(Feature<?> feature, int weight) {
|
||||
public void addCeilFeature(Feature<?> feature, float weight) {
|
||||
ceilFeatures.add(feature, weight);
|
||||
}
|
||||
|
||||
public Feature<?> getFloorFeature() {
|
||||
return ((ShuffelingListExtended<Feature<?>>) floorFeatures).isEmpty() ? null : ((ShuffelingListExtended<Feature<?>>) floorFeatures)
|
||||
.getOne();
|
||||
public Feature<?> getFloorFeature(Random random) {
|
||||
return floorFeatures.isEmpty() ? null : floorFeatures.get(random);
|
||||
}
|
||||
|
||||
public Feature<?> getCeilFeature() {
|
||||
return ((ShuffelingListExtended<Feature<?>>) ceilFeatures).isEmpty() ? null : ((ShuffelingListExtended<Feature<?>>) ceilFeatures)
|
||||
.getOne();
|
||||
public Feature<?> getCeilFeature(Random random) {
|
||||
return ceilFeatures.isEmpty() ? null : ceilFeatures.get(random);
|
||||
}
|
||||
|
||||
public float getFloorDensity() {
|
||||
|
|
|
@ -109,7 +109,7 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
|
|||
floorPositions.forEach((pos) -> {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock);
|
||||
if (density > 0 && random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getFloorFeature();
|
||||
Feature<?> feature = biome.getFloorFeature(random);
|
||||
if (feature != null) {
|
||||
feature.place(new FeaturePlaceContext<>(world, null, random, pos.above(), null));
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
|
|||
BlocksHelper.setWithoutUpdate(world, pos, ceilBlock);
|
||||
}
|
||||
if (density > 0 && random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getCeilFeature();
|
||||
Feature<?> feature = biome.getCeilFeature(random);
|
||||
if (feature != null) {
|
||||
feature.place(new FeaturePlaceContext<>(world, null, random, pos.below(), null));
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock);
|
||||
}
|
||||
if (density > 0 && random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getFloorFeature();
|
||||
Feature<?> feature = biome.getFloorFeature(random);
|
||||
if (feature != null) {
|
||||
feature.place(new FeaturePlaceContext<>(world, null, random, pos.above(), null));
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
BlocksHelper.setWithoutUpdate(world, pos, ceilBlock);
|
||||
}
|
||||
if (density > 0 && random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getCeilFeature();
|
||||
Feature<?> feature = biome.getCeilFeature(random);
|
||||
if (feature != null) {
|
||||
feature.place(new FeaturePlaceContext<>(world, null, random, pos.below(), null));
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ public class TunelCaveFeature extends EndCaveFeature {
|
|||
BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock);
|
||||
}
|
||||
if (density > 0 && random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getFloorFeature();
|
||||
Feature<?> feature = biome.getFloorFeature(random);
|
||||
if (feature != null) {
|
||||
feature.place(new FeaturePlaceContext<>(world, null, random, pos.above(), null));
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ public class TunelCaveFeature extends EndCaveFeature {
|
|||
BlocksHelper.setWithoutUpdate(world, pos, ceilBlock);
|
||||
}
|
||||
if (density > 0 && random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getCeilFeature();
|
||||
Feature<?> feature = biome.getCeilFeature(random);
|
||||
if (feature != null) {
|
||||
feature.place(new FeaturePlaceContext<>(world, null, random, pos.below(), null));
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@ import net.minecraft.util.Mth;
|
|||
import ru.betterend.config.Configs;
|
||||
|
||||
public class GeneratorOptions {
|
||||
private static int biomeSizeLand;
|
||||
private static int biomeSizeVoid;
|
||||
private static int biomeSizeCaves;
|
||||
private static boolean hasPortal;
|
||||
private static boolean hasPillars;
|
||||
|
@ -31,8 +29,6 @@ public class GeneratorOptions {
|
|||
private static boolean directSpikeHeight;
|
||||
|
||||
public static void init() {
|
||||
biomeSizeLand = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeLand", 256);
|
||||
biomeSizeVoid = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeVoid", 256);
|
||||
biomeSizeCaves = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeCaves", 32);
|
||||
hasPortal = Configs.GENERATOR_CONFIG.getBoolean("portal", "hasPortal", true);
|
||||
hasPillars = Configs.GENERATOR_CONFIG.getBoolean("spikes", "hasSpikes", true);
|
||||
|
@ -88,14 +84,6 @@ public class GeneratorOptions {
|
|||
islandDistChunk = (circleRadius >> 3); // Twice bigger than normal
|
||||
}
|
||||
|
||||
public static int getBiomeSizeLand() {
|
||||
return Mth.clamp(biomeSizeLand, 1, 8192);
|
||||
}
|
||||
|
||||
public static int getBiomeSizeVoid() {
|
||||
return Mth.clamp(biomeSizeVoid, 1, 8192);
|
||||
}
|
||||
|
||||
public static int getBiomeSizeCaves() {
|
||||
return Mth.clamp(biomeSizeCaves, 1, 8192);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue