Continue mapping migration

This commit is contained in:
Aleksey 2021-04-12 21:38:22 +03:00
parent 99ade39404
commit f03fd03bd0
499 changed files with 12567 additions and 12723 deletions

View file

@ -1,39 +1,36 @@
package ru.betterend.world.biome;
import java.util.List;
import com.google.common.collect.Lists;
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.block.Blocks;
import net.minecraft.client.sound.MusicType;
import net.minecraft.world.entity.EntityType;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.sound.BiomeAdditionsSound;
import net.minecraft.sound.BiomeMoodSound;
import net.minecraft.sound.MusicSound;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.core.Registry;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.Biome.Category;
import net.minecraft.world.level.biome.Biome.Precipitation;
import net.minecraft.world.biome.BiomeEffects.Builder;
import net.minecraft.world.biome.BiomeParticleConfig;
import net.minecraft.world.biome.GenerationSettings;
import net.minecraft.world.biome.SpawnSettings;
import net.minecraft.world.biome.SpawnSettings.SpawnEntry;
import net.minecraft.world.gen.GenerationStep.Carver;
import net.minecraft.world.gen.GenerationStep.Feature;
import net.minecraft.world.gen.ProbabilityConfig;
import net.minecraft.world.gen.carver.ConfiguredCarver;
import net.minecraft.world.level.levelgen.GenerationStep.Carving;
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
import net.minecraft.world.gen.surfacebuilder.ConfiguredSurfaceBuilder;
import net.minecraft.world.gen.surfacebuilder.ConfiguredSurfaceBuilders;
import net.minecraft.world.gen.surfacebuilder.SurfaceBuilder;
import net.minecraft.world.gen.surfacebuilder.TernarySurfaceConfig;
import net.minecraft.world.level.levelgen.feature.configurations.ProbabilityFeatureConfiguration;
import net.minecraft.world.level.levelgen.surfacebuilders.ConfiguredSurfaceBuilder;
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilder;
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderBaseConfiguration;
import com.google.common.collect.Lists;
import ru.betterend.BetterEnd;
import ru.betterend.registry.EndFeatures;
import ru.betterend.util.MHelper;
@ -44,16 +41,16 @@ import ru.betterend.world.surface.SurfaceBuilders;
public class BiomeDefinition {
private static final int DEF_FOLIAGE = MHelper.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<SpawnEntry> spawns = Lists.newArrayList();
private final List<SpawnerData> spawns = Lists.newArrayList();
private BiomeParticleConfig particleConfig;
private BiomeAdditionsSound additions;
private BiomeMoodSound mood;
private AmbientParticleSettings particleConfig;
private AmbientAdditionsSettings additions;
private AmbientMoodSettings mood;
private SoundEvent music;
private SoundEvent loop;
@ -69,56 +66,58 @@ public class BiomeDefinition {
private float genChance = 1F;
private boolean hasCaves = true;
private boolean isCaveBiome = false;
private ConfiguredSurfaceBuilder<?> surface;
public BiomeDefinition(String name) {
this.id = BetterEnd.makeID(name);
}
public BiomeDefinition setCaveBiome() {
isCaveBiome = true;
return this;
}
public BiomeDefinition setSurface(Block block) {
setSurface(SurfaceBuilder.DEFAULT.withConfig(new TernarySurfaceConfig(block.defaultBlockState(),
Blocks.END_STONE.defaultBlockState(), Blocks.END_STONE.defaultBlockState())));
setSurface(SurfaceBuilder.DEFAULT.configured(new SurfaceBuilderBaseConfiguration(
block.defaultBlockState(),
Blocks.END_STONE.defaultBlockState(),
Blocks.END_STONE.defaultBlockState()
)));
return this;
}
public BiomeDefinition setSurface(Block block1, Block block2) {
setSurface(DoubleBlockSurfaceBuilder.register("be_" + id.getPath() + "_surface").setBlock1(block1)
.setBlock2(block2).configured());
setSurface(DoubleBlockSurfaceBuilder.register("be_" + id.getPath() + "_surface").setBlock1(block1).setBlock2(block2).configured());
return this;
}
public BiomeDefinition setSurface(ConfiguredSurfaceBuilder<?> builder) {
this.surface = builder;
return this;
}
public BiomeDefinition setSurface(SurfaceBuilder<TernarySurfaceConfig> builder) {
return setSurface(builder.withConfig(SurfaceBuilders.DEFAULT_END_CONFIG));
public BiomeDefinition setSurface(SurfaceBuilder<SurfaceBuilderBaseConfiguration> builder) {
return setSurface(builder.configured(SurfaceBuilders.DEFAULT_END_CONFIG));
}
public BiomeDefinition setParticles(ParticleOptions particle, float probability) {
this.particleConfig = new BiomeParticleConfig(particle, probability);
this.particleConfig = new AmbientParticleSettings(particle, probability);
return this;
}
public BiomeDefinition setGenChance(float genChance) {
this.genChance = genChance;
return this;
}
public BiomeDefinition setDepth(float depth) {
this.depth = depth;
return this;
}
public BiomeDefinition addMobSpawn(EntityType<?> type, int weight, int minGroupSize, int maxGroupSize) {
ResourceLocation eID = Registry.ENTITY_TYPE.getId(type);
ResourceLocation eID = Registry.ENTITY_TYPE.getKey(type);
if (eID != Registry.ENTITY_TYPE.getDefaultKey()) {
SpawnInfo info = new SpawnInfo();
info.type = type;
@ -129,8 +128,8 @@ public class BiomeDefinition {
}
return this;
}
public BiomeDefinition addMobSpawn(SpawnEntry entry) {
public BiomeDefinition addMobSpawn(SpawnerData entry) {
spawns.add(entry);
return this;
}
@ -139,12 +138,12 @@ public class BiomeDefinition {
structures.add(feature);
return this;
}
public BiomeDefinition addStructureFeature(EndStructureFeature feature) {
structures.add(feature.getFeatureConfigured());
return this;
}
public BiomeDefinition addFeature(EndFeature feature) {
FeatureInfo info = new FeatureInfo();
info.featureStep = feature.getFeatureStep();
@ -153,14 +152,14 @@ public class BiomeDefinition {
return this;
}
public BiomeDefinition addFeature(Feature featureStep, ConfiguredFeature<?, ?> feature) {
public BiomeDefinition addFeature(Decoration featureStep, ConfiguredFeature<?, ?> 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);
@ -187,21 +186,21 @@ public class BiomeDefinition {
this.waterFogColor = getColor(r, g, b);
return this;
}
public BiomeDefinition setWaterAndFogColor(int r, int g, int b) {
return setWaterColor(r, g, b).setWaterFogColor(r, g, b);
}
public BiomeDefinition setFoliageColor(int r, int g, int b) {
this.foliageColor = getColor(r, g, b);
return this;
}
public BiomeDefinition setGrassColor(int r, int g, int b) {
this.grassColor = getColor(r, g, b);
return this;
}
public BiomeDefinition setPlantsColor(int r, int g, int b) {
return this.setFoliageColor(r, g, b).setGrassColor(r, g, b);
}
@ -212,12 +211,12 @@ public class BiomeDefinition {
}
public BiomeDefinition setMood(SoundEvent mood) {
this.mood = new BiomeMoodSound(mood, 6000, 8, 2.0D);
this.mood = new AmbientMoodSettings(mood, 6000, 8, 2.0D);
return this;
}
public BiomeDefinition setAdditions(SoundEvent additions) {
this.additions = new BiomeAdditionsSound(additions, 0.0111);
this.additions = new AmbientAdditionsSettings(additions, 0.0111);
return this;
}
@ -225,48 +224,49 @@ public class BiomeDefinition {
this.music = music;
return this;
}
public BiomeDefinition setCaves(boolean hasCaves) {
this.hasCaves = hasCaves;
return this;
}
public Biome build() {
SpawnSettings.Builder spawnSettings = new SpawnSettings.Builder();
GenerationSettings.Builder generationSettings = new GenerationSettings.Builder();
MobSpawnSettings.Builder spawnSettings = new MobSpawnSettings.Builder();
BiomeGenerationSettings.Builder generationSettings = new BiomeGenerationSettings.Builder();
Builder effects = new Builder();
mobs.forEach((spawn) -> {
spawnSettings.spawn(spawn.type.getSpawnGroup(),
new SpawnSettings.SpawnEntry(spawn.type, spawn.weight, spawn.minGroupSize, spawn.maxGroupSize));
spawnSettings.addSpawn(spawn.type.getCategory(), new MobSpawnSettings.SpawnerData(spawn.type, spawn.weight, spawn.minGroupSize, spawn.maxGroupSize));
});
spawns.forEach((entry) -> {
spawnSettings.spawn(entry.type.getSpawnGroup(), entry);
spawnSettings.addSpawn(entry.type.getCategory(), entry);
});
EndFeatures.addDefaultFeatures(this);
generationSettings.surfaceBuilder(surface == null ? ConfiguredSurfaceBuilders.END : surface);
structures.forEach((structure) -> generationSettings.structureFeature(structure));
features.forEach((info) -> generationSettings.feature(info.featureStep, info.feature));
carvers.forEach((info) -> generationSettings.carver(info.carverStep, info.carver));
generationSettings.surfaceBuilder(surface == null ? net.minecraft.data.worldgen.SurfaceBuilders.END : surface);
structures.forEach((structure) -> generationSettings.addStructureStart(structure));
features.forEach((info) -> generationSettings.addFeature(info.featureStep, info.feature));
carvers.forEach((info) -> generationSettings.addCarver(info.carverStep, info.carver));
effects.skyColor(0).waterColor(waterColor).waterFogColor(waterFogColor).fogColor(fogColor)
.foliageColor(foliageColor).grassColor(grassColor);
if (loop != null)
effects.loopSound(loop);
if (mood != null)
effects.moodSound(mood);
if (additions != null)
effects.additionsSound(additions);
if (particleConfig != null)
effects.particleConfig(particleConfig);
effects.music(music != null ? new MusicSound(music, 600, 2400, true) : MusicType.END);
effects.skyColor(0).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);
return new Biome.Builder().precipitation(Precipitation.NONE)
.category(isCaveBiome ? Category.NONE : Category.THEEND).depth(depth).scale(0.2F).temperature(2.0F)
.downfall(0.0F).effects(effects.build()).spawnSettings(spawnSettings.build())
.generationSettings(generationSettings.build()).build();
return new Biome.BiomeBuilder()
.precipitation(Precipitation.NONE)
.biomeCategory(isCaveBiome ? BiomeCategory.NONE : BiomeCategory.THEEND)
.depth(depth)
.scale(0.2F)
.temperature(2.0F)
.downfall(0.0F)
.specialEffects(effects.build())
.mobSpawnSettings(spawnSettings.build())
.generationSettings(generationSettings.build())
.build();
}
private static final class SpawnInfo {
@ -277,19 +277,19 @@ public class BiomeDefinition {
}
private static final class FeatureInfo {
Feature featureStep;
Decoration featureStep;
ConfiguredFeature<?, ?> feature;
}
private static final class CarverInfo {
Carver carverStep;
ConfiguredCarver<ProbabilityConfig> carver;
Carving carverStep;
ConfiguredWorldCarver<ProbabilityFeatureConfiguration> carver;
}
public ResourceLocation getID() {
return id;
}
public float getFodDensity() {
return fogDensity;
}
@ -302,7 +302,7 @@ public class BiomeDefinition {
return hasCaves;
}
public BiomeDefinition addCarver(Carver carverStep, ConfiguredCarver<ProbabilityConfig> carver) {
public BiomeDefinition addCarver(Carving carverStep, ConfiguredWorldCarver<ProbabilityFeatureConfiguration> carver) {
CarverInfo info = new CarverInfo();
info.carverStep = carverStep;
info.carver = carver;

View file

@ -3,14 +3,12 @@ package ru.betterend.world.biome;
import java.io.InputStream;
import java.util.List;
import java.util.Random;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.biome.Biome;
import com.google.common.collect.Lists;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import net.minecraft.world.level.biome.Biome;
import ru.betterend.config.Configs;
import ru.betterend.util.JsonFactory;
import ru.betterend.util.StructureHelper;
@ -82,7 +80,7 @@ public class EndBiome {
biome.biomeParent = this;
subbiomes.add(biome);
}
public boolean containsSubBiome(EndBiome biome) {
return subbiomes.contains(biome);
}
@ -137,7 +135,7 @@ public class EndBiome {
public float getFogDensity() {
return fogDensity;
}
protected void readStructureList() {
String ns = mcID.getNamespace();
String nm = mcID.getPath();
@ -162,11 +160,11 @@ public class EndBiome {
}
}
}
public EndFeature getStructuresFeature() {
return structuresFeature;
}
public Biome getActualBiome() {
return this.actualBiome;
}
@ -174,15 +172,15 @@ public class EndBiome {
public float getGenChance() {
return this.genChance;
}
public float getGenChanceImmutable() {
return this.genChanceUnmutable;
}
public boolean hasCaves() {
return hasCaves;
}
public void updateActualBiomes(Registry<Biome> biomeRegistry) {
subbiomes.forEach((sub) -> {
if (sub != this) {
@ -194,7 +192,7 @@ public class EndBiome {
}
this.actualBiome = biomeRegistry.get(mcID);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
@ -203,7 +201,7 @@ public class EndBiome {
EndBiome biome = (EndBiome) obj;
return biome == null ? false : biome.mcID.equals(mcID);
}
@Override
public int hashCode() {
return mcID.hashCode();

View file

@ -9,9 +9,15 @@ import ru.betterend.world.biome.EndBiome;
public class BiomeIceStarfield extends EndBiome {
public BiomeIceStarfield() {
super(new BiomeDefinition("ice_starfield").setFogColor(224, 245, 254).setFogDensity(2.2F)
.setFoliageColor(193, 244, 244).setGenChance(0.25F).setParticles(EndParticles.SNOWFLAKE, 0.002F)
.addStructureFeature(EndStructures.GIANT_ICE_STAR).addFeature(EndFeatures.ICE_STAR)
.addFeature(EndFeatures.ICE_STAR_SMALL).addMobSpawn(EntityType.ENDERMAN, 20, 1, 4));
super(new BiomeDefinition("ice_starfield")
.setFogColor(224, 245, 254)
.setFogDensity(2.2F)
.setFoliageColor(193, 244, 244)
.setGenChance(0.25F)
.setParticles(EndParticles.SNOWFLAKE, 0.002F)
.addStructureFeature(EndStructures.GIANT_ICE_STAR)
.addFeature(EndFeatures.ICE_STAR)
.addFeature(EndFeatures.ICE_STAR_SMALL)
.addMobSpawn(EntityType.ENDERMAN, 20, 1, 4));
}
}

View file

@ -1,10 +1,9 @@
package ru.betterend.world.biome.cave;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.util.collection.WeightedList;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.ai.behavior.WeightedList;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.Feature;
import ru.betterend.registry.EndBiomes;
import ru.betterend.world.biome.BiomeDefinition;
@ -15,42 +14,44 @@ import ru.betterend.world.features.terrain.caves.CaveChunkPopulatorFeature;
public class EndCaveBiome extends EndBiome {
private WeightedList<Feature<?>> floorFeatures = new WeightedList<Feature<?>>();
private WeightedList<Feature<?>> ceilFeatures = new WeightedList<Feature<?>>();
public EndCaveBiome(BiomeDefinition definition) {
super(makeDef(definition));
}
private static BiomeDefinition makeDef(BiomeDefinition definition) {
EndFeature feature = EndFeature.makeChunkFeature(definition.getID().getPath() + "_cave_populator",
new CaveChunkPopulatorFeature(() -> (EndCaveBiome) EndBiomes.getBiome(definition.getID())));
EndFeature feature = EndFeature.makeChunkFeature(
definition.getID().getPath() + "_cave_populator",
new CaveChunkPopulatorFeature(() -> (EndCaveBiome) EndBiomes.getBiome(definition.getID()))
);
definition.addFeature(feature).setCaveBiome();
return definition;
}
public void addFloorFeature(Feature<?> feature, int weight) {
floorFeatures.add(feature, weight);
}
public void addCeilFeature(Feature<?> feature, int weight) {
ceilFeatures.add(feature, weight);
}
public Feature<?> getFloorFeature(Random random) {
return floorFeatures.isEmpty() ? null : floorFeatures.pickRandom(random);
return floorFeatures.isEmpty() ? null : floorFeatures.getOne(random);
}
public Feature<?> getCeilFeature(Random random) {
return ceilFeatures.isEmpty() ? null : ceilFeatures.pickRandom(random);
return ceilFeatures.isEmpty() ? null : ceilFeatures.getOne(random);
}
public float getFloorDensity() {
return 0;
}
public float getCeilDensity() {
return 0;
}
public BlockState getCeil(BlockPos pos) {
return null;
}

View file

@ -1,7 +1,7 @@
package ru.betterend.world.biome.cave;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.registry.EndBlocks;
@ -12,34 +12,39 @@ import ru.betterend.world.biome.BiomeDefinition;
public class LushAuroraCaveBiome extends EndCaveBiome {
public LushAuroraCaveBiome() {
super(new BiomeDefinition("lush_aurora_cave").setFogColor(150, 30, 68).setFogDensity(2.0F)
.setPlantsColor(108, 25, 46).setWaterAndFogColor(186, 77, 237).setMusic(EndSounds.MUSIC_FOREST)
.setParticles(EndParticles.GLOWING_SPHERE, 0.001F).setSurface(EndBlocks.CAVE_MOSS));
super(new BiomeDefinition("lush_aurora_cave")
.setFogColor(150, 30, 68)
.setFogDensity(2.0F)
.setPlantsColor(108, 25, 46)
.setWaterAndFogColor(186, 77, 237)
.setMusic(EndSounds.MUSIC_FOREST)
.setParticles(EndParticles.GLOWING_SPHERE, 0.001F)
.setSurface(EndBlocks.CAVE_MOSS));
this.addFloorFeature(EndFeatures.BIG_AURORA_CRYSTAL, 1);
this.addFloorFeature(EndFeatures.CAVE_BUSH, 5);
this.addFloorFeature(EndFeatures.CAVE_GRASS, 40);
this.addFloorFeature(EndFeatures.END_STONE_STALAGMITE_CAVEMOSS, 5);
this.addCeilFeature(EndFeatures.CAVE_BUSH, 1);
this.addCeilFeature(EndFeatures.CAVE_PUMPKIN, 1);
this.addCeilFeature(EndFeatures.RUBINEA, 3);
this.addCeilFeature(EndFeatures.MAGNULA, 1);
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE_CAVEMOSS, 10);
}
@Override
public float getFloorDensity() {
return 0.2F;
}
@Override
public float getCeilDensity() {
return 0.1F;
}
@Override
public BlockState getCeil(BlockPos pos) {
return EndBlocks.CAVE_MOSS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP);
return EndBlocks.CAVE_MOSS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP);
}
}

View file

@ -1,7 +1,7 @@
package ru.betterend.world.biome.land;
import net.minecraft.data.worldgen.StructureFeatures;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeatures;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndEntities;
import ru.betterend.registry.EndFeatures;
@ -12,15 +12,27 @@ import ru.betterend.world.biome.EndBiome;
public class AmberLandBiome extends EndBiome {
public AmberLandBiome() {
super(new BiomeDefinition("amber_land").setFogColor(255, 184, 71).setFogDensity(2.0F)
.setPlantsColor(219, 115, 38).setWaterAndFogColor(145, 108, 72).setMusic(EndSounds.MUSIC_FOREST)
.setParticles(EndParticles.AMBER_SPHERE, 0.001F).setSurface(EndBlocks.AMBER_MOSS)
.addFeature(EndFeatures.AMBER_ORE).addFeature(EndFeatures.END_LAKE_RARE)
.addFeature(EndFeatures.HELIX_TREE).addFeature(EndFeatures.LANCELEAF)
.addFeature(EndFeatures.GLOW_PILLAR).addFeature(EndFeatures.AMBER_GRASS)
.addFeature(EndFeatures.AMBER_ROOT).addFeature(EndFeatures.BULB_MOSS)
.addFeature(EndFeatures.BULB_MOSS_WOOD).addFeature(EndFeatures.CHARNIA_ORANGE)
.addFeature(EndFeatures.CHARNIA_RED).addStructureFeature(ConfiguredStructureFeatures.END_CITY)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 4).addMobSpawn(EndEntities.END_SLIME, 30, 1, 2));
super(new BiomeDefinition("amber_land")
.setFogColor(255, 184, 71)
.setFogDensity(2.0F)
.setPlantsColor(219, 115, 38)
.setWaterAndFogColor(145, 108, 72)
.setMusic(EndSounds.MUSIC_FOREST)
.setParticles(EndParticles.AMBER_SPHERE, 0.001F)
.setSurface(EndBlocks.AMBER_MOSS)
.addFeature(EndFeatures.AMBER_ORE)
.addFeature(EndFeatures.END_LAKE_RARE)
.addFeature(EndFeatures.HELIX_TREE)
.addFeature(EndFeatures.LANCELEAF)
.addFeature(EndFeatures.GLOW_PILLAR)
.addFeature(EndFeatures.AMBER_GRASS)
.addFeature(EndFeatures.AMBER_ROOT)
.addFeature(EndFeatures.BULB_MOSS)
.addFeature(EndFeatures.BULB_MOSS_WOOD)
.addFeature(EndFeatures.CHARNIA_ORANGE)
.addFeature(EndFeatures.CHARNIA_RED)
.addStructureFeature(StructureFeatures.END_CITY)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 4)
.addMobSpawn(EndEntities.END_SLIME, 30, 1, 2));
}
}

View file

@ -10,14 +10,26 @@ import ru.betterend.world.biome.EndBiome;
public class BlossomingSpiresBiome extends EndBiome {
public BlossomingSpiresBiome() {
super(new BiomeDefinition("blossoming_spires").setFogColor(241, 146, 229).setFogDensity(1.7F)
.setPlantsColor(122, 45, 122).setCaves(false).setSurface(EndBlocks.PINK_MOSS)
.setMusic(EndSounds.MUSIC_FOREST).setLoop(EndSounds.AMBIENT_BLOSSOMING_SPIRES)
.addFeature(EndFeatures.SPIRE).addFeature(EndFeatures.FLOATING_SPIRE).addFeature(EndFeatures.TENANEA)
.addFeature(EndFeatures.TENANEA_BUSH).addFeature(EndFeatures.BULB_VINE)
.addFeature(EndFeatures.BUSHY_GRASS).addFeature(EndFeatures.BUSHY_GRASS_WG)
.addFeature(EndFeatures.BLOSSOM_BERRY).addFeature(EndFeatures.TWISTED_MOSS)
.addFeature(EndFeatures.TWISTED_MOSS_WOOD).addFeature(EndFeatures.SILK_MOTH_NEST)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 4).addMobSpawn(EndEntities.SILK_MOTH, 5, 1, 2));
super(new BiomeDefinition("blossoming_spires")
.setFogColor(241, 146, 229)
.setFogDensity(1.7F)
.setPlantsColor(122, 45, 122)
.setCaves(false)
.setSurface(EndBlocks.PINK_MOSS)
.setMusic(EndSounds.MUSIC_FOREST)
.setLoop(EndSounds.AMBIENT_BLOSSOMING_SPIRES)
.addFeature(EndFeatures.SPIRE)
.addFeature(EndFeatures.FLOATING_SPIRE)
.addFeature(EndFeatures.TENANEA)
.addFeature(EndFeatures.TENANEA_BUSH)
.addFeature(EndFeatures.BULB_VINE)
.addFeature(EndFeatures.BUSHY_GRASS)
.addFeature(EndFeatures.BUSHY_GRASS_WG)
.addFeature(EndFeatures.BLOSSOM_BERRY)
.addFeature(EndFeatures.TWISTED_MOSS)
.addFeature(EndFeatures.TWISTED_MOSS_WOOD)
.addFeature(EndFeatures.SILK_MOTH_NEST)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 4)
.addMobSpawn(EndEntities.SILK_MOTH, 5, 1, 2));
}
}

View file

@ -1,10 +1,10 @@
package ru.betterend.world.biome.land;
import net.minecraft.world.entity.EntityType;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.gen.GenerationStep.Feature;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeatures;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeatures;
import net.minecraft.data.worldgen.Features;
import net.minecraft.data.worldgen.StructureFeatures;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndEntities;
import ru.betterend.registry.EndFeatures;
@ -14,18 +14,30 @@ import ru.betterend.world.biome.EndBiome;
public class ChorusForestBiome extends EndBiome {
public ChorusForestBiome() {
super(new BiomeDefinition("chorus_forest").setFogColor(87, 26, 87).setFogDensity(1.5F)
.setPlantsColor(122, 45, 122).setWaterAndFogColor(73, 30, 73).setSurface(EndBlocks.CHORUS_NYLIUM)
.setParticles(ParticleTypes.PORTAL, 0.01F).setLoop(EndSounds.AMBIENT_CHORUS_FOREST)
.setMusic(EndSounds.MUSIC_DARK).addFeature(EndFeatures.VIOLECITE_LAYER)
.addFeature(EndFeatures.END_LAKE_RARE).addFeature(EndFeatures.PYTHADENDRON_TREE)
.addFeature(EndFeatures.PYTHADENDRON_BUSH).addFeature(EndFeatures.PURPLE_POLYPORE)
.addFeature(Feature.VEGETAL_DECORATION, ConfiguredFeatures.CHORUS_PLANT)
.addFeature(Feature.VEGETAL_DECORATION, ConfiguredFeatures.CHORUS_PLANT)
.addFeature(EndFeatures.CHORUS_GRASS).addFeature(EndFeatures.CHORUS_MUSHROOM)
.addFeature(EndFeatures.TAIL_MOSS).addFeature(EndFeatures.TAIL_MOSS_WOOD)
.addFeature(EndFeatures.CHARNIA_PURPLE).addFeature(EndFeatures.CHARNIA_RED_RARE)
.addStructureFeature(ConfiguredStructureFeatures.END_CITY).addMobSpawn(EndEntities.END_SLIME, 5, 1, 2)
super(new BiomeDefinition("chorus_forest")
.setFogColor(87, 26, 87)
.setFogDensity(1.5F)
.setPlantsColor(122, 45, 122)
.setWaterAndFogColor(73, 30, 73)
.setSurface(EndBlocks.CHORUS_NYLIUM)
.setParticles(ParticleTypes.PORTAL, 0.01F)
.setLoop(EndSounds.AMBIENT_CHORUS_FOREST)
.setMusic(EndSounds.MUSIC_DARK)
.addFeature(EndFeatures.VIOLECITE_LAYER)
.addFeature(EndFeatures.END_LAKE_RARE)
.addFeature(EndFeatures.PYTHADENDRON_TREE)
.addFeature(EndFeatures.PYTHADENDRON_BUSH)
.addFeature(EndFeatures.PURPLE_POLYPORE)
.addFeature(Decoration.VEGETAL_DECORATION, Features.CHORUS_PLANT)
.addFeature(Decoration.VEGETAL_DECORATION, Features.CHORUS_PLANT)
.addFeature(EndFeatures.CHORUS_GRASS)
.addFeature(EndFeatures.CHORUS_MUSHROOM)
.addFeature(EndFeatures.TAIL_MOSS)
.addFeature(EndFeatures.TAIL_MOSS_WOOD)
.addFeature(EndFeatures.CHARNIA_PURPLE)
.addFeature(EndFeatures.CHARNIA_RED_RARE)
.addStructureFeature(StructureFeatures.END_CITY)
.addMobSpawn(EndEntities.END_SLIME, 5, 1, 2)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 4));
}
}

View file

@ -10,9 +10,13 @@ import ru.betterend.world.biome.EndBiome;
public class CrystalMountainsBiome extends EndBiome {
public CrystalMountainsBiome() {
super(new BiomeDefinition("crystal_mountains").setPlantsColor(255, 133, 211).setSurface(EndBlocks.CRYSTAL_MOSS)
.setMusic(EndSounds.MUSIC_OPENSPACE).addStructureFeature(EndStructures.MOUNTAIN)
.addFeature(EndFeatures.ROUND_CAVE).addFeature(EndFeatures.CRYSTAL_GRASS)
super(new BiomeDefinition("crystal_mountains")
.setPlantsColor(255, 133, 211)
.setSurface(EndBlocks.CRYSTAL_MOSS)
.setMusic(EndSounds.MUSIC_OPENSPACE)
.addStructureFeature(EndStructures.MOUNTAIN)
.addFeature(EndFeatures.ROUND_CAVE)
.addFeature(EndFeatures.CRYSTAL_GRASS)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
}
}

View file

@ -10,14 +10,24 @@ import ru.betterend.world.biome.EndBiome;
public class DragonGraveyardsBiome extends EndBiome {
public DragonGraveyardsBiome() {
super(new BiomeDefinition("dragon_graveyards").setGenChance(0.1F).setFogColor(244, 46, 79).setFogDensity(1.3F)
.setParticles(EndParticles.FIREFLY, 0.0007F).setMusic(EndSounds.MUSIC_OPENSPACE)
.setLoop(EndSounds.AMBIENT_GLOWING_GRASSLANDS).setSurface(EndBlocks.SANGNUM)
.setWaterAndFogColor(203, 59, 167).setPlantsColor(244, 46, 79)
.addFeature(EndFeatures.OBSIDIAN_PILLAR_BASEMENT).addFeature(EndFeatures.FALLEN_PILLAR)
.addFeature(EndFeatures.OBSIDIAN_BOULDER).addFeature(EndFeatures.GIGANTIC_AMARANITA)
.addFeature(EndFeatures.LARGE_AMARANITA).addFeature(EndFeatures.SMALL_AMARANITA)
.addFeature(EndFeatures.GLOBULAGUS).addFeature(EndFeatures.CLAWFERN)
super(new BiomeDefinition("dragon_graveyards")
.setGenChance(0.1F)
.setFogColor(244, 46, 79)
.setFogDensity(1.3F)
.setParticles(EndParticles.FIREFLY, 0.0007F)
.setMusic(EndSounds.MUSIC_OPENSPACE)
.setLoop(EndSounds.AMBIENT_GLOWING_GRASSLANDS)
.setSurface(EndBlocks.SANGNUM)
.setWaterAndFogColor(203, 59, 167)
.setPlantsColor(244, 46, 79)
.addFeature(EndFeatures.OBSIDIAN_PILLAR_BASEMENT)
.addFeature(EndFeatures.FALLEN_PILLAR)
.addFeature(EndFeatures.OBSIDIAN_BOULDER)
.addFeature(EndFeatures.GIGANTIC_AMARANITA)
.addFeature(EndFeatures.LARGE_AMARANITA)
.addFeature(EndFeatures.SMALL_AMARANITA)
.addFeature(EndFeatures.GLOBULAGUS)
.addFeature(EndFeatures.CLAWFERN)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
}
}

View file

@ -1,7 +1,7 @@
package ru.betterend.world.biome.land;
import net.minecraft.data.worldgen.StructureFeatures;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeatures;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures;
import ru.betterend.registry.EndSounds;
@ -10,10 +10,18 @@ import ru.betterend.world.biome.EndBiome;
public class DryShrublandBiome extends EndBiome {
public DryShrublandBiome() {
super(new BiomeDefinition("dry_shrubland").setFogColor(132, 35, 13).setFogDensity(1.2F)
.setWaterAndFogColor(113, 88, 53).setPlantsColor(237, 122, 66).setSurface(EndBlocks.RUTISCUS)
.setMusic(EndSounds.MUSIC_OPENSPACE).addFeature(EndFeatures.ORANGO).addFeature(EndFeatures.AERIDIUM)
.addFeature(EndFeatures.LUTEBUS).addFeature(EndFeatures.LAMELLARIUM)
.addStructureFeature(ConfiguredStructureFeatures.END_CITY).addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
super(new BiomeDefinition("dry_shrubland")
.setFogColor(132, 35, 13)
.setFogDensity(1.2F)
.setWaterAndFogColor(113, 88, 53)
.setPlantsColor(237, 122, 66)
.setSurface(EndBlocks.RUTISCUS)
.setMusic(EndSounds.MUSIC_OPENSPACE)
.addFeature(EndFeatures.ORANGO)
.addFeature(EndFeatures.AERIDIUM)
.addFeature(EndFeatures.LUTEBUS)
.addFeature(EndFeatures.LAMELLARIUM)
.addStructureFeature(StructureFeatures.END_CITY)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
}
}

View file

@ -1,8 +1,8 @@
package ru.betterend.world.biome.land;
import net.minecraft.world.entity.EntityType;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeatures;
import net.minecraft.data.worldgen.StructureFeatures;
import net.minecraft.world.entity.EntityType;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndSounds;
import ru.betterend.world.biome.BiomeDefinition;
@ -10,10 +10,15 @@ import ru.betterend.world.biome.EndBiome;
public class DustWastelandsBiome extends EndBiome {
public DustWastelandsBiome() {
super(new BiomeDefinition("dust_wastelands").setFogColor(226, 239, 168).setFogDensity(2)
.setWaterAndFogColor(192, 180, 131).setSurface(EndBlocks.ENDSTONE_DUST)
.setParticles(ParticleTypes.WHITE_ASH, 0.01F).setLoop(EndSounds.AMBIENT_DUST_WASTELANDS)
.setMusic(EndSounds.MUSIC_OPENSPACE).addStructureFeature(ConfiguredStructureFeatures.END_CITY)
super(new BiomeDefinition("dust_wastelands")
.setFogColor(226, 239, 168)
.setFogDensity(2)
.setWaterAndFogColor(192, 180, 131)
.setSurface(EndBlocks.ENDSTONE_DUST)
.setParticles(ParticleTypes.WHITE_ASH, 0.01F)
.setLoop(EndSounds.AMBIENT_DUST_WASTELANDS)
.setMusic(EndSounds.MUSIC_OPENSPACE)
.addStructureFeature(StructureFeatures.END_CITY)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
}
}

View file

@ -1,7 +1,7 @@
package ru.betterend.world.biome.land;
import net.minecraft.data.worldgen.StructureFeatures;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeatures;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndEntities;
import ru.betterend.registry.EndFeatures;
@ -13,20 +13,35 @@ import ru.betterend.world.biome.EndBiome;
public class FoggyMushroomlandBiome extends EndBiome {
public FoggyMushroomlandBiome() {
super(new BiomeDefinition("foggy_mushroomland").setPlantsColor(73, 210, 209).setFogColor(41, 122, 173)
.setFogDensity(3).setWaterAndFogColor(119, 227, 250)
super(new BiomeDefinition("foggy_mushroomland")
.setPlantsColor(73, 210, 209)
.setFogColor(41, 122, 173)
.setFogDensity(3)
.setWaterAndFogColor(119, 227, 250)
.setSurface(EndBlocks.END_MOSS, EndBlocks.END_MYCELIUM)
.setParticles(EndParticles.GLOWING_SPHERE, 0.001F).setLoop(EndSounds.AMBIENT_FOGGY_MUSHROOMLAND)
.setMusic(EndSounds.MUSIC_FOREST).addStructureFeature(EndStructures.GIANT_MOSSY_GLOWSHROOM)
.addFeature(EndFeatures.END_LAKE).addFeature(EndFeatures.MOSSY_GLOWSHROOM)
.addFeature(EndFeatures.BLUE_VINE).addFeature(EndFeatures.UMBRELLA_MOSS)
.addFeature(EndFeatures.CREEPING_MOSS).addFeature(EndFeatures.DENSE_VINE)
.addFeature(EndFeatures.PEARLBERRY).addFeature(EndFeatures.CYAN_MOSS)
.addFeature(EndFeatures.CYAN_MOSS_WOOD).addFeature(EndFeatures.END_LILY)
.addFeature(EndFeatures.BUBBLE_CORAL).addFeature(EndFeatures.CHARNIA_CYAN)
.addFeature(EndFeatures.CHARNIA_LIGHT_BLUE).addFeature(EndFeatures.CHARNIA_RED_RARE)
.addStructureFeature(ConfiguredStructureFeatures.END_CITY).addMobSpawn(EndEntities.DRAGONFLY, 80, 2, 5)
.addMobSpawn(EndEntities.END_FISH, 20, 2, 5).addMobSpawn(EndEntities.CUBOZOA, 10, 3, 8)
.addMobSpawn(EndEntities.END_SLIME, 10, 1, 2).addMobSpawn(EntityType.ENDERMAN, 10, 1, 2));
.setParticles(EndParticles.GLOWING_SPHERE, 0.001F)
.setLoop(EndSounds.AMBIENT_FOGGY_MUSHROOMLAND)
.setMusic(EndSounds.MUSIC_FOREST)
.addStructureFeature(EndStructures.GIANT_MOSSY_GLOWSHROOM)
.addFeature(EndFeatures.END_LAKE)
.addFeature(EndFeatures.MOSSY_GLOWSHROOM)
.addFeature(EndFeatures.BLUE_VINE)
.addFeature(EndFeatures.UMBRELLA_MOSS)
.addFeature(EndFeatures.CREEPING_MOSS)
.addFeature(EndFeatures.DENSE_VINE)
.addFeature(EndFeatures.PEARLBERRY)
.addFeature(EndFeatures.CYAN_MOSS)
.addFeature(EndFeatures.CYAN_MOSS_WOOD)
.addFeature(EndFeatures.END_LILY)
.addFeature(EndFeatures.BUBBLE_CORAL)
.addFeature(EndFeatures.CHARNIA_CYAN)
.addFeature(EndFeatures.CHARNIA_LIGHT_BLUE)
.addFeature(EndFeatures.CHARNIA_RED_RARE)
.addStructureFeature(StructureFeatures.END_CITY)
.addMobSpawn(EndEntities.DRAGONFLY, 80, 2, 5)
.addMobSpawn(EndEntities.END_FISH, 20, 2, 5)
.addMobSpawn(EndEntities.CUBOZOA, 10, 3, 8)
.addMobSpawn(EndEntities.END_SLIME, 10, 1, 2)
.addMobSpawn(EntityType.ENDERMAN, 10, 1, 2));
}
}

View file

@ -1,7 +1,7 @@
package ru.betterend.world.biome.land;
import net.minecraft.data.worldgen.StructureFeatures;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeatures;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures;
import ru.betterend.registry.EndParticles;
@ -11,16 +11,29 @@ import ru.betterend.world.biome.EndBiome;
public class GlowingGrasslandsBiome extends EndBiome {
public GlowingGrasslandsBiome() {
super(new BiomeDefinition("glowing_grasslands").setFogColor(99, 228, 247).setFogDensity(1.3F)
.setParticles(EndParticles.FIREFLY, 0.001F).setMusic(EndSounds.MUSIC_OPENSPACE)
.setLoop(EndSounds.AMBIENT_GLOWING_GRASSLANDS).setSurface(EndBlocks.END_MOSS)
.setWaterAndFogColor(92, 250, 230).setPlantsColor(73, 210, 209).addFeature(EndFeatures.END_LAKE_RARE)
.addFeature(EndFeatures.LUMECORN).addFeature(EndFeatures.BLOOMING_COOKSONIA)
.addFeature(EndFeatures.SALTEAGO).addFeature(EndFeatures.VAIOLUSH_FERN).addFeature(EndFeatures.FRACTURN)
.addFeature(EndFeatures.UMBRELLA_MOSS_RARE).addFeature(EndFeatures.CREEPING_MOSS_RARE)
.addFeature(EndFeatures.TWISTED_UMBRELLA_MOSS_RARE).addFeature(EndFeatures.CHARNIA_CYAN)
.addFeature(EndFeatures.CHARNIA_GREEN).addFeature(EndFeatures.CHARNIA_LIGHT_BLUE)
.addFeature(EndFeatures.CHARNIA_RED_RARE).addStructureFeature(ConfiguredStructureFeatures.END_CITY)
super(new BiomeDefinition("glowing_grasslands")
.setFogColor(99, 228, 247)
.setFogDensity(1.3F)
.setParticles(EndParticles.FIREFLY, 0.001F)
.setMusic(EndSounds.MUSIC_OPENSPACE)
.setLoop(EndSounds.AMBIENT_GLOWING_GRASSLANDS)
.setSurface(EndBlocks.END_MOSS)
.setWaterAndFogColor(92, 250, 230)
.setPlantsColor(73, 210, 209)
.addFeature(EndFeatures.END_LAKE_RARE)
.addFeature(EndFeatures.LUMECORN)
.addFeature(EndFeatures.BLOOMING_COOKSONIA)
.addFeature(EndFeatures.SALTEAGO)
.addFeature(EndFeatures.VAIOLUSH_FERN)
.addFeature(EndFeatures.FRACTURN)
.addFeature(EndFeatures.UMBRELLA_MOSS_RARE)
.addFeature(EndFeatures.CREEPING_MOSS_RARE)
.addFeature(EndFeatures.TWISTED_UMBRELLA_MOSS_RARE)
.addFeature(EndFeatures.CHARNIA_CYAN)
.addFeature(EndFeatures.CHARNIA_GREEN)
.addFeature(EndFeatures.CHARNIA_LIGHT_BLUE)
.addFeature(EndFeatures.CHARNIA_RED_RARE)
.addStructureFeature(StructureFeatures.END_CITY)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
}
}

View file

@ -1,7 +1,7 @@
package ru.betterend.world.biome.land;
import net.minecraft.data.worldgen.StructureFeatures;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeatures;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures;
import ru.betterend.registry.EndParticles;
@ -11,15 +11,29 @@ import ru.betterend.world.biome.EndBiome;
public class LanternWoodsBiome extends EndBiome {
public LanternWoodsBiome() {
super(new BiomeDefinition("lantern_woods").setFogColor(189, 82, 70).setFogDensity(1.1F)
.setWaterAndFogColor(171, 234, 226).setPlantsColor(254, 85, 57).setSurface(EndBlocks.RUTISCUS)
.setMusic(EndSounds.MUSIC_FOREST).setParticles(EndParticles.GLOWING_SPHERE, 0.001F)
.addFeature(EndFeatures.END_LAKE_NORMAL).addFeature(EndFeatures.FLAMAEA)
.addFeature(EndFeatures.LUCERNIA).addFeature(EndFeatures.LUCERNIA_BUSH).addFeature(EndFeatures.FILALUX)
.addFeature(EndFeatures.AERIDIUM).addFeature(EndFeatures.LAMELLARIUM)
.addFeature(EndFeatures.BOLUX_MUSHROOM).addFeature(EndFeatures.AURANT_POLYPORE)
.addFeature(EndFeatures.POND_ANEMONE).addFeature(EndFeatures.CHARNIA_ORANGE)
.addFeature(EndFeatures.CHARNIA_RED).addFeature(EndFeatures.RUSCUS).addFeature(EndFeatures.RUSCUS_WOOD)
.addStructureFeature(ConfiguredStructureFeatures.END_CITY).addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
super(new BiomeDefinition("lantern_woods")
.setFogColor(189, 82, 70)
.setFogDensity(1.1F)
.setWaterAndFogColor(171, 234, 226)
.setPlantsColor(254, 85, 57)
.setSurface(EndBlocks.RUTISCUS)
.setMusic(EndSounds.MUSIC_FOREST)
.setParticles(EndParticles.GLOWING_SPHERE, 0.001F)
.addFeature(EndFeatures.END_LAKE_NORMAL)
.addFeature(EndFeatures.FLAMAEA)
.addFeature(EndFeatures.LUCERNIA)
.addFeature(EndFeatures.LUCERNIA_BUSH)
.addFeature(EndFeatures.FILALUX)
.addFeature(EndFeatures.AERIDIUM)
.addFeature(EndFeatures.LAMELLARIUM)
.addFeature(EndFeatures.BOLUX_MUSHROOM)
.addFeature(EndFeatures.AURANT_POLYPORE)
.addFeature(EndFeatures.POND_ANEMONE)
.addFeature(EndFeatures.CHARNIA_ORANGE)
.addFeature(EndFeatures.CHARNIA_RED)
.addFeature(EndFeatures.RUSCUS)
.addFeature(EndFeatures.RUSCUS_WOOD)
.addStructureFeature(StructureFeatures.END_CITY)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
}
}

View file

@ -11,17 +11,31 @@ import ru.betterend.world.biome.EndBiome;
public class MegalakeBiome extends EndBiome {
public MegalakeBiome() {
super(new BiomeDefinition("megalake").setPlantsColor(73, 210, 209).setFogColor(178, 209, 248)
.setWaterAndFogColor(96, 163, 255).setFogDensity(1.75F).setMusic(EndSounds.MUSIC_WATER)
.setLoop(EndSounds.AMBIENT_MEGALAKE).setSurface(EndBlocks.END_MOSS, EndBlocks.ENDSTONE_DUST)
.setDepth(0F).addStructureFeature(EndStructures.MEGALAKE).addFeature(EndFeatures.END_LOTUS)
.addFeature(EndFeatures.END_LOTUS_LEAF).addFeature(EndFeatures.BUBBLE_CORAL_RARE)
.addFeature(EndFeatures.END_LILY_RARE).addFeature(EndFeatures.UMBRELLA_MOSS)
.addFeature(EndFeatures.CREEPING_MOSS).addFeature(EndFeatures.PEARLBERRY)
.addFeature(EndFeatures.CHARNIA_CYAN).addFeature(EndFeatures.CHARNIA_LIGHT_BLUE)
.addFeature(EndFeatures.CHARNIA_RED_RARE).addFeature(EndFeatures.MENGER_SPONGE)
.addMobSpawn(EndEntities.DRAGONFLY, 50, 1, 3).addMobSpawn(EndEntities.END_FISH, 50, 3, 8)
.addMobSpawn(EndEntities.CUBOZOA, 50, 3, 8).addMobSpawn(EndEntities.END_SLIME, 5, 1, 2)
super(new BiomeDefinition("megalake")
.setPlantsColor(73, 210, 209)
.setFogColor(178, 209, 248)
.setWaterAndFogColor(96, 163, 255)
.setFogDensity(1.75F)
.setMusic(EndSounds.MUSIC_WATER)
.setLoop(EndSounds.AMBIENT_MEGALAKE)
.setSurface(EndBlocks.END_MOSS, EndBlocks.ENDSTONE_DUST)
.setDepth(0F)
.addStructureFeature(EndStructures.MEGALAKE)
.addFeature(EndFeatures.END_LOTUS)
.addFeature(EndFeatures.END_LOTUS_LEAF)
.addFeature(EndFeatures.BUBBLE_CORAL_RARE)
.addFeature(EndFeatures.END_LILY_RARE)
.addFeature(EndFeatures.UMBRELLA_MOSS)
.addFeature(EndFeatures.CREEPING_MOSS)
.addFeature(EndFeatures.PEARLBERRY)
.addFeature(EndFeatures.CHARNIA_CYAN)
.addFeature(EndFeatures.CHARNIA_LIGHT_BLUE)
.addFeature(EndFeatures.CHARNIA_RED_RARE)
.addFeature(EndFeatures.MENGER_SPONGE)
.addMobSpawn(EndEntities.DRAGONFLY, 50, 1, 3)
.addMobSpawn(EndEntities.END_FISH, 50, 3, 8)
.addMobSpawn(EndEntities.CUBOZOA, 50, 3, 8)
.addMobSpawn(EndEntities.END_SLIME, 5, 1, 2)
.addMobSpawn(EntityType.ENDERMAN, 10, 1, 2));
}
}

View file

@ -12,18 +12,33 @@ import ru.betterend.world.biome.EndBiome;
public class MegalakeGroveBiome extends EndBiome {
public MegalakeGroveBiome() {
super(new BiomeDefinition("megalake_grove").setPlantsColor(73, 210, 209).setFogColor(178, 209, 248)
.setWaterAndFogColor(96, 163, 255).setFogDensity(2.0F).setParticles(EndParticles.GLOWING_SPHERE, 0.001F)
.setMusic(EndSounds.MUSIC_WATER).setLoop(EndSounds.AMBIENT_MEGALAKE_GROVE)
.setSurface(EndBlocks.END_MOSS).setDepth(0F).addStructureFeature(EndStructures.MEGALAKE_SMALL)
.addFeature(EndFeatures.LACUGROVE).addFeature(EndFeatures.END_LOTUS)
.addFeature(EndFeatures.END_LOTUS_LEAF).addFeature(EndFeatures.BUBBLE_CORAL_RARE)
.addFeature(EndFeatures.END_LILY_RARE).addFeature(EndFeatures.UMBRELLA_MOSS)
.addFeature(EndFeatures.PEARLBERRY).addFeature(EndFeatures.CREEPING_MOSS)
.addFeature(EndFeatures.CHARNIA_CYAN).addFeature(EndFeatures.CHARNIA_LIGHT_BLUE)
.addFeature(EndFeatures.CHARNIA_RED_RARE).addFeature(EndFeatures.MENGER_SPONGE)
.addMobSpawn(EndEntities.DRAGONFLY, 20, 1, 3).addMobSpawn(EndEntities.END_FISH, 20, 3, 8)
.addMobSpawn(EndEntities.CUBOZOA, 50, 3, 8).addMobSpawn(EndEntities.END_SLIME, 5, 1, 2)
super(new BiomeDefinition("megalake_grove")
.setPlantsColor(73, 210, 209)
.setFogColor(178, 209, 248)
.setWaterAndFogColor(96, 163, 255)
.setFogDensity(2.0F)
.setParticles(EndParticles.GLOWING_SPHERE, 0.001F)
.setMusic(EndSounds.MUSIC_WATER)
.setLoop(EndSounds.AMBIENT_MEGALAKE_GROVE)
.setSurface(EndBlocks.END_MOSS)
.setDepth(0F)
.addStructureFeature(EndStructures.MEGALAKE_SMALL)
.addFeature(EndFeatures.LACUGROVE)
.addFeature(EndFeatures.END_LOTUS)
.addFeature(EndFeatures.END_LOTUS_LEAF)
.addFeature(EndFeatures.BUBBLE_CORAL_RARE)
.addFeature(EndFeatures.END_LILY_RARE)
.addFeature(EndFeatures.UMBRELLA_MOSS)
.addFeature(EndFeatures.PEARLBERRY)
.addFeature(EndFeatures.CREEPING_MOSS)
.addFeature(EndFeatures.CHARNIA_CYAN)
.addFeature(EndFeatures.CHARNIA_LIGHT_BLUE)
.addFeature(EndFeatures.CHARNIA_RED_RARE)
.addFeature(EndFeatures.MENGER_SPONGE)
.addMobSpawn(EndEntities.DRAGONFLY, 20, 1, 3)
.addMobSpawn(EndEntities.END_FISH, 20, 3, 8)
.addMobSpawn(EndEntities.CUBOZOA, 50, 3, 8)
.addMobSpawn(EndEntities.END_SLIME, 5, 1, 2)
.addMobSpawn(EntityType.ENDERMAN, 10, 1, 2));
}
}

View file

@ -1,8 +1,8 @@
package ru.betterend.world.biome.land;
import net.minecraft.world.entity.EntityType;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeatures;
import net.minecraft.data.worldgen.StructureFeatures;
import net.minecraft.world.entity.EntityType;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures;
import ru.betterend.registry.EndSounds;
@ -11,10 +11,17 @@ import ru.betterend.world.biome.EndBiome;
public class NeonOasisBiome extends EndBiome {
public NeonOasisBiome() {
super(new BiomeDefinition("neon_oasis").setGenChance(0.5F).setFogColor(226, 239, 168).setFogDensity(2)
.setWaterAndFogColor(192, 180, 131).setSurface(EndBlocks.ENDSTONE_DUST, EndBlocks.END_MOSS)
.setParticles(ParticleTypes.WHITE_ASH, 0.01F).setLoop(EndSounds.AMBIENT_DUST_WASTELANDS)
.setMusic(EndSounds.MUSIC_OPENSPACE).addFeature(EndFeatures.NEON_CACTUS)
.addStructureFeature(ConfiguredStructureFeatures.END_CITY).addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
super(new BiomeDefinition("neon_oasis")
.setGenChance(0.5F)
.setFogColor(226, 239, 168)
.setFogDensity(2)
.setWaterAndFogColor(192, 180, 131)
.setSurface(EndBlocks.ENDSTONE_DUST, EndBlocks.END_MOSS)
.setParticles(ParticleTypes.WHITE_ASH, 0.01F)
.setLoop(EndSounds.AMBIENT_DUST_WASTELANDS)
.setMusic(EndSounds.MUSIC_OPENSPACE)
.addFeature(EndFeatures.NEON_CACTUS)
.addStructureFeature(StructureFeatures.END_CITY)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
}
}

View file

@ -1,7 +1,7 @@
package ru.betterend.world.biome.land;
import net.minecraft.world.entity.EntityType;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.entity.EntityType;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndSounds;
import ru.betterend.registry.EndStructures;
@ -10,10 +10,16 @@ import ru.betterend.world.biome.EndBiome;
public class PaintedMountainsBiome extends EndBiome {
public PaintedMountainsBiome() {
super(new BiomeDefinition("painted_mountains").setFogColor(226, 239, 168).setFogDensity(2).setCaves(false)
.setWaterAndFogColor(192, 180, 131).setMusic(EndSounds.MUSIC_OPENSPACE)
.setLoop(EndSounds.AMBIENT_DUST_WASTELANDS).setSurface(EndBlocks.ENDSTONE_DUST)
.setParticles(ParticleTypes.WHITE_ASH, 0.01F).addStructureFeature(EndStructures.PAINTED_MOUNTAIN)
super(new BiomeDefinition("painted_mountains")
.setFogColor(226, 239, 168)
.setFogDensity(2)
.setCaves(false)
.setWaterAndFogColor(192, 180, 131)
.setMusic(EndSounds.MUSIC_OPENSPACE)
.setLoop(EndSounds.AMBIENT_DUST_WASTELANDS)
.setSurface(EndBlocks.ENDSTONE_DUST)
.setParticles(ParticleTypes.WHITE_ASH, 0.01F)
.addStructureFeature(EndStructures.PAINTED_MOUNTAIN)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
}
}

View file

@ -1,8 +1,8 @@
package ru.betterend.world.biome.land;
import net.minecraft.world.entity.EntityType;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeatures;
import net.minecraft.data.worldgen.StructureFeatures;
import net.minecraft.world.entity.EntityType;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndEntities;
import ru.betterend.registry.EndFeatures;
@ -12,18 +12,32 @@ import ru.betterend.world.biome.EndBiome;
public class ShadowForestBiome extends EndBiome {
public ShadowForestBiome() {
super(new BiomeDefinition("shadow_forest").setFogColor(0, 0, 0).setFogDensity(2.5F).setPlantsColor(45, 45, 45)
.setWaterAndFogColor(42, 45, 80).setSurface(EndBlocks.SHADOW_GRASS)
.setParticles(ParticleTypes.MYCELIUM, 0.01F).setLoop(EndSounds.AMBIENT_CHORUS_FOREST)
.setMusic(EndSounds.MUSIC_DARK).addFeature(EndFeatures.VIOLECITE_LAYER)
.addFeature(EndFeatures.END_LAKE_RARE).addFeature(EndFeatures.DRAGON_TREE)
.addFeature(EndFeatures.DRAGON_TREE_BUSH).addFeature(EndFeatures.SHADOW_PLANT)
.addFeature(EndFeatures.MURKWEED).addFeature(EndFeatures.NEEDLEGRASS)
.addFeature(EndFeatures.SHADOW_BERRY).addFeature(EndFeatures.TWISTED_VINE)
.addFeature(EndFeatures.PURPLE_POLYPORE).addFeature(EndFeatures.TAIL_MOSS)
.addFeature(EndFeatures.TAIL_MOSS_WOOD).addFeature(EndFeatures.CHARNIA_PURPLE)
.addFeature(EndFeatures.CHARNIA_RED_RARE).addStructureFeature(ConfiguredStructureFeatures.END_CITY)
.addMobSpawn(EndEntities.SHADOW_WALKER, 80, 2, 4).addMobSpawn(EntityType.ENDERMAN, 40, 1, 4)
super(new BiomeDefinition("shadow_forest")
.setFogColor(0, 0, 0)
.setFogDensity(2.5F)
.setPlantsColor(45, 45, 45)
.setWaterAndFogColor(42, 45, 80)
.setSurface(EndBlocks.SHADOW_GRASS)
.setParticles(ParticleTypes.MYCELIUM, 0.01F)
.setLoop(EndSounds.AMBIENT_CHORUS_FOREST)
.setMusic(EndSounds.MUSIC_DARK)
.addFeature(EndFeatures.VIOLECITE_LAYER)
.addFeature(EndFeatures.END_LAKE_RARE)
.addFeature(EndFeatures.DRAGON_TREE)
.addFeature(EndFeatures.DRAGON_TREE_BUSH)
.addFeature(EndFeatures.SHADOW_PLANT)
.addFeature(EndFeatures.MURKWEED)
.addFeature(EndFeatures.NEEDLEGRASS)
.addFeature(EndFeatures.SHADOW_BERRY)
.addFeature(EndFeatures.TWISTED_VINE)
.addFeature(EndFeatures.PURPLE_POLYPORE)
.addFeature(EndFeatures.TAIL_MOSS)
.addFeature(EndFeatures.TAIL_MOSS_WOOD)
.addFeature(EndFeatures.CHARNIA_PURPLE)
.addFeature(EndFeatures.CHARNIA_RED_RARE)
.addStructureFeature(StructureFeatures.END_CITY)
.addMobSpawn(EndEntities.SHADOW_WALKER, 80, 2, 4)
.addMobSpawn(EntityType.ENDERMAN, 40, 1, 4)
.addMobSpawn(EntityType.PHANTOM, 1, 1, 2));
}
}

View file

@ -11,15 +11,27 @@ import ru.betterend.world.surface.SurfaceBuilders;
public class SulphurSpringsBiome extends EndBiome {
public SulphurSpringsBiome() {
super(new BiomeDefinition("sulphur_springs").setSurface(SurfaceBuilders.SULPHURIC_SURFACE)
.setMusic(EndSounds.MUSIC_OPENSPACE).setLoop(EndSounds.AMBIENT_SULPHUR_SPRINGS)
.setWaterColor(25, 90, 157).setWaterFogColor(30, 65, 61).setFogColor(207, 194, 62).setFogDensity(1.5F)
.setCaves(false).setDepth(0F).setParticles(EndParticles.SULPHUR_PARTICLE, 0.001F)
.addFeature(EndFeatures.GEYSER).addFeature(EndFeatures.SURFACE_VENT)
.addFeature(EndFeatures.SULPHURIC_LAKE).addFeature(EndFeatures.SULPHURIC_CAVE)
.addFeature(EndFeatures.HYDRALUX).addFeature(EndFeatures.CHARNIA_GREEN)
.addFeature(EndFeatures.CHARNIA_ORANGE).addFeature(EndFeatures.CHARNIA_RED_RARE)
.addMobSpawn(EndEntities.END_FISH, 50, 3, 8).addMobSpawn(EndEntities.CUBOZOA, 50, 3, 8)
super(new BiomeDefinition("sulphur_springs")
.setSurface(SurfaceBuilders.SULPHURIC_SURFACE)
.setMusic(EndSounds.MUSIC_OPENSPACE)
.setLoop(EndSounds.AMBIENT_SULPHUR_SPRINGS)
.setWaterColor(25, 90, 157)
.setWaterFogColor(30, 65, 61)
.setFogColor(207, 194, 62)
.setFogDensity(1.5F)
.setCaves(false)
.setDepth(0F)
.setParticles(EndParticles.SULPHUR_PARTICLE, 0.001F)
.addFeature(EndFeatures.GEYSER)
.addFeature(EndFeatures.SURFACE_VENT)
.addFeature(EndFeatures.SULPHURIC_LAKE)
.addFeature(EndFeatures.SULPHURIC_CAVE)
.addFeature(EndFeatures.HYDRALUX)
.addFeature(EndFeatures.CHARNIA_GREEN)
.addFeature(EndFeatures.CHARNIA_ORANGE)
.addFeature(EndFeatures.CHARNIA_RED_RARE)
.addMobSpawn(EndEntities.END_FISH, 50, 3, 8)
.addMobSpawn(EndEntities.CUBOZOA, 50, 3, 8)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 4));
}
}

View file

@ -1,7 +1,7 @@
package ru.betterend.world.biome.land;
import net.minecraft.data.worldgen.StructureFeatures;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeatures;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures;
import ru.betterend.registry.EndParticles;
@ -11,18 +11,33 @@ import ru.betterend.world.biome.EndBiome;
public class UmbrellaJungleBiome extends EndBiome {
public UmbrellaJungleBiome() {
super(new BiomeDefinition("umbrella_jungle").setFogColor(87, 223, 221).setWaterAndFogColor(119, 198, 253)
.setFoliageColor(27, 183, 194).setFogDensity(2.3F).setParticles(EndParticles.JUNGLE_SPORE, 0.001F)
.setMusic(EndSounds.MUSIC_FOREST).setLoop(EndSounds.AMBIENT_UMBRELLA_JUNGLE)
.setSurface(EndBlocks.JUNGLE_MOSS).addFeature(EndFeatures.END_LAKE)
.addFeature(EndFeatures.UMBRELLA_TREE).addFeature(EndFeatures.JELLYSHROOM)
.addFeature(EndFeatures.TWISTED_UMBRELLA_MOSS).addFeature(EndFeatures.SMALL_JELLYSHROOM_FLOOR)
.addFeature(EndFeatures.JUNGLE_GRASS).addFeature(EndFeatures.CYAN_MOSS)
.addFeature(EndFeatures.CYAN_MOSS_WOOD).addFeature(EndFeatures.JUNGLE_FERN_WOOD)
.addFeature(EndFeatures.SMALL_JELLYSHROOM_WALL).addFeature(EndFeatures.SMALL_JELLYSHROOM_WOOD)
.addFeature(EndFeatures.SMALL_JELLYSHROOM_CEIL).addFeature(EndFeatures.JUNGLE_VINE)
.addFeature(EndFeatures.CHARNIA_CYAN).addFeature(EndFeatures.CHARNIA_GREEN)
.addFeature(EndFeatures.CHARNIA_LIGHT_BLUE).addFeature(EndFeatures.CHARNIA_RED_RARE)
.addStructureFeature(ConfiguredStructureFeatures.END_CITY).addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
super(new BiomeDefinition("umbrella_jungle")
.setFogColor(87, 223, 221)
.setWaterAndFogColor(119, 198, 253)
.setFoliageColor(27, 183, 194)
.setFogDensity(2.3F)
.setParticles(EndParticles.JUNGLE_SPORE, 0.001F)
.setMusic(EndSounds.MUSIC_FOREST)
.setLoop(EndSounds.AMBIENT_UMBRELLA_JUNGLE)
.setSurface(EndBlocks.JUNGLE_MOSS)
.addFeature(EndFeatures.END_LAKE)
.addFeature(EndFeatures.UMBRELLA_TREE)
.addFeature(EndFeatures.JELLYSHROOM)
.addFeature(EndFeatures.TWISTED_UMBRELLA_MOSS)
.addFeature(EndFeatures.SMALL_JELLYSHROOM_FLOOR)
.addFeature(EndFeatures.JUNGLE_GRASS)
.addFeature(EndFeatures.CYAN_MOSS)
.addFeature(EndFeatures.CYAN_MOSS_WOOD)
.addFeature(EndFeatures.JUNGLE_FERN_WOOD)
.addFeature(EndFeatures.SMALL_JELLYSHROOM_WALL)
.addFeature(EndFeatures.SMALL_JELLYSHROOM_WOOD)
.addFeature(EndFeatures.SMALL_JELLYSHROOM_CEIL)
.addFeature(EndFeatures.JUNGLE_VINE)
.addFeature(EndFeatures.CHARNIA_CYAN)
.addFeature(EndFeatures.CHARNIA_GREEN)
.addFeature(EndFeatures.CHARNIA_LIGHT_BLUE)
.addFeature(EndFeatures.CHARNIA_RED_RARE)
.addStructureFeature(StructureFeatures.END_CITY)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
}
}

View file

@ -1,17 +1,16 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.biome.Biome;
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.configurations.NoneFeatureConfiguration;
import net.minecraft.world.gen.surfacebuilder.SurfaceConfig;
import net.minecraft.world.gen.surfacebuilder.TernarySurfaceConfig;
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderBaseConfiguration;
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderConfiguration;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.sdf.SDF;
@ -31,10 +30,10 @@ public class BiomeIslandFeature extends DefaultFeature {
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
Biome biome = world.getBiome(pos);
SurfaceConfig surfaceConfig = biome.getGenerationSettings().getSurfaceBuilderConfig();
SurfaceBuilderConfiguration surfaceConfig = biome.getGenerationSettings().getSurfaceBuilderConfig();
BlockState topMaterial = surfaceConfig.getTopMaterial();
if (BlocksHelper.isFluid(topMaterial)) {
topBlock = ((TernarySurfaceConfig) surfaceConfig).getUnderwaterMaterial();
topBlock = ((SurfaceBuilderBaseConfiguration) surfaceConfig).getUnderwaterMaterial();
} else {
topBlock = topMaterial;
}
@ -55,13 +54,12 @@ public class BiomeIslandFeature extends DefaultFeature {
});
sdfCone = new SDFTranslate().setTranslate(0, -2, 0).setSource(sdfCone);
sdfCone = new SDFDisplacement().setFunction(pos -> {
float deltaX = Math.abs(pos.getX());
float deltaY = Math.abs(pos.getY());
float deltaZ = Math.abs(pos.getZ());
float deltaX = Math.abs(pos.x());
float deltaY = Math.abs(pos.y());
float deltaZ = Math.abs(pos.z());
if (deltaY < 2.0f && (deltaX < 3.0f || deltaZ < 3.0F))
return 0.0f;
return (float) simplexNoise.eval(CENTER.getX() + pos.getX(), CENTER.getY() + pos.getY(),
CENTER.getZ() + pos.getZ());
return (float) simplexNoise.eval(CENTER.getX() + pos.x(), CENTER.getY() + pos.y(), CENTER.getZ() + pos.z());
}).setSource(sdfCone)
.setReplaceFunction(state -> BlocksHelper.isFluid(state) || state.getMaterial().isReplaceable());
return sdfCone;

View file

@ -1,7 +1,6 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
@ -11,25 +10,24 @@ import ru.betterend.util.MHelper;
public class BlueVineFeature extends ScatterFeature {
private boolean small;
public BlueVineFeature() {
super(5);
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
float d = MHelper.length(center.getX() - blockPos.getX(), center.getZ() - blockPos.getZ()) / radius * 0.6F
+ random.nextFloat() * 0.4F;
float d = MHelper.length(center.getX() - blockPos.getX(), center.getZ() - blockPos.getZ()) / radius * 0.6F + random.nextFloat() * 0.4F;
small = d > 0.5F;
return EndBlocks.BLUE_VINE_SEED.canPlaceAt(AIR, world, blockPos);
return EndBlocks.BLUE_VINE_SEED.canSurvive(AIR, world, blockPos);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
if (small) {
BlocksHelper.setWithoutUpdate(world, blockPos,
EndBlocks.BLUE_VINE_SEED.defaultBlockState().with(EndPlantWithAgeBlock.AGE, random.nextInt(4)));
} else {
BlocksHelper.setWithoutUpdate(world, blockPos, EndBlocks.BLUE_VINE_SEED.defaultBlockState().setValue(EndPlantWithAgeBlock.AGE, random.nextInt(4)));
}
else {
EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.BLUE_VINE_SEED);
seed.growAdult(world, random, blockPos);
}

View file

@ -1,15 +1,14 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import ru.betterend.util.BlocksHelper;
public class CavePlantFeature extends FullHeightScatterFeature {
private final Block plant;
public CavePlantFeature(Block plant, int radius) {
super(radius);
this.plant = plant;
@ -17,11 +16,11 @@ public class CavePlantFeature extends FullHeightScatterFeature {
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return plant.canPlaceAt(world.getBlockState(blockPos), world, blockPos);
return plant.canSurvive(world.getBlockState(blockPos), world, blockPos);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
BlocksHelper.setWithoutUpdate(world, blockPos, plant);
}
}

View file

@ -1,7 +1,6 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
@ -15,17 +14,17 @@ public class CavePumpkinFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.up()).isIn(EndTags.GEN_TERRAIN) || !world.isAir(pos)
|| !world.isAir(pos.below())) {
if (!world.getBlockState(pos.above()).is(EndTags.GEN_TERRAIN) || !world.isEmptyBlock(pos)
|| !world.isEmptyBlock(pos.below())) {
return false;
}
int age = random.nextInt(4);
BlocksHelper.setWithoutUpdate(world, pos,
EndBlocks.CAVE_PUMPKIN_SEED.defaultBlockState().with(BlockProperties.AGE, age));
EndBlocks.CAVE_PUMPKIN_SEED.defaultBlockState().setValue(BlockProperties.AGE, age));
if (age > 1) {
BlocksHelper.setWithoutUpdate(world, pos.below(),
EndBlocks.CAVE_PUMPKIN.defaultBlockState().with(BlockProperties.SMALL, age < 3));
EndBlocks.CAVE_PUMPKIN.defaultBlockState().setValue(BlockProperties.SMALL, age < 3));
}
return true;

View file

@ -6,7 +6,7 @@ public class CharniaFeature extends UnderwaterPlantFeature {
public CharniaFeature(Block plant) {
super(plant, 6);
}
@Override
protected int getChance() {
return 3;

View file

@ -1,25 +1,24 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import net.minecraft.structure.Structure;
import net.minecraft.structure.Structure.StructureBlockInfo;
import net.minecraft.structure.StructurePlacementData;
import net.minecraft.structure.processor.BlockIgnoreStructureProcessor;
import net.minecraft.structure.processor.StructureProcessor;
import net.minecraft.structure.processor.StructureProcessorType;
import net.minecraft.util.BlockMirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.math.BlockBox;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.templatesystem.BlockIgnoreProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
import net.minecraft.world.level.material.Material;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
@ -28,13 +27,12 @@ import ru.betterend.util.StructureHelper;
public class CrashedShipFeature extends NBTStructureFeature {
private static final StructureProcessor REPLACER;
private static final String STRUCTURE_PATH = "/data/minecraft/structures/end_city/ship.nbt";
private Structure structure;
private StructureTemplate structure;
@Override
protected Structure getStructure(WorldGenLevel world, BlockPos pos, Random random) {
protected StructureTemplate getStructure(WorldGenLevel world, BlockPos pos, Random random) {
if (structure == null) {
structure = world.toServerWorld().getStructureManager()
.getStructureOrBlank(new ResourceLocation("end_city/ship"));
structure = world.getLevel().getStructureManager().getOrCreate(new ResourceLocation("end_city/ship"));
if (structure == null) {
structure = StructureHelper.readStructure(STRUCTURE_PATH);
}
@ -49,21 +47,21 @@ public class CrashedShipFeature extends NBTStructureFeature {
if (x * x + z * z < 3600) {
return false;
}
return pos.getY() > 5 && world.getBlockState(pos.below()).isIn(EndTags.GEN_TERRAIN);
return pos.getY() > 5 && world.getBlockState(pos.below()).is(EndTags.GEN_TERRAIN);
}
@Override
protected Rotation getRotation(WorldGenLevel world, BlockPos pos, Random random) {
return Rotation.random(random);
return Rotation.getRandom(random);
}
@Override
protected BlockMirror getMirror(WorldGenLevel world, BlockPos pos, Random random) {
return BlockMirror.values()[random.nextInt(3)];
protected Mirror getMirror(WorldGenLevel world, BlockPos pos, Random random) {
return Mirror.values()[random.nextInt(3)];
}
@Override
protected int getYOffset(Structure structure, WorldGenLevel world, BlockPos pos, Random random) {
protected int getYOffset(StructureTemplate structure, WorldGenLevel world, BlockPos pos, Random random) {
int min = structure.getSize().getY() >> 3;
int max = structure.getSize().getY() >> 2;
return -MHelper.randRange(min, max, random);
@ -79,45 +77,44 @@ public class CrashedShipFeature extends NBTStructureFeature {
NoneFeatureConfiguration featureConfig) {
center = new BlockPos(((center.getX() >> 4) << 4) | 8, 128, ((center.getZ() >> 4) << 4) | 8);
center = getGround(world, center);
BlockBox bounds = makeBox(center);
BoundingBox bounds = makeBox(center);
if (!canSpawn(world, center, random)) {
return false;
}
Structure structure = getStructure(world, center, random);
StructureTemplate structure = getStructure(world, center, random);
Rotation rotation = getRotation(world, center, random);
BlockMirror mirror = getMirror(world, center, random);
BlockPos offset = Structure.transformAround(structure.getSize(), mirror, rotation, BlockPos.ORIGIN);
center = center.add(0, getYOffset(structure, world, center, random) + 0.5, 0);
StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror);
center = center.add(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
Mirror mirror = getMirror(world, center, random);
BlockPos offset = StructureTemplate.transform(structure.getSize(), mirror, rotation, BlockPos.ZERO);
center = center.offset(0, getYOffset(structure, world, center, random) + 0.5, 0);
StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation).setMirror(mirror);
center = center.offset(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
BlockBox structB = structure.calculateBoundingBox(placementData, center);
BoundingBox structB = structure.getBoundingBox(placementData, center);
bounds = StructureHelper.intersectBoxes(bounds, structB);
addStructureData(placementData);
structure.place(world, center, placementData.setBoundingBox(bounds), random);
structure.placeInWorldChunk(world, center, placementData.setBoundingBox(bounds), random);
StructureHelper.erodeIntense(world, bounds, random);
BlocksHelper.fixBlocks(world, new BlockPos(bounds.minX, bounds.minY, bounds.minZ),
new BlockPos(bounds.maxX, bounds.maxY, bounds.maxZ));
BlocksHelper.fixBlocks(world, new BlockPos(bounds.x0, bounds.y0, bounds.z0),
new BlockPos(bounds.x1, bounds.y1, bounds.z1));
return true;
}
@Override
protected void addStructureData(StructurePlacementData data) {
data.addProcessor(BlockIgnoreStructureProcessor.IGNORE_AIR_AND_STRUCTURE_BLOCKS).addProcessor(REPLACER)
.setIgnoreEntities(true);
protected void addStructureData(StructurePlaceSettings data) {
data.addProcessor(BlockIgnoreProcessor.STRUCTURE_AND_AIR).addProcessor(REPLACER).setIgnoreEntities(true);
}
static {
REPLACER = new StructureProcessor() {
@Override
public StructureBlockInfo process(WorldView worldView, BlockPos pos, BlockPos blockPos,
public StructureBlockInfo processBlock(LevelReader worldView, BlockPos pos, BlockPos blockPos,
StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2,
StructurePlacementData structurePlacementData) {
StructurePlaceSettings structurePlacementData) {
BlockState state = structureBlockInfo2.state;
if (state.is(Blocks.SPAWNER) || state.getMaterial().equals(Material.WOOL)) {
return new StructureBlockInfo(structureBlockInfo2.pos, AIR, null);

View file

@ -1,42 +1,42 @@
package ru.betterend.world.features;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.BlockPos;
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.levelgen.Heightmap.Types;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.util.BlocksHelper;
public abstract class DefaultFeature extends Feature<NoneFeatureConfiguration> {
protected static final BlockState AIR = Blocks.AIR.defaultBlockState();
protected static final BlockState WATER = Blocks.WATER.defaultBlockState();
public DefaultFeature() {
super(NoneFeatureConfiguration.CODEC);
}
public static int getYOnSurface(WorldGenLevel world, int x, int z) {
return world.getHeight(Types.WORLD_SURFACE, x, z);
}
public static int getYOnSurfaceWG(WorldGenLevel world, int x, int z) {
return world.getHeight(Types.WORLD_SURFACE_WG, x, z);
}
public static BlockPos getPosOnSurface(WorldGenLevel world, BlockPos pos) {
return world.getHeightmapPos(Types.WORLD_SURFACE, pos);
}
public static BlockPos getPosOnSurfaceWG(WorldGenLevel world, BlockPos pos) {
return world.getHeightmapPos(Types.WORLD_SURFACE_WG, pos);
}
public static BlockPos getPosOnSurfaceRaycast(WorldGenLevel world, BlockPos pos) {
return getPosOnSurfaceRaycast(world, pos, 256);
}
public static BlockPos getPosOnSurfaceRaycast(WorldGenLevel world, BlockPos pos, int dist) {
int h = BlocksHelper.downRay(world, pos, dist);
return pos.below(h);

View file

@ -1,11 +1,10 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.basis.DoublePlantBlock;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
@ -14,29 +13,29 @@ public class DoublePlantFeature extends ScatterFeature {
private final Block smallPlant;
private final Block largePlant;
private Block plant;
public DoublePlantFeature(Block smallPlant, Block largePlant, int radius) {
super(radius);
this.smallPlant = smallPlant;
this.largePlant = largePlant;
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
float d = MHelper.length(center.getX() - blockPos.getX(), center.getZ() - blockPos.getZ()) / radius * 0.6F
+ random.nextFloat() * 0.4F;
float d = MHelper.length(center.getX() - blockPos.getX(), center.getZ() - blockPos.getZ()) / radius * 0.6F + random.nextFloat() * 0.4F;
plant = d < 0.5F ? largePlant : smallPlant;
return plant.canPlaceAt(plant.defaultBlockState(), world, blockPos);
return plant.canSurvive(plant.defaultBlockState(), world, blockPos);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
if (plant instanceof DoublePlantBlock) {
int rot = random.nextInt(4);
BlockState state = plant.defaultBlockState().with(DoublePlantBlock.ROTATION, rot);
BlockState state = plant.defaultBlockState().setValue(DoublePlantBlock.ROTATION, rot);
BlocksHelper.setWithoutUpdate(world, blockPos, state);
BlocksHelper.setWithoutUpdate(world, blockPos.up(), state.with(DoublePlantBlock.TOP, true));
} else {
BlocksHelper.setWithoutUpdate(world, blockPos.above(), state.setValue(DoublePlantBlock.TOP, true));
}
else {
BlocksHelper.setWithoutUpdate(world, blockPos, plant);
}
}

View file

@ -1,23 +1,23 @@
package ru.betterend.world.features;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.structure.rule.BlockMatchRuleTest;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.core.Registry;
import net.minecraft.world.gen.CountConfig;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.decorator.ChanceDecoratorConfig;
import net.minecraft.world.gen.decorator.Decorator;
import net.minecraft.world.gen.decorator.RangeDecoratorConfig;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.data.worldgen.Features;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeatures;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.FeatureConfig;
import net.minecraft.world.level.levelgen.feature.OreFeatureConfig;
import net.minecraft.world.level.levelgen.feature.configurations.CountConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.RangeDecoratorConfiguration;
import net.minecraft.world.level.levelgen.placement.ChanceDecoratorConfiguration;
import net.minecraft.world.level.levelgen.placement.FeatureDecorator;
import net.minecraft.world.level.levelgen.structure.templatesystem.BlockMatchTest;
import ru.betterend.BetterEnd;
import ru.betterend.blocks.complex.StoneMaterial;
import ru.betterend.world.features.terrain.OreLayerFeature;
@ -25,117 +25,100 @@ import ru.betterend.world.features.terrain.OreLayerFeature;
public class EndFeature {
private Feature<?> feature;
private ConfiguredFeature<?, ?> featureConfigured;
private GenerationStep.Feature featureStep;
protected EndFeature() {
}
public EndFeature(Feature<?> feature, ConfiguredFeature<?, ?> configuredFeature,
GenerationStep.Feature featureStep) {
private GenerationStep.Decoration featureStep;
protected EndFeature() {}
public EndFeature(Feature<?> feature, ConfiguredFeature<?, ?> configuredFeature, GenerationStep.Decoration featureStep) {
this.featureStep = featureStep;
this.feature = feature;
this.featureConfigured = configuredFeature;
}
public EndFeature(String name, Feature<NoneFeatureConfiguration> feature, GenerationStep.Feature featureStep,
ConfiguredFeature<?, ?> configuredFeature) {
public EndFeature(String name, Feature<NoneFeatureConfiguration> feature, GenerationStep.Decoration featureStep, ConfiguredFeature<?, ?> configuredFeature) {
ResourceLocation id = BetterEnd.makeID(name);
this.featureStep = featureStep;
this.feature = Registry.register(Registry.FEATURE, id, feature);
this.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, configuredFeature);
}
public EndFeature(String name, Feature<NoneFeatureConfiguration> feature) {
ResourceLocation id = BetterEnd.makeID(name);
this.featureStep = GenerationStep.Feature.VEGETAL_DECORATION;
this.featureStep = GenerationStep.Decoration.VEGETAL_DECORATION;
this.feature = Registry.register(Registry.FEATURE, id, feature);
this.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, feature
.configure(FeatureConfig.DEFAULT).decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(100))));
this.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.CHANCE.configured(new ChanceDecoratorConfiguration(100))));
}
public EndFeature(String name, Feature<NoneFeatureConfiguration> feature, int density) {
ResourceLocation id = BetterEnd.makeID(name);
this.featureStep = GenerationStep.Feature.VEGETAL_DECORATION;
this.featureStep = GenerationStep.Decoration.VEGETAL_DECORATION;
this.feature = Registry.register(Registry.FEATURE, id, feature);
this.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id,
feature.configure(FeatureConfig.DEFAULT).decorate(ConfiguredFeatures.Decorators.SQUARE_HEIGHTMAP)
.repeatRandomly(density));
this.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, feature.configured(FeatureConfiguration.NONE).decorated(Features.Decorators.HEIGHTMAP_SQUARE).countRandom(density));
}
public static EndFeature makeRawGenFeature(String name, Feature<NoneFeatureConfiguration> feature, int chance) {
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT)
.decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(chance)));
return new EndFeature(name, feature, GenerationStep.Feature.RAW_GENERATION, configured);
ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.CHANCE.configured(new ChanceDecoratorConfiguration(chance)));
return new EndFeature(name, feature, GenerationStep.Decoration.RAW_GENERATION, configured);
}
public static EndFeature makeLakeFeature(String name, Feature<NoneFeatureConfiguration> feature, int chance) {
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT)
.decorate(Decorator.WATER_LAKE.configure(new ChanceDecoratorConfig(chance)));
return new EndFeature(name, feature, GenerationStep.Feature.LAKES, configured);
ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.WATER_LAKE.configured(new ChanceDecoratorConfiguration(chance)));
return new EndFeature(name, feature, GenerationStep.Decoration.LAKES, configured);
}
public static EndFeature makeOreFeature(String name, Block blockOre, int veins, int veinSize, int offset, int minY,
int maxY) {
public static EndFeature makeOreFeature(String name, Block blockOre, int veins, int veinSize, int offset, int minY, int maxY) {
EndFeature newFeature = new EndFeature();
OreFeatureConfig featureConfig = new OreFeatureConfig(new BlockMatchRuleTest(Blocks.END_STONE),
blockOre.defaultBlockState(), veinSize);
RangeDecoratorConfig rangeDecorator = new RangeDecoratorConfig(offset, minY, maxY);
ConfiguredFeature<?, ?> oreFeature = Feature.ORE.configure(featureConfig)
.decorate(Decorator.RANGE.configure(rangeDecorator)).spreadHorizontally().repeat(veins);
OreConfiguration featureConfig = new OreConfiguration(new BlockMatchTest(Blocks.END_STONE), blockOre.defaultBlockState(), veinSize);
RangeDecoratorConfiguration rangeDecorator = new RangeDecoratorConfiguration(offset, minY, maxY);
ConfiguredFeature<?, ?> oreFeature = Feature.ORE.configured(featureConfig)
.decorated(FeatureDecorator.RANGE.configured(rangeDecorator))
.squared()
.count(veins);
newFeature.feature = Feature.ORE;
newFeature.featureStep = GenerationStep.Feature.UNDERGROUND_ORES;
newFeature.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, BetterEnd.makeID(name),
oreFeature);
newFeature.featureStep = GenerationStep.Decoration.UNDERGROUND_ORES;
newFeature.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, BetterEnd.makeID(name), oreFeature);
return newFeature;
}
public static EndFeature makeLayerFeature(String name, BlockState state, float radius, int minY, int maxY,
int count) {
public static EndFeature makeLayerFeature(String name, BlockState state, float radius, int minY, int maxY, int count) {
OreLayerFeature layer = new OreLayerFeature(state, radius, minY, maxY);
ConfiguredFeature<?, ?> configured = layer.configure(FeatureConfig.DEFAULT)
.decorate(Decorator.COUNT.configure(new CountConfig(count)));
return new EndFeature(name, layer, GenerationStep.Feature.UNDERGROUND_ORES, configured);
ConfiguredFeature<?, ?> configured = layer.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.COUNT.configured(new CountConfiguration(count)));
return new EndFeature(name, layer, GenerationStep.Decoration.UNDERGROUND_ORES, configured);
}
public static EndFeature makeLayerFeature(String name, Block block, float radius, int minY, int maxY, int count) {
OreLayerFeature layer = new OreLayerFeature(block.defaultBlockState(), radius, minY, maxY);
ConfiguredFeature<?, ?> configured = layer.configure(FeatureConfig.DEFAULT)
.decorate(Decorator.COUNT.configure(new CountConfig(count)));
return new EndFeature(name, layer, GenerationStep.Feature.UNDERGROUND_ORES, configured);
ConfiguredFeature<?, ?> configured = layer.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.COUNT.configured(new CountConfiguration(count)));
return new EndFeature(name, layer, GenerationStep.Decoration.UNDERGROUND_ORES, configured);
}
public static EndFeature makeLayerFeature(String name, StoneMaterial material, float radius, int minY, int maxY,
int count) {
public static EndFeature makeLayerFeature(String name, StoneMaterial material, float radius, int minY, int maxY, int count) {
OreLayerFeature layer = new OreLayerFeature(material.stone.defaultBlockState(), radius, minY, maxY);
ConfiguredFeature<?, ?> configured = layer.configure(FeatureConfig.DEFAULT)
.decorate(Decorator.COUNT.configure(new CountConfig(count)));
return new EndFeature(name, layer, GenerationStep.Feature.UNDERGROUND_ORES, configured);
ConfiguredFeature<?, ?> configured = layer.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.COUNT.configured(new CountConfiguration(count)));
return new EndFeature(name, layer, GenerationStep.Decoration.UNDERGROUND_ORES, configured);
}
public static EndFeature makeChunkFeature(String name, Feature<NoneFeatureConfiguration> feature) {
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT)
.decorate(Decorator.COUNT.configure(new CountConfig(1)));
return new EndFeature(name, feature, GenerationStep.Feature.LOCAL_MODIFICATIONS, configured);
ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.COUNT.configured(new CountConfiguration(1)));
return new EndFeature(name, feature, GenerationStep.Decoration.LOCAL_MODIFICATIONS, configured);
}
public static EndFeature makeChansedFeature(String name, Feature<NoneFeatureConfiguration> feature, int chance) {
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT)
.decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(chance)));
return new EndFeature(name, feature, GenerationStep.Feature.SURFACE_STRUCTURES, configured);
ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.CHANCE.configured(new ChanceDecoratorConfiguration(chance)));
return new EndFeature(name, feature, GenerationStep.Decoration.SURFACE_STRUCTURES, configured);
}
public static EndFeature makeCountRawFeature(String name, Feature<NoneFeatureConfiguration> feature, int chance) {
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT)
.decorate(Decorator.COUNT.configure(new CountConfig(chance)));
return new EndFeature(name, feature, GenerationStep.Feature.RAW_GENERATION, configured);
ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.COUNT.configured(new CountConfiguration(chance)));
return new EndFeature(name, feature, GenerationStep.Decoration.RAW_GENERATION, configured);
}
public static EndFeature makeFeatureConfigured(String name, Feature<NoneFeatureConfiguration> feature) {
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT);
return new EndFeature(name, feature, GenerationStep.Feature.RAW_GENERATION, configured);
ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE);
return new EndFeature(name, feature, GenerationStep.Decoration.RAW_GENERATION, configured);
}
public Feature<?> getFeature() {
return feature;
}
@ -144,7 +127,7 @@ public class EndFeature {
return featureConfigured;
}
public GenerationStep.Feature getFeatureStep() {
public GenerationStep.Decoration getFeatureStep() {
return featureStep;
}
}

View file

@ -1,7 +1,6 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import ru.betterend.blocks.EndLilySeedBlock;
@ -13,11 +12,11 @@ public class EndLilyFeature extends UnderwaterPlantScatter {
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
EndLilySeedBlock seed = (EndLilySeedBlock) EndBlocks.END_LILY_SEED;
seed.grow(world, random, blockPos);
}
@Override
protected int getChance() {
return 15;

View file

@ -1,7 +1,6 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import ru.betterend.blocks.EndLotusSeedBlock;
@ -13,11 +12,11 @@ public class EndLotusFeature extends UnderwaterPlantScatter {
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
EndLotusSeedBlock seed = (EndLotusSeedBlock) EndBlocks.END_LOTUS_SEED;
seed.grow(world, random, blockPos);
}
@Override
protected int getChance() {
return 15;

View file

@ -1,13 +1,12 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.EndLotusLeafBlock;
import ru.betterend.registry.EndBlocks;
@ -19,48 +18,46 @@ public class EndLotusLeafFeature extends ScatterFeature {
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
if (canGenerate(world, blockPos)) {
generateLeaf(world, blockPos);
}
}
@Override
protected int getChance() {
return 15;
}
@Override
protected BlockPos getCenterGround(WorldGenLevel world, BlockPos pos) {
return getPosOnSurface(world, pos);
}
private void generateLeaf(WorldGenLevel world, BlockPos pos) {
MutableBlockPos p = new MutableBlockPos();
BlockState leaf = EndBlocks.END_LOTUS_LEAF.defaultBlockState();
BlocksHelper.setWithoutUpdate(world, pos, leaf.with(EndLotusLeafBlock.SHAPE, TripleShape.BOTTOM));
for (Direction move : BlocksHelper.HORIZONTAL) {
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf
.with(EndLotusLeafBlock.HORIZONTAL_FACING, move).with(EndLotusLeafBlock.SHAPE, TripleShape.MIDDLE));
BlocksHelper.setWithoutUpdate(world, pos, leaf.setValue(EndLotusLeafBlock.SHAPE, TripleShape.BOTTOM));
for (Direction move: BlocksHelper.HORIZONTAL) {
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf.setValue(EndLotusLeafBlock.HORIZONTAL_FACING, move).setValue(EndLotusLeafBlock.SHAPE, TripleShape.MIDDLE));
}
for (int i = 0; i < 4; i++) {
for (int i = 0; i < 4; i ++) {
Direction d1 = BlocksHelper.HORIZONTAL[i];
Direction d2 = BlocksHelper.HORIZONTAL[(i + 1) & 3];
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2),
leaf.with(EndLotusLeafBlock.HORIZONTAL_FACING, d1).with(EndLotusLeafBlock.SHAPE, TripleShape.TOP));
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2), leaf.setValue(EndLotusLeafBlock.HORIZONTAL_FACING, d1).setValue(EndLotusLeafBlock.SHAPE, TripleShape.TOP));
}
}
private boolean canGenerate(WorldGenLevel world, BlockPos pos) {
MutableBlockPos p = new MutableBlockPos();
p.setY(pos.getY());
int count = 0;
for (int x = -1; x < 2; x++) {
for (int x = -1; x < 2; x ++) {
p.setX(pos.getX() + x);
for (int z = -1; z < 2; z++) {
for (int z = -1; z < 2; z ++) {
p.setZ(pos.getZ() + z);
if (world.isAir(p) && world.getBlockState(p.below()).is(Blocks.WATER))
count++;
if (world.isEmptyBlock(p) && world.getBlockState(p.below()).is(Blocks.WATER))
count ++;
}
}
return count == 9;
@ -68,6 +65,6 @@ public class EndLotusLeafFeature extends ScatterFeature {
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return world.isAir(blockPos) && world.getBlockState(blockPos.below()).is(Blocks.WATER);
return world.isEmptyBlock(blockPos) && world.getBlockState(blockPos.below()).is(Blocks.WATER);
}
}

View file

@ -1,12 +1,11 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.registry.EndBlocks;
@ -19,13 +18,13 @@ public class FilaluxFeature extends SkyScatterFeature {
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
BlockState vine = EndBlocks.FILALUX.defaultBlockState();
BlockState wings = EndBlocks.FILALUX_WINGS.defaultBlockState();
BlocksHelper.setWithoutUpdate(world, blockPos, EndBlocks.FILALUX_LANTERN);
BlocksHelper.setWithoutUpdate(world, blockPos.up(), wings.with(Properties.FACING, Direction.UP));
for (Direction dir : BlocksHelper.HORIZONTAL) {
BlocksHelper.setWithoutUpdate(world, blockPos.offset(dir), wings.with(Properties.FACING, dir));
BlocksHelper.setWithoutUpdate(world, blockPos.above(), wings.setValue(BlockStateProperties.FACING, Direction.UP));
for (Direction dir: BlocksHelper.HORIZONTAL) {
BlocksHelper.setWithoutUpdate(world, blockPos.relative(dir), wings.setValue(BlockStateProperties.FACING, dir));
}
int length = MHelper.randRange(1, 3, random);
for (int i = 1; i <= length; i++) {
@ -33,7 +32,7 @@ public class FilaluxFeature extends SkyScatterFeature {
if (i > 1) {
shape = i == length ? TripleShape.BOTTOM : TripleShape.MIDDLE;
}
BlocksHelper.setWithoutUpdate(world, blockPos.down(i), vine.with(BlockProperties.TRIPLE_SHAPE, shape));
BlocksHelper.setWithoutUpdate(world, blockPos.below(i), vine.setValue(BlockProperties.TRIPLE_SHAPE, shape));
}
}
}

View file

@ -1,12 +1,11 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.Heightmap;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
@ -22,12 +21,12 @@ public abstract class FullHeightScatterFeature extends DefaultFeature {
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos,
float radius);
public abstract void place(WorldGenLevel world, Random random, BlockPos blockPos);
public abstract void generate(WorldGenLevel world, Random random, BlockPos blockPos);
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos center,
NoneFeatureConfiguration featureConfig) {
int maxY = world.getTopY(Heightmap.Type.WORLD_SURFACE_WG, center.getX(), center.getZ());
int maxY = world.getHeight(Heightmap.Types.WORLD_SURFACE_WG, center.getX(), center.getZ());
int minY = BlocksHelper.upRay(world, new BlockPos(center.getX(), 0, center.getZ()), maxY);
for (int y = maxY; y > minY; y--) {
POS.set(center.getX(), y, center.getZ());

View file

@ -1,7 +1,6 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
@ -14,15 +13,15 @@ public class GlowPillarFeature extends ScatterFeature {
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return EndBlocks.GLOWING_PILLAR_SEED.canPlaceAt(AIR, world, blockPos);
return EndBlocks.GLOWING_PILLAR_SEED.canSurvive(AIR, world, blockPos);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.GLOWING_PILLAR_SEED);
seed.growAdult(world, random, blockPos);
}
@Override
protected int getChance() {
return 10;

View file

@ -1,7 +1,6 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import ru.betterend.blocks.HydraluxSaplingBlock;
@ -13,11 +12,11 @@ public class HydraluxFeature extends UnderwaterPlantScatter {
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
HydraluxSaplingBlock seed = (HydraluxSaplingBlock) EndBlocks.HYDRALUX_SAPLING;
seed.grow(world, random, blockPos);
}
@Override
protected int getChance() {
return 15;

View file

@ -1,12 +1,11 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.Heightmap;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
@ -22,16 +21,16 @@ public abstract class InvertedScatterFeature extends DefaultFeature {
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos,
float radius);
public abstract void place(WorldGenLevel world, Random random, BlockPos blockPos);
public abstract void generate(WorldGenLevel world, Random random, BlockPos blockPos);
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos center,
NoneFeatureConfiguration featureConfig) {
int maxY = world.getTopY(Heightmap.Type.WORLD_SURFACE, center.getX(), center.getZ());
int maxY = world.getHeight(Heightmap.Types.WORLD_SURFACE, center.getX(), center.getZ());
int minY = BlocksHelper.upRay(world, new BlockPos(center.getX(), 0, center.getZ()), maxY);
for (int y = maxY; y > minY; y--) {
POS.set(center.getX(), y, center.getZ());
if (world.getBlockState(POS).isAir() && !world.getBlockState(POS.up()).isAir()) {
if (world.getBlockState(POS).isAir() && !world.getBlockState(POS.above()).isAir()) {
float r = MHelper.randRange(radius * 0.5F, radius, random);
int count = MHelper.floor(r * r * MHelper.randRange(0.5F, 1.5F, random));
for (int i = 0; i < count; i++) {

View file

@ -1,7 +1,6 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
@ -14,15 +13,15 @@ public class LanceleafFeature extends ScatterFeature {
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return EndBlocks.LANCELEAF_SEED.canPlaceAt(AIR, world, blockPos);
return EndBlocks.LANCELEAF_SEED.canSurvive(AIR, world, blockPos);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.LANCELEAF_SEED);
seed.growAdult(world, random, blockPos);
}
@Override
protected int getChance() {
return 5;

View file

@ -2,26 +2,25 @@ package ru.betterend.world.features;
import java.util.List;
import java.util.Random;
import net.minecraft.structure.Structure;
import net.minecraft.structure.StructurePlacementData;
import net.minecraft.util.BlockMirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import ru.betterend.registry.EndTags;
import ru.betterend.util.StructureHelper;
public class ListFeature extends NBTStructureFeature {
private final List<StructureInfo> list;
private StructureInfo selected;
public ListFeature(List<StructureInfo> list) {
this.list = list;
}
@Override
protected Structure getStructure(WorldGenLevel world, BlockPos pos, Random random) {
protected StructureTemplate getStructure(WorldGenLevel world, BlockPos pos, Random random) {
selected = list.get(random.nextInt(list.size()));
return selected.getStructure();
}
@ -30,21 +29,21 @@ public class ListFeature extends NBTStructureFeature {
protected boolean canSpawn(WorldGenLevel world, BlockPos pos, Random random) {
int cx = pos.getX() >> 4;
int cz = pos.getZ() >> 4;
return ((cx + cz) & 1) == 0 && pos.getY() > 58 && world.getBlockState(pos.below()).isIn(EndTags.GEN_TERRAIN);
return ((cx + cz) & 1) == 0 && pos.getY() > 58 && world.getBlockState(pos.below()).is(EndTags.GEN_TERRAIN);
}
@Override
protected Rotation getRotation(WorldGenLevel world, BlockPos pos, Random random) {
return Rotation.random(random);
return Rotation.getRandom(random);
}
@Override
protected BlockMirror getMirror(WorldGenLevel world, BlockPos pos, Random random) {
return BlockMirror.values()[random.nextInt(3)];
protected Mirror getMirror(WorldGenLevel world, BlockPos pos, Random random) {
return Mirror.values()[random.nextInt(3)];
}
@Override
protected int getYOffset(Structure structure, WorldGenLevel world, BlockPos pos, Random random) {
protected int getYOffset(StructureTemplate structure, WorldGenLevel world, BlockPos pos, Random random) {
return selected.offsetY;
}
@ -52,25 +51,24 @@ public class ListFeature extends NBTStructureFeature {
protected TerrainMerge getTerrainMerge(WorldGenLevel world, BlockPos pos, Random random) {
return selected.terrainMerge;
}
@Override
protected void addStructureData(StructurePlacementData data) {
}
protected void addStructureData(StructurePlaceSettings data) {}
public static final class StructureInfo {
public final TerrainMerge terrainMerge;
public final String structurePath;
public final int offsetY;
private Structure structure;
private StructureTemplate structure;
public StructureInfo(String structurePath, int offsetY, TerrainMerge terrainMerge) {
this.terrainMerge = terrainMerge;
this.structurePath = structurePath;
this.offsetY = offsetY;
}
public Structure getStructure() {
public StructureTemplate getStructure() {
if (structure == null) {
structure = StructureHelper.readStructure(structurePath);
}

View file

@ -2,34 +2,33 @@ package ru.betterend.world.features;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
public class MengerSpongeFeature extends UnderwaterPlantScatter {
private static final Function<BlockState, Boolean> REPLACE;
public MengerSpongeFeature(int radius) {
super(radius);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
BlocksHelper.setWithoutUpdate(world, blockPos, EndBlocks.MENGER_SPONGE_WET);
if (random.nextBoolean()) {
for (Direction dir : BlocksHelper.DIRECTIONS) {
BlockPos pos = blockPos.offset(dir);
for (Direction dir: BlocksHelper.DIRECTIONS) {
BlockPos pos = blockPos.relative(dir);
if (REPLACE.apply(world.getBlockState(pos))) {
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.MENGER_SPONGE_WET);
}
}
}
}
static {
REPLACE = (state) -> {
if (state.is(EndBlocks.END_LOTUS_STEM)) {

View file

@ -3,25 +3,24 @@ package ru.betterend.world.features;
import java.io.IOException;
import java.io.InputStream;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo;
import net.minecraft.server.MinecraftServer;
import net.minecraft.structure.Structure;
import net.minecraft.structure.StructurePlacementData;
import net.minecraft.util.BlockMirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.math.BlockBox;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.gen.surfacebuilder.SurfaceConfig;
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 net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderConfiguration;
import ru.betterend.registry.EndBiomes;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
@ -30,19 +29,19 @@ import ru.betterend.world.processors.DestructionStructureProcessor;
public abstract class NBTStructureFeature extends DefaultFeature {
protected static final DestructionStructureProcessor DESTRUCTION = new DestructionStructureProcessor();
protected abstract Structure getStructure(WorldGenLevel world, BlockPos pos, Random random);
protected abstract StructureTemplate getStructure(WorldGenLevel world, BlockPos pos, Random random);
protected abstract boolean canSpawn(WorldGenLevel world, BlockPos pos, Random random);
protected abstract Rotation getRotation(WorldGenLevel world, BlockPos pos, Random random);
protected abstract BlockMirror getMirror(WorldGenLevel world, BlockPos pos, Random random);
protected abstract Mirror getMirror(WorldGenLevel world, BlockPos pos, Random random);
protected abstract int getYOffset(Structure structure, WorldGenLevel world, BlockPos pos, Random random);
protected abstract int getYOffset(StructureTemplate structure, WorldGenLevel world, BlockPos pos, Random random);
protected abstract TerrainMerge getTerrainMerge(WorldGenLevel world, BlockPos pos, Random random);
protected abstract void addStructureData(StructurePlacementData data);
protected abstract void addStructureData(StructurePlaceSettings data);
protected BlockPos getGround(WorldGenLevel world, BlockPos center) {
Biome biome = world.getBiome(center);
@ -85,18 +84,18 @@ public abstract class NBTStructureFeature extends DefaultFeature {
}
int posY = center.getY() + 1;
Structure structure = getStructure(world, center, random);
StructureTemplate structure = getStructure(world, center, random);
Rotation rotation = getRotation(world, center, random);
BlockMirror mirror = getMirror(world, center, random);
BlockPos offset = Structure.transformAround(structure.getSize(), mirror, rotation, BlockPos.ORIGIN);
center = center.add(0, getYOffset(structure, world, center, random) + 0.5, 0);
Mirror mirror = getMirror(world, center, random);
BlockPos offset = StructureTemplate.transform(structure.getSize(), mirror, rotation, BlockPos.ZERO);
center = center.offset(0, getYOffset(structure, world, center, random) + 0.5, 0);
BlockBox bounds = makeBox(center);
StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror)
BoundingBox bounds = makeBox(center);
StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation).setMirror(mirror)
.setBoundingBox(bounds);
addStructureData(placementData);
center = center.add(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
structure.place(world, center, placementData, random);
center = center.offset(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
structure.placeInWorldChunk(world, center, placementData, random);
TerrainMerge merge = getTerrainMerge(world, center, random);
int x1 = center.getX();
@ -125,24 +124,24 @@ public abstract class NBTStructureFeature extends DefaultFeature {
mut.setZ(z);
mut.setY(surfMax);
BlockState state = world.getBlockState(mut);
if (!state.isIn(EndTags.GEN_TERRAIN) && state.isSideSolidFullSquare(world, mut, Direction.DOWN)) {
if (!state.is(EndTags.GEN_TERRAIN) && state.isFaceSturdy(world, mut, Direction.DOWN)) {
for (int i = 0; i < 10; i++) {
mut.setY(mut.getY() - 1);
BlockState stateSt = world.getBlockState(mut);
if (!stateSt.isIn(EndTags.GEN_TERRAIN)) {
if (!stateSt.is(EndTags.GEN_TERRAIN)) {
if (merge == TerrainMerge.SURFACE) {
SurfaceConfig config = world.getBiome(mut).getGenerationSettings()
SurfaceBuilderConfiguration config = world.getBiome(mut).getGenerationSettings()
.getSurfaceBuilderConfig();
boolean isTop = mut.getY() == surfMax && state.getMaterial().blocksLight();
boolean isTop = mut.getY() == surfMax && state.getMaterial().isSolidBlocking();
BlockState top = isTop ? config.getTopMaterial() : config.getUnderMaterial();
BlocksHelper.setWithoutUpdate(world, mut, top);
} else {
BlocksHelper.setWithoutUpdate(world, mut, state);
}
} else {
if (stateSt.isIn(EndTags.END_GROUND) && state.getMaterial().blocksLight()) {
if (stateSt.is(EndTags.END_GROUND) && state.getMaterial().isSolidBlocking()) {
if (merge == TerrainMerge.SURFACE) {
SurfaceConfig config = world.getBiome(mut).getGenerationSettings()
SurfaceBuilderConfiguration config = world.getBiome(mut).getGenerationSettings()
.getSurfaceBuilderConfig();
BlocksHelper.setWithoutUpdate(world, mut, config.getUnderMaterial());
} else {
@ -162,15 +161,15 @@ public abstract class NBTStructureFeature extends DefaultFeature {
return true;
}
protected BlockBox makeBox(BlockPos pos) {
protected BoundingBox makeBox(BlockPos pos) {
int sx = ((pos.getX() >> 4) << 4) - 16;
int sz = ((pos.getZ() >> 4) << 4) - 16;
int ex = sx + 47;
int ez = sz + 47;
return BlockBox.create(sx, 0, sz, ex, 255, ez);
return BoundingBox.createProper(sx, 0, sz, ex, 255, ez);
}
protected static Structure readStructure(ResourceLocation resource) {
protected static StructureTemplate readStructure(ResourceLocation resource) {
String ns = resource.getNamespace();
String nm = resource.getPath();
@ -185,11 +184,11 @@ public abstract class NBTStructureFeature extends DefaultFeature {
return null;
}
private static Structure readStructureFromStream(InputStream stream) throws IOException {
private static StructureTemplate readStructureFromStream(InputStream stream) throws IOException {
CompoundTag nbttagcompound = NbtIo.readCompressed(stream);
Structure template = new Structure();
template.fromTag(nbttagcompound);
StructureTemplate template = new StructureTemplate();
template.load(nbttagcompound);
return template;
}

View file

@ -1,12 +1,11 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.blocks.BlockProperties;
@ -31,15 +30,16 @@ public class NeonCactusFeature extends DefaultFeature {
break;
}
int size = (h - i) >> 2;
BlocksHelper.setWithUpdate(world, mut, EndBlocks.NEON_CACTUS.defaultBlockState()
.with(BlockProperties.TRIPLE_SHAPE, getBySize(size)).with(Properties.FACING, Direction.UP));
BlocksHelper.setWithUpdate(world, mut,
EndBlocks.NEON_CACTUS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, getBySize(size))
.setValue(BlockStateProperties.FACING, Direction.UP));
if (i > 2 && i < (h - 1) && random.nextBoolean()) {
int length = h - i - MHelper.randRange(1, 2, random);
if (length > 0) {
Direction dir2 = hor;
hor = hor.getClockWise();
int bsize = i > ((h << 1) / 3) ? 0 : size > 1 ? 1 : size;
branch(world, mut.offset(dir2), dir2, random, length, bsize);
branch(world, mut.relative(dir2), dir2, random, length, bsize);
}
}
mut.move(Direction.UP);
@ -56,8 +56,9 @@ public class NeonCactusFeature extends DefaultFeature {
if (!world.getBlockState(mut).getMaterial().isReplaceable()) {
return;
}
BlocksHelper.setWithUpdate(world, mut, EndBlocks.NEON_CACTUS.defaultBlockState()
.with(BlockProperties.TRIPLE_SHAPE, getBySize(size)).with(Properties.FACING, dir));
BlocksHelper.setWithUpdate(world, mut,
EndBlocks.NEON_CACTUS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, getBySize(size))
.setValue(BlockStateProperties.FACING, dir));
if (i == rotIndex) {
dir = Direction.UP;
size--;
@ -65,7 +66,7 @@ public class NeonCactusFeature extends DefaultFeature {
if (i > 1 && i < (length - 1) && random.nextBoolean()) {
Direction dir2 = dir == Direction.UP ? hor : Direction.UP;
hor = hor.getClockWise();
branch(world, mut.offset(dir2), dir2, random, MHelper.randRange(length / 4, length / 2, random),
branch(world, mut.relative(dir2), dir2, random, MHelper.randRange(length / 4, length / 2, random),
size > 0 ? size - 1 : size);
}
mut.move(dir);

View file

@ -1,7 +1,6 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
@ -22,7 +21,7 @@ public abstract class ScatterFeature extends DefaultFeature {
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos,
float radius);
public abstract void place(WorldGenLevel world, Random random, BlockPos blockPos);
public abstract void generate(WorldGenLevel world, Random random, BlockPos blockPos);
protected BlockPos getCenterGround(WorldGenLevel world, BlockPos pos) {
return getPosOnSurfaceWG(world, pos);
@ -31,7 +30,7 @@ public abstract class ScatterFeature extends DefaultFeature {
protected boolean canSpawn(WorldGenLevel world, BlockPos pos) {
if (pos.getY() < 5) {
return false;
} else if (!world.getBlockState(pos.below()).isIn(EndTags.END_GROUND)) {
} else if (!world.getBlockState(pos.below()).is(EndTags.END_GROUND)) {
return false;
}
return true;

View file

@ -1,16 +1,15 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.state.property.Properties;
import net.minecraft.tags.BlockTags;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.Heightmap;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.registry.EndBlocks;
@ -20,12 +19,12 @@ public class SilkMothNestFeature extends DefaultFeature {
private static final MutableBlockPos POS = new MutableBlockPos();
private boolean canGenerate(WorldGenLevel world, BlockPos pos) {
BlockState state = world.getBlockState(pos.up());
if (state.isIn(BlockTags.LEAVES) || state.isIn(BlockTags.LOGS)) {
BlockState state = world.getBlockState(pos.above());
if (state.is(BlockTags.LEAVES) || state.is(BlockTags.LOGS)) {
state = world.getBlockState(pos);
if ((state.isAir() || state.is(EndBlocks.TENANEA_OUTER_LEAVES)) && world.isAir(pos.below())) {
if ((state.isAir() || state.is(EndBlocks.TENANEA_OUTER_LEAVES)) && world.isEmptyBlock(pos.below())) {
for (Direction dir : BlocksHelper.HORIZONTAL) {
if (world.getBlockState(pos.below().offset(dir)).getMaterial().blocksMovement()) {
if (world.getBlockState(pos.below().relative(dir)).getMaterial().blocksMotion()) {
return false;
}
return true;
@ -38,7 +37,7 @@ public class SilkMothNestFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos center,
NoneFeatureConfiguration featureConfig) {
int maxY = world.getTopY(Heightmap.Type.WORLD_SURFACE, center.getX(), center.getZ());
int maxY = world.getHeight(Heightmap.Types.WORLD_SURFACE, center.getX(), center.getZ());
int minY = BlocksHelper.upRay(world, new BlockPos(center.getX(), 0, center.getZ()), maxY);
POS.set(center);
for (int y = maxY; y > minY; y--) {
@ -46,10 +45,10 @@ public class SilkMothNestFeature extends DefaultFeature {
if (canGenerate(world, POS)) {
Direction dir = BlocksHelper.randomHorizontal(random);
BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.SILK_MOTH_NEST.defaultBlockState()
.with(Properties.HORIZONTAL_FACING, dir).with(BlockProperties.ACTIVE, false));
.setValue(BlockStateProperties.HORIZONTAL_FACING, dir).setValue(BlockProperties.ACTIVE, false));
POS.setY(y - 1);
BlocksHelper.setWithoutUpdate(world, POS,
EndBlocks.SILK_MOTH_NEST.defaultBlockState().with(Properties.HORIZONTAL_FACING, dir));
BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.SILK_MOTH_NEST.defaultBlockState()
.setValue(BlockStateProperties.HORIZONTAL_FACING, dir));
return true;
}
}

View file

@ -1,19 +1,18 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import ru.betterend.blocks.basis.AttachedBlock;
import ru.betterend.util.BlocksHelper;
public class SingleInvertedScatterFeature extends InvertedScatterFeature {
private final Block block;
public SingleInvertedScatterFeature(Block block, int radius) {
super(radius);
this.block = block;
@ -21,21 +20,21 @@ public class SingleInvertedScatterFeature extends InvertedScatterFeature {
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
if (!world.isAir(blockPos)) {
if (!world.isEmptyBlock(blockPos)) {
return false;
}
BlockState state = block.defaultBlockState();
if (block instanceof AttachedBlock) {
state = state.with(Properties.FACING, Direction.DOWN);
state = state.setValue(BlockStateProperties.FACING, Direction.DOWN);
}
return state.canPlaceAt(world, blockPos);
return state.canSurvive(world, blockPos);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
BlockState state = block.defaultBlockState();
if (block instanceof AttachedBlock) {
state = state.with(Properties.FACING, Direction.DOWN);
state = state.setValue(BlockStateProperties.FACING, Direction.DOWN);
}
BlocksHelper.setWithoutUpdate(world, blockPos, state);
}

View file

@ -1,11 +1,10 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.basis.DoublePlantBlock;
import ru.betterend.blocks.basis.EndCropBlock;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
@ -15,55 +14,58 @@ public class SinglePlantFeature extends ScatterFeature {
private final Block plant;
private final boolean rawHeightmap;
private final int chance;
public SinglePlantFeature(Block plant, int radius) {
this(plant, radius, true, 1);
}
public SinglePlantFeature(Block plant, int radius, int chance) {
this(plant, radius, true, chance);
}
public SinglePlantFeature(Block plant, int radius, boolean rawHeightmap) {
this(plant, radius, rawHeightmap, 1);
}
public SinglePlantFeature(Block plant, int radius, boolean rawHeightmap, int chance) {
super(radius);
this.plant = plant;
this.rawHeightmap = rawHeightmap;
this.chance = chance;
}
protected int getChance() {
return chance;
}
@Override
protected BlockPos getCenterGround(WorldGenLevel world, BlockPos pos) {
return rawHeightmap ? getPosOnSurfaceWG(world, pos) : getPosOnSurface(world, pos);
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return plant.canPlaceAt(plant.defaultBlockState(), world, blockPos);
return plant.canSurvive(plant.defaultBlockState(), world, blockPos);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
if (plant instanceof DoublePlantBlock) {
int rot = random.nextInt(4);
BlockState state = plant.defaultBlockState().with(DoublePlantBlock.ROTATION, rot);
BlockState state = plant.defaultBlockState().setValue(DoublePlantBlock.ROTATION, rot);
BlocksHelper.setWithoutUpdate(world, blockPos, state);
BlocksHelper.setWithoutUpdate(world, blockPos.up(), state.with(DoublePlantBlock.TOP, true));
} else if (plant instanceof EndCropBlock) {
BlockState state = plant.defaultBlockState().with(EndCropBlock.AGE, 3);
BlocksHelper.setWithoutUpdate(world, blockPos.above(), state.setValue(DoublePlantBlock.TOP, true));
}
else if (plant instanceof EndCropBlock) {
BlockState state = plant.defaultBlockState().setValue(EndCropBlock.AGE, 3);
BlocksHelper.setWithoutUpdate(world, blockPos, state);
} else if (plant instanceof EndPlantWithAgeBlock) {
}
else if (plant instanceof EndPlantWithAgeBlock) {
int age = random.nextInt(4);
BlockState state = plant.defaultBlockState().with(EndPlantWithAgeBlock.AGE, age);
BlockState state = plant.defaultBlockState().setValue(EndPlantWithAgeBlock.AGE, age);
BlocksHelper.setWithoutUpdate(world, blockPos, state);
} else {
}
else {
BlocksHelper.setWithoutUpdate(world, blockPos, plant);
}
}

View file

@ -1,7 +1,6 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
@ -13,7 +12,7 @@ public abstract class SkyScatterFeature extends ScatterFeature {
public SkyScatterFeature(int radius) {
super(radius);
}
@Override
protected int getChance() {
return 10;
@ -21,32 +20,32 @@ public abstract class SkyScatterFeature extends ScatterFeature {
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
if (!world.isAir(blockPos)) {
if (!world.isEmptyBlock(blockPos)) {
return false;
}
for (Direction dir : BlocksHelper.HORIZONTAL) {
if (!world.isAir(blockPos.offset(dir))) {
for (Direction dir: BlocksHelper.HORIZONTAL) {
if (!world.isEmptyBlock(blockPos.relative(dir))) {
return false;
}
}
int maxD = getYOffset() + 2;
int maxV = getYOffset() - 2;
return BlocksHelper.upRay(world, blockPos, maxD) > maxV && BlocksHelper.downRay(world, blockPos, maxD) > maxV;
}
@Override
protected boolean canSpawn(WorldGenLevel world, BlockPos pos) {
return true;
}
@Override
protected BlockPos getCenterGround(WorldGenLevel world, BlockPos pos) {
return new BlockPos(pos.getX(), MHelper.randRange(32, 192, world.getRandom()), pos.getZ());
}
protected boolean getGroundPlant(WorldGenLevel world, MutableBlockPos pos) {
pos.setY(pos.getY() + MHelper.randRange(-getYOffset(), getYOffset(), world.getRandom()));
return true;

View file

@ -1,35 +1,35 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.basis.DoublePlantBlock;
import ru.betterend.util.BlocksHelper;
public class UnderwaterPlantFeature extends UnderwaterPlantScatter {
private final Block plant;
public UnderwaterPlantFeature(Block plant, int radius) {
super(radius);
this.plant = plant;
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return super.canSpawn(world, blockPos) && plant.canPlaceAt(plant.defaultBlockState(), world, blockPos);
return super.canSpawn(world, blockPos) && plant.canSurvive(plant.defaultBlockState(), world, blockPos);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
if (plant instanceof DoublePlantBlock) {
int rot = random.nextInt(4);
BlockState state = plant.defaultBlockState().with(DoublePlantBlock.ROTATION, rot);
BlockState state = plant.defaultBlockState().setValue(DoublePlantBlock.ROTATION, rot);
BlocksHelper.setWithoutUpdate(world, blockPos, state);
BlocksHelper.setWithoutUpdate(world, blockPos.up(), state.with(DoublePlantBlock.TOP, true));
} else {
BlocksHelper.setWithoutUpdate(world, blockPos.above(), state.setValue(DoublePlantBlock.TOP, true));
}
else {
BlocksHelper.setWithoutUpdate(world, blockPos, plant);
}
}

View file

@ -1,19 +1,18 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
public abstract class UnderwaterPlantScatter extends ScatterFeature {
private static final MutableBlockPos POS = new MutableBlockPos();
public UnderwaterPlantScatter(int radius) {
super(radius);
}
@Override
protected BlockPos getCenterGround(WorldGenLevel world, BlockPos pos) {
POS.setX(pos.getX());
@ -21,32 +20,32 @@ public abstract class UnderwaterPlantScatter extends ScatterFeature {
POS.setY(0);
return getGround(world, POS).immutable();
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return world.getBlockState(blockPos).is(Blocks.WATER);
}
@Override
protected boolean canSpawn(WorldGenLevel world, BlockPos pos) {
return world.getBlockState(pos).is(Blocks.WATER);
}
@Override
protected boolean getGroundPlant(WorldGenLevel world, MutableBlockPos pos) {
return getGround(world, pos).getY() < 128;
}
@Override
protected int getYOffset() {
return -5;
}
@Override
protected int getChance() {
return 5;
}
private BlockPos getGround(WorldGenLevel world, MutableBlockPos pos) {
while (pos.getY() < 128 && world.getFluidState(pos).isEmpty()) {
pos.setY(pos.getY() + 1);

View file

@ -1,11 +1,10 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.VineBlock;
@ -15,7 +14,7 @@ public class VineFeature extends InvertedScatterFeature {
private final Block vineBlock;
private final int maxLength;
private final boolean vine;
public VineFeature(Block vineBlock, int maxLength) {
super(6);
this.vineBlock = vineBlock;
@ -30,7 +29,7 @@ public class VineFeature extends InvertedScatterFeature {
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
int h = BlocksHelper.downRay(world, blockPos, random.nextInt(maxLength)) - 1;
if (h > 2) {
BlockState top = getTopState();
@ -38,32 +37,33 @@ public class VineFeature extends InvertedScatterFeature {
BlockState bottom = getBottomState();
BlocksHelper.setWithoutUpdate(world, blockPos, top);
for (int i = 1; i < h; i++) {
BlocksHelper.setWithoutUpdate(world, blockPos.down(i), middle);
BlocksHelper.setWithoutUpdate(world, blockPos.below(i), middle);
}
BlocksHelper.setWithoutUpdate(world, blockPos.down(h), bottom);
BlocksHelper.setWithoutUpdate(world, blockPos.below(h), bottom);
}
}
private boolean canPlaceBlock(BlockState state, WorldGenLevel world, BlockPos blockPos) {
if (vine) {
return ((VineBlock) vineBlock).canGenerate(state, world, blockPos);
} else {
return vineBlock.canPlaceAt(state, world, blockPos);
}
else {
return vineBlock.canSurvive(state, world, blockPos);
}
}
private BlockState getTopState() {
BlockState state = vineBlock.defaultBlockState();
return vine ? state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP) : state;
return vine ? state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP) : state;
}
private BlockState getMiggleState() {
BlockState state = vineBlock.defaultBlockState();
return vine ? state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE) : state;
return vine ? state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE) : state;
}
private BlockState getBottomState() {
BlockState state = vineBlock.defaultBlockState();
return vine ? state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM) : state;
return vine ? state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM) : state;
}
}

View file

@ -1,20 +1,19 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import ru.betterend.blocks.basis.AttachedBlock;
import ru.betterend.blocks.basis.EndWallPlantBlock;
import ru.betterend.util.BlocksHelper;
public class WallPlantFeature extends WallScatterFeature {
private final Block block;
public WallPlantFeature(Block block, int radius) {
super(radius);
this.block = block;
@ -23,22 +22,24 @@ public class WallPlantFeature extends WallScatterFeature {
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos pos, Direction dir) {
if (block instanceof EndWallPlantBlock) {
BlockState state = block.defaultBlockState().with(EndWallPlantBlock.FACING, dir);
return block.canPlaceAt(state, world, pos);
} else if (block instanceof AttachedBlock) {
BlockState state = block.defaultBlockState().with(Properties.FACING, dir);
return block.canPlaceAt(state, world, pos);
BlockState state = block.defaultBlockState().setValue(EndWallPlantBlock.FACING, dir);
return block.canSurvive(state, world, pos);
}
return block.canPlaceAt(block.defaultBlockState(), world, pos);
else if (block instanceof AttachedBlock) {
BlockState state = block.defaultBlockState().setValue(BlockStateProperties.FACING, dir);
return block.canSurvive(state, world, pos);
}
return block.canSurvive(block.defaultBlockState(), world, pos);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos pos, Direction dir) {
public void generate(WorldGenLevel world, Random random, BlockPos pos, Direction dir) {
BlockState state = block.defaultBlockState();
if (block instanceof EndWallPlantBlock) {
state = state.with(EndWallPlantBlock.FACING, dir);
} else if (block instanceof AttachedBlock) {
state = state.with(Properties.FACING, dir);
state = state.setValue(EndWallPlantBlock.FACING, dir);
}
else if (block instanceof AttachedBlock) {
state = state.setValue(BlockStateProperties.FACING, dir);
}
BlocksHelper.setWithoutUpdate(world, pos, state);
}

View file

@ -1,13 +1,12 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.tags.BlockTags;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
public class WallPlantOnLogFeature extends WallPlantFeature {
public WallPlantOnLogFeature(Block block, int radius) {
@ -18,6 +17,6 @@ public class WallPlantOnLogFeature extends WallPlantFeature {
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos pos, Direction dir) {
BlockPos blockPos = pos.relative(dir.getOpposite());
BlockState blockState = world.getBlockState(blockPos);
return blockState.isIn(BlockTags.LOGS);
return blockState.is(BlockTags.LOGS);
}
}

View file

@ -1,13 +1,12 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.Heightmap;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
@ -22,12 +21,12 @@ public abstract class WallScatterFeature extends DefaultFeature {
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos pos, Direction dir);
public abstract void place(WorldGenLevel world, Random random, BlockPos pos, Direction dir);
public abstract void generate(WorldGenLevel world, Random random, BlockPos pos, Direction dir);
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos center,
NoneFeatureConfiguration featureConfig) {
int maxY = world.getTopY(Heightmap.Type.WORLD_SURFACE, center.getX(), center.getZ());
int maxY = world.getHeight(Heightmap.Types.WORLD_SURFACE, center.getX(), center.getZ());
int minY = BlocksHelper.upRay(world, new BlockPos(center.getX(), 0, center.getZ()), maxY);
if (maxY < 10 || maxY < minY) {
return false;
@ -41,7 +40,7 @@ public abstract class WallScatterFeature extends DefaultFeature {
mut.setY(py + y);
for (int z = -radius; z <= radius; z++) {
mut.setZ(center.getZ() + z);
if (random.nextInt(4) == 0 && world.isAir(mut)) {
if (random.nextInt(4) == 0 && world.isEmptyBlock(mut)) {
shuffle(random);
for (Direction dir : DIR) {
if (canGenerate(world, random, mut, dir)) {

View file

@ -2,16 +2,15 @@ package ru.betterend.world.features.bushes;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.material.Material;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
@ -37,8 +36,8 @@ public class BushFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)
&& !world.getBlockState(pos.up()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND)
&& !world.getBlockState(pos.above()).getBlock().is(EndTags.END_GROUND))
return false;
float radius = MHelper.randRange(1.8F, 3.5F, random);
@ -56,9 +55,9 @@ public class BushFeature extends DefaultFeature {
sphere.setReplaceFunction(REPLACE);
sphere.addPostProcess((info) -> {
if (info.getState().getBlock() instanceof LeavesBlock) {
int distance = info.getPos().getManhattanDistance(pos);
int distance = info.getPos().distManhattan(pos);
if (distance < 7) {
return info.getState().with(LeavesBlock.DISTANCE, distance);
return info.getState().setValue(LeavesBlock.DISTANCE, distance);
} else {
return AIR;
}
@ -69,9 +68,10 @@ public class BushFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, pos, stem);
for (Direction d : Direction.values()) {
BlockPos p = pos.relative(d);
if (world.isAir(p)) {
if (world.isEmptyBlock(p)) {
if (leaves instanceof LeavesBlock) {
BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState().with(LeavesBlock.DISTANCE, 1));
BlocksHelper.setWithoutUpdate(world, p,
leaves.defaultBlockState().setValue(LeavesBlock.DISTANCE, 1));
} else {
BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState());
}

View file

@ -2,17 +2,16 @@ package ru.betterend.world.features.bushes;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.material.Material;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
@ -41,8 +40,8 @@ public class BushWithOuterFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)
&& !world.getBlockState(pos.up()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND)
&& !world.getBlockState(pos.above()).getBlock().is(EndTags.END_GROUND))
return false;
float radius = MHelper.randRange(1.8F, 3.5F, random);
@ -60,9 +59,9 @@ public class BushWithOuterFeature extends DefaultFeature {
sphere.setReplaceFunction(REPLACE);
sphere.addPostProcess((info) -> {
if (info.getState().getBlock() instanceof LeavesBlock) {
int distance = info.getPos().getManhattanDistance(pos);
int distance = info.getPos().distManhattan(pos);
if (distance < 7) {
return info.getState().with(LeavesBlock.DISTANCE, distance);
return info.getState().setValue(LeavesBlock.DISTANCE, distance);
} else {
return AIR;
}
@ -73,8 +72,8 @@ public class BushWithOuterFeature extends DefaultFeature {
MHelper.shuffle(DIRECTIONS, random);
for (Direction dir : DIRECTIONS) {
if (info.getState(dir).isAir()) {
info.setBlockPos(info.getPos().offset(dir),
outer_leaves.defaultBlockState().with(Properties.FACING, dir));
info.setBlockPos(info.getPos().relative(dir),
outer_leaves.defaultBlockState().setValue(BlockStateProperties.FACING, dir));
}
}
}
@ -84,9 +83,10 @@ public class BushWithOuterFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, pos, stem);
for (Direction d : Direction.values()) {
BlockPos p = pos.relative(d);
if (world.isAir(p)) {
if (world.isEmptyBlock(p)) {
if (leaves instanceof LeavesBlock) {
BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState().with(LeavesBlock.DISTANCE, 1));
BlocksHelper.setWithoutUpdate(world, p,
leaves.defaultBlockState().setValue(LeavesBlock.DISTANCE, 1));
} else {
BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState());
}

View file

@ -1,12 +1,11 @@
package ru.betterend.world.features.bushes;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.blocks.BlockProperties;
@ -21,27 +20,27 @@ public class LargeAmaranitaFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
MutableBlockPos mut = new MutableBlockPos().set(pos);
int height = MHelper.randRange(2, 3, random);
for (int i = 1; i < height; i++) {
mut.setY(mut.getY() + 1);
if (!world.isAir(mut)) {
if (!world.isEmptyBlock(mut)) {
return false;
}
}
mut.set(pos);
BlockState state = EndBlocks.LARGE_AMARANITA_MUSHROOM.defaultBlockState();
BlocksHelper.setWithUpdate(world, mut, state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
BlocksHelper.setWithUpdate(world, mut, state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
if (height > 2) {
BlocksHelper.setWithUpdate(world, mut.move(Direction.UP),
state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
}
BlocksHelper.setWithUpdate(world, mut.move(Direction.UP),
state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
return true;
}

View file

@ -1,12 +1,11 @@
package ru.betterend.world.features.bushes;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.blocks.BlockProperties.LumecornShape;
@ -21,28 +20,28 @@ public class Lumecorn extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
int height = MHelper.randRange(4, 7, random);
MutableBlockPos mut = new MutableBlockPos().set(pos);
for (int i = 1; i < height; i++) {
mut.move(Direction.UP);
if (!world.isAir(mut)) {
if (!world.isEmptyBlock(mut)) {
return false;
}
}
mut.set(pos);
BlockState topMiddle = EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE,
BlockState topMiddle = EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE,
LumecornShape.LIGHT_TOP_MIDDLE);
BlockState middle = EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE,
BlockState middle = EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE,
LumecornShape.LIGHT_MIDDLE);
BlockState bottom = EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE,
BlockState bottom = EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE,
LumecornShape.LIGHT_BOTTOM);
BlockState top = EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT_TOP);
BlockState top = EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.LIGHT_TOP);
if (height == 4) {
BlocksHelper.setWithoutUpdate(world, mut,
EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), bottom);
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), topMiddle);
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), top);
@ -50,12 +49,12 @@ public class Lumecorn extends DefaultFeature {
}
if (random.nextBoolean()) {
BlocksHelper.setWithoutUpdate(world, mut,
EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
} else {
BlocksHelper.setWithoutUpdate(world, mut,
EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_BIG));
EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.BOTTOM_BIG));
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP),
EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.MIDDLE));
EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.MIDDLE));
height--;
}
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), bottom);

View file

@ -3,18 +3,16 @@ package ru.betterend.world.features.bushes;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.material.Material;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.collect.Lists;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.FurBlock;
@ -41,7 +39,7 @@ public class TenaneaBushFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
float radius = MHelper.randRange(1.8F, 3.5F, random);
@ -61,7 +59,7 @@ public class TenaneaBushFeature extends DefaultFeature {
List<BlockPos> support = Lists.newArrayList();
sphere.addPostProcess((info) -> {
if (info.getState().getBlock() instanceof LeavesBlock) {
int distance = info.getPos().getManhattanDistance(pos);
int distance = info.getPos().distManhattan(pos);
if (distance < 7) {
if (random.nextInt(4) == 0 && info.getStateDown().isAir()) {
BlockPos d = info.getPos().below();
@ -71,12 +69,12 @@ public class TenaneaBushFeature extends DefaultFeature {
MHelper.shuffle(DIRECTIONS, random);
for (Direction d : DIRECTIONS) {
if (info.getState(d).isAir()) {
info.setBlockPos(info.getPos().offset(d),
EndBlocks.TENANEA_OUTER_LEAVES.defaultBlockState().with(FurBlock.FACING, d));
info.setBlockPos(info.getPos().relative(d),
EndBlocks.TENANEA_OUTER_LEAVES.defaultBlockState().setValue(FurBlock.FACING, d));
}
}
return info.getState().with(LeavesBlock.DISTANCE, distance);
return info.getState().setValue(LeavesBlock.DISTANCE, distance);
} else {
return AIR;
}
@ -88,28 +86,28 @@ public class TenaneaBushFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, pos, stem);
for (Direction d : Direction.values()) {
BlockPos p = pos.relative(d);
if (world.isAir(p)) {
BlocksHelper.setWithoutUpdate(world, p, leaves.with(LeavesBlock.DISTANCE, 1));
if (world.isEmptyBlock(p)) {
BlocksHelper.setWithoutUpdate(world, p, leaves.setValue(LeavesBlock.DISTANCE, 1));
}
}
MutableBlockPos mut = new MutableBlockPos();
BlockState top = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
BlockState top = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.TOP);
BlockState middle = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
BlockState middle = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.MIDDLE);
BlockState bottom = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
BlockState bottom = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.BOTTOM);
support.forEach((bpos) -> {
BlockState state = world.getBlockState(bpos);
if (state.isAir() || state.is(EndBlocks.TENANEA_OUTER_LEAVES)) {
int count = MHelper.randRange(3, 8, random);
mut.set(bpos);
if (world.getBlockState(mut.up()).is(EndBlocks.TENANEA_LEAVES)) {
if (world.getBlockState(mut.above()).is(EndBlocks.TENANEA_LEAVES)) {
BlocksHelper.setWithoutUpdate(world, mut, top);
for (int i = 1; i < count; i++) {
mut.setY(mut.getY() - 1);
if (world.isAir(mut.below())) {
if (world.isEmptyBlock(mut.below())) {
BlocksHelper.setWithoutUpdate(world, mut, middle);
} else {
break;

View file

@ -1,13 +1,12 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
@ -37,7 +36,7 @@ public class BigAuroraCrystalFeature extends DefaultFeature {
Vector3f vec = MHelper.randomHorizontal(random);
prism = new SDFRotation().setRotation(vec, random.nextFloat()).setSource(prism);
prism.setReplaceFunction((bState) -> {
return bState.getMaterial().isReplaceable() || bState.isIn(EndTags.GEN_TERRAIN)
return bState.getMaterial().isReplaceable() || bState.is(EndTags.GEN_TERRAIN)
|| bState.getMaterial().equals(Material.PLANT) || bState.getMaterial().equals(Material.LEAVES);
});
prism.fillRecursive(world, pos);

View file

@ -1,16 +1,15 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import net.minecraft.fluid.FluidState;
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.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Material;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -37,22 +36,22 @@ public class EndLakeFeature extends DefaultFeature {
int waterLevel = blockPos.getY();
BlockPos pos = getPosOnSurfaceRaycast(world, blockPos.north(dist).up(10), 20);
BlockPos pos = getPosOnSurfaceRaycast(world, blockPos.north(dist).above(10), 20);
if (Math.abs(blockPos.getY() - pos.getY()) > 5)
return false;
waterLevel = MHelper.min(pos.getY(), waterLevel);
pos = getPosOnSurfaceRaycast(world, blockPos.south(dist).up(10), 20);
pos = getPosOnSurfaceRaycast(world, blockPos.south(dist).above(10), 20);
if (Math.abs(blockPos.getY() - pos.getY()) > 5)
return false;
waterLevel = MHelper.min(pos.getY(), waterLevel);
pos = getPosOnSurfaceRaycast(world, blockPos.east(dist).up(10), 20);
pos = getPosOnSurfaceRaycast(world, blockPos.east(dist).above(10), 20);
if (Math.abs(blockPos.getY() - pos.getY()) > 5)
return false;
waterLevel = MHelper.min(pos.getY(), waterLevel);
pos = getPosOnSurfaceRaycast(world, blockPos.west(dist).up(10), 20);
pos = getPosOnSurfaceRaycast(world, blockPos.west(dist).above(10), 20);
if (Math.abs(blockPos.getY() - pos.getY()) > 5)
return false;
waterLevel = MHelper.min(pos.getY(), waterLevel);
@ -116,11 +115,11 @@ public class EndLakeFeature extends DefaultFeature {
r *= r;
if (x2 + z2 <= r) {
state = world.getBlockState(POS);
if (state.isIn(EndTags.GEN_TERRAIN)) {
if (state.is(EndTags.GEN_TERRAIN)) {
BlocksHelper.setWithoutUpdate(world, POS, AIR);
}
pos = POS.below();
if (world.getBlockState(pos).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(pos).is(EndTags.GEN_TERRAIN)) {
state = world.getBiome(pos).getGenerationSettings().getSurfaceBuilderConfig()
.getTopMaterial();
if (y > waterLevel + 1)
@ -165,24 +164,24 @@ public class EndLakeFeature extends DefaultFeature {
if (y2 + x2 + z2 <= r) {
state = world.getBlockState(POS);
if (canReplace(state)) {
state = world.getBlockState(POS.up());
state = world.getBlockState(POS.above());
state = canReplace(state) ? (y < waterLevel ? WATER : AIR) : state;
BlocksHelper.setWithoutUpdate(world, POS, state);
}
pos = POS.below();
if (world.getBlockState(pos).getBlock().isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(pos).getBlock().is(EndTags.GEN_TERRAIN)) {
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.ENDSTONE_DUST.defaultBlockState());
}
pos = POS.up();
pos = POS.above();
while (canReplace(state = world.getBlockState(pos)) && !state.isAir()
&& state.getFluidState().isEmpty()) {
BlocksHelper.setWithoutUpdate(world, pos, pos.getY() < waterLevel ? WATER : AIR);
pos = pos.up();
pos = pos.above();
}
}
// Make border
else if (y < waterLevel && y2 + x2 + z2 <= rb) {
if (world.isAir(POS.up())) {
if (world.isEmptyBlock(POS.above())) {
state = world.getBiome(POS).getGenerationSettings().getSurfaceBuilderConfig()
.getTopMaterial();
BlocksHelper.setWithoutUpdate(world, POS,
@ -206,9 +205,8 @@ public class EndLakeFeature extends DefaultFeature {
}
private boolean canReplace(BlockState state) {
return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)
|| state.is(EndBlocks.ENDSTONE_DUST) || state.getMaterial().equals(Material.PLANT)
|| state.getMaterial().equals(Material.UNDERWATER_PLANT)
|| state.getMaterial().equals(Material.UNUSED_PLANT);
return state.getMaterial().isReplaceable() || state.is(EndTags.GEN_TERRAIN) || state.is(EndBlocks.ENDSTONE_DUST)
|| state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.WATER_PLANT)
|| state.getMaterial().equals(Material.CORAL);
}
}

View file

@ -1,15 +1,14 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import java.util.Random;
import net.minecraft.core.BlockPos;
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.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -27,7 +26,7 @@ public class FallenPillarFeature extends DefaultFeature {
NoneFeatureConfiguration config) {
pos = getPosOnSurface(world,
new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
if (!world.getBlockState(pos.down(5)).isIn(EndTags.GEN_TERRAIN)) {
if (!world.getBlockState(pos.below(5)).is(EndTags.GEN_TERRAIN)) {
return false;
}
@ -51,7 +50,7 @@ public class FallenPillarFeature extends DefaultFeature {
}
return info.getState();
}).setReplaceFunction((state) -> {
return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)
return state.getMaterial().isReplaceable() || state.is(EndTags.GEN_TERRAIN)
|| state.getMaterial().equals(Material.PLANT);
}).fillRecursive(world, pos);

View file

@ -2,15 +2,13 @@ package ru.betterend.world.features.terrain;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import com.google.common.collect.Lists;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBiomes;
import ru.betterend.registry.EndFeatures;
@ -50,7 +48,7 @@ public class FloatingSpireFeature extends SpireFeature {
sdf.setReplaceFunction(REPLACE).addPostProcess((info) -> {
if (info.getStateUp().isAir()) {
if (random.nextInt(16) == 0) {
support.add(info.getPos().up());
support.add(info.getPos().above());
}
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
} else if (info.getState(Direction.UP, 3).isAir()) {

View file

@ -1,20 +1,19 @@
package ru.betterend.world.features.terrain;
import com.mojang.math.Vector3f;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.HorizontalFacingBlock;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.Mth;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.blocks.HydrothermalVentBlock;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
@ -56,7 +55,7 @@ public class GeyserFeature extends DefaultFeature {
MutableBlockPos bpos = new MutableBlockPos().set(pos);
bpos.setY(bpos.getY() - 1);
BlockState state = world.getBlockState(bpos);
while (state.isIn(EndTags.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) {
while (state.is(EndTags.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) {
bpos.setY(bpos.getY() - 1);
state = world.getBlockState(bpos);
}
@ -107,7 +106,7 @@ public class GeyserFeature extends DefaultFeature {
bowl = new SDFSubtraction().setSourceA(bowl).setSourceB(cut);
bowl = new SDFTranslate().setTranslate(radius, py - radius, 0).setSource(bowl);
bowl = new SDFRotation().setRotation(Vector3f.POSITIVE_Y, i * 4F).setSource(bowl);
bowl = new SDFRotation().setRotation(Vector3f.YP, i * 4F).setSource(bowl);
sdf = new SDFUnion().setSourceA(sdf).setSourceB(bowl);
}
sdf.setReplaceFunction(REPLACE2).fillRecursive(world, pos);
@ -165,7 +164,7 @@ public class GeyserFeature extends DefaultFeature {
for (int i = 0; i < count; i++) {
BlocksHelper.setWithoutUpdate(world, mut, WATER);
for (Direction dir : BlocksHelper.HORIZONTAL) {
BlocksHelper.setWithoutUpdate(world, mut.offset(dir), WATER);
BlocksHelper.setWithoutUpdate(world, mut.relative(dir), WATER);
}
mut.setY(mut.getY() + 1);
}
@ -177,24 +176,25 @@ public class GeyserFeature extends DefaultFeature {
int dist = MHelper.floor(6 - distRaw) + random.nextInt(2);
if (dist >= 0) {
state = world.getBlockState(mut);
while (!state.getFluidState().isEmpty() || state.getMaterial().equals(Material.UNDERWATER_PLANT)) {
while (!state.getFluidState().isEmpty() || state.getMaterial().equals(Material.WATER_PLANT)) {
mut.setY(mut.getY() - 1);
state = world.getBlockState(mut);
}
if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).is(EndBlocks.HYDROTHERMAL_VENT)) {
if (state.is(EndTags.GEN_TERRAIN)
&& !world.getBlockState(mut.above()).is(EndBlocks.HYDROTHERMAL_VENT)) {
for (int j = 0; j <= dist; j++) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
MHelper.shuffle(HORIZONTAL, random);
for (Direction dir : HORIZONTAL) {
BlockPos p = mut.offset(dir);
BlockPos p = mut.relative(dir);
if (random.nextBoolean() && world.getBlockState(p).is(Blocks.WATER)) {
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TUBE_WORM.defaultBlockState()
.with(HorizontalFacingBlock.FACING, dir));
.setValue(HorizontalDirectionalBlock.FACING, dir));
}
}
mut.setY(mut.getY() + 1);
}
state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().with(HydrothermalVentBlock.ACTIVATED,
state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().setValue(HydrothermalVentBlock.ACTIVATED,
distRaw < 2);
BlocksHelper.setWithoutUpdate(world, mut, state);
mut.setY(mut.getY() + 1);
@ -219,12 +219,12 @@ public class GeyserFeature extends DefaultFeature {
mut.setY(mut.getY() - 1);
state = world.getBlockState(mut);
}
if (state.isIn(EndTags.GEN_TERRAIN)) {
if (state.is(EndTags.GEN_TERRAIN)) {
for (int j = 0; j <= dist; j++) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
mut.setY(mut.getY() + 1);
}
state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().with(HydrothermalVentBlock.ACTIVATED,
state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().setValue(HydrothermalVentBlock.ACTIVATED,
distRaw < 2);
BlocksHelper.setWithoutUpdate(world, mut, state);
mut.setY(mut.getY() + 1);
@ -250,11 +250,11 @@ public class GeyserFeature extends DefaultFeature {
static {
REPLACE1 = (state) -> {
return state.isAir() || (state.isIn(EndTags.GEN_TERRAIN));
return state.isAir() || (state.is(EndTags.GEN_TERRAIN));
};
REPLACE2 = (state) -> {
if (state.isIn(EndTags.GEN_TERRAIN) || state.is(EndBlocks.HYDROTHERMAL_VENT)
if (state.is(EndTags.GEN_TERRAIN) || state.is(EndBlocks.HYDROTHERMAL_VENT)
|| state.is(EndBlocks.SULPHUR_CRYSTAL)) {
return true;
}

View file

@ -1,13 +1,12 @@
package ru.betterend.world.features.terrain;
import com.mojang.math.Vector3f;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.registry.EndBlocks;
@ -45,12 +44,12 @@ public class IceStarFeature extends DefaultFeature {
for (Vector3f point : points) {
SDF rotated = spike;
point = MHelper.normalize(point);
float angle = MHelper.angle(Vector3f.POSITIVE_Y, point);
float angle = MHelper.angle(Vector3f.YP, point);
if (angle > 0.01F && angle < 3.14F) {
Vector3f axis = MHelper.normalize(MHelper.cross(Vector3f.POSITIVE_Y, point));
Vector3f axis = MHelper.normalize(MHelper.cross(Vector3f.YP, point));
rotated = new SDFRotation().setRotation(axis, angle).setSource(spike);
} else if (angle > 1) {
rotated = new SDFRotation().setRotation(Vector3f.POSITIVE_Y, (float) Math.PI).setSource(spike);
rotated = new SDFRotation().setRotation(Vector3f.YP, (float) Math.PI).setSource(spike);
}
sdf = (sdf == null) ? rotated : new SDFUnion().setSourceA(sdf).setSourceB(rotated);
}

View file

@ -1,14 +1,13 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import net.minecraft.core.BlockPos;
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.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -25,7 +24,7 @@ public class ObsidianBoulderFeature extends DefaultFeature {
NoneFeatureConfiguration config) {
pos = getPosOnSurface(world,
new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
if (!world.getBlockState(pos.below()).isIn(EndTags.END_GROUND)) {
if (!world.getBlockState(pos.below()).is(EndTags.END_GROUND)) {
return false;
}
@ -40,7 +39,7 @@ public class ObsidianBoulderFeature extends DefaultFeature {
}
private void makeBoulder(WorldGenLevel world, BlockPos pos, Random random) {
if (!world.getBlockState(pos.below()).isIn(EndTags.END_GROUND)) {
if (!world.getBlockState(pos.below()).is(EndTags.END_GROUND)) {
return;
}
@ -62,7 +61,7 @@ public class ObsidianBoulderFeature extends DefaultFeature {
}
return info.getState();
}).setReplaceFunction((state) -> {
return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)
return state.getMaterial().isReplaceable() || state.is(EndTags.GEN_TERRAIN)
|| state.getMaterial().equals(Material.PLANT);
}).fillRecursive(world, pos);
}

View file

@ -1,15 +1,14 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import java.util.Random;
import net.minecraft.core.BlockPos;
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.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -29,7 +28,7 @@ public class ObsidianPillarBasementFeature extends DefaultFeature {
NoneFeatureConfiguration config) {
pos = getPosOnSurface(world,
new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
if (!world.getBlockState(pos.down(5)).isIn(EndTags.GEN_TERRAIN)) {
if (!world.getBlockState(pos.below(5)).is(EndTags.GEN_TERRAIN)) {
return false;
}
@ -59,7 +58,7 @@ public class ObsidianPillarBasementFeature extends DefaultFeature {
}
return info.getState();
}).setReplaceFunction((state) -> {
return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)
return state.getMaterial().isReplaceable() || state.is(EndTags.GEN_TERRAIN)
|| state.getMaterial().equals(Material.PLANT);
}).fillRecursive(world, pos);

View file

@ -1,11 +1,10 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.BlockPos;
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.configurations.NoneFeatureConfiguration;
import ru.betterend.noise.OpenSimplexNoise;

View file

@ -1,12 +1,11 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.registry.EndTags;
@ -23,14 +22,14 @@ public class SingleBlockFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).isIn(EndTags.GEN_TERRAIN)) {
if (!world.getBlockState(pos.below()).is(EndTags.GEN_TERRAIN)) {
return false;
}
BlockState state = block.defaultBlockState();
if (block.getStateManager().getProperty("waterlogged") != null) {
if (block.getStateDefinition().getProperty("waterlogged") != null) {
boolean waterlogged = !world.getFluidState(pos).isEmpty();
state = state.with(Properties.WATERLOGGED, waterlogged);
state = state.setValue(BlockStateProperties.WATERLOGGED, waterlogged);
}
BlocksHelper.setWithoutUpdate(world, pos, state);

View file

@ -1,12 +1,11 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.registry.EndBlocks;
@ -19,7 +18,7 @@ public class SmaragdantCrystalFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).isIn(EndTags.GEN_TERRAIN)) {
if (!world.getBlockState(pos.below()).is(EndTags.GEN_TERRAIN)) {
return false;
}
@ -38,13 +37,14 @@ public class SmaragdantCrystalFeature extends DefaultFeature {
mut.setY(mut.getY() - 1);
state = world.getBlockState(mut);
}
if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).is(crystal.getBlock())) {
if (state.is(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.above()).is(crystal.getBlock())) {
for (int j = 0; j <= dist; j++) {
BlocksHelper.setWithoutUpdate(world, mut, crystal);
mut.setY(mut.getY() + 1);
}
boolean waterlogged = !world.getFluidState(mut).isEmpty();
BlocksHelper.setWithoutUpdate(world, mut, shard.with(Properties.WATERLOGGED, waterlogged));
BlocksHelper.setWithoutUpdate(world, mut,
shard.setValue(BlockStateProperties.WATERLOGGED, waterlogged));
}
}
}

View file

@ -3,18 +3,16 @@ package ru.betterend.world.features.terrain;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.material.Material;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.collect.Lists;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBiomes;
import ru.betterend.registry.EndFeatures;
@ -46,7 +44,7 @@ public class SpireFeature extends DefaultFeature {
sdf = addSegment(sdf, MHelper.randRange(rMin, rMin + 1.5F, random), random);
}
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
sdf = new SDFDisplacement().setFunction(vec -> {
sdf = new SDFDisplacement().setFunction((vec) -> {
return (float) (Math.abs(noise.eval(vec.x() * 0.1, vec.y() * 0.1, vec.z() * 0.1)) * 3F
+ Math.abs(noise.eval(vec.x() * 0.3, vec.y() * 0.3 + 100, vec.z() * 0.3)) * 1.3F);
}).setSource(sdf);

View file

@ -1,14 +1,13 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.util.Mth;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.blocks.basis.StalactiteBlock;
@ -30,7 +29,7 @@ public class StalactiteFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!isGround(world.getBlockState(ceiling ? pos.up() : pos.below()).getBlock())) {
if (!isGround(world.getBlockState(ceiling ? pos.above() : pos.below()).getBlock())) {
return false;
}
@ -43,7 +42,7 @@ public class StalactiteFeature extends DefaultFeature {
mut.setY(pos.getY() + i * dir);
BlockState state = world.getBlockState(mut);
if (!state.getMaterial().isReplaceable()) {
stalagnate = state.isIn(EndTags.GEN_TERRAIN);
stalagnate = state.is(EndTags.GEN_TERRAIN);
height = i;
break;
}
@ -58,10 +57,10 @@ public class StalactiteFeature extends DefaultFeature {
mut.setY(pos.getY() + i * dir);
int size = stalagnate ? Mth.clamp((int) (Mth.abs(i - center) + 1), 1, 7) : height - i - 1;
boolean waterlogged = !world.getFluidState(mut).isEmpty();
BlockState base = block.defaultBlockState().with(StalactiteBlock.SIZE, size).with(Properties.WATERLOGGED,
waterlogged);
BlockState state = stalagnate ? base.with(StalactiteBlock.IS_FLOOR, dir > 0 ? i < center : i > center)
: base.with(StalactiteBlock.IS_FLOOR, dir > 0);
BlockState base = block.defaultBlockState().setValue(StalactiteBlock.SIZE, size)
.setValue(BlockStateProperties.WATERLOGGED, waterlogged);
BlockState state = stalagnate ? base.setValue(StalactiteBlock.IS_FLOOR, dir > 0 ? i < center : i > center)
: base.setValue(StalactiteBlock.IS_FLOOR, dir > 0);
BlocksHelper.setWithoutUpdate(world, mut, state);
}

View file

@ -1,13 +1,12 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
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.configurations.NoneFeatureConfiguration;
import ru.betterend.blocks.BlockProperties;
@ -46,7 +45,7 @@ public class SulphurHillFeature extends DefaultFeature {
int max = radius + 4;
MutableBlockPos mut = new MutableBlockPos();
BlockState rock = EndBlocks.SULPHURIC_ROCK.stone.defaultBlockState();
BlockState brimstone = EndBlocks.BRIMSTONE.defaultBlockState().with(BlockProperties.ACTIVE, true);
BlockState brimstone = EndBlocks.BRIMSTONE.defaultBlockState().setValue(BlockProperties.ACTIVE, true);
for (int x = min; x < max; x++) {
int x2 = x * x;
int px = pos.getX() + x;

View file

@ -2,20 +2,18 @@ package ru.betterend.world.features.terrain;
import java.util.Random;
import java.util.Set;
import com.google.common.collect.Sets;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.HorizontalFacingBlock;
import net.minecraft.world.level.material.Material;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.Heightmap;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.collect.Sets;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.SulphurCrystalBlock;
import ru.betterend.noise.OpenSimplexNoise;
@ -35,14 +33,14 @@ public class SulphuricCaveFeature extends DefaultFeature {
NoneFeatureConfiguration config) {
int radius = MHelper.randRange(10, 30, random);
int top = world.getTopY(Heightmap.Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
int top = world.getHeight(Heightmap.Types.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
MutableBlockPos bpos = new MutableBlockPos();
bpos.setX(pos.getX());
bpos.setZ(pos.getZ());
bpos.setY(top - 1);
BlockState state = world.getBlockState(bpos);
while (!state.isIn(EndTags.GEN_TERRAIN) && bpos.getY() > 5) {
while (!state.is(EndTags.GEN_TERRAIN) && bpos.getY() > 5) {
bpos.setY(bpos.getY() - 1);
state = world.getBlockState(bpos);
}
@ -51,7 +49,7 @@ public class SulphuricCaveFeature extends DefaultFeature {
}
top = (int) (bpos.getY() - (radius * 1.3F + 5));
while (state.isIn(EndTags.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) {
while (state.is(EndTags.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) {
bpos.setY(bpos.getY() - 1);
state = world.getBlockState(bpos);
}
@ -102,7 +100,7 @@ public class SulphuricCaveFeature extends DefaultFeature {
}
} else if (dist < r2 * r2) {
state = world.getBlockState(mut);
if (state.isIn(EndTags.GEN_TERRAIN) || state.is(Blocks.AIR)) {
if (state.is(EndTags.GEN_TERRAIN) || state.is(Blocks.AIR)) {
double v = noise.eval(x * 0.1, y * 0.1, z * 0.1)
+ noise.eval(x * 0.03, y * 0.03, z * 0.03) * 0.5;
if (v > 0.4) {
@ -128,20 +126,20 @@ public class SulphuricCaveFeature extends DefaultFeature {
+ random.nextInt(2);
if (dist > 0) {
state = world.getBlockState(mut);
while (!state.getFluidState().isEmpty() || state.getMaterial().equals(Material.UNDERWATER_PLANT)) {
while (!state.getFluidState().isEmpty() || state.getMaterial().equals(Material.WATER_PLANT)) {
mut.setY(mut.getY() - 1);
state = world.getBlockState(mut);
}
if (state.isIn(EndTags.GEN_TERRAIN)
&& !world.getBlockState(mut.up()).is(EndBlocks.HYDROTHERMAL_VENT)) {
if (state.is(EndTags.GEN_TERRAIN)
&& !world.getBlockState(mut.above()).is(EndBlocks.HYDROTHERMAL_VENT)) {
for (int j = 0; j <= dist; j++) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
MHelper.shuffle(HORIZONTAL, random);
for (Direction dir : HORIZONTAL) {
BlockPos p = mut.offset(dir);
BlockPos p = mut.relative(dir);
if (random.nextBoolean() && world.getBlockState(p).is(Blocks.WATER)) {
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TUBE_WORM.defaultBlockState()
.with(HorizontalFacingBlock.FACING, dir));
.setValue(HorizontalDirectionalBlock.FACING, dir));
}
}
mut.setY(mut.getY() + 1);
@ -151,7 +149,7 @@ public class SulphuricCaveFeature extends DefaultFeature {
state = world.getBlockState(mut);
while (state.is(Blocks.WATER)) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.VENT_BUBBLE_COLUMN.defaultBlockState());
world.getBlockTickScheduler().schedule(mut, EndBlocks.VENT_BUBBLE_COLUMN,
world.getBlockTicks().scheduleTick(mut, EndBlocks.VENT_BUBBLE_COLUMN,
MHelper.randRange(8, 32, random));
mut.setY(mut.getY() + 1);
state = world.getBlockState(mut);
@ -167,10 +165,10 @@ public class SulphuricCaveFeature extends DefaultFeature {
}
private boolean isReplaceable(BlockState state) {
return state.isIn(EndTags.GEN_TERRAIN) || state.is(EndBlocks.HYDROTHERMAL_VENT)
return state.is(EndTags.GEN_TERRAIN) || state.is(EndBlocks.HYDROTHERMAL_VENT)
|| state.is(EndBlocks.VENT_BUBBLE_COLUMN) || state.is(EndBlocks.SULPHUR_CRYSTAL)
|| state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT)
|| state.getMaterial().equals(Material.UNDERWATER_PLANT) || state.getMaterial().equals(Material.LEAVES);
|| state.getMaterial().equals(Material.WATER_PLANT) || state.getMaterial().equals(Material.LEAVES);
}
private void placeBrimstone(WorldGenLevel world, BlockPos pos, Random random) {
@ -184,7 +182,7 @@ public class SulphuricCaveFeature extends DefaultFeature {
private BlockState getBrimstone(WorldGenLevel world, BlockPos pos) {
for (Direction dir : BlocksHelper.DIRECTIONS) {
if (world.getBlockState(pos.relative(dir)).is(Blocks.WATER)) {
return EndBlocks.BRIMSTONE.defaultBlockState().with(BlockProperties.ACTIVE, true);
return EndBlocks.BRIMSTONE.defaultBlockState().setValue(BlockProperties.ACTIVE, true);
}
}
return EndBlocks.BRIMSTONE.defaultBlockState();
@ -195,8 +193,8 @@ public class SulphuricCaveFeature extends DefaultFeature {
BlockPos side;
if (random.nextInt(16) == 0 && world.getBlockState((side = pos.relative(dir))).is(Blocks.WATER)) {
BlockState state = EndBlocks.SULPHUR_CRYSTAL.defaultBlockState()
.with(SulphurCrystalBlock.WATERLOGGED, true).with(SulphurCrystalBlock.FACING, dir)
.with(SulphurCrystalBlock.AGE, random.nextInt(3));
.setValue(SulphurCrystalBlock.WATERLOGGED, true).setValue(SulphurCrystalBlock.FACING, dir)
.setValue(SulphurCrystalBlock.AGE, random.nextInt(3));
BlocksHelper.setWithoutUpdate(world, side, state);
}
}

View file

@ -2,18 +2,16 @@ package ru.betterend.world.features.terrain;
import java.util.Random;
import java.util.Set;
import com.google.common.collect.Sets;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
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.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Fluids;
import com.google.common.collect.Sets;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.SulphurCrystalBlock;
import ru.betterend.noise.OpenSimplexNoise;
@ -60,25 +58,25 @@ public class SulphuricLakeFeature extends DefaultFeature {
int dist = x2 + z2;
if (dist <= r) {
POS.setY(getYOnSurface(world, x, z) - 1);
if (world.getBlockState(POS).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(POS).is(EndTags.GEN_TERRAIN)) {
if (isBorder(world, POS)) {
if (random.nextInt(8) > 0) {
brimstone.add(POS.immutable());
if (random.nextBoolean()) {
brimstone.add(POS.below());
if (random.nextBoolean()) {
brimstone.add(POS.down(2));
brimstone.add(POS.below(2));
}
}
} else {
if (!isAbsoluteBorder(world, POS)) {
BlocksHelper.setWithoutUpdate(world, POS, Blocks.WATER);
world.getFluidTickScheduler().schedule(POS, Fluids.WATER, 0);
world.getLiquidTicks().scheduleTick(POS, Fluids.WATER, 0);
brimstone.add(POS.below());
if (random.nextBoolean()) {
brimstone.add(POS.down(2));
brimstone.add(POS.below(2));
if (random.nextBoolean()) {
brimstone.add(POS.down(3));
brimstone.add(POS.below(3));
}
}
} else {
@ -92,8 +90,8 @@ public class SulphuricLakeFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, POS, Blocks.WATER);
brimstone.remove(POS);
for (Direction dir : BlocksHelper.HORIZONTAL) {
BlockPos offseted = POS.offset(dir);
if (world.getBlockState(offseted).isIn(EndTags.GEN_TERRAIN)) {
BlockPos offseted = POS.relative(dir);
if (world.getBlockState(offseted).is(EndTags.GEN_TERRAIN)) {
brimstone.add(offseted);
}
}
@ -101,29 +99,29 @@ public class SulphuricLakeFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, POS.move(Direction.DOWN), Blocks.WATER);
brimstone.remove(POS);
for (Direction dir : BlocksHelper.HORIZONTAL) {
BlockPos offseted = POS.offset(dir);
if (world.getBlockState(offseted).isIn(EndTags.GEN_TERRAIN)) {
BlockPos offseted = POS.relative(dir);
if (world.getBlockState(offseted).is(EndTags.GEN_TERRAIN)) {
brimstone.add(offseted);
}
}
}
brimstone.add(POS.below());
if (random.nextBoolean()) {
brimstone.add(POS.down(2));
brimstone.add(POS.below(2));
if (random.nextBoolean()) {
brimstone.add(POS.down(3));
brimstone.add(POS.below(3));
}
}
}
}
} else if (dist < r2) {
POS.setY(getYOnSurface(world, x, z) - 1);
if (world.getBlockState(POS).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(POS).is(EndTags.GEN_TERRAIN)) {
brimstone.add(POS.immutable());
if (random.nextBoolean()) {
brimstone.add(POS.below());
if (random.nextBoolean()) {
brimstone.add(POS.down(2));
brimstone.add(POS.below(2));
}
}
}
@ -141,7 +139,7 @@ public class SulphuricLakeFeature extends DefaultFeature {
private boolean isBorder(WorldGenLevel world, BlockPos pos) {
int y = pos.getY() + 1;
for (Direction dir : BlocksHelper.DIRECTIONS) {
if (getYOnSurface(world, pos.getX() + dir.getOffsetX(), pos.getZ() + dir.getOffsetZ()) < y) {
if (getYOnSurface(world, pos.getX() + dir.getStepX(), pos.getZ() + dir.getStepZ()) < y) {
return true;
}
}
@ -151,7 +149,7 @@ public class SulphuricLakeFeature extends DefaultFeature {
private boolean isAbsoluteBorder(WorldGenLevel world, BlockPos pos) {
int y = pos.getY() - 2;
for (Direction dir : BlocksHelper.DIRECTIONS) {
if (getYOnSurface(world, pos.getX() + dir.getOffsetX() * 3, pos.getZ() + dir.getOffsetZ() * 3) < y) {
if (getYOnSurface(world, pos.getX() + dir.getStepX() * 3, pos.getZ() + dir.getStepZ() * 3) < y) {
return true;
}
}
@ -161,9 +159,9 @@ public class SulphuricLakeFeature extends DefaultFeature {
private boolean isDeepWater(WorldGenLevel world, BlockPos pos) {
int y = pos.getY() + 1;
for (Direction dir : BlocksHelper.DIRECTIONS) {
if (getYOnSurface(world, pos.getX() + dir.getOffsetX(), pos.getZ() + dir.getOffsetZ()) < y
|| getYOnSurface(world, pos.getX() + dir.getOffsetX() * 2, pos.getZ() + dir.getOffsetZ() * 2) < y
|| getYOnSurface(world, pos.getX() + dir.getOffsetX() * 3, pos.getZ() + dir.getOffsetZ() * 3) < y) {
if (getYOnSurface(world, pos.getX() + dir.getStepX(), pos.getZ() + dir.getStepZ()) < y
|| getYOnSurface(world, pos.getX() + dir.getStepX() * 2, pos.getZ() + dir.getStepZ() * 2) < y
|| getYOnSurface(world, pos.getX() + dir.getStepX() * 3, pos.getZ() + dir.getStepZ() * 3) < y) {
return false;
}
}
@ -181,7 +179,7 @@ public class SulphuricLakeFeature extends DefaultFeature {
private BlockState getBrimstone(WorldGenLevel world, BlockPos pos) {
for (Direction dir : BlocksHelper.DIRECTIONS) {
if (world.getBlockState(pos.relative(dir)).is(Blocks.WATER)) {
return EndBlocks.BRIMSTONE.defaultBlockState().with(BlockProperties.ACTIVE, true);
return EndBlocks.BRIMSTONE.defaultBlockState().setValue(BlockProperties.ACTIVE, true);
}
}
return EndBlocks.BRIMSTONE.defaultBlockState();
@ -192,8 +190,8 @@ public class SulphuricLakeFeature extends DefaultFeature {
BlockPos side;
if (random.nextInt(16) == 0 && world.getBlockState((side = pos.relative(dir))).is(Blocks.WATER)) {
BlockState state = EndBlocks.SULPHUR_CRYSTAL.defaultBlockState()
.with(SulphurCrystalBlock.WATERLOGGED, true).with(SulphurCrystalBlock.FACING, dir)
.with(SulphurCrystalBlock.AGE, random.nextInt(3));
.setValue(SulphurCrystalBlock.WATERLOGGED, true).setValue(SulphurCrystalBlock.FACING, dir)
.setValue(SulphurCrystalBlock.AGE, random.nextInt(3));
BlocksHelper.setWithoutUpdate(world, side, state);
}
}

View file

@ -1,11 +1,10 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.blocks.HydrothermalVentBlock;
@ -21,13 +20,13 @@ public class SurfaceVentFeature extends DefaultFeature {
NoneFeatureConfiguration config) {
pos = getPosOnSurface(world,
new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
if (!world.getBlockState(pos.down(3)).isIn(EndTags.GEN_TERRAIN)) {
if (!world.getBlockState(pos.below(3)).is(EndTags.GEN_TERRAIN)) {
return false;
}
MutableBlockPos mut = new MutableBlockPos();
int count = MHelper.randRange(15, 30, random);
BlockState vent = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().with(HydrothermalVentBlock.WATERLOGGED,
BlockState vent = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().setValue(HydrothermalVentBlock.WATERLOGGED,
false);
for (int i = 0; i < count; i++) {
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 5,
@ -40,7 +39,8 @@ public class SurfaceVentFeature extends DefaultFeature {
mut.setY(mut.getY() - 1);
state = world.getBlockState(mut);
}
if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).is(EndBlocks.HYDROTHERMAL_VENT)) {
if (state.is(EndTags.GEN_TERRAIN)
&& !world.getBlockState(mut.above()).is(EndBlocks.HYDROTHERMAL_VENT)) {
for (int j = 0; j <= dist; j++) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
mut.setY(mut.getY() + 1);

View file

@ -3,18 +3,16 @@ package ru.betterend.world.features.terrain.caves;
import java.util.Random;
import java.util.Set;
import java.util.function.Supplier;
import com.google.common.collect.Sets;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import com.google.common.collect.Sets;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
import ru.betterend.world.biome.cave.EndCaveBiome;
@ -45,8 +43,8 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
return true;
}
protected void fillSets(int sx, int sz, Chunk chunk, Set<BlockPos> floorPositions, Set<BlockPos> ceilPositions,
MutableBlockPos min, MutableBlockPos max) {
protected void fillSets(int sx, int sz, ChunkAccess chunk, Set<BlockPos> floorPositions,
Set<BlockPos> ceilPositions, MutableBlockPos min, MutableBlockPos max) {
MutableBlockPos mut = new MutableBlockPos();
MutableBlockPos mut2 = new MutableBlockPos();
MutableBlockPos mut3 = new MutableBlockPos();
@ -57,16 +55,16 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
mut.setZ(z);
mut2.setZ(z);
mut2.setY(0);
for (int y = 1; y < chunk.getHeight(); y++) {
for (int y = 1; y < chunk.getMaxBuildHeight(); y++) {
mut.setY(y);
BlockState top = chunk.getBlockState(mut);
BlockState bottom = chunk.getBlockState(mut2);
if (top.isAir() && (bottom.isIn(EndTags.GEN_TERRAIN) || bottom.is(Blocks.STONE))) {
if (top.isAir() && (bottom.is(EndTags.GEN_TERRAIN) || bottom.is(Blocks.STONE))) {
mut3.set(mut2).move(sx, 0, sz);
floorPositions.add(mut3.immutable());
updateMin(mut3, min);
updateMax(mut3, max);
} else if (bottom.isAir() && (top.isIn(EndTags.GEN_TERRAIN) || top.is(Blocks.STONE))) {
} else if (bottom.isAir() && (top.is(EndTags.GEN_TERRAIN) || top.is(Blocks.STONE))) {
mut3.set(mut).move(sx, 0, sz);
ceilPositions.add(mut3.immutable());
updateMin(mut3, min);
@ -110,7 +108,7 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
if (density > 0 && random.nextFloat() <= density) {
Feature<?> feature = biome.getFloorFeature(random);
if (feature != null) {
feature.place(world, null, random, pos.up(), null);
feature.place(world, null, random, pos.above(), null);
}
}
});

View file

@ -2,20 +2,18 @@ package ru.betterend.world.features.terrain.caves;
import java.util.Random;
import java.util.Set;
import com.google.common.collect.Sets;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.Heightmap;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.biome.Biome;
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.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import com.google.common.collect.Sets;
import ru.betterend.interfaces.IBiomeArray;
import ru.betterend.registry.EndBiomes;
import ru.betterend.registry.EndTags;
@ -62,11 +60,11 @@ public abstract class EndCaveFeature extends DefaultFeature {
mut.set(bpos);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
mut.setY(bpos.getY() - 1);
if (world.getBlockState(mut).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(mut).is(EndTags.GEN_TERRAIN)) {
floorPositions.add(mut.immutable());
}
mut.setY(bpos.getY() + 1);
if (world.getBlockState(mut).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(mut).is(EndTags.GEN_TERRAIN)) {
ceilPositions.add(mut.immutable());
}
}
@ -82,7 +80,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
return true;
}
protected abstract Set<BlockPos> place(WorldGenLevel world, BlockPos center, int radius, Random random);
protected abstract Set<BlockPos> generate(WorldGenLevel world, BlockPos center, int radius, Random random);
protected void placeFloor(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> floorPositions, Random random,
BlockState surfaceBlock) {
@ -92,7 +90,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
if (density > 0 && random.nextFloat() <= density) {
Feature<?> feature = biome.getFloorFeature(random);
if (feature != null) {
feature.place(world, null, random, pos.up(), null);
feature.place(world, null, random, pos.above(), null);
}
}
});
@ -119,21 +117,21 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
private void setBiome(WorldGenLevel world, BlockPos pos, EndCaveBiome biome) {
IBiomeArray array = (IBiomeArray) world.getChunk(pos).getBiomeArray();
IBiomeArray array = (IBiomeArray) world.getChunk(pos).getBiomes();
if (array != null) {
array.setBiome(biome.getActualBiome(), pos);
}
}
private BlockPos findPos(WorldGenLevel world, BlockPos pos, int radius, Random random) {
int top = world.getTopY(Heightmap.Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
int top = world.getHeight(Heightmap.Types.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
MutableBlockPos bpos = new MutableBlockPos();
bpos.setX(pos.getX());
bpos.setZ(pos.getZ());
bpos.setY(top - 1);
BlockState state = world.getBlockState(bpos);
while (!state.isIn(EndTags.GEN_TERRAIN) && bpos.getY() > 5) {
while (!state.is(EndTags.GEN_TERRAIN) && bpos.getY() > 5) {
bpos.setY(bpos.getY() - 1);
state = world.getBlockState(bpos);
}
@ -142,7 +140,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
top = (int) (bpos.getY() - (radius * 1.3F + 5));
while (state.isIn(EndTags.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) {
while (state.is(EndTags.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) {
bpos.setY(bpos.getY() - 1);
state = world.getBlockState(bpos);
}
@ -181,7 +179,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
end.setZ(bpos.getZ());
}
});
BlocksHelper.fixBlocks(world, start.add(-5, -5, -5), end.add(5, 5, 5));
BlocksHelper.fixBlocks(world, start.offset(-5, -5, -5), end.offset(5, 5, 5));
}
protected boolean isWaterNear(WorldGenLevel world, BlockPos pos) {

View file

@ -2,14 +2,12 @@ package ru.betterend.world.features.terrain.caves;
import java.util.Random;
import java.util.Set;
import com.google.common.collect.Sets;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import com.google.common.collect.Sets;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
@ -17,19 +15,19 @@ import ru.betterend.util.MHelper;
public class RoundCaveFeature extends EndCaveFeature {
@Override
protected Set<BlockPos> place(WorldGenLevel world, BlockPos center, int radius, Random random) {
protected Set<BlockPos> generate(WorldGenLevel world, BlockPos center, int radius, Random random) {
OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ()));
int x1 = center.getX() - radius - 5;
int z1 = center.getZ() - radius - 5;
int x2 = center.getX() + radius + 5;
int z2 = center.getZ() + radius + 5;
int y1 = MHelper.floor(center.getY() - (radius + 5) / 1.6);
int y2 = MHelper.floor(center.getY() + (radius + 5) / 1.6);
double hr = radius * 0.75;
double nr = radius * 0.25;
BlockState state;
MutableBlockPos bpos = new MutableBlockPos();
Set<BlockPos> blocks = Sets.newHashSet();
@ -53,13 +51,13 @@ public class RoundCaveFeature extends EndCaveFeature {
if (isReplaceable(state) && !isWaterNear(world, bpos)) {
BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR);
blocks.add(bpos.immutable());
while (state.getMaterial().equals(Material.LEAVES)) {
BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR);
bpos.setY(bpos.getY() + 1);
state = world.getBlockState(bpos);
}
bpos.setY(y - 1);
while (state.getMaterial().equals(Material.LEAVES)) {
BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR);
@ -71,12 +69,14 @@ public class RoundCaveFeature extends EndCaveFeature {
}
}
}
return blocks;
}
private boolean isReplaceable(BlockState state) {
return state.isIn(EndTags.GEN_TERRAIN) || state.getMaterial().isReplaceable()
|| state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.LEAVES);
return state.is(EndTags.GEN_TERRAIN)
|| state.getMaterial().isReplaceable()
|| state.getMaterial().equals(Material.PLANT)
|| state.getMaterial().equals(Material.LEAVES);
}
}

View file

@ -1,17 +1,16 @@
package ru.betterend.world.features.terrain.caves;
import com.mojang.math.Vector3f;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.function.Function;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.util.Mth;
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.material.Material;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.SplineHelper;
@ -19,18 +18,17 @@ import ru.betterend.util.sdf.SDF;
public class TunelCaveFeature extends EndCaveFeature {
private static final Function<BlockState, Boolean> REPLACE;
@Override
protected Set<BlockPos> place(WorldGenLevel world, BlockPos center, int radius, Random random) {
// OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534,
// center.getX(), center.getZ()));
protected Set<BlockPos> generate(WorldGenLevel world, BlockPos center, int radius, Random random) {
//OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ()));
float rad = radius * 0.15F;
int min = Mth.ceil(rad) - 15;
int max = 31 - Mth.floor(rad);
List<Vector3f> spline = SplineHelper.makeSpline(0, 0, 0, 0, 0, 0, radius / 3);
spline = SplineHelper.smoothSpline(spline, 5);
SplineHelper.offsetParts(spline, random, 5, radius * 0.4F, 5);
for (Vector3f vec : spline) {
for (Vector3f vec: spline) {
float x = Mth.clamp(vec.x(), min, max);
float y = Mth.clamp(vec.y(), -radius, radius);
float z = Mth.clamp(vec.z(), min, max);
@ -38,16 +36,18 @@ public class TunelCaveFeature extends EndCaveFeature {
}
SDF sdf = SplineHelper.buildSDF(spline, rad, rad, (vec) -> Blocks.AIR.defaultBlockState());
Set<BlockPos> positions = sdf.setReplaceFunction(REPLACE).getPositions(world, center);
for (BlockPos p : positions) {
for (BlockPos p: positions) {
BlocksHelper.setWithoutUpdate(world, p, CAVE_AIR);
}
return positions;
}
static {
REPLACE = (state) -> {
return state.isIn(EndTags.GEN_TERRAIN) || state.getMaterial().isReplaceable()
|| state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.LEAVES);
return state.is(EndTags.GEN_TERRAIN)
|| state.getMaterial().isReplaceable()
|| state.getMaterial().equals(Material.PLANT)
|| state.getMaterial().equals(Material.LEAVES);
};
}
}

View file

@ -3,19 +3,17 @@ package ru.betterend.world.features.trees;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.collect.Lists;
import com.mojang.math.Vector3f;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -44,7 +42,7 @@ public class DragonTreeFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
float size = MHelper.randRange(10, 25, random);
@ -59,10 +57,10 @@ public class DragonTreeFeature extends DefaultFeature {
Vector3f last = SplineHelper.getPos(spline, 3.5F);
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
float radius = size * MHelper.randRange(0.5F, 0.7F, random);
makeCap(world, pos.offset(last.getX(), last.getY(), last.getZ()), radius, random, noise);
makeCap(world, pos.offset(last.x(), last.y(), last.z()), radius, random, noise);
last = spline.get(0);
makeRoots(world, pos.offset(last.getX(), last.getY(), last.getZ()), radius, random);
makeRoots(world, pos.offset(last.x(), last.y(), last.z()), radius, random);
radius = MHelper.randRange(1.2F, 2.3F, random);
SDF function = SplineHelper.buildSDF(spline, radius, 1.2F, (bpos) -> {
@ -78,7 +76,7 @@ public class DragonTreeFeature extends DefaultFeature {
private void makeCap(WorldGenLevel world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) {
int count = (int) radius;
int offset = (int) (BRANCH.get(BRANCH.size() - 1).getY() * radius);
int offset = (int) (BRANCH.get(BRANCH.size() - 1).y() * radius);
for (int i = 0; i < count; i++) {
float angle = (float) i / (float) count * MHelper.PI2;
float scale = radius * MHelper.randRange(0.85F, 1.15F, random);
@ -98,7 +96,7 @@ public class DragonTreeFeature extends DefaultFeature {
SplineHelper.scale(branch, scale);
SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.defaultBlockState(), pos, REPLACE);
}
leavesBall(world, pos.up(offset), radius * 1.15F + 2, random, noise);
leavesBall(world, pos.above(offset), radius * 1.15F + 2, random, noise);
}
private void makeRoots(WorldGenLevel world, BlockPos pos, float radius, Random random) {
@ -111,7 +109,7 @@ public class DragonTreeFeature extends DefaultFeature {
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
Vector3f last = branch.get(branch.size() - 1);
if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(pos.offset(last.x(), last.y(), last.z())).is(EndTags.GEN_TERRAIN)) {
SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.defaultBlockState(), pos, REPLACE);
}
}
@ -119,7 +117,7 @@ public class DragonTreeFeature extends DefaultFeature {
private void leavesBall(WorldGenLevel world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) {
SDF sphere = new SDFSphere().setRadius(radius)
.setBlock(EndBlocks.DRAGON_TREE_LEAVES.defaultBlockState().with(LeavesBlock.DISTANCE, 6));
.setBlock(EndBlocks.DRAGON_TREE_LEAVES.defaultBlockState().setValue(LeavesBlock.DISTANCE, 6));
SDF sub = new SDFScale().setScale(5).setSource(sphere);
sub = new SDFTranslate().setTranslate(0, -radius * 5, 0).setSource(sub);
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub);
@ -155,7 +153,7 @@ public class DragonTreeFeature extends DefaultFeature {
if (state.getBlock() instanceof LeavesBlock) {
int distance = state.getValue(LeavesBlock.DISTANCE);
if (d < distance) {
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
info.setState(mut, state.setValue(LeavesBlock.DISTANCE, d));
}
}
}
@ -174,7 +172,7 @@ public class DragonTreeFeature extends DefaultFeature {
random.nextGaussian() * 1);
boolean place = true;
for (Direction d : Direction.values()) {
BlockState state = world.getBlockState(p.offset(d));
BlockState state = world.getBlockState(p.relative(d));
if (!EndBlocks.DRAGON_TREE.isTreeLog(state) && !state.is(EndBlocks.DRAGON_TREE_LEAVES)) {
place = false;
break;
@ -191,7 +189,7 @@ public class DragonTreeFeature extends DefaultFeature {
static {
REPLACE = (state) -> {
if (state.isIn(EndTags.END_GROUND)) {
if (state.is(EndTags.END_GROUND)) {
return true;
}
if (state.getBlock() == EndBlocks.DRAGON_TREE_LEAVES) {

View file

@ -1,12 +1,9 @@
package ru.betterend.world.features.trees;
import com.mojang.math.Vector3f;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
@ -14,8 +11,10 @@ import net.minecraft.core.Direction.Axis;
import net.minecraft.core.Direction.AxisDirection;
import net.minecraft.util.Mth;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.blocks.basis.AttachedBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -34,7 +33,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
float size = MHelper.randRange(5, 10, random);
@ -52,8 +51,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
});
Vector3f capPos = spline.get(spline.size() - 1);
makeHead(world, pos.offset(capPos.getX() + 0.5F, capPos.getY() + 1.5F, capPos.getZ() + 0.5F),
Mth.floor(size / 1.6F));
makeHead(world, pos.offset(capPos.x() + 0.5F, capPos.y() + 1.5F, capPos.z() + 0.5F), Mth.floor(size / 1.6F));
function.setReplaceFunction(REPLACE);
function.addPostProcess(POST);
@ -99,7 +97,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
mut.move(Direction.DOWN);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.defaultBlockState()
.with(AttachedBlock.FACING, Direction.DOWN));
.setValue(AttachedBlock.FACING, Direction.DOWN));
}
}
}
@ -159,18 +157,18 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_LANTERN);
Axis axis = x < 0 || x > 1 ? Axis.X : Axis.Z;
int distance = axis == Axis.X ? x < 0 ? -1 : 1 : z < 0 ? -1 : 1;
BlockPos offseted = mut.offset(axis, distance);
BlockPos offseted = mut.relative(axis, distance);
if (world.getBlockState(offseted).getMaterial().isReplaceable()) {
Direction dir = Direction.fromAxisAndDirection(axis,
distance < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE);
BlocksHelper.setWithoutUpdate(world, offseted,
EndBlocks.AMARANITA_FUR.defaultBlockState().with(AttachedBlock.FACING, dir));
BlocksHelper.setWithoutUpdate(world, offseted, EndBlocks.AMARANITA_FUR
.defaultBlockState().setValue(AttachedBlock.FACING, dir));
}
mut.move(Direction.DOWN);
}
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.defaultBlockState()
.with(AttachedBlock.FACING, Direction.DOWN));
.setValue(AttachedBlock.FACING, Direction.DOWN));
}
}
}
@ -273,18 +271,18 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_LANTERN);
Axis axis = x < 0 || x > 1 ? Axis.X : Axis.Z;
int distance = axis == Axis.X ? x < 0 ? -1 : 1 : z < 0 ? -1 : 1;
BlockPos offseted = mut.offset(axis, distance);
BlockPos offseted = mut.relative(axis, distance);
if (world.getBlockState(offseted).getMaterial().isReplaceable()) {
Direction dir = Direction.fromAxisAndDirection(axis,
distance < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE);
BlocksHelper.setWithoutUpdate(world, offseted,
EndBlocks.AMARANITA_FUR.defaultBlockState().with(AttachedBlock.FACING, dir));
BlocksHelper.setWithoutUpdate(world, offseted, EndBlocks.AMARANITA_FUR
.defaultBlockState().setValue(AttachedBlock.FACING, dir));
}
mut.move(Direction.DOWN);
}
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.defaultBlockState()
.with(AttachedBlock.FACING, Direction.DOWN));
.setValue(AttachedBlock.FACING, Direction.DOWN));
}
}
}
@ -329,7 +327,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
static {
REPLACE = (state) -> {
if (state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)) {
if (state.is(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)) {
return true;
}
return state.getMaterial().isReplaceable();

View file

@ -1,19 +1,18 @@
package ru.betterend.world.features.trees;
import com.mojang.math.Vector3f;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.world.level.block.state.BlockState;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.phys.AABB;
import net.minecraft.util.Mth;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.phys.AABB;
import ru.betterend.blocks.HelixTreeLeavesBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -35,7 +34,7 @@ public class HelixTreeFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
BlocksHelper.setWithoutUpdate(world, pos, AIR);
@ -55,7 +54,7 @@ public class HelixTreeFeature extends DefaultFeature {
SDF sdf = SplineHelper.buildSDF(spline, 1.7F, 0.5F, (p) -> {
return EndBlocks.HELIX_TREE.bark.defaultBlockState();
});
SDF rotated = new SDFRotation().setRotation(Vector3f.POSITIVE_Y, (float) Math.PI).setSource(sdf);
SDF rotated = new SDFRotation().setRotation(Vector3f.YP, (float) Math.PI).setSource(sdf);
sdf = new SDFUnion().setSourceA(rotated).setSourceB(sdf);
Vector3f lastPoint = spline.get(spline.size() - 1);
@ -63,14 +62,14 @@ public class HelixTreeFeature extends DefaultFeature {
SDF stem = SplineHelper.buildSDF(spline2, 1.0F, 0.5F, (p) -> {
return EndBlocks.HELIX_TREE.bark.defaultBlockState();
});
stem = new SDFTranslate().setTranslate(lastPoint.getX(), lastPoint.getY(), lastPoint.getZ()).setSource(stem);
stem = new SDFTranslate().setTranslate(lastPoint.x(), lastPoint.y(), lastPoint.z()).setSource(stem);
sdf = new SDFSmoothUnion().setRadius(3).setSourceA(sdf).setSourceB(stem);
sdf = new SDFScale().setScale(scale).setSource(sdf);
dx = 30 * scale;
float dy1 = -20 * scale;
float dy2 = 100 * scale;
sdf.addPostProcess(POST).fillArea(world, pos, new Box(pos.offset(-dx, dy1, -dx), pos.offset(dx, dy2, dx)));
sdf.addPostProcess(POST).fillArea(world, pos, new AABB(pos.offset(-dx, dy1, -dx), pos.offset(dx, dy2, dx)));
SplineHelper.scale(spline, scale);
SplineHelper.fillSplineForce(spline, world, EndBlocks.HELIX_TREE.bark.defaultBlockState(), pos, (state) -> {
return state.getMaterial().isReplaceable();
@ -80,7 +79,7 @@ public class HelixTreeFeature extends DefaultFeature {
return state.getMaterial().isReplaceable();
});
SplineHelper.scale(spline2, scale);
BlockPos leafStart = pos.offset(lastPoint.getX() + 0.5, lastPoint.getY() + 0.5, lastPoint.getZ() + 0.5);
BlockPos leafStart = pos.offset(lastPoint.x() + 0.5, lastPoint.y() + 0.5, lastPoint.z() + 0.5);
SplineHelper.fillSplineForce(spline2, world, EndBlocks.HELIX_TREE.log.defaultBlockState(), leafStart,
(state) -> {
return state.getMaterial().isReplaceable();
@ -107,38 +106,38 @@ public class HelixTreeFeature extends DefaultFeature {
BlockState leaf = EndBlocks.HELIX_TREE_LEAVES.defaultBlockState();
for (int i = 1; i < spline.size(); i++) {
Vector3f point = spline.get(i);
int minY = MHelper.floor(lastPoint.getY());
int maxY = MHelper.floor(point.getY());
float div = point.getY() - lastPoint.getY();
int minY = MHelper.floor(lastPoint.y());
int maxY = MHelper.floor(point.y());
float div = point.y() - lastPoint.y();
for (float py = minY; py <= maxY; py += 0.2F) {
start.set(0, py, 0);
float delta = (float) (py - minY) / div;
float px = Mth.lerp(delta, lastPoint.getX(), point.getX());
float pz = Mth.lerp(delta, lastPoint.getZ(), point.getZ());
float px = Mth.lerp(delta, lastPoint.x(), point.x());
float pz = Mth.lerp(delta, lastPoint.z(), point.z());
end.set(px, py, pz);
fillLine(start, end, world, leaf, leafStart, i / 2 - 1);
float ax = Math.abs(px);
float az = Math.abs(pz);
if (ax > az) {
start.set(start.getX(), start.getY(), start.getZ() + az > 0 ? 1 : -1);
end.set(end.getX(), end.getY(), end.getZ() + az > 0 ? 1 : -1);
start.set(start.x(), start.y(), start.z() + az > 0 ? 1 : -1);
end.set(end.x(), end.y(), end.z() + az > 0 ? 1 : -1);
} else {
start.set(start.getX() + ax > 0 ? 1 : -1, start.getY(), start.getZ());
end.set(end.getX() + ax > 0 ? 1 : -1, end.getY(), end.getZ());
start.set(start.x() + ax > 0 ? 1 : -1, start.y(), start.z());
end.set(end.x() + ax > 0 ? 1 : -1, end.y(), end.z());
}
fillLine(start, end, world, leaf, leafStart, i / 2 - 1);
}
lastPoint = point;
}
leaf = leaf.with(HelixTreeLeavesBlock.COLOR, 7);
leafStart = leafStart.add(0, lastPoint.getY(), 0);
leaf = leaf.setValue(HelixTreeLeavesBlock.COLOR, 7);
leafStart = leafStart.offset(0, lastPoint.y(), 0);
if (world.getBlockState(leafStart).isAir()) {
BlocksHelper.setWithoutUpdate(world, leafStart, leaf);
leafStart = leafStart.up();
leafStart = leafStart.above();
if (world.getBlockState(leafStart).isAir()) {
BlocksHelper.setWithoutUpdate(world, leafStart, leaf);
leafStart = leafStart.up();
leafStart = leafStart.above();
if (world.getBlockState(leafStart).isAir()) {
BlocksHelper.setWithoutUpdate(world, leafStart, leaf);
}
@ -150,17 +149,17 @@ public class HelixTreeFeature extends DefaultFeature {
private void fillLine(Vector3f start, Vector3f end, WorldGenLevel world, BlockState state, BlockPos pos,
int offset) {
float dx = end.getX() - start.getX();
float dy = end.getY() - start.getY();
float dz = end.getZ() - start.getZ();
float dx = end.x() - start.x();
float dy = end.y() - start.y();
float dz = end.z() - start.z();
float max = MHelper.max(Math.abs(dx), Math.abs(dy), Math.abs(dz));
int count = MHelper.floor(max + 1);
dx /= max;
dy /= max;
dz /= max;
float x = start.getX();
float y = start.getY();
float z = start.getZ();
float x = start.x();
float y = start.y();
float z = start.z();
MutableBlockPos bPos = new MutableBlockPos();
for (int i = 0; i < count; i++) {
@ -168,15 +167,15 @@ public class HelixTreeFeature extends DefaultFeature {
int color = MHelper.floor((float) i / (float) count * 7F + 0.5F) + offset;
color = Mth.clamp(color, 0, 7);
if (world.getBlockState(bPos).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, bPos, state.with(HelixTreeLeavesBlock.COLOR, color));
BlocksHelper.setWithoutUpdate(world, bPos, state.setValue(HelixTreeLeavesBlock.COLOR, color));
}
x += dx;
y += dy;
z += dz;
}
bPos.set(end.getX() + pos.getX(), end.getY() + pos.getY(), end.getZ() + pos.getZ());
bPos.set(end.x() + pos.getX(), end.y() + pos.getY(), end.z() + pos.getZ());
if (world.getBlockState(bPos).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, bPos, state.with(HelixTreeLeavesBlock.COLOR, 7));
BlocksHelper.setWithoutUpdate(world, bPos, state.setValue(HelixTreeLeavesBlock.COLOR, 7));
}
}

View file

@ -3,17 +3,15 @@ package ru.betterend.world.features.trees;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.util.Mth;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.collect.Lists;
import com.mojang.math.Vector3f;
import ru.betterend.blocks.JellyshroomCapBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -35,7 +33,7 @@ public class JellyshroomFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
BlockState bark = EndBlocks.JELLYSHROOM.bark.defaultBlockState();
@ -56,7 +54,7 @@ public class JellyshroomFeature extends DefaultFeature {
final float membraneRadius = radius;
SDF cap = makeCap(membraneRadius, random, membrane);
final Vector3f last = spline.get(spline.size() - 1);
cap = new SDFTranslate().setTranslate(last.getX(), last.getY(), last.getZ()).setSource(cap);
cap = new SDFTranslate().setTranslate(last.x(), last.y(), last.z()).setSource(cap);
sdf = new SDFSmoothUnion().setRadius(3F).setSourceA(sdf).setSourceB(cap);
sdf.setReplaceFunction(REPLACE).addPostProcess((info) -> {
if (EndBlocks.JELLYSHROOM.isTreeLog(info.getState())) {
@ -65,11 +63,11 @@ public class JellyshroomFeature extends DefaultFeature {
return EndBlocks.JELLYSHROOM.log.defaultBlockState();
}
} else if (info.getState().is(EndBlocks.JELLYSHROOM_CAP_PURPLE)) {
float dx = info.getPos().getX() - pos.getX() - last.getX();
float dz = info.getPos().getZ() - pos.getZ() - last.getZ();
float dx = info.getPos().getX() - pos.getX() - last.x();
float dz = info.getPos().getZ() - pos.getZ() - last.z();
float distance = MHelper.length(dx, dz) / membraneRadius * 7F;
int color = Mth.clamp(MHelper.floor(distance), 0, 7);
return info.getState().with(JellyshroomCapBlock.COLOR, color);
return info.getState().setValue(JellyshroomCapBlock.COLOR, color);
}
return info.getState();
}).fillRecursive(world, pos);
@ -89,7 +87,7 @@ public class JellyshroomFeature extends DefaultFeature {
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
Vector3f last = branch.get(branch.size() - 1);
if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(pos.offset(last.x(), last.y(), last.z())).is(EndTags.GEN_TERRAIN)) {
SplineHelper.fillSpline(branch, world, wood, pos, REPLACE);
}
}
@ -118,7 +116,7 @@ public class JellyshroomFeature extends DefaultFeature {
SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0));
REPLACE = (state) -> {
if (state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)) {
if (state.is(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)) {
return true;
}
return state.getMaterial().isReplaceable();

View file

@ -1,19 +1,18 @@
package ru.betterend.world.features.trees;
import com.mojang.math.Vector3f;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -36,7 +35,7 @@ public class LacugroveFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).is(EndTags.END_GROUND))
return false;
float size = MHelper.randRange(15, 25, random);
@ -52,7 +51,7 @@ public class LacugroveFeature extends DefaultFeature {
float radius = MHelper.randRange(6F, 8F, random);
radius *= (size - 15F) / 20F + 1F;
Vector3f center = spline.get(4);
leavesBall(world, pos.offset(center.getX(), center.getY(), center.getZ()), radius, random, noise);
leavesBall(world, pos.offset(center.x(), center.y(), center.z()), radius, random, noise);
radius = MHelper.randRange(1.2F, 1.8F, random);
SDF function = SplineHelper.buildSDF(spline, radius, 0.7F, (bpos) -> {
@ -81,7 +80,7 @@ public class LacugroveFeature extends DefaultFeature {
boolean generate = false;
for (int y = minY; y < maxY; y++) {
mut.setY(y);
if (world.getBlockState(mut).isIn(EndTags.END_GROUND)) {
if (world.getBlockState(mut).is(EndTags.END_GROUND)) {
generate = true;
break;
}
@ -92,7 +91,7 @@ public class LacugroveFeature extends DefaultFeature {
mut.setY(y);
BlockState state = world.getBlockState(mut);
if (state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT)
|| state.isIn(EndTags.END_GROUND)) {
|| state.is(EndTags.END_GROUND)) {
BlocksHelper.setWithoutUpdate(world, mut,
y == top ? EndBlocks.LACUGROVE.bark : EndBlocks.LACUGROVE.log);
} else {
@ -109,7 +108,7 @@ public class LacugroveFeature extends DefaultFeature {
private void leavesBall(WorldGenLevel world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) {
SDF sphere = new SDFSphere().setRadius(radius)
.setBlock(EndBlocks.LACUGROVE_LEAVES.defaultBlockState().with(LeavesBlock.DISTANCE, 6));
.setBlock(EndBlocks.LACUGROVE_LEAVES.defaultBlockState().setValue(LeavesBlock.DISTANCE, 6));
sphere = new SDFDisplacement().setFunction((vec) -> {
return (float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 3;
}).setSource(sphere);
@ -143,7 +142,7 @@ public class LacugroveFeature extends DefaultFeature {
if (state.getBlock() instanceof LeavesBlock) {
int distance = state.getValue(LeavesBlock.DISTANCE);
if (d < distance) {
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
info.setState(mut, state.setValue(LeavesBlock.DISTANCE, d));
}
}
}
@ -162,7 +161,7 @@ public class LacugroveFeature extends DefaultFeature {
random.nextGaussian() * 1);
boolean place = true;
for (Direction d : Direction.values()) {
BlockState state = world.getBlockState(p.offset(d));
BlockState state = world.getBlockState(p.relative(d));
if (!EndBlocks.LACUGROVE.isTreeLog(state) && !state.is(EndBlocks.LACUGROVE_LEAVES)) {
place = false;
break;
@ -179,7 +178,7 @@ public class LacugroveFeature extends DefaultFeature {
static {
REPLACE = (state) -> {
if (state.isIn(EndTags.END_GROUND)) {
if (state.is(EndTags.END_GROUND)) {
return true;
}
if (EndBlocks.LACUGROVE.isTreeLog(state)) {

View file

@ -3,19 +3,17 @@ package ru.betterend.world.features.trees;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.collect.Lists;
import com.mojang.math.Vector3f;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.FurBlock;
@ -44,7 +42,7 @@ public class LucerniaFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
float size = MHelper.randRange(12, 20, random);
@ -61,8 +59,7 @@ public class LucerniaFeature extends DefaultFeature {
Vector3f last = spline.get(spline.size() - 1);
float leavesRadius = (size * 0.13F + MHelper.randRange(0.8F, 1.5F, random)) * 1.4F;
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
leavesBall(world, pos.offset(last.getX(), last.getY(), last.getZ()), leavesRadius, random, noise,
config != null);
leavesBall(world, pos.offset(last.x(), last.y(), last.z()), leavesRadius, random, noise, config != null);
}
makeRoots(world, pos.offset(0, MHelper.randRange(3, 5, random), 0), size * 0.35F, random);
@ -73,7 +70,7 @@ public class LucerniaFeature extends DefaultFeature {
private void leavesBall(WorldGenLevel world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise,
boolean natural) {
SDF sphere = new SDFSphere().setRadius(radius)
.setBlock(EndBlocks.LUCERNIA_LEAVES.defaultBlockState().with(LeavesBlock.DISTANCE, 6));
.setBlock(EndBlocks.LUCERNIA_LEAVES.defaultBlockState().setValue(LeavesBlock.DISTANCE, 6));
SDF sub = new SDFScale().setScale(5).setSource(sphere);
sub = new SDFTranslate().setTranslate(0, -radius * 5, 0).setSource(sub);
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub);
@ -95,10 +92,10 @@ public class LucerniaFeature extends DefaultFeature {
}
}
BlockState top = EndBlocks.FILALUX.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP);
BlockState middle = EndBlocks.FILALUX.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
BlockState top = EndBlocks.FILALUX.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP);
BlockState middle = EndBlocks.FILALUX.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.MIDDLE);
BlockState bottom = EndBlocks.FILALUX.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
BlockState bottom = EndBlocks.FILALUX.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.BOTTOM);
BlockState outer = EndBlocks.LUCERNIA_OUTER_LEAVES.defaultBlockState();
@ -121,7 +118,7 @@ public class LucerniaFeature extends DefaultFeature {
MHelper.shuffle(DIRECTIONS, random);
for (Direction d : DIRECTIONS) {
if (info.getState(d).isAir()) {
info.setBlockPos(info.getPos().offset(d), outer.with(FurBlock.FACING, d));
info.setBlockPos(info.getPos().relative(d), outer.setValue(FurBlock.FACING, d));
}
}
@ -141,7 +138,7 @@ public class LucerniaFeature extends DefaultFeature {
if (state.getBlock() instanceof LeavesBlock) {
int distance = state.getValue(LeavesBlock.DISTANCE);
if (d < distance) {
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
info.setState(mut, state.setValue(LeavesBlock.DISTANCE, d));
}
}
}
@ -159,11 +156,11 @@ public class LucerniaFeature extends DefaultFeature {
if (state.isAir() || state.is(EndBlocks.LUCERNIA_OUTER_LEAVES)) {
int count = MHelper.randRange(3, 8, random);
mut.set(bpos);
if (world.getBlockState(mut.up()).is(EndBlocks.LUCERNIA_LEAVES)) {
if (world.getBlockState(mut.above()).is(EndBlocks.LUCERNIA_LEAVES)) {
BlocksHelper.setWithoutUpdate(world, mut, top);
for (int i = 1; i < count; i++) {
mut.setY(mut.getY() - 1);
if (world.isAir(mut.below())) {
if (world.isEmptyBlock(mut.below())) {
BlocksHelper.setWithoutUpdate(world, mut, middle);
} else {
break;
@ -185,7 +182,7 @@ public class LucerniaFeature extends DefaultFeature {
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
Vector3f last = branch.get(branch.size() - 1);
if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(pos.offset(last.x(), last.y(), last.z())).is(EndTags.GEN_TERRAIN)) {
SplineHelper.fillSplineForce(branch, world, EndBlocks.LUCERNIA.bark.defaultBlockState(), pos, REPLACE);
}
}
@ -193,7 +190,7 @@ public class LucerniaFeature extends DefaultFeature {
static {
REPLACE = (state) -> {
if (state.isIn(EndTags.END_GROUND)) {
if (state.is(EndTags.END_GROUND)) {
return true;
}
if (state.getBlock() == EndBlocks.LUCERNIA_LEAVES) {

View file

@ -1,17 +1,16 @@
package ru.betterend.world.features.trees;
import com.mojang.math.Vector3f;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.blocks.MossyGlowshroomCapBlock;
import ru.betterend.blocks.basis.FurBlock;
import ru.betterend.noise.OpenSimplexNoise;
@ -75,7 +74,7 @@ public class MossyGlowshroomFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, blockPos, AIR);
CENTER.set(blockPos.getX(), 0, blockPos.getZ());
HEAD_POS.setTranslate(pos.getX(), pos.getY(), pos.getZ());
HEAD_POS.setTranslate(pos.x(), pos.y(), pos.z());
ROOTS_ROT.setAngle(random.nextFloat() * MHelper.PI2);
FUNCTION.setSourceA(sdf);
@ -83,7 +82,7 @@ public class MossyGlowshroomFeature extends DefaultFeature {
if (EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getState())) {
if (random.nextBoolean() && info.getStateUp().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) {
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState()
.with(MossyGlowshroomCapBlock.TRANSITION, true));
.setValue(MossyGlowshroomCapBlock.TRANSITION, true));
return info.getState();
} else if (!EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateUp())
|| !EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown())) {
@ -93,7 +92,7 @@ public class MossyGlowshroomFeature extends DefaultFeature {
} else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) {
if (EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown().getBlock())) {
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState()
.with(MossyGlowshroomCapBlock.TRANSITION, true));
.setValue(MossyGlowshroomCapBlock.TRANSITION, true));
return info.getState();
}
@ -102,14 +101,14 @@ public class MossyGlowshroomFeature extends DefaultFeature {
} else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) {
for (Direction dir : BlocksHelper.HORIZONTAL) {
if (info.getState(dir) == AIR) {
info.setBlockPos(info.getPos().offset(dir),
EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState().with(FurBlock.FACING, dir));
info.setBlockPos(info.getPos().relative(dir),
EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState().setValue(FurBlock.FACING, dir));
}
}
if (info.getStateDown().getBlock() != EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) {
info.setBlockPos(info.getPos().below(),
EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState().with(FurBlock.FACING, Direction.DOWN));
info.setBlockPos(info.getPos().below(), EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState()
.setValue(FurBlock.FACING, Direction.DOWN));
}
}
return info.getState();
@ -144,12 +143,10 @@ public class MossyGlowshroomFeature extends DefaultFeature {
OpenSimplexNoise noise = new OpenSimplexNoise(1234);
cones = new SDFCoordModify().setFunction((pos) -> {
float dist = MHelper.length(pos.getX(), pos.getZ());
float y = pos.getY()
+ (float) noise.eval(pos.getX() * 0.1 + CENTER.getX(), pos.getZ() * 0.1 + CENTER.getZ()) * dist
* 0.3F
float dist = MHelper.length(pos.x(), pos.z());
float y = pos.y() + (float) noise.eval(pos.x() * 0.1 + CENTER.x(), pos.z() * 0.1 + CENTER.z()) * dist * 0.3F
- dist * 0.15F;
pos.set(pos.getX(), y, pos.getZ());
pos.set(pos.x(), y, pos.z());
}).setSource(cones);
HEAD_POS = (SDFTranslate) new SDFTranslate()
@ -164,7 +161,7 @@ public class MossyGlowshroomFeature extends DefaultFeature {
.setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(ROOTS_ROT));
REPLACE = (state) -> {
if (state.isIn(EndTags.END_GROUND)) {
if (state.is(EndTags.END_GROUND)) {
return true;
}
if (state.getMaterial().equals(Material.PLANT)) {

View file

@ -1,19 +1,18 @@
package ru.betterend.world.features.trees;
import com.mojang.math.Vector3f;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -48,8 +47,8 @@ public class PythadendronTreeFeature extends DefaultFeature {
int depth = MHelper.floor((size - 10F) * 3F / 10F + 1F);
float bsize = (10F - (size - 10F)) / 10F + 1.5F;
branch(last.getX(), last.getY(), last.getZ(), size * bsize, MHelper.randRange(0, MHelper.PI2, random), random,
depth, world, pos);
branch(last.x(), last.y(), last.z(), size * bsize, MHelper.randRange(0, MHelper.PI2, random), random, depth,
world, pos);
SDF function = SplineHelper.buildSDF(spline, 1.7F, 1.1F, (bpos) -> {
return EndBlocks.PYTHADENDRON.bark.defaultBlockState();
@ -93,10 +92,10 @@ public class PythadendronTreeFeature extends DefaultFeature {
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
if (depth < 3) {
if (s1) {
leavesBall(world, pos.offset(pos1.getX(), pos1.getY(), pos1.getZ()), random, noise);
leavesBall(world, pos.offset(pos1.x(), pos1.y(), pos1.z()), random, noise);
}
if (s2) {
leavesBall(world, pos.offset(pos2.getX(), pos2.getY(), pos2.getZ()), random, noise);
leavesBall(world, pos.offset(pos2.x(), pos2.y(), pos2.z()), random, noise);
}
}
@ -106,10 +105,10 @@ public class PythadendronTreeFeature extends DefaultFeature {
float angle2 = angle + (float) Math.PI * 0.5F + MHelper.randRange(-0.1F, 0.1F, random);
if (s1) {
branch(pos1.getX(), pos1.getY(), pos1.getZ(), size1, angle1, random, depth - 1, world, pos);
branch(pos1.x(), pos1.y(), pos1.z(), size1, angle1, random, depth - 1, world, pos);
}
if (s2) {
branch(pos2.getX(), pos2.getY(), pos2.getZ(), size2, angle2, random, depth - 1, world, pos);
branch(pos2.x(), pos2.y(), pos2.z(), size2, angle2, random, depth - 1, world, pos);
}
}
@ -117,7 +116,7 @@ public class PythadendronTreeFeature extends DefaultFeature {
float radius = MHelper.randRange(4.5F, 6.5F, random);
SDF sphere = new SDFSphere().setRadius(radius)
.setBlock(EndBlocks.PYTHADENDRON_LEAVES.defaultBlockState().with(LeavesBlock.DISTANCE, 6));
.setBlock(EndBlocks.PYTHADENDRON_LEAVES.defaultBlockState().setValue(LeavesBlock.DISTANCE, 6));
sphere = new SDFScale3D().setScale(1, 0.6F, 1).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> {
return (float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 3;
@ -152,7 +151,7 @@ public class PythadendronTreeFeature extends DefaultFeature {
if (state.getBlock() instanceof LeavesBlock) {
int distance = state.getValue(LeavesBlock.DISTANCE);
if (d < distance) {
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
info.setState(mut, state.setValue(LeavesBlock.DISTANCE, d));
}
}
}
@ -167,7 +166,7 @@ public class PythadendronTreeFeature extends DefaultFeature {
static {
REPLACE = (state) -> {
if (state.isIn(EndTags.END_GROUND)) {
if (state.is(EndTags.END_GROUND)) {
return true;
}
if (state.getBlock() == EndBlocks.PYTHADENDRON_LEAVES) {

View file

@ -3,19 +3,17 @@ package ru.betterend.world.features.trees;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.collect.Lists;
import com.mojang.math.Vector3f;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.FurBlock;
@ -43,7 +41,7 @@ public class TenaneaFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
float size = MHelper.randRange(7, 10, random);
@ -60,7 +58,7 @@ public class TenaneaFeature extends DefaultFeature {
Vector3f last = spline.get(spline.size() - 1);
float leavesRadius = (size * 0.3F + MHelper.randRange(0.8F, 1.5F, random)) * 1.4F;
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
leavesBall(world, pos.offset(last.getX(), last.getY(), last.getZ()), leavesRadius, random, noise);
leavesBall(world, pos.offset(last.x(), last.y(), last.z()), leavesRadius, random, noise);
}
return true;
@ -68,7 +66,7 @@ public class TenaneaFeature extends DefaultFeature {
private void leavesBall(WorldGenLevel world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) {
SDF sphere = new SDFSphere().setRadius(radius)
.setBlock(EndBlocks.TENANEA_LEAVES.defaultBlockState().with(LeavesBlock.DISTANCE, 6));
.setBlock(EndBlocks.TENANEA_LEAVES.defaultBlockState().setValue(LeavesBlock.DISTANCE, 6));
SDF sub = new SDFScale().setScale(5).setSource(sphere);
sub = new SDFTranslate().setTranslate(0, -radius * 5, 0).setSource(sub);
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub);
@ -90,11 +88,11 @@ public class TenaneaFeature extends DefaultFeature {
}
}
BlockState top = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
BlockState top = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.TOP);
BlockState middle = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
BlockState middle = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.MIDDLE);
BlockState bottom = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
BlockState bottom = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.BOTTOM);
BlockState outer = EndBlocks.TENANEA_OUTER_LEAVES.defaultBlockState();
@ -117,7 +115,7 @@ public class TenaneaFeature extends DefaultFeature {
MHelper.shuffle(DIRECTIONS, random);
for (Direction d : DIRECTIONS) {
if (info.getState(d).isAir()) {
info.setBlockPos(info.getPos().offset(d), outer.with(FurBlock.FACING, d));
info.setBlockPos(info.getPos().relative(d), outer.setValue(FurBlock.FACING, d));
}
}
@ -137,7 +135,7 @@ public class TenaneaFeature extends DefaultFeature {
if (state.getBlock() instanceof LeavesBlock) {
int distance = state.getValue(LeavesBlock.DISTANCE);
if (d < distance) {
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
info.setState(mut, state.setValue(LeavesBlock.DISTANCE, d));
}
}
}
@ -155,11 +153,11 @@ public class TenaneaFeature extends DefaultFeature {
if (state.isAir() || state.is(EndBlocks.TENANEA_OUTER_LEAVES)) {
int count = MHelper.randRange(3, 8, random);
mut.set(bpos);
if (world.getBlockState(mut.up()).is(EndBlocks.TENANEA_LEAVES)) {
if (world.getBlockState(mut.above()).is(EndBlocks.TENANEA_LEAVES)) {
BlocksHelper.setWithoutUpdate(world, mut, top);
for (int i = 1; i < count; i++) {
mut.setY(mut.getY() - 1);
if (world.isAir(mut.below())) {
if (world.isEmptyBlock(mut.below())) {
BlocksHelper.setWithoutUpdate(world, mut, middle);
} else {
break;
@ -173,7 +171,7 @@ public class TenaneaFeature extends DefaultFeature {
static {
REPLACE = (state) -> {
if (state.isIn(EndTags.END_GROUND)) {
if (state.is(EndTags.END_GROUND)) {
return true;
}
if (state.getBlock() == EndBlocks.TENANEA_LEAVES) {

View file

@ -3,19 +3,17 @@ package ru.betterend.world.features.trees;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.Mth;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.collect.Lists;
import com.mojang.math.Vector3f;
import ru.betterend.blocks.UmbrellaTreeClusterBlock;
import ru.betterend.blocks.UmbrellaTreeMembraneBlock;
import ru.betterend.registry.EndBlocks;
@ -42,16 +40,16 @@ public class UmbrellaTreeFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
BlockState wood = EndBlocks.UMBRELLA_TREE.bark.defaultBlockState();
BlockState membrane = EndBlocks.UMBRELLA_TREE_MEMBRANE.defaultBlockState().with(UmbrellaTreeMembraneBlock.COLOR,
1);
BlockState center = EndBlocks.UMBRELLA_TREE_MEMBRANE.defaultBlockState().with(UmbrellaTreeMembraneBlock.COLOR,
0);
BlockState fruit = EndBlocks.UMBRELLA_TREE_CLUSTER.defaultBlockState().with(UmbrellaTreeClusterBlock.NATURAL,
true);
BlockState membrane = EndBlocks.UMBRELLA_TREE_MEMBRANE.defaultBlockState()
.setValue(UmbrellaTreeMembraneBlock.COLOR, 1);
BlockState center = EndBlocks.UMBRELLA_TREE_MEMBRANE.defaultBlockState()
.setValue(UmbrellaTreeMembraneBlock.COLOR, 0);
BlockState fruit = EndBlocks.UMBRELLA_TREE_CLUSTER.defaultBlockState()
.setValue(UmbrellaTreeClusterBlock.NATURAL, true);
float size = MHelper.randRange(10, 20, random);
int count = (int) (size * 0.15F);
@ -123,7 +121,7 @@ public class UmbrellaTreeFeature extends DefaultFeature {
}
int color = MHelper.floor(d / min.radius * 7);
color = Mth.clamp(color, 1, 7);
return info.getState().with(UmbrellaTreeMembraneBlock.COLOR, color);
return info.getState().setValue(UmbrellaTreeMembraneBlock.COLOR, color);
}
return info.getState();
}).fillRecursive(world, pos);
@ -156,7 +154,7 @@ public class UmbrellaTreeFeature extends DefaultFeature {
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
Vector3f last = branch.get(branch.size() - 1);
if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(pos.offset(last.x(), last.y(), last.z())).is(EndTags.GEN_TERRAIN)) {
SplineHelper.fillSplineForce(branch, world, wood, pos, REPLACE);
}
}
@ -186,8 +184,8 @@ public class UmbrellaTreeFeature extends DefaultFeature {
MutableBlockPos mut = new MutableBlockPos().set(px, py, pz);
for (int i = 0; i < 8; i++) {
mut.move(Direction.DOWN);
if (world.isAir(mut)) {
BlockState state = world.getBlockState(mut.up());
if (world.isEmptyBlock(mut)) {
BlockState state = world.getBlockState(mut.above());
if (state.is(EndBlocks.UMBRELLA_TREE_MEMBRANE) && state.getValue(UmbrellaTreeMembraneBlock.COLOR) < 2) {
BlocksHelper.setWithoutUpdate(world, mut, fruit);
}
@ -206,7 +204,7 @@ public class UmbrellaTreeFeature extends DefaultFeature {
SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0));
REPLACE = (state) -> {
if (state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
if (state.is(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
|| state.is(EndBlocks.UMBRELLA_TREE_MEMBRANE)) {
return true;
}

View file

@ -1,19 +1,17 @@
package ru.betterend.world.generator;
import java.util.List;
import net.minecraft.core.Registry;
import net.minecraft.resources.RegistryLookupCodec;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.biome.TheEndBiomeSource;
import net.minecraft.world.level.levelgen.WorldgenRandom;
import net.minecraft.world.level.levelgen.synth.SimplexNoise;
import com.google.common.collect.Lists;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.util.math.noise.SimplexNoiseSampler;
import net.minecraft.core.Registry;
import net.minecraft.util.registry.RegistryLookupCodec;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.biome.source.BiomeSource;
import net.minecraft.world.biome.source.TheEndBiomeSource;
import net.minecraft.world.gen.ChunkRandom;
import ru.betterend.BetterEnd;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBiomes;
@ -23,7 +21,7 @@ import ru.betterend.world.biome.EndBiome;
public class BetterEndBiomeSource extends BiomeSource {
public static final Codec<BetterEndBiomeSource> CODEC = RecordCodecBuilder.create((instance) -> {
return instance.group(RegistryLookupCodec.of(Registry.BIOME_KEY).forGetter((theEndBiomeSource) -> {
return instance.group(RegistryLookupCodec.create(Registry.BIOME_REGISTRY).forGetter((theEndBiomeSource) -> {
return theEndBiomeSource.biomeRegistry;
}), Codec.LONG.fieldOf("seed").stable().forGetter((theEndBiomeSource) -> {
return theEndBiomeSource.seed;
@ -31,7 +29,7 @@ public class BetterEndBiomeSource extends BiomeSource {
});
private static final OpenSimplexNoise SMALL_NOISE = new OpenSimplexNoise(8324);
private final Registry<Biome> biomeRegistry;
private final SimplexNoiseSampler noise;
private final SimplexNoise noise;
private final Biome centerBiome;
private final Biome barrens;
private BiomeMap mapLand;
@ -40,27 +38,27 @@ public class BetterEndBiomeSource extends BiomeSource {
public BetterEndBiomeSource(Registry<Biome> biomeRegistry, long seed) {
super(getBiomes(biomeRegistry));
this.mapLand = new BiomeMap(seed, GeneratorOptions.getBiomeSizeLand(), EndBiomes.LAND_BIOMES);
this.mapVoid = new BiomeMap(seed, GeneratorOptions.getBiomeSizeVoid(), EndBiomes.VOID_BIOMES);
this.centerBiome = biomeRegistry.getOrThrow(Biomes.THE_END);
this.barrens = biomeRegistry.getOrThrow(Biomes.END_BARRENS);
this.biomeRegistry = biomeRegistry;
this.seed = seed;
ChunkRandom chunkRandom = new ChunkRandom(seed);
chunkRandom.consume(17292);
this.noise = new SimplexNoiseSampler(chunkRandom);
WorldgenRandom chunkRandom = new WorldgenRandom(seed);
chunkRandom.consumeCount(17292);
this.noise = new SimplexNoise(chunkRandom);
EndBiomes.mutateRegistry(biomeRegistry);
EndTags.addTerrainTags(biomeRegistry);
FeaturesHelper.addFeatures(biomeRegistry);
}
private static List<Biome> getBiomes(Registry<Biome> biomeRegistry) {
List<Biome> list = Lists.newArrayList();
biomeRegistry.forEach((biome) -> {
if (EndBiomes.hasBiome(biomeRegistry.getId(biome))) {
if (EndBiomes.hasBiome(biomeRegistry.getKey(biome))) {
list.add(biome);
}
});
@ -68,58 +66,58 @@ public class BetterEndBiomeSource extends BiomeSource {
}
@Override
public Biome getBiomeForNoiseGen(int biomeX, int biomeY, int biomeZ) {
public Biome getNoiseBiome(int biomeX, int biomeY, int biomeZ) {
boolean hasVoid = !GeneratorOptions.useNewGenerator() || !GeneratorOptions.noRingVoid();
long i = (long) biomeX * (long) biomeX;
long j = (long) biomeZ * (long) biomeZ;
long dist = i + j;
if (hasVoid) {
if (dist <= 65536L)
return this.centerBiome;
} else if (dist <= 625L) {
dist += noise.sample(i * 0.2, j * 0.2) * 10;
if (dist <= 65536L) return this.centerBiome;
}
else if (dist <= 625L) {
dist += noise.getValue(i * 0.2, j * 0.2) * 10;
if (dist <= 625L) {
return this.centerBiome;
}
}
if (biomeX == 0 && biomeZ == 0) {
mapLand.clearCache();
mapVoid.clearCache();
}
if (GeneratorOptions.useNewGenerator()) {
if (TerrainGenerator.isLand(biomeX, biomeZ)) {
return mapLand.getBiome(biomeX << 2, biomeZ << 2).getActualBiome();
} else {
}
else {
return mapVoid.getBiome(biomeX << 2, biomeZ << 2).getActualBiome();
}
} else {
float height = TheEndBiomeSource.getNoiseAt(noise, (biomeX >> 1) + 1, (biomeZ >> 1) + 1)
+ (float) SMALL_NOISE.eval(biomeX, biomeZ) * 5;
}
else {
float height = TheEndBiomeSource.getHeightValue(noise, (biomeX >> 1) + 1, (biomeZ >> 1) + 1) + (float) SMALL_NOISE.eval(biomeX, biomeZ) * 5;
if (height > -20F && height < -5F) {
return barrens;
}
EndBiome endBiome = height < -10F ? mapVoid.getBiome(biomeX << 2, biomeZ << 2)
: mapLand.getBiome(biomeX << 2, biomeZ << 2);
EndBiome endBiome = height < -10F ? mapVoid.getBiome(biomeX << 2, biomeZ << 2) : mapLand.getBiome(biomeX << 2, biomeZ << 2);
return endBiome.getActualBiome();
}
}
public Biome getLandBiome(int biomeX, int biomeY, int biomeZ) {
boolean hasVoid = !GeneratorOptions.useNewGenerator() || !GeneratorOptions.noRingVoid();
long i = (long) biomeX * (long) biomeX;
long j = (long) biomeZ * (long) biomeZ;
long dist = i + j;
if (hasVoid) {
if (dist <= 65536L)
return this.centerBiome;
} else if (dist <= 625L) {
dist += noise.sample(i * 0.2, j * 0.2) * 10;
if (dist <= 65536L) return this.centerBiome;
}
else if (dist <= 625L) {
dist += noise.getValue(i * 0.2, j * 0.2) * 10;
if (dist <= 625L) {
return this.centerBiome;
}
@ -133,7 +131,7 @@ public class BetterEndBiomeSource extends BiomeSource {
}
@Override
protected Codec<? extends BiomeSource> getCodec() {
protected Codec<? extends BiomeSource> codec() {
return CODEC;
}

View file

@ -1,17 +1,15 @@
package ru.betterend.world.generator;
import java.util.Map;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.levelgen.WorldgenRandom;
import com.google.common.collect.Maps;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.gen.ChunkRandom;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.util.MHelper;
import ru.betterend.world.biome.EndBiome;
public class BiomeMap {
private static final ChunkRandom RANDOM = new ChunkRandom();
private static final WorldgenRandom RANDOM = new WorldgenRandom();
private final Map<ChunkPos, BiomeChunk> maps = Maps.newHashMap();
private final int size;
@ -70,7 +68,7 @@ public class BiomeMap {
ChunkPos cpos = new ChunkPos(MHelper.floor(x / BiomeChunk.WIDTH), MHelper.floor(z / BiomeChunk.WIDTH));
BiomeChunk chunk = maps.get(cpos);
if (chunk == null) {
RANDOM.setTerrainSeed(cpos.x, cpos.z);
RANDOM.setBaseChunkSeed(cpos.x, cpos.z);
chunk = new BiomeChunk(this, RANDOM, picker);
maps.put(cpos, chunk);
}

View file

@ -3,11 +3,9 @@ package ru.betterend.world.generator;
import java.util.List;
import java.util.Random;
import java.util.Set;
import net.minecraft.resources.ResourceLocation;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import net.minecraft.resources.ResourceLocation;
import ru.betterend.world.biome.EndBiome;
public class BiomePicker {
@ -17,38 +15,38 @@ public class BiomePicker {
private float maxChance = 0;
private int biomeCount = 0;
private WeighTree tree;
public void addBiome(EndBiome biome) {
maxChance = biome.mutateGenChance(maxChance);
immutableIDs.add(biome.getID());
maxChanceUnmutable = maxChance;
biomes.add(biome);
biomeCount++;
biomeCount ++;
}
public void addBiomeMutable(EndBiome biome) {
biomes.add(biome);
}
public void clearMutables() {
maxChance = maxChanceUnmutable;
for (int i = biomes.size() - 1; i >= biomeCount; i--) {
biomes.remove(i);
}
}
public EndBiome getBiome(Random random) {
return biomes.isEmpty() ? null : tree.getBiome(random.nextFloat() * maxChance);
}
public List<EndBiome> getBiomes() {
return biomes;
}
public boolean containsImmutable(ResourceLocation id) {
return immutableIDs.contains(id);
}
public void removeMutableBiome(ResourceLocation id) {
for (int i = biomeCount; i < biomes.size(); i++) {
EndBiome biome = biomes.get(i);
@ -58,7 +56,7 @@ public class BiomePicker {
}
}
}
public void rebuild() {
if (biomes.isEmpty()) {
return;

View file

@ -23,10 +23,10 @@ public class GeneratorOptions {
public static LayerOptions smallOptions;
private static boolean changeSpawn;
private static BlockPos spawn;
private static BlockPos portal = BlockPos.ORIGIN;
private static BlockPos portal = BlockPos.ZERO;
private static boolean replacePortal;
private static boolean replacePillars;
public static void init() {
biomeSizeLand = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeLand", 256);
biomeSizeVoid = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeVoid", 256);
@ -35,23 +35,21 @@ public class GeneratorOptions {
hasDragonFights = Configs.GENERATOR_CONFIG.getBooleanRoot("hasDragonFights", true);
swapOverworldToEnd = Configs.GENERATOR_CONFIG.getBooleanRoot("swapOverworldToEnd", false);
changeChorusPlant = Configs.GENERATOR_CONFIG.getBoolean("chorusPlant", "changeChorusPlant", true);
removeChorusFromVanillaBiomes = Configs.GENERATOR_CONFIG.getBoolean("chorusPlant",
"removeChorusFromVanillaBiomes", true);
removeChorusFromVanillaBiomes = Configs.GENERATOR_CONFIG.getBoolean("chorusPlant", "removeChorusFromVanillaBiomes", true);
newGenerator = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "useNewGenerator", true);
noRingVoid = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "noRingVoid", false);
generateCentralIsland = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "generateCentralIsland", true);
endCityFailChance = Configs.GENERATOR_CONFIG.getInt("customGenerator", "endCityFailChance", 5);
generateObsidianPlatform = Configs.GENERATOR_CONFIG.getBooleanRoot("generateObsidianPlatform", true);
bigOptions = new LayerOptions("customGenerator.layers.bigIslands", Configs.GENERATOR_CONFIG, 300, 200, 70, 10,
false);
mediumOptions = new LayerOptions("customGenerator.layers.mediumIslands", Configs.GENERATOR_CONFIG, 150, 100, 70,
20, true);
smallOptions = new LayerOptions("customGenerator.layers.smallIslands", Configs.GENERATOR_CONFIG, 60, 50, 70, 30,
false);
bigOptions = new LayerOptions("customGenerator.layers.bigIslands", Configs.GENERATOR_CONFIG, 300, 200, 70, 10, false);
mediumOptions = new LayerOptions("customGenerator.layers.mediumIslands", Configs.GENERATOR_CONFIG, 150, 100, 70, 20, true);
smallOptions = new LayerOptions("customGenerator.layers.smallIslands", Configs.GENERATOR_CONFIG, 60, 50, 70, 30, false);
changeSpawn = Configs.GENERATOR_CONFIG.getBoolean("spawn", "changeSpawn", false);
spawn = new BlockPos(Configs.GENERATOR_CONFIG.getInt("spawn.point", "x", 20),
Configs.GENERATOR_CONFIG.getInt("spawn.point", "y", 65),
Configs.GENERATOR_CONFIG.getInt("spawn.point", "z", 0));
spawn = new BlockPos(
Configs.GENERATOR_CONFIG.getInt("spawn.point", "x", 20),
Configs.GENERATOR_CONFIG.getInt("spawn.point", "y", 65),
Configs.GENERATOR_CONFIG.getInt("spawn.point", "z", 0)
);
replacePortal = Configs.GENERATOR_CONFIG.getBoolean("portal", "customEndPortal", true);
replacePillars = Configs.GENERATOR_CONFIG.getBoolean("spikes", "customObsidianSpikes", true);
}
@ -59,7 +57,7 @@ public class GeneratorOptions {
public static int getBiomeSizeLand() {
return Mth.clamp(biomeSizeLand, 1, 8192);
}
public static int getBiomeSizeVoid() {
return Mth.clamp(biomeSizeVoid, 1, 8192);
}
@ -67,15 +65,15 @@ public class GeneratorOptions {
public static boolean hasPortal() {
return hasPortal;
}
public static boolean hasPillars() {
return hasPillars;
}
public static boolean hasDragonFights() {
return hasDragonFights;
}
public static boolean swapOverworldToEnd() {
return swapOverworldToEnd;
}
@ -87,23 +85,23 @@ public class GeneratorOptions {
public static boolean removeChorusFromVanillaBiomes() {
return removeChorusFromVanillaBiomes;
}
public static boolean noRingVoid() {
return noRingVoid;
}
public static boolean useNewGenerator() {
return newGenerator;
}
public static boolean hasCentralIsland() {
return generateCentralIsland;
}
public static boolean generateObsidianPlatform() {
return generateObsidianPlatform;
}
public static int getEndCityFailChance() {
return endCityFailChance;
}
@ -123,11 +121,11 @@ public class GeneratorOptions {
public static void setPortalPos(BlockPos portal) {
GeneratorOptions.portal = portal;
}
public static boolean replacePortal() {
return replacePortal;
}
public static boolean replacePillars() {
return replacePillars;
}

View file

@ -4,11 +4,9 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import net.minecraft.core.BlockPos;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.minecraft.core.BlockPos;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.util.MHelper;
import ru.betterend.util.sdf.SDF;
@ -22,7 +20,7 @@ public class IslandLayer {
private static final Random RANDOM = new Random();
private final SDFRadialNoiseMap noise;
private final SDF island;
private final List<BlockPos> positions = new ArrayList<BlockPos>(9);
private final Map<BlockPos, SDF> islands = Maps.newHashMap();
private final OpenSimplexNoise density;
@ -30,34 +28,33 @@ public class IslandLayer {
private int lastX = Integer.MIN_VALUE;
private int lastZ = Integer.MIN_VALUE;
private final LayerOptions options;
public IslandLayer(int seed, LayerOptions options) {
this.density = new OpenSimplexNoise(seed);
this.options = options;
this.seed = seed;
SDF cone1 = makeCone(0, 0.4F, 0.2F, -0.3F);
SDF cone2 = makeCone(0.4F, 0.5F, 0.1F, -0.1F);
SDF cone3 = makeCone(0.5F, 0.45F, 0.03F, 0.0F);
SDF cone4 = makeCone(0.45F, 0, 0.02F, 0.03F);
SDF coneBottom = new SDFSmoothUnion().setRadius(0.02F).setSourceA(cone1).setSourceB(cone2);
SDF coneTop = new SDFSmoothUnion().setRadius(0.02F).setSourceA(cone3).setSourceB(cone4);
noise = (SDFRadialNoiseMap) new SDFRadialNoiseMap().setSeed(seed).setRadius(0.5F).setIntensity(0.2F)
.setSource(coneTop);
noise = (SDFRadialNoiseMap) new SDFRadialNoiseMap().setSeed(seed).setRadius(0.5F).setIntensity(0.2F).setSource(coneTop);
island = new SDFSmoothUnion().setRadius(0.01F).setSourceA(noise).setSourceB(coneBottom);
}
private int getSeed(int x, int z) {
int h = seed + x * 374761393 + z * 668265263;
h = (h ^ (h >> 13)) * 1274126177;
return h ^ (h >> 16);
}
public void updatePositions(double x, double z) {
int ix = MHelper.floor(x / options.distance);
int iz = MHelper.floor(z / options.distance);
if (lastX != ix || lastZ != iz) {
lastX = ix;
lastZ = iz;
@ -80,7 +77,7 @@ public class IslandLayer {
}
}
}
if (GeneratorOptions.hasCentralIsland() && ix < 4 && iz < 4 && ix > -4 && iz > -4) {
List<BlockPos> remove = Lists.newArrayList();
positions.forEach((pos) -> {
@ -95,13 +92,14 @@ public class IslandLayer {
}
}
}
private SDF getIsland(BlockPos pos) {
SDF island = islands.get(pos);
if (island == null) {
if (pos.getX() == 0 && pos.getZ() == 0) {
island = new SDFScale().setScale(1.3F).setSource(this.island);
} else {
}
else {
RANDOM.setSeed(getSeed(pos.getX(), pos.getZ()));
island = new SDFScale().setScale(RANDOM.nextFloat() + 0.5F).setSource(this.island);
}
@ -110,74 +108,78 @@ public class IslandLayer {
noise.setOffset(pos.getX(), pos.getZ());
return island;
}
private float getRelativeDistance(SDF sdf, BlockPos center, double px, double py, double pz) {
float x = (float) (px - center.getX()) / options.scale;
float y = (float) (py - center.getY()) / options.scale;
float z = (float) (pz - center.getZ()) / options.scale;
return sdf.getDistance(x, y, z);
}
private float calculateSDF(double x, double y, double z) {
float distance = 10;
for (BlockPos pos : positions) {
for (BlockPos pos: positions) {
SDF island = getIsland(pos);
float dist = getRelativeDistance(island, pos, x, y, z);
distance = MHelper.min(distance, dist);
}
return distance;
}
public float getDensity(double x, double y, double z) {
return -calculateSDF(x, y, z);
}
public float getDensity(double x, double y, double z, float height) {
noise.setIntensity(height);
noise.setRadius(0.5F / (1 + height));
return -calculateSDF(x, y, z);
}
public void clearCache() {
if (islands.size() > 128) {
islands.clear();
}
}
private static SDF makeCone(float radiusBottom, float radiusTop, float height, float minY) {
float hh = height * 0.5F;
SDF sdf = new SDFCappedCone().setHeight(hh).setRadius1(radiusBottom).setRadius2(radiusTop);
return new SDFTranslate().setTranslate(0, minY + hh, 0).setSource(sdf);
}
/*
* private static NativeImage loadMap(String path) { InputStream stream =
* IslandLayer.class.getResourceAsStream(path); if (stream != null) { try {
* NativeImage map = NativeImage.read(stream); stream.close(); return map; }
* catch (IOException e) { BetterEnd.LOGGER.warning(e.getMessage()); } } return
* null; }
*/
/*
* static { NativeImage map = loadMap("/assets/" + BetterEnd.MOD_ID +
* "/textures/heightmaps/mountain_1.png");
*
* SDF cone1 = makeCone(0, 0.4F, 0.2F, -0.3F); SDF cone2 = makeCone(0.4F, 0.5F,
* 0.1F, -0.1F); SDF cone3 = makeCone(0.5F, 0.45F, 0.03F, 0.0F); SDF cone4 =
* makeCone(0.45F, 0, 0.02F, 0.03F);
*
* SDF coneBottom = new
* SDFSmoothUnion().setRadius(0.02F).setSourceA(cone1).setSourceB(cone2); SDF
* coneTop = new
* SDFSmoothUnion().setRadius(0.02F).setSourceA(cone3).setSourceB(cone4);
*
* SDF map1 = new
* SDFHeightmap().setMap(map).setIntensity(0.3F).setSource(coneTop); NOISE =
* (SDFRadialNoiseMap) new SDFRadialNoiseMap().setSource(coneTop);
*
* ISLAND = new SDF[] { new
* SDFSmoothUnion().setRadius(0.01F).setSourceA(coneTop).setSourceB(coneBottom),
* new SDFSmoothUnion().setRadius(0.01F).setSourceA(map1).setSourceB(coneBottom)
* }; }
*/
/*private static NativeImage loadMap(String path) {
InputStream stream = IslandLayer.class.getResourceAsStream(path);
if (stream != null) {
try {
NativeImage map = NativeImage.read(stream);
stream.close();
return map;
}
catch (IOException e) {
BetterEnd.LOGGER.warning(e.getMessage());
}
}
return null;
}*/
/*static {
NativeImage map = loadMap("/assets/" + BetterEnd.MOD_ID + "/textures/heightmaps/mountain_1.png");
SDF cone1 = makeCone(0, 0.4F, 0.2F, -0.3F);
SDF cone2 = makeCone(0.4F, 0.5F, 0.1F, -0.1F);
SDF cone3 = makeCone(0.5F, 0.45F, 0.03F, 0.0F);
SDF cone4 = makeCone(0.45F, 0, 0.02F, 0.03F);
SDF coneBottom = new SDFSmoothUnion().setRadius(0.02F).setSourceA(cone1).setSourceB(cone2);
SDF coneTop = new SDFSmoothUnion().setRadius(0.02F).setSourceA(cone3).setSourceB(cone4);
SDF map1 = new SDFHeightmap().setMap(map).setIntensity(0.3F).setSource(coneTop);
NOISE = (SDFRadialNoiseMap) new SDFRadialNoiseMap().setSource(coneTop);
ISLAND = new SDF[] {
new SDFSmoothUnion().setRadius(0.01F).setSourceA(coneTop).setSourceB(coneBottom),
new SDFSmoothUnion().setRadius(0.01F).setSourceA(map1).setSourceB(coneBottom)
};
}*/
}

View file

@ -13,9 +13,8 @@ public class LayerOptions {
public final int maxY;
public final long centerDist;
public final boolean hasCentralIsland;
public LayerOptions(String name, PathConfig config, float distance, float scale, int center, int heightVariation,
boolean hasCentral) {
public LayerOptions(String name, PathConfig config, float distance, float scale, int center, int heightVariation, boolean hasCentral) {
this.distance = clampDistance(config.getFloat(name, "distance[1-8192]", distance));
this.scale = clampScale(config.getFloat(name, "scale[0.1-1024]", scale));
this.center = clampCenter(config.getInt(name, "averageHeight[0-255]", center));
@ -26,23 +25,23 @@ public class LayerOptions {
this.centerDist = Mth.floor(1000 / this.distance);
this.hasCentralIsland = config.getBoolean(name, "hasCentralIsland", hasCentral);
}
private float clampDistance(float value) {
return Mth.clamp(value, 1, 8192);
}
private float clampScale(float value) {
return Mth.clamp(value, 0.1F, 1024);
}
private float clampCoverage(float value) {
return 0.9999F - Mth.clamp(value, 0, 1) * 2;
}
private int clampCenter(int value) {
return Mth.clamp(value, 0, 255);
}
private int clampVariation(int value) {
return Mth.clamp(value, 0, 255);
}

View file

@ -4,12 +4,10 @@ import java.awt.Point;
import java.util.List;
import java.util.Random;
import java.util.concurrent.locks.ReentrantLock;
import com.google.common.collect.Lists;
import net.minecraft.util.Mth;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.biome.source.BiomeSource;
import net.minecraft.world.level.biome.BiomeSource;
import com.google.common.collect.Lists;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.util.MHelper;
@ -19,18 +17,17 @@ public class TerrainGenerator {
private static final double SCALE_Y = 4.0;
private static final float[] COEF;
private static final Point[] OFFS;
private static IslandLayer largeIslands;
private static IslandLayer mediumIslands;
private static IslandLayer smallIslands;
private static OpenSimplexNoise noise1;
private static OpenSimplexNoise noise2;
/*
* public static boolean canGenerate(int x, int z) { return
* GeneratorOptions.noRingVoid() || (long) x + (long) z > CENTER; }
*/
/*public static boolean canGenerate(int x, int z) {
return GeneratorOptions.noRingVoid() || (long) x + (long) z > CENTER;
}*/
public static void initNoise(long seed) {
Random random = new Random(seed);
largeIslands = new IslandLayer(random.nextInt(), GeneratorOptions.bigOptions);
@ -39,27 +36,25 @@ public class TerrainGenerator {
noise1 = new OpenSimplexNoise(random.nextInt());
noise2 = new OpenSimplexNoise(random.nextInt());
}
public static void fillTerrainDensity(double[] buffer, int x, int z, BiomeSource biomeSource) {
LOCKER.lock();
largeIslands.clearCache();
mediumIslands.clearCache();
smallIslands.clearCache();
double distortion1 = noise1.eval(x * 0.1, z * 0.1) * 20 + noise2.eval(x * 0.2, z * 0.2) * 10
+ noise1.eval(x * 0.4, z * 0.4) * 5;
double distortion2 = noise2.eval(x * 0.1, z * 0.1) * 20 + noise1.eval(x * 0.2, z * 0.2) * 10
+ noise2.eval(x * 0.4, z * 0.4) * 5;
double distortion1 = noise1.eval(x * 0.1, z * 0.1) * 20 + noise2.eval(x * 0.2, z * 0.2) * 10 + noise1.eval(x * 0.4, z * 0.4) * 5;
double distortion2 = noise2.eval(x * 0.1, z * 0.1) * 20 + noise1.eval(x * 0.2, z * 0.2) * 10 + noise2.eval(x * 0.4, z * 0.4) * 5;
double px = (double) x * SCALE_XZ + distortion1;
double pz = (double) z * SCALE_XZ + distortion2;
largeIslands.updatePositions(px, pz);
mediumIslands.updatePositions(px, pz);
smallIslands.updatePositions(px, pz);
float height = getAverageDepth(biomeSource, x << 1, z << 1) * 0.5F;
for (int y = 0; y < buffer.length; y++) {
double py = (double) y * SCALE_Y;
float dist = largeIslands.getDensity(px, py, pz, height);
@ -72,10 +67,10 @@ public class TerrainGenerator {
}
buffer[y] = dist;
}
LOCKER.unlock();
}
private static float getAverageDepth(BiomeSource biomeSource, int x, int z) {
if (getBiome(biomeSource, x, z).getDepth() < 0.1F) {
return 0F;
@ -88,37 +83,34 @@ public class TerrainGenerator {
}
return depth;
}
private static Biome getBiome(BiomeSource biomeSource, int x, int z) {
if (biomeSource instanceof BetterEndBiomeSource) {
return ((BetterEndBiomeSource) biomeSource).getLandBiome(x, 0, z);
}
return biomeSource.getBiomeForNoiseGen(x, 0, z);
return biomeSource.getNoiseBiome(x, 0, z);
}
/**
* Check if this is land
*
* @param x - biome pos x
* @param z - biome pos z
*/
public static boolean isLand(int x, int z) {
LOCKER.lock();
double px = (x >> 1) + 0.5;
double pz = (z >> 1) + 0.5;
double distortion1 = noise1.eval(px * 0.1, pz * 0.1) * 20 + noise2.eval(px * 0.2, pz * 0.2) * 10
+ noise1.eval(px * 0.4, pz * 0.4) * 5;
double distortion2 = noise2.eval(px * 0.1, pz * 0.1) * 20 + noise1.eval(px * 0.2, pz * 0.2) * 10
+ noise2.eval(px * 0.4, pz * 0.4) * 5;
double distortion1 = noise1.eval(px * 0.1, pz * 0.1) * 20 + noise2.eval(px * 0.2, pz * 0.2) * 10 + noise1.eval(px * 0.4, pz * 0.4) * 5;
double distortion2 = noise2.eval(px * 0.1, pz * 0.1) * 20 + noise1.eval(px * 0.2, pz * 0.2) * 10 + noise2.eval(px * 0.4, pz * 0.4) * 5;
px = px * SCALE_XZ + distortion1;
pz = pz * SCALE_XZ + distortion2;
largeIslands.updatePositions(px, pz);
mediumIslands.updatePositions(px, pz);
smallIslands.updatePositions(px, pz);
for (int y = 0; y < 32; y++) {
double py = (double) y * SCALE_Y;
float dist = largeIslands.getDensity(px, py, pz);
@ -134,34 +126,31 @@ public class TerrainGenerator {
return true;
}
}
LOCKER.unlock();
return false;
}
/**
* Get something like height
*
* @param x - block pos x
* @param z - block pos z
*/
public static int getHeight(int x, int z) {
LOCKER.lock();
double px = (double) x / 8.0;
double pz = (double) z / 8.0;
double distortion1 = noise1.eval(px * 0.1, pz * 0.1) * 20 + noise2.eval(px * 0.2, pz * 0.2) * 10
+ noise1.eval(px * 0.4, pz * 0.4) * 5;
double distortion2 = noise2.eval(px * 0.1, pz * 0.1) * 20 + noise1.eval(px * 0.2, pz * 0.2) * 10
+ noise2.eval(px * 0.4, pz * 0.4) * 5;
double distortion1 = noise1.eval(px * 0.1, pz * 0.1) * 20 + noise2.eval(px * 0.2, pz * 0.2) * 10 + noise1.eval(px * 0.4, pz * 0.4) * 5;
double distortion2 = noise2.eval(px * 0.1, pz * 0.1) * 20 + noise1.eval(px * 0.2, pz * 0.2) * 10 + noise2.eval(px * 0.4, pz * 0.4) * 5;
px = (double) x * SCALE_XZ + distortion1;
pz = (double) z * SCALE_XZ + distortion2;
largeIslands.updatePositions(px, pz);
mediumIslands.updatePositions(px, pz);
smallIslands.updatePositions(px, pz);
for (int y = 32; y >= 0; y--) {
double py = (double) y * SCALE_Y;
float dist = largeIslands.getDensity(px, py, pz);
@ -177,11 +166,11 @@ public class TerrainGenerator {
return Mth.floor(Mth.clamp(y + dist, y, y + 1) * SCALE_Y);
}
}
LOCKER.unlock();
return 0;
}
static {
float sum = 0;
List<Float> coef = Lists.newArrayList();
@ -192,7 +181,7 @@ public class TerrainGenerator {
if (dist <= 1) {
sum += dist;
coef.add(dist);
pos.offset(new Point(x, z));
pos.add(new Point(x, z));
}
}
}

View file

@ -1,28 +1,24 @@
package ru.betterend.world.processors;
import net.minecraft.structure.Structure.StructureBlockInfo;
import net.minecraft.structure.StructurePlacementData;
import net.minecraft.structure.processor.StructureProcessor;
import net.minecraft.structure.processor.StructureProcessorType;
import net.minecraft.core.BlockPos;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.MHelper;
public class DestructionStructureProcessor extends StructureProcessor {
private int chance = 4;
public void setChance(int chance) {
this.chance = chance;
}
@Override
public StructureBlockInfo process(WorldView worldView, BlockPos pos, BlockPos blockPos,
StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2,
StructurePlacementData structurePlacementData) {
if (!structureBlockInfo2.state.is(EndBlocks.ETERNAL_PEDESTAL)
&& !structureBlockInfo2.state.is(EndBlocks.FLAVOLITE_RUNED_ETERNAL)
&& MHelper.RANDOM.nextInt(chance) == 0) {
public StructureBlockInfo processBlock(LevelReader worldView, BlockPos pos, BlockPos blockPos, StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, StructurePlaceSettings structurePlacementData) {
if (!structureBlockInfo2.state.is(EndBlocks.ETERNAL_PEDESTAL) && !structureBlockInfo2.state.is(EndBlocks.FLAVOLITE_RUNED_ETERNAL) && MHelper.RANDOM.nextInt(chance) == 0) {
return null;
}
return structureBlockInfo2;

View file

@ -1,24 +1,21 @@
package ru.betterend.world.processors;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.structure.Structure.StructureBlockInfo;
import net.minecraft.structure.StructurePlacementData;
import net.minecraft.structure.processor.StructureProcessor;
import net.minecraft.structure.processor.StructureProcessorType;
import net.minecraft.core.BlockPos;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
public class TerrainStructureProcessor extends StructureProcessor {
@Override
public StructureBlockInfo process(WorldView worldView, BlockPos pos, BlockPos blockPos,
StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2,
StructurePlacementData structurePlacementData) {
public StructureBlockInfo processBlock(LevelReader worldView, BlockPos pos, BlockPos blockPos, StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, StructurePlaceSettings structurePlacementData) {
BlockPos bpos = structureBlockInfo2.pos;
if (structureBlockInfo2.state.is(Blocks.END_STONE) && worldView.isAir(bpos.up())) {
BlockState top = worldView.getBiome(structureBlockInfo2.pos).getGenerationSettings()
.getSurfaceBuilderConfig().getTopMaterial();
return new StructureBlockInfo(bpos, top, structureBlockInfo2.tag);
if (structureBlockInfo2.state.is(Blocks.END_STONE) && worldView.isEmptyBlock(bpos.above())) {
BlockState top = worldView.getBiome(structureBlockInfo2.pos).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
return new StructureBlockInfo(bpos, top, structureBlockInfo2.nbt);
}
return structureBlockInfo2;
}

Some files were not shown because too many files have changed in this diff Show more