Biome Features Updated
This commit is contained in:
parent
aca43764ad
commit
78bf62bdca
8 changed files with 57 additions and 19 deletions
|
@ -1,5 +1,6 @@
|
|||
package ru.betterend.item;
|
||||
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.item.MobBucketItem;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
|
@ -8,6 +9,6 @@ import ru.betterend.registry.EndItems;
|
|||
|
||||
public class EndBucketItem extends MobBucketItem implements ItemModelProvider {
|
||||
public EndBucketItem(EntityType<?> type) {
|
||||
super(type, Fluids.WATER, EndItems.makeEndItemSettings().stacksTo(1));
|
||||
super(type, Fluids.WATER, SoundEvents.BUCKET_EMPTY, EndItems.makeEndItemSettings().stacksTo(1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
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.util.ShuffelingListExtended;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
11
src/main/java/ru/betterend/util/ShuffelingListExtended.java
Normal file
11
src/main/java/ru/betterend/util/ShuffelingListExtended.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package ru.betterend.util;
|
||||
|
||||
import net.minecraft.world.entity.ai.behavior.ShufflingList;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public interface ShuffelingListExtended<U> {
|
||||
public boolean isEmpty();
|
||||
public U getOne();
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
package ru.betterend.world.biome.cave;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.ai.behavior.ShufflingList;
|
||||
import net.minecraft.world.level.biome.Biome.BiomeCategory;
|
||||
|
@ -12,12 +10,15 @@ import ru.bclib.world.biomes.BCLBiomeDef;
|
|||
import ru.bclib.world.features.BCLFeature;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.registry.EndSounds;
|
||||
import ru.betterend.util.ShuffelingListExtended;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
import ru.betterend.world.features.terrain.caves.CaveChunkPopulatorFeature;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class EndCaveBiome extends EndBiome {
|
||||
private ShufflingList<Feature<?>> floorFeatures = new ShufflingList<Feature<?>>();
|
||||
private ShufflingList<Feature<?>> ceilFeatures = new ShufflingList<Feature<?>>();
|
||||
final private ShufflingList<Feature<?>> floorFeatures = new ShufflingList<>();
|
||||
final private ShufflingList<Feature<?>> ceilFeatures = new ShufflingList<>();
|
||||
|
||||
public EndCaveBiome(BCLBiomeDef definition) {
|
||||
super(makeDef(definition));
|
||||
|
@ -42,12 +43,12 @@ public class EndCaveBiome extends EndBiome {
|
|||
ceilFeatures.add(feature, weight);
|
||||
}
|
||||
|
||||
public Feature<?> getFloorFeature(Random random) {
|
||||
return floorFeatures.isEmpty() ? null : floorFeatures.getOne(random);
|
||||
public Feature<?> getFloorFeature() {
|
||||
return ((ShuffelingListExtended<Feature<?>>)floorFeatures).isEmpty() ? null : ((ShuffelingListExtended<Feature<?>>)floorFeatures).getOne();
|
||||
}
|
||||
|
||||
public Feature<?> getCeilFeature(Random random) {
|
||||
return ceilFeatures.isEmpty() ? null : ceilFeatures.getOne(random);
|
||||
public Feature<?> getCeilFeature() {
|
||||
return ((ShuffelingListExtended<Feature<?>>)ceilFeatures).isEmpty() ? null : ((ShuffelingListExtended<Feature<?>>)ceilFeatures).getOne();
|
||||
}
|
||||
|
||||
public float getFloorDensity() {
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
package ru.betterend.world.features.terrain;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
|
@ -20,6 +17,8 @@ import ru.betterend.noise.OpenSimplexNoise;
|
|||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.util.BlockFixer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class EndLakeFeature extends DefaultFeature {
|
||||
private static final BlockState END_STONE = Blocks.END_STONE.defaultBlockState();
|
||||
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(15152);
|
||||
|
@ -28,7 +27,7 @@ public class EndLakeFeature extends DefaultFeature {
|
|||
@Override
|
||||
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
|
||||
final Random random = featureConfig.random();
|
||||
final BlockPos blockPos = featureConfig.origin();
|
||||
BlockPos blockPos = featureConfig.origin();
|
||||
final WorldGenLevel world = featureConfig.level();
|
||||
double radius = MHelper.randRange(10.0, 20.0, random);
|
||||
double depth = radius * 0.5 * MHelper.randRange(0.8, 1.2, random);
|
||||
|
|
|
@ -113,7 +113,7 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
|
|||
floorPositions.forEach((pos) -> {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock);
|
||||
if (density > 0 && random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getFloorFeature(random);
|
||||
Feature<?> feature = biome.getFloorFeature();
|
||||
if (feature != null) {
|
||||
feature.place(new FeaturePlaceContext<>(world, null, random, pos.above(), null));
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
|
|||
BlocksHelper.setWithoutUpdate(world, pos, ceilBlock);
|
||||
}
|
||||
if (density > 0 && random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getCeilFeature(random);
|
||||
Feature<?> feature = biome.getCeilFeature();
|
||||
if (feature != null) {
|
||||
feature.place(new FeaturePlaceContext<>(world, null, random, pos.below(), null));
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock);
|
||||
}
|
||||
if (density > 0 && random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getFloorFeature(random);
|
||||
Feature<?> feature = biome.getFloorFeature();
|
||||
if (feature != null) {
|
||||
feature.place(new FeaturePlaceContext<>(world, null, random, pos.above(), null));
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
BlocksHelper.setWithoutUpdate(world, pos, ceilBlock);
|
||||
}
|
||||
if (density > 0 && random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getCeilFeature(random);
|
||||
Feature<?> feature = biome.getCeilFeature();
|
||||
if (feature != null) {
|
||||
feature.place(new FeaturePlaceContext<>(world, null, random, pos.below(), null));
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ public class TunelCaveFeature extends EndCaveFeature {
|
|||
BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock);
|
||||
}
|
||||
if (density > 0 && random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getFloorFeature(random);
|
||||
Feature<?> feature = biome.getFloorFeature();
|
||||
if (feature != null) {
|
||||
feature.place(new FeaturePlaceContext<>(world, null, random, pos.above(), null));
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ public class TunelCaveFeature extends EndCaveFeature {
|
|||
BlocksHelper.setWithoutUpdate(world, pos, ceilBlock);
|
||||
}
|
||||
if (density > 0 && random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getCeilFeature(random);
|
||||
Feature<?> feature = biome.getCeilFeature();
|
||||
if (feature != null) {
|
||||
feature.place(new FeaturePlaceContext<>(world, null, random, pos.below(), null));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue