Painted Mountains
This commit is contained in:
parent
74403c297a
commit
d0974ab646
13 changed files with 311 additions and 5 deletions
|
@ -8,7 +8,7 @@
|
|||
loader_version = 0.10.3+build.211
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 0.4.1-alpha
|
||||
mod_version = 0.5.0-alpha
|
||||
maven_group = ru.betterend
|
||||
archives_base_name = better-end
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ import net.minecraft.state.property.BooleanProperty;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.explosion.Explosion;
|
||||
|
||||
import ru.betterend.blocks.basis.BlockSlab;
|
||||
import ru.betterend.registry.BlockRegistry;
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import ru.betterend.world.biome.BiomeCrystalMountains;
|
|||
import ru.betterend.world.biome.BiomeDustWastelands;
|
||||
import ru.betterend.world.biome.BiomeFoggyMushroomland;
|
||||
import ru.betterend.world.biome.BiomeMegalake;
|
||||
import ru.betterend.world.biome.BiomePaintedMountains;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
import ru.betterend.world.generator.BiomePicker;
|
||||
import ru.betterend.world.generator.BiomeType;
|
||||
|
@ -51,6 +52,7 @@ public class BiomeRegistry {
|
|||
public static final EndBiome DUST_WASTELANDS = registerBiome(new BiomeDustWastelands(), BiomeType.LAND);
|
||||
public static final EndBiome MEGALAKE = registerBiome(new BiomeMegalake(), BiomeType.LAND);
|
||||
public static final EndBiome CRYSTAL_MOUNTAINS = registerBiome(new BiomeCrystalMountains(), BiomeType.LAND);
|
||||
public static final EndBiome PAINTED_MOUNTAINS = registerSubBiome(new BiomePaintedMountains(), DUST_WASTELANDS);
|
||||
|
||||
public static void register() {}
|
||||
|
||||
|
@ -100,7 +102,8 @@ public class BiomeRegistry {
|
|||
return endBiome;
|
||||
}
|
||||
|
||||
public static EndBiome registerSubBiome(EndBiome biome, EndBiome parent, float genChance) {
|
||||
public static EndBiome registerSubBiome(EndBiome biome, EndBiome parent) {
|
||||
registerBiomeDirect(biome);
|
||||
parent.addSubBiome(biome);
|
||||
makeLink(biome);
|
||||
return biome;
|
||||
|
|
|
@ -10,6 +10,7 @@ public class SoundRegistry {
|
|||
public static final SoundEvent MUSIC_CHORUS_FOREST = register("music", "chorus_forest");
|
||||
public static final SoundEvent MUSIC_CRYSTAL_MOUNTAINS = register("music", "crystal_mountains");
|
||||
public static final SoundEvent MUSIC_MEGALAKE = register("music", "megalake");
|
||||
public static final SoundEvent DUST_WASTELANDS = register("music", "dust_wastelands");
|
||||
|
||||
// Ambient
|
||||
public static final SoundEvent AMBIENT_FOGGY_MUSHROOMLAND = register("ambient", "foggy_mushroomland");
|
||||
|
|
|
@ -14,9 +14,11 @@ import ru.betterend.world.structures.EndStructureFeature;
|
|||
import ru.betterend.world.structures.features.StructureGiantMossyGlowshroom;
|
||||
import ru.betterend.world.structures.features.StructureMegaLake;
|
||||
import ru.betterend.world.structures.features.StructureMountain;
|
||||
import ru.betterend.world.structures.features.StructurePaintedMountain;
|
||||
import ru.betterend.world.structures.piece.CavePiece;
|
||||
import ru.betterend.world.structures.piece.LakePiece;
|
||||
import ru.betterend.world.structures.piece.MountainPiece;
|
||||
import ru.betterend.world.structures.piece.PaintedMountainPiece;
|
||||
import ru.betterend.world.structures.piece.VoxelPiece;
|
||||
|
||||
public class StructureRegistry {
|
||||
|
@ -24,10 +26,12 @@ public class StructureRegistry {
|
|||
public static final StructurePieceType MOUNTAIN_PIECE = register("mountain_piece", MountainPiece::new);
|
||||
public static final StructurePieceType CAVE_PIECE = register("cave_piece", CavePiece::new);
|
||||
public static final StructurePieceType LAKE_PIECE = register("lake_piece", LakePiece::new);
|
||||
public static final StructurePieceType PAINTED_MOUNTAIN_PIECE = register("painted_mountain_piece", PaintedMountainPiece::new);
|
||||
|
||||
public static final EndStructureFeature GIANT_MOSSY_GLOWSHROOM = new EndStructureFeature("giant_mossy_glowshroom", new StructureGiantMossyGlowshroom(), Feature.SURFACE_STRUCTURES, 16, 8);
|
||||
public static final EndStructureFeature MEGALAKE = new EndStructureFeature("megalake", new StructureMegaLake(), Feature.RAW_GENERATION, 4, 1);
|
||||
public static final EndStructureFeature MOUNTAIN = new EndStructureFeature("mountain", new StructureMountain(), Feature.RAW_GENERATION, 3, 2);
|
||||
public static final EndStructureFeature PAINTED_MOUNTAIN = new EndStructureFeature("painted_mountain", new StructurePaintedMountain(), Feature.RAW_GENERATION, 3, 2);
|
||||
|
||||
public static void register() {}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import net.minecraft.entity.EntityType;
|
|||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.world.gen.feature.ConfiguredStructureFeatures;
|
||||
import ru.betterend.registry.BlockRegistry;
|
||||
import ru.betterend.registry.SoundRegistry;
|
||||
|
||||
public class BiomeDustWastelands extends EndBiome {
|
||||
public BiomeDustWastelands() {
|
||||
|
@ -15,7 +16,7 @@ public class BiomeDustWastelands extends EndBiome {
|
|||
.setSurface(BlockRegistry.ENDSTONE_DUST)
|
||||
.setParticles(ParticleTypes.WHITE_ASH, 0.01F)
|
||||
//.setLoop(SoundRegistry.AMBIENT_FOGGY_MUSHROOMLAND)
|
||||
//.setMusic(SoundRegistry.MUSIC_FOGGY_MUSHROOMLAND)
|
||||
.setMusic(SoundRegistry.DUST_WASTELANDS)
|
||||
.addStructureFeature(ConfiguredStructureFeatures.END_CITY)
|
||||
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package ru.betterend.world.biome;
|
||||
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import ru.betterend.registry.BlockRegistry;
|
||||
import ru.betterend.registry.SoundRegistry;
|
||||
import ru.betterend.registry.StructureRegistry;
|
||||
|
||||
public class BiomePaintedMountains extends EndBiome {
|
||||
public BiomePaintedMountains() {
|
||||
super(new BiomeDefinition("painted_mountains")
|
||||
.setFogColor(226, 239, 168)
|
||||
.setFogDensity(2)
|
||||
.setWaterColor(192, 180, 131)
|
||||
.setWaterFogColor(192, 180, 131)
|
||||
.setMusic(SoundRegistry.DUST_WASTELANDS)
|
||||
.setSurface(BlockRegistry.ENDSTONE_DUST)
|
||||
.setParticles(ParticleTypes.WHITE_ASH, 0.01F)
|
||||
.addStructureFeature(StructureRegistry.PAINTED_MOUNTAIN)
|
||||
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package ru.betterend.world.structures.features;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.structure.StructureManager;
|
||||
import net.minecraft.structure.StructureStart;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||
import net.minecraft.world.Heightmap.Type;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
import ru.betterend.registry.BlockRegistry;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.world.structures.piece.PaintedMountainPiece;
|
||||
|
||||
public class StructurePaintedMountain extends StructureFeatureBase {
|
||||
private static final BlockState[] VARIANTS;
|
||||
|
||||
@Override
|
||||
public StructureFeature.StructureStartFactory<DefaultFeatureConfig> getStructureStartFactory() {
|
||||
return SDFStructureStart::new;
|
||||
}
|
||||
|
||||
public static class SDFStructureStart extends StructureStart<DefaultFeatureConfig> {
|
||||
public SDFStructureStart(StructureFeature<DefaultFeatureConfig> feature, int chunkX, int chunkZ, BlockBox box, int references, long seed) {
|
||||
super(feature, chunkX, chunkZ, box, references, seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, StructureManager manager, int chunkX, int chunkZ, Biome biome, DefaultFeatureConfig config) {
|
||||
int x = (chunkX << 4) | MHelper.randRange(4, 12, random);
|
||||
int z = (chunkZ << 4) | MHelper.randRange(4, 12, random);
|
||||
int y = chunkGenerator.getHeight(x, z, Type.WORLD_SURFACE_WG);
|
||||
if (y > 50) {
|
||||
float radius = MHelper.randRange(50, 100, random);
|
||||
float height = radius * MHelper.randRange(0.2F, 0.4F, random);
|
||||
int count = MHelper.floor(height * MHelper.randRange(0.1F, 0.35F, random) + 1);
|
||||
BlockState[] slises = new BlockState[count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
slises[i] = VARIANTS[random.nextInt(VARIANTS.length)];
|
||||
}
|
||||
this.children.add(new PaintedMountainPiece(new BlockPos(x, y, z), radius, height, random.nextInt(), biome, slises ));
|
||||
}
|
||||
this.setBoundingBoxFromChildren();
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
VARIANTS = new BlockState[] {
|
||||
Blocks.END_STONE.getDefaultState(),
|
||||
BlockRegistry.FLAVOLITE.stone.getDefaultState(),
|
||||
BlockRegistry.VIOLECITE.stone.getDefaultState(),
|
||||
};
|
||||
}
|
||||
}
|
|
@ -99,7 +99,10 @@ public class LakePiece extends BasePiece {
|
|||
lerp = 1;
|
||||
}
|
||||
minY = MathHelper.lerp(lerp, maxY - minY, 56 - minY);
|
||||
//System.out.println(minY + " " + maxY);
|
||||
pos.setY(maxY);
|
||||
while (chunk.getBlockState(pos).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||
pos.setY(maxY ++);
|
||||
}
|
||||
for (int y = maxY; y >= minY; y--) {
|
||||
pos.setY(y - 1);
|
||||
BlockState state = chunk.getBlockState(pos);
|
||||
|
|
|
@ -0,0 +1,200 @@
|
|||
package ru.betterend.world.structures.piece;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtHelper;
|
||||
import net.minecraft.structure.StructureManager;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.Heightmap.Type;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.BiomeRegistry;
|
||||
import ru.betterend.registry.BlockTagRegistry;
|
||||
import ru.betterend.registry.StructureRegistry;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class PaintedMountainPiece extends BasePiece {
|
||||
private Map<Integer, Integer> heightmap = Maps.newHashMap();
|
||||
private OpenSimplexNoise noise;
|
||||
private BlockPos center;
|
||||
private float radius;
|
||||
private float height;
|
||||
private float r2;
|
||||
private Identifier biomeID;
|
||||
private BlockState[] slises;
|
||||
|
||||
public PaintedMountainPiece(BlockPos center, float radius, float height, int id, Biome biome, BlockState[] slises) {
|
||||
super(StructureRegistry.PAINTED_MOUNTAIN_PIECE, id);
|
||||
this.center = center;
|
||||
this.radius = radius;
|
||||
this.height = height;
|
||||
this.r2 = radius * radius;
|
||||
this.noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ()));
|
||||
this.biomeID = BiomeRegistry.getBiomeID(biome);
|
||||
this.slises = slises;
|
||||
makeBoundingBox();
|
||||
}
|
||||
|
||||
public PaintedMountainPiece(StructureManager manager, CompoundTag tag) {
|
||||
super(StructureRegistry.PAINTED_MOUNTAIN_PIECE, tag);
|
||||
makeBoundingBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void toNbt(CompoundTag tag) {
|
||||
tag.put("center", NbtHelper.fromBlockPos(center));
|
||||
tag.putFloat("radius", radius);
|
||||
tag.putFloat("height", height);
|
||||
tag.putString("biome", biomeID.toString());
|
||||
|
||||
ListTag slise = new ListTag();
|
||||
for (BlockState state: slises) {
|
||||
slise.add(NbtHelper.fromBlockState(state));
|
||||
}
|
||||
tag.put("slises", slise);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fromNbt(CompoundTag tag) {
|
||||
center = NbtHelper.toBlockPos(tag.getCompound("center"));
|
||||
radius = tag.getFloat("radius");
|
||||
height = tag.getFloat("height");
|
||||
biomeID = new Identifier(tag.getString("biome"));
|
||||
r2 = radius * radius;
|
||||
noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ()));
|
||||
ListTag slise = tag.getList("slises", 10);
|
||||
slises = new BlockState[slise.size()];
|
||||
for (int i = 0; i < slises.length; i++) {
|
||||
slises[i] = NbtHelper.toBlockState(slise.getCompound(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, StructureAccessor arg, ChunkGenerator chunkGenerator, Random random, BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) {
|
||||
int sx = chunkPos.getStartX();
|
||||
int sz = chunkPos.getStartZ();
|
||||
Mutable pos = new Mutable();
|
||||
Chunk chunk = world.getChunk(chunkPos.x, chunkPos.z);
|
||||
Heightmap map = chunk.getHeightmap(Type.WORLD_SURFACE_WG);
|
||||
for (int x = 0; x < 16; x++) {
|
||||
int px = x + sx;
|
||||
int px2 = px - center.getX();
|
||||
px2 *= px2;
|
||||
pos.setX(x);
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int pz = z + sz;
|
||||
int pz2 = pz - center.getZ();
|
||||
pz2 *= pz2;
|
||||
float dist = px2 + pz2;
|
||||
if (dist < r2) {
|
||||
pos.setZ(z);
|
||||
dist = 1 - dist / r2;
|
||||
int minY = map.get(x, z);
|
||||
if (minY > 56) {
|
||||
pos.setY(minY - 1);
|
||||
while (chunk.getBlockState(pos).isAir() && pos.getY() > 50) {
|
||||
pos.setY(minY --);
|
||||
}
|
||||
|
||||
float maxY = dist * height * getHeightClamp(world, 4, px, pz);
|
||||
if (maxY > 0) {
|
||||
maxY *= (float) noise.eval(px * 0.05, pz * 0.05) * 0.03F + 0.97F;
|
||||
maxY *= (float) noise.eval(px * 0.1, pz * 0.1) * 0.01F + 0.99F;
|
||||
maxY += 56;
|
||||
float offset = (float) (noise.eval(px * 0.07, pz * 0.07) * 5 + noise.eval(px * 0.2, pz * 0.2) * 2 + 7);
|
||||
for (int y = minY - 1; y < maxY; y++) {
|
||||
pos.setY(y);
|
||||
int index = MHelper.floor((y + offset) * 0.65F) % slises.length;
|
||||
chunk.setBlockState(pos, slises[index], false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private int getHeight(StructureWorldAccess world, BlockPos pos) {
|
||||
int p = ((pos.getX() & 2047) << 11) | (pos.getZ() & 2047);
|
||||
int h = heightmap.getOrDefault(p, Integer.MIN_VALUE);
|
||||
if (h > Integer.MIN_VALUE) {
|
||||
return h;
|
||||
}
|
||||
|
||||
if (!BiomeRegistry.getBiomeID(world.getBiome(pos)).equals(biomeID)) {
|
||||
heightmap.put(p, -6);
|
||||
return -6;
|
||||
}
|
||||
h = world.getTopY(Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
|
||||
if (h < 57) {
|
||||
heightmap.put(p, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Mutable m = new Mutable();
|
||||
m.set(pos.getX(), h - 1, pos.getZ());
|
||||
while (h > 56 && world.getBlockState(pos).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||
m.setY(m.getY() - 1);
|
||||
}
|
||||
h = m.getY();
|
||||
|
||||
h -= 57;
|
||||
|
||||
if (h < 0) {
|
||||
heightmap.put(p, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
heightmap.put(p, h);
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
private float getHeightClamp(StructureWorldAccess world, int radius, int posX, int posZ) {
|
||||
Mutable mut = new Mutable();
|
||||
int r2 = radius * radius;
|
||||
float height = 0;
|
||||
float max = 0;
|
||||
for (int x = -radius; x <= radius; x++) {
|
||||
mut.setX(posX + x);
|
||||
int x2 = x * x;
|
||||
for (int z = -radius; z <= radius; z++) {
|
||||
mut.setZ(posZ + z);
|
||||
int z2 = z * z;
|
||||
if (x2 + z2 < r2) {
|
||||
float mult = 1 - (float) Math.sqrt(x2 + z2) / radius;
|
||||
max += mult;
|
||||
height += getHeight(world, mut) * mult;
|
||||
}
|
||||
}
|
||||
}
|
||||
height /= max;
|
||||
return MathHelper.clamp(height / radius, 0, 1);
|
||||
}
|
||||
|
||||
private void makeBoundingBox() {
|
||||
int minX = MHelper.floor(center.getX() - radius);
|
||||
int minZ = MHelper.floor(center.getZ() - radius);
|
||||
int maxX = MHelper.floor(center.getX() + radius + 1);
|
||||
int maxZ = MHelper.floor(center.getZ() + radius + 1);
|
||||
this.boundingBox = new BlockBox(minX, minZ, maxX, maxZ);
|
||||
}
|
||||
}
|
|
@ -59,6 +59,21 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"betterend.music.dust_wastelands": {
|
||||
"category": "music",
|
||||
"sounds": [
|
||||
{
|
||||
"name": "betterend:music/letter_box-far_the_days_come",
|
||||
"volume": 0.25,
|
||||
"stream": false
|
||||
},
|
||||
{
|
||||
"name": "betterend:music/jade_wii-sahara_desert",
|
||||
"volume": 0.25,
|
||||
"stream": false
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"betterend.ambient.foggy_mushroomland": {
|
||||
"category": "ambient",
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue