Skip to content

Commit 1896ba9

Browse files
committed
Fix registries
1 parent 5ec4524 commit 1896ba9

File tree

8 files changed

+37
-55
lines changed

8 files changed

+37
-55
lines changed

Common/src/main/kotlin/gay/object/hexdebug/HexDebug.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import gay.`object`.hexdebug.adapter.DebugAdapterManager
44
import gay.`object`.hexdebug.config.HexDebugConfig
55
import gay.`object`.hexdebug.networking.HexDebugNetworking
66
import gay.`object`.hexdebug.registry.HexDebugActions
7-
import gay.`object`.hexdebug.registry.HexDebugContinuationTypes
8-
import gay.`object`.hexdebug.registry.HexDebugCreativeTabs
97
import gay.`object`.hexdebug.registry.HexDebugItems
108
import net.minecraft.resources.ResourceLocation
119
import org.apache.logging.log4j.LogManager
@@ -22,10 +20,8 @@ object HexDebug {
2220
HexDebugConfig.init()
2321
initRegistries(
2422
HexDebugItems,
25-
HexDebugCreativeTabs,
26-
HexDebugActions,
27-
HexDebugContinuationTypes,
2823
)
24+
HexDebugActions.init()
2925
HexDebugNetworking.init()
3026
DebugAdapterManager.init()
3127
}

Common/src/main/kotlin/gay/object/hexdebug/debugger/allocators/SourceAllocator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package gay.`object`.hexdebug.debugger.allocators
22

3-
import at.petrak.hexcasting.api.casting.iota.Iota
3+
import at.petrak.hexcasting.api.spell.iota.Iota
44
import gay.`object`.hexdebug.utils.nextHexString
55
import org.eclipse.lsp4j.debug.Source
66
import kotlin.random.Random
Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
package gay.`object`.hexdebug.registry
22

3-
import at.petrak.hexcasting.api.casting.ActionRegistryEntry
4-
import at.petrak.hexcasting.api.casting.castables.Action
5-
import at.petrak.hexcasting.api.casting.math.HexDir
6-
import at.petrak.hexcasting.api.casting.math.HexPattern
3+
import at.petrak.hexcasting.api.PatternRegistry
74
import at.petrak.hexcasting.api.misc.MediaConstants
8-
import at.petrak.hexcasting.common.casting.actions.spells.OpMakePackagedSpell
5+
import at.petrak.hexcasting.api.spell.Action
6+
import at.petrak.hexcasting.api.spell.iota.PatternIota
7+
import at.petrak.hexcasting.api.spell.math.HexDir
8+
import at.petrak.hexcasting.api.spell.math.HexPattern
9+
import at.petrak.hexcasting.common.casting.operators.spells.OpMakePackagedSpell
910
import at.petrak.hexcasting.common.items.magic.ItemPackagedHex
10-
import at.petrak.hexcasting.common.lib.HexRegistries
11-
import at.petrak.hexcasting.common.lib.hex.HexActions
11+
import gay.`object`.hexdebug.HexDebug
1212
import gay.`object`.hexdebug.casting.actions.OpBreakpoint
1313
import gay.`object`.hexdebug.casting.actions.OpIsDebugging
14+
import net.minecraft.resources.ResourceLocation
1415

15-
object HexDebugActions : HexDebugRegistrar<ActionRegistryEntry>(HexRegistries.ACTION, { HexActions.REGISTRY }) {
16+
object HexDebugActions {
1617
val IS_DEBUGGING = make("const/debugging", HexDir.EAST, "qqqqqewaa", OpIsDebugging)
1718

1819
val BREAKPOINT_BEFORE = make("breakpoint/before", HexDir.SOUTH_WEST, "awqdeew", OpBreakpoint(true))
@@ -23,10 +24,23 @@ object HexDebugActions : HexDebugRegistrar<ActionRegistryEntry>(HexRegistries.AC
2324
OpMakePackagedSpell(HexDebugItems.DEBUGGER.value as ItemPackagedHex, 10 * MediaConstants.CRYSTAL_UNIT)
2425
}
2526

27+
// registry stuff
28+
29+
private val patterns = mutableMapOf<ResourceLocation, Pair<HexPattern, () -> Action>>()
30+
2631
private fun make(name: String, startDir: HexDir, signature: String, action: Action) =
2732
make(name, startDir, signature) { action }
2833

29-
private fun make(name: String, startDir: HexDir, signature: String, getAction: () -> Action) = register(name) {
30-
ActionRegistryEntry(HexPattern.fromAngles(signature, startDir), getAction())
34+
private fun make(name: String, startDir: HexDir, signature: String, getAction: () -> Action): PatternIota {
35+
val pattern = HexPattern.fromAngles(signature, startDir)
36+
patterns[HexDebug.id(name)] = Pair(pattern, getAction)
37+
return PatternIota(pattern)
38+
}
39+
40+
fun init() {
41+
for ((location, value) in patterns) {
42+
val (pattern, getAction) = value
43+
PatternRegistry.mapPattern(pattern, location, getAction())
44+
}
3145
}
3246
}

Common/src/main/kotlin/gay/object/hexdebug/registry/HexDebugContinuationTypes.kt

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
11
package gay.`object`.hexdebug.registry
22

33
import dev.architectury.registry.CreativeTabRegistry
4-
import net.minecraft.core.registries.BuiltInRegistries
5-
import net.minecraft.core.registries.Registries
6-
import net.minecraft.network.chat.Component
4+
import gay.`object`.hexdebug.HexDebug
75
import net.minecraft.world.item.CreativeModeTab
86

9-
object HexDebugCreativeTabs : HexDebugRegistrar<CreativeModeTab>(
10-
Registries.CREATIVE_MODE_TAB,
11-
{ BuiltInRegistries.CREATIVE_MODE_TAB },
12-
) {
13-
val HEX_DEBUG = make("hexdebug") {
14-
icon { HexDebugItems.DEBUGGER.value.noIconsInstance }
15-
displayItems { _, output ->
16-
output.accept(HexDebugItems.DEBUGGER.value.defaultInstance)
17-
}
18-
}
19-
20-
@Suppress("SameParameterValue")
21-
private fun make(name: String, action: CreativeModeTab.Builder.() -> Unit) = register(name) {
22-
CreativeTabRegistry.create { builder ->
23-
builder.title(Component.translatable("itemGroup.$name"))
24-
action.invoke(builder)
25-
}
7+
object HexDebugCreativeTabs {
8+
val HEX_DEBUG: CreativeModeTab = CreativeTabRegistry.create(HexDebug.id("hexdebug")) {
9+
HexDebugItems.DEBUGGER.value.noIconsInstance
2610
}
2711
}

Common/src/main/kotlin/gay/object/hexdebug/registry/HexDebugItems.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ import dev.architectury.platform.Platform
44
import dev.architectury.registry.item.ItemPropertiesRegistry
55
import gay.`object`.hexdebug.items.ItemDebugger
66
import net.fabricmc.api.EnvType
7-
import net.minecraft.core.registries.BuiltInRegistries
8-
import net.minecraft.core.registries.Registries
7+
import net.minecraft.core.Registry
98
import net.minecraft.resources.ResourceLocation
109
import net.minecraft.world.item.Item
1110
import net.minecraft.world.item.Item.Properties
1211

13-
object HexDebugItems : HexDebugRegistrar<Item>(Registries.ITEM, { BuiltInRegistries.ITEM }) {
12+
object HexDebugItems : HexDebugRegistrar<Item>(Registry.ITEM_REGISTRY, { Registry.ITEM }) {
1413
@JvmField
15-
val DEBUGGER = register("debugger") { ItemDebugger(unstackable) }
14+
val DEBUGGER = register("debugger") {
15+
ItemDebugger(unstackable.tab(HexDebugCreativeTabs.HEX_DEBUG))
16+
}
1617

1718
// TODO: maybe we should have our own tab, but I'm gonna be lazy for now
1819
private val props get() = Properties()

Common/src/main/resources/assets/hexdebug/lang/en_us.flatten.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
debugger: "Debugger",
44
},
55

6-
"itemGroup.hexdebug": "HexDebug",
6+
"itemGroup.hexdebug.hexdebug": "HexDebug",
77

88
text: {
99
hexdebug: {

Common/src/main/resources/assets/hexdebug/lang/zh_cn.flatten.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
debugger: "调试杖",
44
},
55

6-
"itemGroup.hexdebug": "咒术调试",
6+
"itemGroup.hexdebug.hexdebug": "咒术调试",
77

88
text: {
99
hexdebug: {

0 commit comments

Comments
 (0)