Ceiling generation
This commit is contained in:
parent
9b464bcc06
commit
82c0b12118
7 changed files with 59 additions and 45 deletions
|
@ -9,6 +9,7 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.EnumProperty;
|
||||
|
@ -35,6 +36,13 @@ public class TripleTerrainBlock extends EndTerrainBlock {
|
|||
stateManager.add(SHAPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
Direction dir = ctx.getSide();
|
||||
TripleShape shape = dir == Direction.UP ? TripleShape.BOTTOM : dir == Direction.DOWN ? TripleShape.TOP : TripleShape.MIDDLE;
|
||||
return this.getDefaultState().with(SHAPE, shape);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
System.out.println(block);
|
||||
|
|
|
@ -197,6 +197,7 @@ public class EndFeatures {
|
|||
public static final DefaultFeature BIG_AURORA_CRYSTAL = new BigAuroraCrystalFeature();
|
||||
public static final DefaultFeature CAVE_BUSH = new BushFeature(EndBlocks.CAVE_BUSH, EndBlocks.CAVE_BUSH);
|
||||
public static final DefaultFeature CAVE_GRASS = new SingleBlockFeature(EndBlocks.CAVE_GRASS);
|
||||
public static final DefaultFeature RUBINEA = new VineFeature(EndBlocks.RUBINEA, 8);
|
||||
public static final DefaultFeature END_STONE_STALACTITE = new StalactiteFeature(true, EndBlocks.END_STONE_STALACTITE, Blocks.END_STONE);
|
||||
public static final DefaultFeature END_STONE_STALAGMITE = new StalactiteFeature(false, EndBlocks.END_STONE_STALACTITE, Blocks.END_STONE);
|
||||
public static final DefaultFeature END_STONE_STALACTITE_CAVEMOSS = new StalactiteFeature(true, EndBlocks.END_STONE_STALACTITE_CAVEMOSS, Blocks.END_STONE, EndBlocks.CAVE_MOSS);
|
||||
|
|
|
@ -2,7 +2,9 @@ package ru.betterend.world.biome.cave;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.collection.WeightedList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import ru.betterend.world.biome.land.BiomeDefinition;
|
||||
import ru.betterend.world.biome.land.EndBiome;
|
||||
|
@ -38,4 +40,8 @@ public class EndCaveBiome extends EndBiome {
|
|||
public float getCeilDensity() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public BlockState getCeil(BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package ru.betterend.world.biome.cave;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import ru.betterend.blocks.BlockProperties;
|
||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndFeatures;
|
||||
import ru.betterend.registry.EndParticles;
|
||||
|
@ -20,10 +24,11 @@ public class LushAuroraCaveBiome extends EndCaveBiome {
|
|||
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, 10);
|
||||
this.addFloorFeature(EndFeatures.END_STONE_STALAGMITE_CAVEMOSS, 5);
|
||||
|
||||
this.addCeilFeature(EndFeatures.CAVE_BUSH, 1);
|
||||
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE_CAVEMOSS, 20);
|
||||
this.addCeilFeature(EndFeatures.RUBINEA, 3);
|
||||
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE_CAVEMOSS, 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,4 +40,9 @@ public class LushAuroraCaveBiome extends EndCaveBiome {
|
|||
public float getCeilDensity() {
|
||||
return 0.1F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getCeil(BlockPos pos) {
|
||||
return EndBlocks.CAVE_MOSS.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class BushFeature extends DefaultFeature {
|
|||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND) && !world.getBlockState(pos.up()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
float radius = MHelper.randRange(1.8F, 3.5F, random);
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
|
||||
|
|
|
@ -52,31 +52,23 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
Set<BlockPos> caveBlocks = generate(world, center, radius, random);
|
||||
if (!caveBlocks.isEmpty()) {
|
||||
if (biome != null) {
|
||||
boolean fillFloor = biome.getFloorDensity() > 0;
|
||||
boolean fillCeil = biome.getCeilDensity() > 0;
|
||||
setBiomes(world, biome, caveBlocks);
|
||||
Set<BlockPos> floorPositions = Sets.newHashSet();
|
||||
Set<BlockPos> ceilPositions = Sets.newHashSet();
|
||||
Mutable mut = new Mutable();
|
||||
if (fillFloor || fillCeil) {
|
||||
caveBlocks.forEach((bpos) -> {
|
||||
mut.set(bpos);
|
||||
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
if (fillFloor) {
|
||||
mut.setY(bpos.getY() - 1);
|
||||
if (world.getBlockState(mut).isIn(EndTags.GEN_TERRAIN)) {
|
||||
floorPositions.add(mut.toImmutable());
|
||||
}
|
||||
}
|
||||
if (fillCeil) {
|
||||
mut.setY(bpos.getY() + 1);
|
||||
if (world.getBlockState(mut).isIn(EndTags.GEN_TERRAIN)) {
|
||||
ceilPositions.add(mut.toImmutable());
|
||||
}
|
||||
}
|
||||
caveBlocks.forEach((bpos) -> {
|
||||
mut.set(bpos);
|
||||
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
mut.setY(bpos.getY() - 1);
|
||||
if (world.getBlockState(mut).isIn(EndTags.GEN_TERRAIN)) {
|
||||
floorPositions.add(mut.toImmutable());
|
||||
}
|
||||
});
|
||||
}
|
||||
mut.setY(bpos.getY() + 1);
|
||||
if (world.getBlockState(mut).isIn(EndTags.GEN_TERRAIN)) {
|
||||
ceilPositions.add(mut.toImmutable());
|
||||
}
|
||||
}
|
||||
});
|
||||
BlockState surfaceBlock = biome.getBiome().getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||
placeFloor(world, biome, floorPositions, random, surfaceBlock);
|
||||
placeCeil(world, biome, ceilPositions, random);
|
||||
|
@ -90,35 +82,32 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
protected abstract Set<BlockPos> generate(StructureWorldAccess world, BlockPos center, int radius, Random random);
|
||||
|
||||
protected void placeFloor(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> floorPositions, Random random, BlockState surfaceBlock) {
|
||||
float density = biome.getFloorDensity();
|
||||
floorPositions.forEach((pos) -> {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock);
|
||||
});
|
||||
|
||||
float density = biome.getFloorDensity();
|
||||
if (density > 0) {
|
||||
floorPositions.forEach((pos) -> {
|
||||
if (random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getFloorFeature(random);
|
||||
if (feature != null) {
|
||||
feature.generate(world, null, random, pos.up(), null);
|
||||
}
|
||||
if (density > 0 && random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getFloorFeature(random);
|
||||
if (feature != null) {
|
||||
feature.generate(world, null, random, pos.up(), null);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void placeCeil(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> ceilPositions, Random random) {
|
||||
float density = biome.getCeilDensity();
|
||||
if (density > 0) {
|
||||
ceilPositions.forEach((pos) -> {
|
||||
if (random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getCeilFeature(random);
|
||||
if (feature != null) {
|
||||
feature.generate(world, null, random, pos.down(), null);
|
||||
}
|
||||
ceilPositions.forEach((pos) -> {
|
||||
BlockState ceilBlock = biome.getCeil(pos);
|
||||
if (ceilBlock != null) {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, ceilBlock);
|
||||
}
|
||||
if (density > 0 && random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getCeilFeature(random);
|
||||
if (feature != null) {
|
||||
feature.generate(world, null, random, pos.down(), null);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void setBiomes(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> blocks) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue