mirror of
https://github.com/chylex/Hardcore-Ender-Expansion-2.git
synced 2025-04-08 03:15:50 +02:00
Improve Tomb Dungeon generation
This commit is contained in:
parent
8971a0e0ab
commit
5b3bf3bd8c
src
main/java/chylex/hee/game/world
feature
energyshrine
obsidiantower
stronghold
tombdungeon
territory/generators
system/src/main/java/chylex/hee/game/world/structure
@ -22,7 +22,7 @@ import chylex.hee.system.random.nextItemOrNull
|
||||
import chylex.hee.system.random.removeItemOrNull
|
||||
import java.util.Random
|
||||
|
||||
object EnergyShrineBuilder : IStructureBuilder {
|
||||
object EnergyShrineBuilder : IStructureBuilder<IStructureBuild> {
|
||||
override fun build(rand: Random): IStructureBuild? {
|
||||
val remainingRooms = EnergyShrinePieces.generateRoomConfiguration(rand, targetMainPathRoomAmount = rand.nextInt(3, 4))
|
||||
val remainingCorridors = EnergyShrinePieces.generateCorridorConfiguration(rand, remainingRooms)
|
||||
|
@ -13,7 +13,7 @@ import chylex.hee.system.random.nextItem
|
||||
import net.minecraft.util.Rotation
|
||||
import java.util.Random
|
||||
|
||||
class ObsidianTowerBuilder(private val arrangement: ObsidianTowerRoomArrangement, private val rotation: Rotation? = null) : IStructureBuilder {
|
||||
class ObsidianTowerBuilder(private val arrangement: ObsidianTowerRoomArrangement, private val rotation: Rotation? = null) : IStructureBuilder<IStructureBuild> {
|
||||
override fun build(rand: Random): IStructureBuild? {
|
||||
val transform1 = Transform(rotation = rotation ?: rand.nextItem(), mirror = false)
|
||||
val transform2 = transform1.copy(rotation = transform1.rotation.add(Rotation.CLOCKWISE_180))
|
||||
|
@ -34,7 +34,7 @@ import java.util.Random
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
object StrongholdBuilder : IStructureBuilder {
|
||||
object StrongholdBuilder : IStructureBuilder<IStructureBuild> {
|
||||
fun buildWithEyeOfEnderTarget(rand: Random): Pair<IStructureBuild, BlockPos?>? {
|
||||
val build = StructureBuild(STRUCTURE_SIZE, rand.nextItem(PIECES_START).StrongholdInst(distanceToPortal = 0, facingFromPortal = null, transform = rand.nextItem(Transform.ALL)))
|
||||
val process = Process(build, rand)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package chylex.hee.game.world.feature.tombdungeon
|
||||
|
||||
import chylex.hee.game.world.feature.tombdungeon.TombDungeonBuilder.TombDungeonBuild
|
||||
import chylex.hee.game.world.feature.tombdungeon.TombDungeonPieces.STRUCTURE_SIZE
|
||||
import chylex.hee.game.world.feature.tombdungeon.connection.TombDungeonConnection
|
||||
import chylex.hee.game.world.feature.tombdungeon.connection.TombDungeonConnectionType.SECRET_CONNECTOR
|
||||
@ -35,10 +36,12 @@ import org.apache.commons.lang3.mutable.MutableInt
|
||||
import java.util.Random
|
||||
import kotlin.math.min
|
||||
|
||||
object TombDungeonBuilder : IStructureBuilder {
|
||||
object TombDungeonBuilder : IStructureBuilder<TombDungeonBuild> {
|
||||
val ENTRANCE_POS: BlockPos = STRUCTURE_SIZE.getPos(CENTER, MAX, MAX).add(-TombDungeonStart.size.centerX, -TombDungeonStart.size.y, -STRUCTURE_SIZE.x / 3)
|
||||
|
||||
override fun build(rand: Random): IStructureBuild? {
|
||||
class TombDungeonBuild(val bedrockHeights: List<Int>, delegate: IStructureBuild) : IStructureBuild by delegate
|
||||
|
||||
override fun build(rand: Random): TombDungeonBuild? {
|
||||
val startingPiece = TombDungeonStart.MutableInstance(Transform.NONE)
|
||||
val startingPiecePos = ENTRANCE_POS
|
||||
|
||||
@ -205,7 +208,7 @@ object TombDungeonBuilder : IStructureBuilder {
|
||||
return null
|
||||
}
|
||||
|
||||
return build.freeze()
|
||||
return TombDungeonBuild(emptyList(), build.freeze()) // TODO where the fuck did the code go
|
||||
}
|
||||
|
||||
private class Process(build: StructureBuild<StructurePiece<TombDungeonLevel>.MutableInstance>, rand: Random) : ProcessBase<StructurePiece<TombDungeonLevel>.MutableInstance>(build, rand) {
|
||||
|
@ -72,8 +72,16 @@ object TombDungeonPieces : IStructureDescription {
|
||||
)
|
||||
|
||||
val PALETTE_ENTRY_FANCY_WALL = Weighted(
|
||||
94 to ModBlocks.DUSTY_STONE_BRICKS,
|
||||
6 to ModBlocks.DUSTY_STONE_CRACKED_BRICKS
|
||||
932 to ModBlocks.DUSTY_STONE_BRICKS.defaultState,
|
||||
52 to ModBlocks.DUSTY_STONE_CRACKED_BRICKS.defaultState,
|
||||
2 to ModBlocks.DUSTY_STONE_BRICK_STAIRS.with(BlockStairs.HALF, Half.BOTTOM).withFacing(NORTH),
|
||||
2 to ModBlocks.DUSTY_STONE_BRICK_STAIRS.with(BlockStairs.HALF, Half.BOTTOM).withFacing(SOUTH),
|
||||
2 to ModBlocks.DUSTY_STONE_BRICK_STAIRS.with(BlockStairs.HALF, Half.BOTTOM).withFacing(EAST),
|
||||
2 to ModBlocks.DUSTY_STONE_BRICK_STAIRS.with(BlockStairs.HALF, Half.BOTTOM).withFacing(WEST),
|
||||
2 to ModBlocks.DUSTY_STONE_BRICK_STAIRS.with(BlockStairs.HALF, Half.TOP).withFacing(NORTH),
|
||||
2 to ModBlocks.DUSTY_STONE_BRICK_STAIRS.with(BlockStairs.HALF, Half.TOP).withFacing(SOUTH),
|
||||
2 to ModBlocks.DUSTY_STONE_BRICK_STAIRS.with(BlockStairs.HALF, Half.TOP).withFacing(EAST),
|
||||
2 to ModBlocks.DUSTY_STONE_BRICK_STAIRS.with(BlockStairs.HALF, Half.TOP).withFacing(WEST),
|
||||
)
|
||||
|
||||
val PALETTE_ENTRY_FANCY_CEILING = Weighted(
|
||||
|
@ -114,6 +114,17 @@ abstract class TombDungeonAbstractPiece : StructurePiece<TombDungeonLevel>() {
|
||||
}
|
||||
}
|
||||
|
||||
protected fun placeWallTorch(world: IStructureWorld, pos: BlockPos, facing: Direction) {
|
||||
if (!world.isAir(pos)) {
|
||||
return
|
||||
}
|
||||
|
||||
val wall = world.getBlock(pos.offset(facing.opposite))
|
||||
if (wall == ModBlocks.DUSTY_STONE || wall == ModBlocks.DUSTY_STONE_BRICKS || wall == ModBlocks.DUSTY_STONE_BRICK_STAIRS) {
|
||||
world.placeBlock(pos, Single(Blocks.REDSTONE_WALL_TORCH.withFacing(facing)))
|
||||
}
|
||||
}
|
||||
|
||||
protected fun placeChest(world: IStructureWorld, instance: Instance, pos: BlockPos, facing: Direction, secret: Boolean = false) {
|
||||
val level = instance.context ?: TombDungeonLevel.FIRST
|
||||
val chest = TileEntityChest().apply { TombDungeonLoot.generate(this, world.rand, level, secret) }
|
||||
|
@ -1,10 +1,8 @@
|
||||
package chylex.hee.game.world.feature.tombdungeon.piece
|
||||
|
||||
import chylex.hee.game.block.withFacing
|
||||
import chylex.hee.game.world.Pos
|
||||
import chylex.hee.game.world.feature.tombdungeon.connection.TombDungeonConnection
|
||||
import chylex.hee.game.world.feature.tombdungeon.connection.TombDungeonConnectionType.CORRIDOR
|
||||
import chylex.hee.game.world.generation.IBlockPicker.Single
|
||||
import chylex.hee.game.world.generation.IBlockPicker.Single.Air
|
||||
import chylex.hee.game.world.math.Size
|
||||
import chylex.hee.game.world.structure.IStructureWorld
|
||||
@ -13,7 +11,6 @@ import chylex.hee.system.migration.Facing.EAST
|
||||
import chylex.hee.system.migration.Facing.NORTH
|
||||
import chylex.hee.system.migration.Facing.SOUTH
|
||||
import chylex.hee.system.migration.Facing.WEST
|
||||
import net.minecraft.block.Blocks
|
||||
|
||||
class TombDungeonCorridor_Straight(length: Int, override val isFancy: Boolean) : TombDungeonAbstractPiece() {
|
||||
override val size = Size(5, 5, length)
|
||||
@ -50,10 +47,10 @@ class TombDungeonCorridor_Straight(length: Int, override val isFancy: Boolean) :
|
||||
|
||||
val type = rand.nextInt(2)
|
||||
if (type == 0 || rand.nextInt(13) == 0) {
|
||||
world.placeBlock(Pos(1, 2, z), Single(Blocks.REDSTONE_WALL_TORCH.withFacing(EAST)))
|
||||
placeWallTorch(world, Pos(1, 2, z), EAST)
|
||||
}
|
||||
if (type == 1 || rand.nextInt(13) == 0) {
|
||||
world.placeBlock(Pos(size.maxX - 1, 2, z), Single(Blocks.REDSTONE_WALL_TORCH.withFacing(WEST)))
|
||||
placeWallTorch(world, Pos(size.maxX - 1, 2, z), WEST)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,9 @@
|
||||
package chylex.hee.game.world.feature.tombdungeon.piece
|
||||
|
||||
import chylex.hee.game.block.withFacing
|
||||
import chylex.hee.game.world.Pos
|
||||
import chylex.hee.game.world.feature.tombdungeon.connection.TombDungeonConnection
|
||||
import chylex.hee.game.world.feature.tombdungeon.connection.TombDungeonConnectionType.CORRIDOR
|
||||
import chylex.hee.game.world.feature.tombdungeon.connection.TombDungeonConnectionType.TOMB_ENTRANCE_OUTSIDE
|
||||
import chylex.hee.game.world.generation.IBlockPicker.Single
|
||||
import chylex.hee.game.world.generation.IBlockPicker.Single.Air
|
||||
import chylex.hee.game.world.math.Size
|
||||
import chylex.hee.game.world.structure.IStructureWorld
|
||||
@ -15,7 +13,6 @@ import chylex.hee.system.migration.Facing.NORTH
|
||||
import chylex.hee.system.migration.Facing.SOUTH
|
||||
import chylex.hee.system.migration.Facing.WEST
|
||||
import chylex.hee.system.random.nextItem
|
||||
import net.minecraft.block.Blocks
|
||||
import java.util.Random
|
||||
|
||||
class TombDungeonCorridor_StraightTombs(entranceSpacing: Int, configuration: Configuration, tombsPerSide: Int, private val tombConstructor: (Boolean) -> TombDungeonAbstractPiece, override val isFancy: Boolean) : TombDungeonAbstractPiece(), ITombDungeonPieceWithTombs {
|
||||
@ -72,12 +69,12 @@ class TombDungeonCorridor_StraightTombs(entranceSpacing: Int, configuration: Con
|
||||
val type = rand.nextInt(2)
|
||||
if (type == 0 || rand.nextInt(13) == 0) {
|
||||
if (connections.find { it.offset.z == z && it.facing === WEST }.let { it == null || !instance.isConnectionUsed(it) }) {
|
||||
world.placeBlock(Pos(1, 2, z), Single(Blocks.REDSTONE_WALL_TORCH.withFacing(EAST)))
|
||||
placeWallTorch(world, Pos(1, 2, z), EAST)
|
||||
}
|
||||
}
|
||||
if (type == 1 || rand.nextInt(13) == 0) {
|
||||
if (connections.find { it.offset.z == z && it.facing === EAST }.let { it == null || !instance.isConnectionUsed(it) }) {
|
||||
world.placeBlock(Pos(size.maxX - 1, 2, z), Single(Blocks.REDSTONE_WALL_TORCH.withFacing(WEST)))
|
||||
placeWallTorch(world, Pos(size.maxX - 1, 2, z), WEST)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ object Generator_ForgottenTombs : ITerritoryGenerator {
|
||||
PortalGenerator.VoidPortalReturnActive.place(world, spawnPoint)
|
||||
|
||||
val entrancePoint = TombDungeonEntrance.generate(world, rand, spawnPoint)
|
||||
TombDungeon.generate(world, rand, entrancePoint)
|
||||
TombDungeon.generate(world, size, rand, entrancePoint)
|
||||
|
||||
return TerritoryGenerationInfo(spawnPoint)
|
||||
}
|
||||
@ -350,12 +350,19 @@ object Generator_ForgottenTombs : ITerritoryGenerator {
|
||||
}
|
||||
|
||||
private object TombDungeon {
|
||||
fun generate(world: SegmentedWorld, rand: Random, entrance: BlockPos) {
|
||||
fun generate(world: SegmentedWorld, size: Size, rand: Random, entrance: BlockPos) {
|
||||
for(attempt in 1..1000) {
|
||||
val build = TombDungeonBuilder.build(rand)
|
||||
|
||||
if (build != null) {
|
||||
build.generate(OffsetStructureWorld(world, entrance.up().subtract(TombDungeonBuilder.ENTRANCE_POS).subtract(TombDungeonStart.size.centerPos)))
|
||||
val offset = entrance.up().subtract(TombDungeonBuilder.ENTRANCE_POS).subtract(TombDungeonStart.size.centerPos)
|
||||
|
||||
for (y in build.bedrockHeights) {
|
||||
val offsetY = offset.y + y
|
||||
world.placeCube(Pos(0, offsetY - 1, 0), Pos(size.maxX, offsetY + 1, size.maxZ), Single(Blocks.BEDROCK))
|
||||
}
|
||||
|
||||
build.generate(OffsetStructureWorld(world, offset))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import net.minecraft.world.server.ServerWorld
|
||||
interface IStructureDescription {
|
||||
val STRUCTURE_SIZE: Size
|
||||
|
||||
val STRUCTURE_BUILDER: IStructureBuilder
|
||||
val STRUCTURE_BUILDER: IStructureBuilder<*>
|
||||
val STRUCTURE_LOCATOR: (ServerWorld, PosXZ) -> BlockPos?
|
||||
|
||||
val PALETTE: Palette
|
||||
|
@ -7,8 +7,8 @@ import chylex.hee.system.facades.Rotation4
|
||||
import chylex.hee.system.random.nextItem
|
||||
import java.util.Random
|
||||
|
||||
interface IStructureBuilder {
|
||||
fun build(rand: Random): IStructureBuild?
|
||||
interface IStructureBuilder<T : IStructureBuild> {
|
||||
fun build(rand: Random): T?
|
||||
|
||||
abstract class ProcessBase<T : StructurePiece<*>.MutableInstance>(protected val build: StructureBuild<T>, protected val rand: Random) {
|
||||
protected fun baseAddPiece(mode: AddMode, targetPiece: PositionedPiece<T>, targetConnection: IStructurePieceConnection, generatedPieceConstructor: (Transform) -> T): PositionedPiece<T>? {
|
||||
|
Loading…
Reference in New Issue
Block a user