diff --git a/src/main/java/ru/betterend/blocks/basis/TripleTerrainBlock.java b/src/main/java/ru/betterend/blocks/basis/TripleTerrainBlock.java index 21fd221f..25154c94 100644 --- a/src/main/java/ru/betterend/blocks/basis/TripleTerrainBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/TripleTerrainBlock.java @@ -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); diff --git a/src/main/java/ru/betterend/registry/EndFeatures.java b/src/main/java/ru/betterend/registry/EndFeatures.java index e6ae3f86..e5d18f4f 100644 --- a/src/main/java/ru/betterend/registry/EndFeatures.java +++ b/src/main/java/ru/betterend/registry/EndFeatures.java @@ -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); diff --git a/src/main/java/ru/betterend/world/biome/cave/EndCaveBiome.java b/src/main/java/ru/betterend/world/biome/cave/EndCaveBiome.java index b9a5b338..4ca1e5a6 100644 --- a/src/main/java/ru/betterend/world/biome/cave/EndCaveBiome.java +++ b/src/main/java/ru/betterend/world/biome/cave/EndCaveBiome.java @@ -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; + } } diff --git a/src/main/java/ru/betterend/world/biome/cave/LushAuroraCaveBiome.java b/src/main/java/ru/betterend/world/biome/cave/LushAuroraCaveBiome.java index 284d38de..5d56029a 100644 --- a/src/main/java/ru/betterend/world/biome/cave/LushAuroraCaveBiome.java +++ b/src/main/java/ru/betterend/world/biome/cave/LushAuroraCaveBiome.java @@ -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); + } } diff --git a/src/main/java/ru/betterend/world/features/bushes/BushFeature.java b/src/main/java/ru/betterend/world/features/bushes/BushFeature.java index c7248e0b..f06a4f4d 100644 --- a/src/main/java/ru/betterend/world/features/bushes/BushFeature.java +++ b/src/main/java/ru/betterend/world/features/bushes/BushFeature.java @@ -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()); diff --git a/src/main/java/ru/betterend/world/features/terrain/caves/EndCaveFeature.java b/src/main/java/ru/betterend/world/features/terrain/caves/EndCaveFeature.java index d41efa0d..7b8ff74f 100644 --- a/src/main/java/ru/betterend/world/features/terrain/caves/EndCaveFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/caves/EndCaveFeature.java @@ -52,31 +52,23 @@ public abstract class EndCaveFeature extends DefaultFeature { Set 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 floorPositions = Sets.newHashSet(); Set 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 generate(StructureWorldAccess world, BlockPos center, int radius, Random random); protected void placeFloor(StructureWorldAccess world, EndCaveBiome biome, Set 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 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 blocks) { diff --git a/src/main/resources/assets/betterend/patterns/blockstate/triple_rotated_top.json b/src/main/resources/assets/betterend/patterns/blockstate/triple_rotated_top.json index 7fd583ce..36ff9261 100644 --- a/src/main/resources/assets/betterend/patterns/blockstate/triple_rotated_top.json +++ b/src/main/resources/assets/betterend/patterns/blockstate/triple_rotated_top.json @@ -13,7 +13,7 @@ { "model": "betterend:pattern/%block%_middle", "y": 270 } ], "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": 180 }, { "model": "betterend:pattern/%block%", "x": 180, "y": 270 }