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
|
@ -1,10 +0,0 @@
|
|||
package ru.betterend.interfaces;
|
||||
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IBiomeList {
|
||||
public List<ResourceKey<Biome>> getBiomes();
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package ru.betterend.interfaces;
|
||||
|
||||
public interface ShuffelingListExtended<U> {
|
||||
public boolean isEmpty();
|
||||
|
||||
public U getOne();
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package ru.betterend.mixin.common;
|
||||
|
||||
import net.minecraft.world.entity.ai.behavior.ShufflingList;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import ru.betterend.interfaces.ShuffelingListExtended;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(ShufflingList.class)
|
||||
public abstract class ShuffelingListMixin<U> implements ShuffelingListExtended<U> {
|
||||
@Shadow
|
||||
@Final
|
||||
protected List<ShufflingList.WeightedEntry<U>> entries;
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.entries.isEmpty();
|
||||
}
|
||||
|
||||
@Shadow
|
||||
public abstract ShufflingList<U> shuffle();
|
||||
|
||||
public U getOne() {
|
||||
return this.shuffle().stream().findFirst().orElseThrow(RuntimeException::new);
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package ru.betterend.mixin.common;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.fabricmc.fabric.impl.biome.InternalBiomeData;
|
||||
import net.fabricmc.fabric.impl.biome.WeightedBiomePicker;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
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.betterend.interfaces.IBiomeList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(value = WeightedBiomePicker.class, remap = false)
|
||||
public class WeightedBiomePickerMixin implements IBiomeList {
|
||||
private final List<ResourceKey<Biome>> biomes = Lists.newArrayList();
|
||||
|
||||
@Inject(method = "addBiome", at = @At("TAIL"))
|
||||
private void be_addBiome(final ResourceKey<Biome> biome, final double weight, CallbackInfo info) {
|
||||
if (be_isCorrectPicker(WeightedBiomePicker.class.cast(this))) {
|
||||
biomes.add(biome);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ResourceKey<Biome>> getBiomes() {
|
||||
return biomes;
|
||||
}
|
||||
|
||||
private boolean be_isCorrectPicker(WeightedBiomePicker picker) {
|
||||
return picker == InternalBiomeData.getEndBiomesMap()
|
||||
.get(Biomes.SMALL_END_ISLANDS) || picker == InternalBiomeData.getEndBarrensMap()
|
||||
.get(Biomes.END_BARRENS);
|
||||
}
|
||||
}
|
|
@ -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