Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/repo/rooms/** linguist-generated
src/main/kotlin/me/owdding/mortem/Mortem.kt ident
10 changes: 9 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@file:Suppress("UnstableApiUsage")

import org.gradle.internal.impldep.org.junit.experimental.categories.Categories.CategoryFilter.exclude
import org.gradle.kotlin.dsl.modImplementation
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Expand All @@ -12,6 +11,7 @@ plugins {
kotlin("jvm") version "2.2.20"
alias(libs.plugins.ksp)
`versioned-catalogues`
alias(libs.plugins.meowdding.resources)
}

repositories {
Expand Down Expand Up @@ -86,6 +86,14 @@ loom {
}
}

compactingResources {
basePath = "repo"
pathDirectory = "../../src"

configureTask(tasks.named<AbstractCopyTask>("processResources").get())
compactToArray("rooms")
}

ksp {
arg("meowdding.project_name", "mortem")
arg("meowdding.package", "me.owdding.mortem.generated")
Expand Down
1 change: 0 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ repositories {
}

dependencies {
implementation(libs.meowdding.resources)
implementation(libs.gson)
}
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ repo-lib = "3.0.2"
devauth = "1.2.1"

ksp = "2.2.10-2.0.2"
meowdding-resources = "1.0.17"

rconfigkt = "3.5.15"

gson = "2.12.1"

meowdding-resources = "1.0.15"
meowdding-ktmodules = "1.0.5"
meowdding-ktcodecs = "1.1.0"
meowdding-lib = "3.0.13"
Expand All @@ -39,4 +39,5 @@ meowdding-lib = { module = "me.owdding.meowdding-lib:meowdding-lib", version.ref
meowdding-remote-repo = { module = "me.owdding.repo:remote-repo", version.ref = "meowdding-remote-repo" }

[plugins]
meowdding-resources = { id = "me.owdding.resources", version.ref = "meowdding-resources" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pluginManagement {
maven("https://maven.kikugie.dev/snapshots")
maven("https://maven.fabricmc.net/")
gradlePluginPortal()
maven("https://maven.teamresourceful.com/repository/maven-public/")
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package me.owdding.mortem.mixins;

import net.minecraft.core.SectionPos;
import net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(ClientboundSectionBlocksUpdatePacket.class)
public interface ClientboundSectionBlocksUpdatePacketAccessor {

@Accessor("sectionPos")
SectionPos mortem$sectionPos();

}
1 change: 1 addition & 0 deletions src/main/kotlin/me/owdding/mortem/Mortem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import tech.thatgravyboat.skyblockapi.api.SkyBlockAPI

@Module
object Mortem : ClientModInitializer, MeowddingLogger by MeowddingLogger.autoResolve() {
const val gitRef = $$"$Id$"

val SELF = FabricLoader.getInstance().getModContainer("mortem").get()
val MOD_ID: String = SELF.metadata.id
Expand Down
11 changes: 11 additions & 0 deletions src/main/kotlin/me/owdding/mortem/core/Instance.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package me.owdding.mortem.core

interface Instance {
val instance: InstanceType
}

enum class InstanceType {
CATACOMBS,
KUUDRA,
;
}
117 changes: 117 additions & 0 deletions src/main/kotlin/me/owdding/mortem/core/catacombs/Catacomb.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package me.owdding.mortem.core.catacombs

import me.owdding.ktcodecs.FieldName
import me.owdding.ktcodecs.GenerateCodec
import me.owdding.mortem.core.Instance
import me.owdding.mortem.core.InstanceType
import me.owdding.mortem.core.catacombs.nodes.CatacombNodeType
import me.owdding.mortem.core.catacombs.nodes.CatacombsNode
import me.owdding.mortem.utils.Utils
import me.owdding.mortem.utils.Utils.unsafeCast
import net.minecraft.core.Direction
import org.joml.Vector2i
import org.joml.minus
import org.joml.plus
import tech.thatgravyboat.skyblockapi.api.area.dungeon.DungeonFloor
import tech.thatgravyboat.skyblockapi.utils.extentions.filterValuesNotNull
import java.util.concurrent.ConcurrentHashMap

data class Catacomb(
val floor: DungeonFloor,
) : Instance {
var size: CatacombSize = CatacombSize.forFloor(floor)

var mapTopLeft: Vector2i? = null
var mapRoomSize: Int = 0
set(value) {
mapRoomAndDoorSize = value + DOOR_WIDTH
field = value
}
var mapRoomAndDoorSize: Int = 0

val grid: MutableMap<Vector2i, CatacombsNode<*>> = ConcurrentHashMap()

fun <T : CatacombsNode<T>> getOrCreateNode(position: Vector2i, type: CatacombNodeType<T>) : T = grid.getOrPut(position, type.constructor).unsafeCast()

inline fun <reified T : CatacombsNode<T>> getNeighbours(position: Vector2i): Map<Vector2i, T> = buildList {
add(position + Utils.vectorOneZero)
add(position + Utils.vectorZeroOne)
add(position - Utils.vectorOneZero)
add(position - Utils.vectorZeroOne)
}.associateWith { grid[it] as? T }.filterValuesNotNull()

override val instance: InstanceType get() = InstanceType.CATACOMBS
}

fun interface CatacombsColorProvider {
fun getColor(): Int
}

enum class CatacombRoomType(val provider: CatacombsColorProvider) : CatacombsColorProvider by provider {
NORMAL({ 0xAb6b00 }),
TRAP({ 0xFF7F0F }),
FAIRY({ 0xF080FF }),
PUZZLE({ 0xe050F0 }),
MINIBOSS({ 0xFFFF00 }),
BLOOD({ 0xFF0000 }),
START({ 0x00FF00 }),
UNKNOWN({ 0xababab }),
DEFAULT({ 0x000000 }),
;

companion object {
fun getByColor(color: CatacombMapColor): CatacombRoomType? = when (color) {
CatacombMapColor.COMPLETE -> START
CatacombMapColor.UNKNOWN -> UNKNOWN
CatacombMapColor.FAILED -> BLOOD
CatacombMapColor.PUZZLE -> PUZZLE
CatacombMapColor.TRAP -> TRAP
CatacombMapColor.MINIBOSS -> MINIBOSS
CatacombMapColor.FAIRY -> FAIRY
CatacombMapColor.NORMAL -> NORMAL
else -> null
}
}

}

enum class CatacombDoorType(val provider: CatacombsColorProvider) : CatacombsColorProvider by provider {
WITHER({ 0x4f4f4f }),
BLOOD({ 0xFF0000 }),
NORMAL({ 0xab6b00 }),
TRAP({ 0xff7f0f }),
MINIBOSS({ 0xFFFF00 }),
PUZZLE({ 0xe060f0 }),
FAIRY({ 0xf080ff }),
DEFAULT({ 0x000000 }),
;

companion object {
fun getByColor(color: CatacombMapColor): CatacombDoorType? = when (color) {
CatacombMapColor.FAILED -> BLOOD
CatacombMapColor.NORMAL -> NORMAL
CatacombMapColor.WITHER -> WITHER
CatacombMapColor.FAIRY -> FAIRY
CatacombMapColor.PUZZLE -> PUZZLE
CatacombMapColor.TRAP -> TRAP
CatacombMapColor.MINIBOSS -> MINIBOSS
CatacombMapColor.UNKNOWN -> DEFAULT
else -> null
}
}
}

@GenerateCodec
data class StoredCatacombRoom(
var name: String,
var id: String,
var secrets: Int,
@FieldName("center") val centerHash: String,
@FieldName("directions") val directionalHashes: Map<String, Direction>,
) {
var shouldSerialize = false

fun markChange() {
shouldSerialize = true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package me.owdding.mortem.core.catacombs

const val DOOR_WIDTH: Int = 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package me.owdding.mortem.core.catacombs

import net.minecraft.world.level.material.MapColor

enum class CatacombMapColor(
val mapColor: MapColor,
val brightness: MapColor.Brightness,
) {

/** Also used for entrance */
COMPLETE(MapColor.PLANT, MapColor.Brightness.HIGH),

/** Also used for blood */
FAILED(MapColor.FIRE, MapColor.Brightness.HIGH),
CLEARED(MapColor.SNOW, MapColor.Brightness.HIGH),
NORMAL(MapColor.COLOR_ORANGE, MapColor.Brightness.LOWEST),
PUZZLE(MapColor.COLOR_MAGENTA, MapColor.Brightness.HIGH),
MINIBOSS(MapColor.COLOR_YELLOW, MapColor.Brightness.HIGH),
FAIRY(MapColor.COLOR_PINK, MapColor.Brightness.HIGH),
TRAP(MapColor.COLOR_ORANGE, MapColor.Brightness.HIGH),
WITHER(MapColor.COLOR_BLACK, MapColor.Brightness.LOWEST),
UNKNOWN(MapColor.COLOR_GRAY, MapColor.Brightness.NORMAL),
NONE(MapColor.NONE, MapColor.Brightness.LOW),
;

val packedId = mapColor.getPackedId(brightness)
val colorId = mapColor.id
val brightnessId = brightness.id

companion object {
fun getByPackedId(id: Byte?): CatacombMapColor = when (id) {
COMPLETE.packedId -> COMPLETE
FAILED.packedId -> FAILED
CLEARED.packedId -> CLEARED
NORMAL.packedId -> NORMAL
PUZZLE.packedId -> PUZZLE
MINIBOSS.packedId -> MINIBOSS
FAIRY.packedId -> FAIRY
TRAP.packedId -> TRAP
WITHER.packedId -> WITHER
UNKNOWN.packedId -> UNKNOWN
else -> NONE
}
}
}
41 changes: 41 additions & 0 deletions src/main/kotlin/me/owdding/mortem/core/catacombs/CatacombSize.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package me.owdding.mortem.core.catacombs

import tech.thatgravyboat.skyblockapi.api.area.dungeon.DungeonFloor
import tech.thatgravyboat.skyblockapi.api.area.dungeon.DungeonFloor.*

enum class CatacombSize(
val xRooms: Int,
val yRooms: Int,
val mapSize: MapSize,
val boundaryX: Int = xRooms,
val boundaryY: Int = yRooms,
) {

TINY(4, 4, MapSize.SMALL),
SMALL(4, 5, MapSize.SMALL),
NORMAL(5, 5, MapSize.SMALL),
LARGE(6, 5, MapSize.LARGE),
GIGANTIC(6, 5, MapSize.LARGE, 6, 6),
COLOSSAL(6, 6, MapSize.LARGE),
;

companion object {

fun forFloor(floor: DungeonFloor): CatacombSize = when (floor) {
E -> TINY
F1, M1 -> SMALL
F2, M2, F3, M3 -> NORMAL
F4, M4 -> LARGE
F5, M5, F6, M6 -> GIGANTIC
else -> COLOSSAL
}
}
}

enum class MapSize(
val roomWidth: Int,
val offset: Int,
) {
SMALL(22, 0),
LARGE(20, 1)
}
Loading