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.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.block.MaterialColor;
|
||||||
|
import net.minecraft.item.ItemPlacementContext;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.state.StateManager;
|
||||||
import net.minecraft.state.property.EnumProperty;
|
import net.minecraft.state.property.EnumProperty;
|
||||||
|
@ -35,6 +36,13 @@ public class TripleTerrainBlock extends EndTerrainBlock {
|
||||||
stateManager.add(SHAPE);
|
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
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelPattern(String block) {
|
||||||
System.out.println(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 BIG_AURORA_CRYSTAL = new BigAuroraCrystalFeature();
|
||||||
public static final DefaultFeature CAVE_BUSH = new BushFeature(EndBlocks.CAVE_BUSH, EndBlocks.CAVE_BUSH);
|
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 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_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_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);
|
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 java.util.Random;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.collection.WeightedList;
|
import net.minecraft.util.collection.WeightedList;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.gen.feature.Feature;
|
import net.minecraft.world.gen.feature.Feature;
|
||||||
import ru.betterend.world.biome.land.BiomeDefinition;
|
import ru.betterend.world.biome.land.BiomeDefinition;
|
||||||
import ru.betterend.world.biome.land.EndBiome;
|
import ru.betterend.world.biome.land.EndBiome;
|
||||||
|
@ -38,4 +40,8 @@ public class EndCaveBiome extends EndBiome {
|
||||||
public float getCeilDensity() {
|
public float getCeilDensity() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BlockState getCeil(BlockPos pos) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package ru.betterend.world.biome.cave;
|
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.EndBlocks;
|
||||||
import ru.betterend.registry.EndFeatures;
|
import ru.betterend.registry.EndFeatures;
|
||||||
import ru.betterend.registry.EndParticles;
|
import ru.betterend.registry.EndParticles;
|
||||||
|
@ -20,10 +24,11 @@ public class LushAuroraCaveBiome extends EndCaveBiome {
|
||||||
this.addFloorFeature(EndFeatures.BIG_AURORA_CRYSTAL, 1);
|
this.addFloorFeature(EndFeatures.BIG_AURORA_CRYSTAL, 1);
|
||||||
this.addFloorFeature(EndFeatures.CAVE_BUSH, 5);
|
this.addFloorFeature(EndFeatures.CAVE_BUSH, 5);
|
||||||
this.addFloorFeature(EndFeatures.CAVE_GRASS, 40);
|
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.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
|
@Override
|
||||||
|
@ -35,4 +40,9 @@ public class LushAuroraCaveBiome extends EndCaveBiome {
|
||||||
public float getCeilDensity() {
|
public float getCeilDensity() {
|
||||||
return 0.1F;
|
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
|
@Override
|
||||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
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);
|
float radius = MHelper.randRange(1.8F, 3.5F, random);
|
||||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
|
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
|
||||||
|
|
|
@ -52,31 +52,23 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
||||||
Set<BlockPos> caveBlocks = generate(world, center, radius, random);
|
Set<BlockPos> caveBlocks = generate(world, center, radius, random);
|
||||||
if (!caveBlocks.isEmpty()) {
|
if (!caveBlocks.isEmpty()) {
|
||||||
if (biome != null) {
|
if (biome != null) {
|
||||||
boolean fillFloor = biome.getFloorDensity() > 0;
|
|
||||||
boolean fillCeil = biome.getCeilDensity() > 0;
|
|
||||||
setBiomes(world, biome, caveBlocks);
|
setBiomes(world, biome, caveBlocks);
|
||||||
Set<BlockPos> floorPositions = Sets.newHashSet();
|
Set<BlockPos> floorPositions = Sets.newHashSet();
|
||||||
Set<BlockPos> ceilPositions = Sets.newHashSet();
|
Set<BlockPos> ceilPositions = Sets.newHashSet();
|
||||||
Mutable mut = new Mutable();
|
Mutable mut = new Mutable();
|
||||||
if (fillFloor || fillCeil) {
|
|
||||||
caveBlocks.forEach((bpos) -> {
|
caveBlocks.forEach((bpos) -> {
|
||||||
mut.set(bpos);
|
mut.set(bpos);
|
||||||
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||||
if (fillFloor) {
|
|
||||||
mut.setY(bpos.getY() - 1);
|
mut.setY(bpos.getY() - 1);
|
||||||
if (world.getBlockState(mut).isIn(EndTags.GEN_TERRAIN)) {
|
if (world.getBlockState(mut).isIn(EndTags.GEN_TERRAIN)) {
|
||||||
floorPositions.add(mut.toImmutable());
|
floorPositions.add(mut.toImmutable());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (fillCeil) {
|
|
||||||
mut.setY(bpos.getY() + 1);
|
mut.setY(bpos.getY() + 1);
|
||||||
if (world.getBlockState(mut).isIn(EndTags.GEN_TERRAIN)) {
|
if (world.getBlockState(mut).isIn(EndTags.GEN_TERRAIN)) {
|
||||||
ceilPositions.add(mut.toImmutable());
|
ceilPositions.add(mut.toImmutable());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
BlockState surfaceBlock = biome.getBiome().getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
BlockState surfaceBlock = biome.getBiome().getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||||
placeFloor(world, biome, floorPositions, random, surfaceBlock);
|
placeFloor(world, biome, floorPositions, random, surfaceBlock);
|
||||||
placeCeil(world, biome, ceilPositions, random);
|
placeCeil(world, biome, ceilPositions, random);
|
||||||
|
@ -90,14 +82,10 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
||||||
protected abstract Set<BlockPos> generate(StructureWorldAccess world, BlockPos center, int radius, Random random);
|
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) {
|
protected void placeFloor(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> floorPositions, Random random, BlockState surfaceBlock) {
|
||||||
|
float density = biome.getFloorDensity();
|
||||||
floorPositions.forEach((pos) -> {
|
floorPositions.forEach((pos) -> {
|
||||||
BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock);
|
BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock);
|
||||||
});
|
if (density > 0 && random.nextFloat() <= density) {
|
||||||
|
|
||||||
float density = biome.getFloorDensity();
|
|
||||||
if (density > 0) {
|
|
||||||
floorPositions.forEach((pos) -> {
|
|
||||||
if (random.nextFloat() <= density) {
|
|
||||||
Feature<?> feature = biome.getFloorFeature(random);
|
Feature<?> feature = biome.getFloorFeature(random);
|
||||||
if (feature != null) {
|
if (feature != null) {
|
||||||
feature.generate(world, null, random, pos.up(), null);
|
feature.generate(world, null, random, pos.up(), null);
|
||||||
|
@ -105,13 +93,15 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected void placeCeil(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> ceilPositions, Random random) {
|
protected void placeCeil(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> ceilPositions, Random random) {
|
||||||
float density = biome.getCeilDensity();
|
float density = biome.getCeilDensity();
|
||||||
if (density > 0) {
|
|
||||||
ceilPositions.forEach((pos) -> {
|
ceilPositions.forEach((pos) -> {
|
||||||
if (random.nextFloat() <= density) {
|
BlockState ceilBlock = biome.getCeil(pos);
|
||||||
|
if (ceilBlock != null) {
|
||||||
|
BlocksHelper.setWithoutUpdate(world, pos, ceilBlock);
|
||||||
|
}
|
||||||
|
if (density > 0 && random.nextFloat() <= density) {
|
||||||
Feature<?> feature = biome.getCeilFeature(random);
|
Feature<?> feature = biome.getCeilFeature(random);
|
||||||
if (feature != null) {
|
if (feature != null) {
|
||||||
feature.generate(world, null, random, pos.down(), null);
|
feature.generate(world, null, random, pos.down(), null);
|
||||||
|
@ -119,7 +109,6 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected void setBiomes(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> blocks) {
|
protected void setBiomes(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> blocks) {
|
||||||
blocks.forEach((pos) -> setBiome(world, pos, biome));
|
blocks.forEach((pos) -> setBiome(world, pos, biome));
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
{ "model": "betterend:pattern/%block%_middle", "y": 270 }
|
{ "model": "betterend:pattern/%block%_middle", "y": 270 }
|
||||||
],
|
],
|
||||||
"shape=top": [
|
"shape=top": [
|
||||||
{ "model": "betterend:pattern/%block%" },
|
{ "model": "betterend:pattern/%block%", "x": 180 },
|
||||||
{ "model": "betterend:pattern/%block%", "x": 180, "y": 90 },
|
{ "model": "betterend:pattern/%block%", "x": 180, "y": 90 },
|
||||||
{ "model": "betterend:pattern/%block%", "x": 180, "y": 180 },
|
{ "model": "betterend:pattern/%block%", "x": 180, "y": 180 },
|
||||||
{ "model": "betterend:pattern/%block%", "x": 180, "y": 270 }
|
{ "model": "betterend:pattern/%block%", "x": 180, "y": 270 }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue