Skip to content

Commit f6eb786

Browse files
meoworaItsEmpa
andauthored
feat: add dungeon map detection (#4)
* feat: add dungeon map detection * feat: add colours, and remove node overwriting * feat: add room matching stuff and room middle section * feat: switch to sha256 for hashing since the array had problems * feat: a lot of room stuff * feat: add room rotations and more rooms * style: use sealed classes and objects for CatacombNodeType * requested chagnes * git attributes * git attributes v2 --------- Co-authored-by: Empa <itsempa@users.noreply.github.com>
1 parent d971bd0 commit f6eb786

115 files changed

Lines changed: 2107 additions & 4 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
src/repo/rooms/** linguist-generated
2+
src/main/kotlin/me/owdding/mortem/Mortem.kt ident

build.gradle.kts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@file:Suppress("UnstableApiUsage")
22

3-
import org.gradle.internal.impldep.org.junit.experimental.categories.Categories.CategoryFilter.exclude
43
import org.gradle.kotlin.dsl.modImplementation
54
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
65
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
@@ -12,6 +11,7 @@ plugins {
1211
kotlin("jvm") version "2.2.20"
1312
alias(libs.plugins.ksp)
1413
`versioned-catalogues`
14+
alias(libs.plugins.meowdding.resources)
1515
}
1616

1717
repositories {
@@ -86,6 +86,14 @@ loom {
8686
}
8787
}
8888

89+
compactingResources {
90+
basePath = "repo"
91+
pathDirectory = "../../src"
92+
93+
configureTask(tasks.named<AbstractCopyTask>("processResources").get())
94+
compactToArray("rooms")
95+
}
96+
8997
ksp {
9098
arg("meowdding.project_name", "mortem")
9199
arg("meowdding.package", "me.owdding.mortem.generated")

buildSrc/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ repositories {
88
}
99

1010
dependencies {
11-
implementation(libs.meowdding.resources)
1211
implementation(libs.gson)
1312
}

gradle/libs.versions.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ repo-lib = "3.0.2"
88
devauth = "1.2.1"
99

1010
ksp = "2.2.10-2.0.2"
11+
meowdding-resources = "1.0.17"
1112

1213
rconfigkt = "3.5.15"
1314

1415
gson = "2.12.1"
1516

16-
meowdding-resources = "1.0.15"
1717
meowdding-ktmodules = "1.0.5"
1818
meowdding-ktcodecs = "1.1.0"
1919
meowdding-lib = "3.0.13"
@@ -39,4 +39,5 @@ meowdding-lib = { module = "me.owdding.meowdding-lib:meowdding-lib", version.ref
3939
meowdding-remote-repo = { module = "me.owdding.repo:remote-repo", version.ref = "meowdding-remote-repo" }
4040

4141
[plugins]
42+
meowdding-resources = { id = "me.owdding.resources", version.ref = "meowdding-resources" }
4243
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pluginManagement {
33
maven("https://maven.kikugie.dev/snapshots")
44
maven("https://maven.fabricmc.net/")
55
gradlePluginPortal()
6+
maven("https://maven.teamresourceful.com/repository/maven-public/")
67
}
78
}
89

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package me.owdding.mortem.mixins;
2+
3+
import net.minecraft.core.SectionPos;
4+
import net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.gen.Accessor;
7+
8+
@Mixin(ClientboundSectionBlocksUpdatePacket.class)
9+
public interface ClientboundSectionBlocksUpdatePacketAccessor {
10+
11+
@Accessor("sectionPos")
12+
SectionPos mortem$sectionPos();
13+
14+
}

src/main/kotlin/me/owdding/mortem/Mortem.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import tech.thatgravyboat.skyblockapi.api.SkyBlockAPI
1111

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

1516
val SELF = FabricLoader.getInstance().getModContainer("mortem").get()
1617
val MOD_ID: String = SELF.metadata.id
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package me.owdding.mortem.core
2+
3+
interface Instance {
4+
val instance: InstanceType
5+
}
6+
7+
enum class InstanceType {
8+
CATACOMBS,
9+
KUUDRA,
10+
;
11+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package me.owdding.mortem.core.catacombs
2+
3+
import me.owdding.ktcodecs.FieldName
4+
import me.owdding.ktcodecs.GenerateCodec
5+
import me.owdding.mortem.core.Instance
6+
import me.owdding.mortem.core.InstanceType
7+
import me.owdding.mortem.core.catacombs.nodes.CatacombNodeType
8+
import me.owdding.mortem.core.catacombs.nodes.CatacombsNode
9+
import me.owdding.mortem.utils.Utils
10+
import me.owdding.mortem.utils.Utils.unsafeCast
11+
import net.minecraft.core.Direction
12+
import org.joml.Vector2i
13+
import org.joml.minus
14+
import org.joml.plus
15+
import tech.thatgravyboat.skyblockapi.api.area.dungeon.DungeonFloor
16+
import tech.thatgravyboat.skyblockapi.utils.extentions.filterValuesNotNull
17+
import java.util.concurrent.ConcurrentHashMap
18+
19+
data class Catacomb(
20+
val floor: DungeonFloor,
21+
) : Instance {
22+
var size: CatacombSize = CatacombSize.forFloor(floor)
23+
24+
var mapTopLeft: Vector2i? = null
25+
var mapRoomSize: Int = 0
26+
set(value) {
27+
mapRoomAndDoorSize = value + DOOR_WIDTH
28+
field = value
29+
}
30+
var mapRoomAndDoorSize: Int = 0
31+
32+
val grid: MutableMap<Vector2i, CatacombsNode<*>> = ConcurrentHashMap()
33+
34+
fun <T : CatacombsNode<T>> getOrCreateNode(position: Vector2i, type: CatacombNodeType<T>) : T = grid.getOrPut(position, type.constructor).unsafeCast()
35+
36+
inline fun <reified T : CatacombsNode<T>> getNeighbours(position: Vector2i): Map<Vector2i, T> = buildList {
37+
add(position + Utils.vectorOneZero)
38+
add(position + Utils.vectorZeroOne)
39+
add(position - Utils.vectorOneZero)
40+
add(position - Utils.vectorZeroOne)
41+
}.associateWith { grid[it] as? T }.filterValuesNotNull()
42+
43+
override val instance: InstanceType get() = InstanceType.CATACOMBS
44+
}
45+
46+
fun interface CatacombsColorProvider {
47+
fun getColor(): Int
48+
}
49+
50+
enum class CatacombRoomType(val provider: CatacombsColorProvider) : CatacombsColorProvider by provider {
51+
NORMAL({ 0xAb6b00 }),
52+
TRAP({ 0xFF7F0F }),
53+
FAIRY({ 0xF080FF }),
54+
PUZZLE({ 0xe050F0 }),
55+
MINIBOSS({ 0xFFFF00 }),
56+
BLOOD({ 0xFF0000 }),
57+
START({ 0x00FF00 }),
58+
UNKNOWN({ 0xababab }),
59+
DEFAULT({ 0x000000 }),
60+
;
61+
62+
companion object {
63+
fun getByColor(color: CatacombMapColor): CatacombRoomType? = when (color) {
64+
CatacombMapColor.COMPLETE -> START
65+
CatacombMapColor.UNKNOWN -> UNKNOWN
66+
CatacombMapColor.FAILED -> BLOOD
67+
CatacombMapColor.PUZZLE -> PUZZLE
68+
CatacombMapColor.TRAP -> TRAP
69+
CatacombMapColor.MINIBOSS -> MINIBOSS
70+
CatacombMapColor.FAIRY -> FAIRY
71+
CatacombMapColor.NORMAL -> NORMAL
72+
else -> null
73+
}
74+
}
75+
76+
}
77+
78+
enum class CatacombDoorType(val provider: CatacombsColorProvider) : CatacombsColorProvider by provider {
79+
WITHER({ 0x4f4f4f }),
80+
BLOOD({ 0xFF0000 }),
81+
NORMAL({ 0xab6b00 }),
82+
TRAP({ 0xff7f0f }),
83+
MINIBOSS({ 0xFFFF00 }),
84+
PUZZLE({ 0xe060f0 }),
85+
FAIRY({ 0xf080ff }),
86+
DEFAULT({ 0x000000 }),
87+
;
88+
89+
companion object {
90+
fun getByColor(color: CatacombMapColor): CatacombDoorType? = when (color) {
91+
CatacombMapColor.FAILED -> BLOOD
92+
CatacombMapColor.NORMAL -> NORMAL
93+
CatacombMapColor.WITHER -> WITHER
94+
CatacombMapColor.FAIRY -> FAIRY
95+
CatacombMapColor.PUZZLE -> PUZZLE
96+
CatacombMapColor.TRAP -> TRAP
97+
CatacombMapColor.MINIBOSS -> MINIBOSS
98+
CatacombMapColor.UNKNOWN -> DEFAULT
99+
else -> null
100+
}
101+
}
102+
}
103+
104+
@GenerateCodec
105+
data class StoredCatacombRoom(
106+
var name: String,
107+
var id: String,
108+
var secrets: Int,
109+
@FieldName("center") val centerHash: String,
110+
@FieldName("directions") val directionalHashes: Map<String, Direction>,
111+
) {
112+
var shouldSerialize = false
113+
114+
fun markChange() {
115+
shouldSerialize = true
116+
}
117+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package me.owdding.mortem.core.catacombs
2+
3+
const val DOOR_WIDTH: Int = 4

0 commit comments

Comments
 (0)