1
0
mirror of https://github.com/chylex/Hardcore-Ender-Expansion-2.git synced 2025-04-08 03:15:50 +02:00

Improve Tomb Dungeon generation (corridor torches, tomb exits, chests, mob spawners)

This commit is contained in:
chylex 2021-04-02 00:23:21 +02:00
parent 3cce30eb84
commit df42079c73
20 changed files with 199 additions and 53 deletions

View File

@ -154,7 +154,7 @@ object TombDungeonBuilder : IStructureBuilder {
val targetPieces = build
.generatedPieces
.subList(firstCorridorIndex, lastCorridorIndex + 1)
.drop(firstCorridorIndex - 1)
.filter { it.instance.hasAvailableConnections }
.mapNotNull { (it.instance.owner as? TombDungeonAbstractPiece)?.sidePathAttachWeight?.takeIf { weight -> weight > 0 }?.let { weight -> weight to it } }
.takeIf { it.isNotEmpty() }

View File

@ -34,7 +34,7 @@ enum class TombDungeonLevel(val isFancy: Boolean, private val corridorFactor: In
LAST (isFancy = true, corridorFactor = 6, mainRooms = 1..1, sideRooms = 0..1, dustPerRoom = 20..48);
fun getMainCorridorLength(rand: Random): Int {
return rand.nextInt(45 + (corridorFactor * 2), 57) + (2 * (6 - corridorFactor)) + ((corridorFactor - 1) * rand.nextFloat(12.5F, 14.2F)).floorToInt() + (if (this == LAST) 10 else 0)
return rand.nextInt(45 + (corridorFactor * 2), 57) + (2 * (6 - corridorFactor)) + ((corridorFactor - 1) * rand.nextFloat(12.5F, 14.2F)).floorToInt() + (if (this == LAST) 13 else 0)
}
fun nextMainCorridorSplitLength(rand: Random, remaining: Int): Int {
@ -54,9 +54,9 @@ enum class TombDungeonLevel(val isFancy: Boolean, private val corridorFactor: In
fun getTombCount(rand: Random): Int {
return if (this == LAST)
rand.nextInt(10, 15)
rand.nextInt(18, 21)
else
rand.nextInt(5, 7) + (ordinal / 2) + (rand.nextInt(2, 3) * ordinal)
rand.nextInt(5, 7) + ((ordinal + 1) / 2) + (rand.nextInt(2, 3) * ordinal)
}
fun pickTombGeneratorAndSpacing(rand: Random): Pair<Int, (Boolean) -> TombDungeonAbstractPiece> {
@ -78,7 +78,7 @@ enum class TombDungeonLevel(val isFancy: Boolean, private val corridorFactor: In
else -> 7 to TOMB_RANDOM(rand, PIECE_TOMB_RANDOM_MASS_5X_BORDER)
}
THIRD -> when(rand.nextInt(0, 7)) {
THIRD -> when(rand.nextInt(0, 8)) {
0 -> 11 to TOMB_RANDOM(rand, PIECE_TOMB_RANDOM_MASS_SPACIOUS)
in 1..2 -> 11 to PIECE_TOMB_RANDOM_MASS_SPACIOUS.generateItem(rand)
3 -> 9 to TOMB_RANDOM(rand, PIECE_TOMB_RANDOM_MULTI_NARROW)
@ -97,10 +97,11 @@ enum class TombDungeonLevel(val isFancy: Boolean, private val corridorFactor: In
else -> 5 to PIECE_TOMB_SINGLE_NARROW
}
else -> when(rand.nextInt(0, 7)) {
in 0..2 -> 7 to PIECE_TOMB_SINGLE_SPACIOUS
in 3..6 -> 5 to PIECE_TOMB_SINGLE_NARROW
else -> 11 to TOMB_RANDOM(rand, PIECE_TOMB_RANDOM_MULTI_SPACIOUS)
else -> when(rand.nextInt(0, 11)) {
in 0..3 -> 7 to PIECE_TOMB_SINGLE_SPACIOUS
in 4..8 -> 5 to PIECE_TOMB_SINGLE_NARROW
in 9..10 -> 11 to TOMB_RANDOM(rand, PIECE_TOMB_RANDOM_MULTI_SPACIOUS)
else -> 11 to TOMB_RANDOM(rand, PIECE_TOMB_RANDOM_MULTI_DEEP_LONG)
}
}
}

View File

@ -178,7 +178,7 @@ object TombDungeonPieces : IStructureDescription {
val isFancy = level.isFancy
var lengthRemaining = level.getMainCorridorLength(rand)
for(attempt in 0..2) {
for (attempt in 0..2) {
val (sideTombSpacing, sideTombGenerator) = level.pickTombGeneratorAndSpacing(rand)
val tombsPerSide = rand.nextInt(6, 7) - attempt - min(2, (sideTombSpacing - 3) / 3)
@ -194,7 +194,7 @@ object TombDungeonPieces : IStructureDescription {
}
}
while(lengthRemaining > 0) {
while (lengthRemaining > 0) {
var nextLength = level.nextMainCorridorSplitLength(rand, lengthRemaining)
lengthRemaining -= nextLength
@ -236,7 +236,7 @@ object TombDungeonPieces : IStructureDescription {
return mutableListOf<TombDungeonAbstractPiece>().apply {
val isFancy = level.isFancy
repeat(rand.nextInt(0, rand.nextInt(1, 6))) {
repeat(rand.nextInt(0, rand.nextInt(1, 5))) {
val length = rand.nextInt(1, 6)
if (length >= 5 && rand.nextBoolean()) {
@ -258,6 +258,10 @@ object TombDungeonPieces : IStructureDescription {
shuffle(rand)
if (isEmpty() || get(0).let { it is TombDungeonCorridor_Straight && it.size.z < 4 }) {
add(0, TombDungeonCorridor_Straight(3, isFancy))
}
if (endRoom != null) {
add(endRoom)
}
@ -273,11 +277,11 @@ object TombDungeonPieces : IStructureDescription {
val randomPieces = mutableListOf<TombDungeonSecret>()
while(randomPieces.size < amount) {
while (randomPieces.size < amount) {
randomPieces.addAll(PIECES_SECRET_RANDOM)
}
while(size < amount) {
while (size < amount) {
add(rand.removeItem(randomPieces))
}
}

View File

@ -8,7 +8,7 @@ import chylex.hee.init.ModBlocks
enum class TombDungeonConnectionType : IStructurePieceConnectionType {
CORRIDOR {
override fun canBeAttachedTo(target: IStructurePieceConnectionType) = target == CORRIDOR || target == ROOM_ENTRANCE || target == STAIR_BOTTOM
override fun canBeAttachedTo(target: IStructurePieceConnectionType) = target == CORRIDOR || target == TOMB_EXIT || target == ROOM_ENTRANCE || target == STAIR_BOTTOM
},
STAIR_BOTTOM {
@ -28,13 +28,15 @@ enum class TombDungeonConnectionType : IStructurePieceConnectionType {
TOMB_ENTRANCE_INSIDE {
override fun canBeAttachedTo(target: IStructurePieceConnectionType) = target == TOMB_ENTRANCE_OUTSIDE
override fun placeConnection(world: IStructureWorld, connection: IStructurePieceConnection) {
val offset = connection.offset
world.setBlock(offset, ModBlocks.DUSTY_STONE)
world.setAir(offset.up(1))
world.setAir(offset.up(2))
placeSimpleHole(world, connection)
}
},
TOMB_EXIT {
override fun canBeAttachedTo(target: IStructurePieceConnectionType) = target == CORRIDOR
override fun placeConnection(world: IStructureWorld, connection: IStructurePieceConnection) {
placeSimpleHole(world, connection)
}
},
@ -56,4 +58,12 @@ enum class TombDungeonConnectionType : IStructurePieceConnectionType {
world.placeCube(offset.add(-addX, 1, -addZ), offset.add(addX, 3, addZ), Air)
}
protected fun placeSimpleHole(world: IStructureWorld, connection: IStructurePieceConnection) {
val offset = connection.offset
world.setBlock(offset, ModBlocks.DUSTY_STONE)
world.setAir(offset.up(1))
world.setAir(offset.up(2))
}
}

View File

@ -14,7 +14,7 @@ import chylex.hee.system.migration.Facing.WEST
class TombDungeonCorridor_Intersection(override val isFancy: Boolean) : TombDungeonAbstractPiece() {
override val size = Size(5, 5, 5)
override val sidePathAttachWeight = 1
override val sidePathAttachWeight = 8
override val secretAttachWeight = 0
override val connections = arrayOf<IStructurePieceConnection>(

View File

@ -1,14 +1,19 @@
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
import chylex.hee.game.world.structure.piece.IStructurePieceConnection
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)
@ -30,11 +35,27 @@ class TombDungeonCorridor_Straight(length: Int, override val isFancy: Boolean) :
}
if (length > 2) {
val rand = world.rand
world.placeCube(Pos(1, 1, 1), Pos(size.maxX - 1, size.maxY - 1, size.maxZ - 1), Air)
if (world.rand.nextInt(4) == 0) {
if (rand.nextInt(4) == 0) {
placeCrumblingCeiling(world, instance, 1)
}
for (z in 1 until length step 3) {
if (rand.nextInt(16) != 0) {
continue
}
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)))
}
if (type == 1 || rand.nextInt(13) == 0) {
world.placeBlock(Pos(size.maxX - 1, 2, z), Single(Blocks.REDSTONE_WALL_TORCH.withFacing(WEST)))
}
}
}
placeCobwebs(world, instance)

View File

@ -1,9 +1,11 @@
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
@ -13,6 +15,7 @@ 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 {
@ -53,12 +56,32 @@ class TombDungeonCorridor_StraightTombs(entranceSpacing: Int, configuration: Con
override fun generate(world: IStructureWorld, instance: Instance) {
super.generate(world, instance)
val rand = world.rand
world.placeCube(Pos(1, 1, 1), Pos(size.maxX - 1, size.maxY - 1, size.maxZ - 1), Air)
if (world.rand.nextInt(5) == 0) {
if (rand.nextInt(5) == 0) {
placeCrumblingCeiling(world, instance, 1)
}
for (z in 1 until size.z step 3) {
if (rand.nextInt(15) != 0) {
continue
}
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)))
}
}
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)))
}
}
}
placeCobwebs(world, instance)
}

View File

@ -1,6 +1,6 @@
package chylex.hee.game.world.feature.tombdungeon.piece
abstract class TombDungeonRoom(file: String, isFancy: Boolean) : TombDungeonAbstractPieceFromFile(file, isFancy) {
override val sidePathAttachWeight = 5
override val sidePathAttachWeight = 45
override val secretAttachWeight = 0
}

View File

@ -43,7 +43,7 @@ class TombDungeonRoom_Main_Pillars(file: String, isFancy: Boolean) : TombDungeon
)
if (world.getBlock(chestPos) === ModBlocks.DUSTY_STONE_BRICKS) {
world.setBlock(chestPos.up(), ModBlocks.DUSTY_STONE_CRACKED)
world.setBlock(chestPos.up(), if (it == 1) ModBlocks.DUSTY_STONE_CRACKED else ModBlocks.DUSTY_STONE_DAMAGED)
placeChest(world, instance, chestPos, rand.nextItem(Facing4))
}
}

View File

@ -20,6 +20,7 @@ import chylex.hee.game.world.feature.tombdungeon.TombDungeonLevel
import chylex.hee.game.world.feature.tombdungeon.TombDungeonLevel.MobAmount
import chylex.hee.game.world.feature.tombdungeon.connection.TombDungeonConnection
import chylex.hee.game.world.feature.tombdungeon.connection.TombDungeonConnectionType.TOMB_ENTRANCE_INSIDE
import chylex.hee.game.world.feature.tombdungeon.connection.TombDungeonConnectionType.TOMB_EXIT
import chylex.hee.game.world.getBlock
import chylex.hee.game.world.getState
import chylex.hee.game.world.isAir
@ -59,11 +60,15 @@ import net.minecraft.util.math.Vec3d
import net.minecraft.world.World
import java.util.Random
abstract class TombDungeonRoom_Tomb(file: String, entranceY: Int, allowSecrets: Boolean, isFancy: Boolean) : TombDungeonRoom(file, isFancy) {
abstract class TombDungeonRoom_Tomb(file: String, entranceY: Int, allowExit: Boolean, allowSecrets: Boolean, isFancy: Boolean) : TombDungeonRoom(file, isFancy) {
final override val secretAttachWeight = if (allowSecrets) 2 else 0
final override val secretAttachY = entranceY
final override val connections = arrayOf<IStructurePieceConnection>(
final override val connections = if (allowExit) arrayOf<IStructurePieceConnection>(
TombDungeonConnection(TOMB_ENTRANCE_INSIDE, Pos(centerX, entranceY, maxZ), SOUTH),
TombDungeonConnection(TOMB_EXIT, Pos(centerX, entranceY, 0), NORTH)
)
else arrayOf<IStructurePieceConnection>(
TombDungeonConnection(TOMB_ENTRANCE_INSIDE, Pos(centerX, entranceY, maxZ), SOUTH)
)
@ -83,6 +88,10 @@ abstract class TombDungeonRoom_Tomb(file: String, entranceY: Int, allowSecrets:
protected abstract fun getSpawnerTriggerMobAmount(rand: Random, level: TombDungeonLevel): MobAmount?
protected fun isExitConnected(instance: Instance): Boolean {
return instance.findAvailableConnections().none { it.type === TOMB_EXIT }
}
class MobSpawnerTrigger() : ITriggerHandler {
companion object {
private const val WIDTH_TAG = "Width"

View File

@ -7,6 +7,7 @@ import chylex.hee.game.world.feature.tombdungeon.TombDungeonLevel.MobAmount
import chylex.hee.game.world.feature.tombdungeon.TombDungeonPieces
import chylex.hee.game.world.feature.tombdungeon.connection.TombDungeonConnection
import chylex.hee.game.world.feature.tombdungeon.connection.TombDungeonConnectionType.TOMB_ENTRANCE_INSIDE
import chylex.hee.game.world.feature.tombdungeon.connection.TombDungeonConnectionType.TOMB_EXIT
import chylex.hee.game.world.feature.tombdungeon.piece.TombDungeonRoom_Tomb.MobSpawnerTrigger
import chylex.hee.game.world.generation.IBlockPicker.Single
import chylex.hee.game.world.generation.IBlockPicker.Single.Air
@ -14,16 +15,21 @@ import chylex.hee.game.world.math.Size
import chylex.hee.game.world.structure.IStructureWorld
import chylex.hee.game.world.structure.piece.IStructurePieceConnection
import chylex.hee.init.ModBlocks
import chylex.hee.system.migration.Facing.NORTH
import chylex.hee.system.migration.Facing.SOUTH
class TombDungeonRoom_Tomb_Mass(width: Int, depth: Int, private val border: Boolean, private val split: Boolean, override val isFancy: Boolean) : TombDungeonAbstractPiece() {
override val size = Size(width + 2, 6, depth + 2)
override val sidePathAttachWeight = 0
override val sidePathAttachWeight = 6
override val secretAttachWeight = 2
override val secretAttachY = 1
override val connections = arrayOf<IStructurePieceConnection>(
override val connections = if (border || split) arrayOf<IStructurePieceConnection>(
TombDungeonConnection(TOMB_ENTRANCE_INSIDE, Pos(size.centerX, secretAttachY, size.maxZ), SOUTH),
TombDungeonConnection(TOMB_EXIT, Pos(size.centerX, secretAttachY, 0), NORTH)
)
else arrayOf<IStructurePieceConnection>(
TombDungeonConnection(TOMB_ENTRANCE_INSIDE, Pos(size.centerX, secretAttachY, size.maxZ), SOUTH)
)
@ -59,7 +65,7 @@ class TombDungeonRoom_Tomb_Mass(width: Int, depth: Int, private val border: Bool
world.setBlock(Pos(centerX, 1, maxZ - 1), ModBlocks.DUSTY_STONE)
}
if (rand.nextInt(6) == 0 && (border || split)) {
if (rand.nextInt(6) == 0 && (border || split) && instance.findAvailableConnections().any { it.type === TOMB_EXIT }) {
placeJars(world, instance, listOf(Pos(centerX, 2, 1)))
if (level != null && rand.nextInt(9) != 0) {

View File

@ -8,7 +8,7 @@ import chylex.hee.system.migration.Facing.NORTH
import chylex.hee.system.random.nextInt
import java.util.Random
class TombDungeonRoom_Tomb_MassSpacious(file: String, entranceY: Int, isFancy: Boolean) : TombDungeonRoom_Tomb(file, entranceY, allowSecrets = false, isFancy) {
class TombDungeonRoom_Tomb_MassSpacious(file: String, entranceY: Int, isFancy: Boolean) : TombDungeonRoom_Tomb(file, entranceY, allowExit = false, allowSecrets = false, isFancy) {
override fun generate(world: IStructureWorld, instance: Instance) {
super.generate(world, instance)

View File

@ -9,25 +9,40 @@ import chylex.hee.system.migration.Facing.EAST
import chylex.hee.system.migration.Facing.WEST
import chylex.hee.system.random.nextInt
import chylex.hee.system.random.nextRounded
import net.minecraft.util.Mirror
import java.util.Random
class TombDungeonRoom_Tomb_MultiDeep(file: String, private val tombsPerColumn: Int, entranceY: Int, isFancy: Boolean) : TombDungeonRoom_Tomb(file, entranceY, allowSecrets = false, isFancy) {
class TombDungeonRoom_Tomb_MultiDeep(file: String, private val tombsPerColumn: Int, entranceY: Int, isFancy: Boolean) : TombDungeonRoom_Tomb(file, entranceY, allowExit = true, allowSecrets = false, isFancy) {
override val sidePathAttachWeight = 6
override fun generate(world: IStructureWorld, instance: Instance) {
super.generate(world, instance)
val rand = world.rand
val chests = rand.nextInt(0, (tombsPerColumn * 2) / 5) * rand.nextRounded(0.66F)
val chests = rand.nextInt(0, (tombsPerColumn * 2) / 5) * rand.nextRounded(0.85F)
repeat(chests) {
val (offset, facing) = if (rand.nextBoolean())
-3 to EAST
-1 to EAST
else
3 to WEST
1 to WEST
val pos = Pos(centerX + offset, 1, 4 + (2 * rand.nextInt(tombsPerColumn)))
if (world.getBlock(pos) is BlockGraveDirt) {
placeChest(world, instance, pos, facing)
if (rand.nextInt(7) <= 1) {
val pos = Pos(centerX + (3 * offset), 1, 4 + (2 * rand.nextInt(tombsPerColumn)))
if (world.getBlock(pos) is BlockGraveDirt) {
placeChest(world, instance, pos, facing)
if (rand.nextInt(9) == 0) {
world.setAir(pos.add(0, 1, 0))
world.setAir(pos.add(-offset, 1, 0))
}
}
}
else {
val pos = Pos(centerX + (4 * offset), 3, 4 + (2 * rand.nextInt(tombsPerColumn)))
if (world.isAir(pos)) {
placeChest(world, instance, pos, facing)
}
}
}
@ -39,6 +54,12 @@ class TombDungeonRoom_Tomb_MultiDeep(file: String, private val tombsPerColumn: I
)
})
}
if (isExitConnected(instance)) {
for (x in 1 until maxX) for (y in 3..6) for (z in 0..2) {
world.setState(Pos(x, y, z), world.getState(Pos(x, y, maxZ - z)).mirror(Mirror.LEFT_RIGHT))
}
}
}
override fun getSpawnerTriggerMobAmount(rand: Random, level: TombDungeonLevel): MobAmount? {
@ -47,7 +68,10 @@ class TombDungeonRoom_Tomb_MultiDeep(file: String, private val tombsPerColumn: I
}
return when {
tombsPerColumn <= 6 -> MobAmount.MEDIUM
tombsPerColumn <= 4 -> if (rand.nextBoolean()) MobAmount.LOW else MobAmount.MEDIUM
tombsPerColumn <= 5 -> if (rand.nextInt(3) != 0) MobAmount.MEDIUM else MobAmount.HIGH
tombsPerColumn <= 6 -> if (rand.nextInt(2) != 0) MobAmount.MEDIUM else MobAmount.HIGH
tombsPerColumn <= 7 -> if (rand.nextInt(4) == 0) MobAmount.MEDIUM else MobAmount.HIGH
else -> MobAmount.HIGH
}
}

View File

@ -3,10 +3,14 @@ package chylex.hee.game.world.feature.tombdungeon.piece
import chylex.hee.game.world.Pos
import chylex.hee.game.world.feature.tombdungeon.TombDungeonLevel
import chylex.hee.game.world.feature.tombdungeon.TombDungeonLevel.MobAmount
import chylex.hee.game.world.feature.tombdungeon.TombDungeonPieces
import chylex.hee.game.world.structure.IStructureWorld
import net.minecraft.util.Mirror
import java.util.Random
class TombDungeonRoom_Tomb_MultiNarrow(file: String, private val tombsPerColumn: Int, entranceY: Int, isFancy: Boolean) : TombDungeonRoom_Tomb(file, entranceY, allowSecrets = false, isFancy) {
class TombDungeonRoom_Tomb_MultiNarrow(file: String, private val tombsPerColumn: Int, entranceY: Int, isFancy: Boolean) : TombDungeonRoom_Tomb(file, entranceY, allowExit = true, allowSecrets = false, isFancy) {
override val sidePathAttachWeight = 5
override fun generate(world: IStructureWorld, instance: Instance) {
super.generate(world, instance)
@ -20,6 +24,16 @@ class TombDungeonRoom_Tomb_MultiNarrow(file: String, private val tombsPerColumn:
)
})
}
if (isExitConnected(instance)) {
for (x in 1 until maxX) for (y in 2..3) {
world.setState(Pos(x, y, 1), world.getState(Pos(x, y, maxZ - 1)).mirror(Mirror.LEFT_RIGHT))
}
val palette = if (isFancy) TombDungeonPieces.PALETTE_ENTRY_FANCY_WALL else TombDungeonPieces.PALETTE_ENTRY_PLAIN_WALL_CEILING
world.setState(Pos(2, 2, 1), palette.pick(rand))
world.setState(Pos(maxX - 2, 2, 1), palette.pick(rand))
}
}
override fun getSpawnerTriggerMobAmount(rand: Random, level: TombDungeonLevel): MobAmount? {
@ -29,7 +43,8 @@ class TombDungeonRoom_Tomb_MultiNarrow(file: String, private val tombsPerColumn:
return when {
tombsPerColumn <= 4 -> MobAmount.LOW
tombsPerColumn <= 6 -> MobAmount.MEDIUM
tombsPerColumn <= 5 -> if (rand.nextBoolean()) MobAmount.LOW else MobAmount.MEDIUM
tombsPerColumn <= 6 -> if (rand.nextBoolean()) MobAmount.MEDIUM else MobAmount.HIGH
else -> MobAmount.HIGH
}
}

View File

@ -1,33 +1,54 @@
package chylex.hee.game.world.feature.tombdungeon.piece
import chylex.hee.game.block.BlockGraveDirt
import chylex.hee.game.block.withFacing
import chylex.hee.game.world.Pos
import chylex.hee.game.world.feature.tombdungeon.TombDungeonLevel
import chylex.hee.game.world.feature.tombdungeon.TombDungeonLevel.MobAmount
import chylex.hee.game.world.structure.IStructureWorld
import chylex.hee.init.ModBlocks
import chylex.hee.system.migration.BlockStairs
import chylex.hee.system.migration.Facing.EAST
import chylex.hee.system.migration.Facing.NORTH
import chylex.hee.system.migration.Facing.WEST
import chylex.hee.system.random.nextInt
import chylex.hee.system.random.nextRounded
import net.minecraft.state.properties.Half
import net.minecraft.state.properties.StairsShape
import net.minecraft.util.Mirror
import java.util.Random
class TombDungeonRoom_Tomb_MultiSpacious(file: String, private val tombsPerColumn: Int, entranceY: Int, isFancy: Boolean) : TombDungeonRoom_Tomb(file, entranceY, allowSecrets = false, isFancy) {
class TombDungeonRoom_Tomb_MultiSpacious(file: String, private val tombsPerColumn: Int, entranceY: Int, isFancy: Boolean) : TombDungeonRoom_Tomb(file, entranceY, allowExit = true, allowSecrets = false, isFancy) {
override val sidePathAttachWeight = 7
override fun generate(world: IStructureWorld, instance: Instance) {
super.generate(world, instance)
val rand = world.rand
val chests = rand.nextInt(0, (tombsPerColumn * 2) / 5) * rand.nextRounded(0.77F)
val chests = rand.nextInt(1, rand.nextInt(2, (tombsPerColumn / 2))) * rand.nextRounded(0.86F)
repeat(chests) {
val (offset, facing) = if (rand.nextBoolean())
-3 to EAST
-1 to EAST
else
3 to WEST
1 to WEST
val pos = Pos(centerX + offset, 1, 3 + (3 * rand.nextInt(tombsPerColumn)))
if (world.getBlock(pos) is BlockGraveDirt) {
placeChest(world, instance, pos, facing)
if (rand.nextInt(5) == 0) {
val pos = Pos(centerX + (3 * offset), 1, 3 + (3 * rand.nextInt(tombsPerColumn)))
if (world.getBlock(pos) is BlockGraveDirt) {
placeChest(world, instance, pos, facing)
if (rand.nextInt(17) == 0) {
world.setAir(pos.add(0, 1, 0))
world.setAir(pos.add(-offset, 1, 0))
}
}
}
else {
val pos = Pos(centerX + (4 * offset), 4, 3 + (3 * rand.nextInt(tombsPerColumn)))
if (world.isAir(pos)) {
placeChest(world, instance, pos, facing)
}
}
}
@ -39,6 +60,17 @@ class TombDungeonRoom_Tomb_MultiSpacious(file: String, private val tombsPerColum
)
})
}
if (isExitConnected(instance)) {
for (x in 1 until maxX) for (y in 3..5) {
world.setState(Pos(x, y, 0), world.getState(Pos(x, y, maxZ)).mirror(Mirror.LEFT_RIGHT))
}
world.setState(Pos(2, maxY - 1, 1), ModBlocks.DUSTY_STONE_BRICK_STAIRS.withFacing(NORTH).with(BlockStairs.HALF, Half.TOP))
world.setState(Pos(3, maxY - 1, 1), ModBlocks.DUSTY_STONE_BRICK_STAIRS.withFacing(WEST).with(BlockStairs.HALF, Half.TOP).with(BlockStairs.SHAPE, StairsShape.OUTER_RIGHT))
world.setState(Pos(maxX - 2, maxY - 1, 1), ModBlocks.DUSTY_STONE_BRICK_STAIRS.withFacing(NORTH).with(BlockStairs.HALF, Half.TOP))
world.setState(Pos(maxX - 3, maxY - 1, 1), ModBlocks.DUSTY_STONE_BRICK_STAIRS.withFacing(EAST).with(BlockStairs.HALF, Half.TOP).with(BlockStairs.SHAPE, StairsShape.OUTER_LEFT))
}
}
override fun getSpawnerTriggerMobAmount(rand: Random, level: TombDungeonLevel): MobAmount? {
@ -47,7 +79,8 @@ class TombDungeonRoom_Tomb_MultiSpacious(file: String, private val tombsPerColum
}
return when {
tombsPerColumn <= 6 -> MobAmount.MEDIUM
tombsPerColumn <= 4 -> if (rand.nextInt(3) == 0) MobAmount.LOW else MobAmount.MEDIUM
tombsPerColumn <= 6 -> if (rand.nextBoolean()) MobAmount.MEDIUM else MobAmount.HIGH
else -> MobAmount.HIGH
}
}

View File

@ -7,7 +7,7 @@ import chylex.hee.game.world.structure.IStructureWorld
import chylex.hee.system.migration.Facing.SOUTH
import java.util.Random
abstract class TombDungeonRoom_Tomb_Single(file: String, entranceY: Int, isFancy: Boolean) : TombDungeonRoom_Tomb(file, entranceY, allowSecrets = false, isFancy) {
abstract class TombDungeonRoom_Tomb_Single(file: String, entranceY: Int, isFancy: Boolean) : TombDungeonRoom_Tomb(file, entranceY, allowExit = false, allowSecrets = false, isFancy) {
override fun generate(world: IStructureWorld, instance: Instance) {
super.generate(world, instance)