Skip to content

Commit 0fb5261

Browse files
committed
It runs!
1 parent 1896ba9 commit 0fb5261

File tree

11 files changed

+35
-63
lines changed

11 files changed

+35
-63
lines changed

Common/src/main/java/gay/object/hexdebug/mixin/MixinCastingContext.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,4 @@ public abstract class MixinCastingContext implements IMixinCastingContext {
7575
public void setLastDebugStepType$hexdebug(@Nullable DebugStepType lastDebugStepType) {
7676
lastDebugStepType$hexdebug = lastDebugStepType;
7777
}
78-
79-
// TODO: are these necessary?
80-
81-
@Override
82-
public void printDebugMessage$hexdebug(@NotNull ServerPlayer caster, @NotNull Component message, @NotNull String category, boolean withSource) {
83-
IMixinCastingContext.super.printDebugMessage$hexdebug(caster, message, category, withSource);
84-
}
85-
86-
@Override
87-
public void reset$hexdebug() {
88-
IMixinCastingContext.super.reset$hexdebug();
89-
}
9078
}

Common/src/main/java/gay/object/hexdebug/mixin/MixinFrameEvaluate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class MixinFrameEvaluate implements IMixinFrameEvaluate {
2727
@Unique
2828
private boolean isFatal$hexdebug = false;
2929

30-
@Inject(method = "breakDownwards", at = @At("HEAD"), cancellable = true)
30+
@Inject(method = "breakDownwards", at = @At("HEAD"), cancellable = true, remap = false)
3131
private void breakDownwardsFrameBreakpoint$hexdebug(
3232
List<Iota> stack,
3333
CallbackInfoReturnable<Pair<Boolean, List<Iota>>> cir

Common/src/main/kotlin/gay/object/hexdebug/items/ItemDebugger.kt

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
package gay.`object`.hexdebug.items
22

3-
import at.petrak.hexcasting.api.casting.iota.ListIota
4-
import at.petrak.hexcasting.api.casting.iota.PatternIota
5-
import at.petrak.hexcasting.api.mod.HexConfig
3+
import at.petrak.hexcasting.api.spell.casting.CastingContext
4+
import at.petrak.hexcasting.api.spell.iota.ListIota
65
import at.petrak.hexcasting.api.utils.getBoolean
76
import at.petrak.hexcasting.api.utils.getInt
87
import at.petrak.hexcasting.api.utils.putBoolean
98
import at.petrak.hexcasting.api.utils.putInt
109
import at.petrak.hexcasting.common.items.magic.ItemPackagedHex
11-
import at.petrak.hexcasting.common.msgs.MsgNewSpiralPatternsS2C
1210
import at.petrak.hexcasting.xplat.IXplatAbstractions
1311
import gay.`object`.hexdebug.HexDebug
1412
import gay.`object`.hexdebug.adapter.DebugAdapterManager
15-
import gay.`object`.hexdebug.casting.eval.DebugItemCastEnv
1613
import gay.`object`.hexdebug.debugger.CastArgs
1714
import gay.`object`.hexdebug.utils.getWrapping
1815
import gay.`object`.hexdebug.utils.itemPredicate
@@ -37,8 +34,6 @@ class ItemDebugger(properties: Properties) : ItemPackagedHex(properties) {
3734

3835
override fun breakAfterDepletion() = false
3936

40-
override fun cooldown() = HexConfig.common().artifactCooldown()
41-
4237
override fun isFoil(stack: ItemStack) = false
4338

4439
override fun getRarity(stack: ItemStack) = Rarity.RARE
@@ -89,14 +84,8 @@ class ItemDebugger(properties: Properties) : ItemPackagedHex(properties) {
8984
}
9085
} ?: return InteractionResultHolder.fail(stack)
9186

92-
val ctx = DebugItemCastEnv(serverPlayer, usedHand)
93-
val args = CastArgs(instrs, ctx, serverLevel) {
94-
if (it is PatternIota) {
95-
val packet = MsgNewSpiralPatternsS2C(serverPlayer.uuid, listOf(it.pattern), 140)
96-
IXplatAbstractions.INSTANCE.sendPacketToPlayer(serverPlayer, packet)
97-
IXplatAbstractions.INSTANCE.sendPacketTracking(serverPlayer, packet)
98-
}
99-
}
87+
val ctx = CastingContext(serverPlayer, usedHand, CastingContext.CastSource.PACKAGED_HEX)
88+
val args = CastArgs(instrs, ctx, serverLevel) {}
10089

10190
if (!debugAdapter.startDebugging(args)) {
10291
return noClient(player, stack)
@@ -108,7 +97,7 @@ class ItemDebugger(properties: Properties) : ItemPackagedHex(properties) {
10897
val stat = Stats.ITEM_USED[this]
10998
player.awardStat(stat)
11099

111-
serverPlayer.cooldowns.addCooldown(this, this.cooldown())
100+
serverPlayer.cooldowns.addCooldown(this, 5)
112101
return InteractionResultHolder.consume(stack)
113102
}
114103

@@ -135,12 +124,12 @@ class ItemDebugger(properties: Properties) : ItemPackagedHex(properties) {
135124

136125
private fun rotateStepMode(stack: ItemStack, increase: Boolean): StepMode {
137126
val idx = getStepModeIdx(stack) + (if (increase) 1 else -1)
138-
return StepMode.entries.getWrapping(idx).also {
127+
return StepMode.values().getWrapping(idx).also {
139128
stack.putInt(STEP_MODE_TAG, it.ordinal)
140129
}
141130
}
142131

143-
private fun getStepMode(stack: ItemStack) = StepMode.entries.getWrapping(getStepModeIdx(stack))
132+
private fun getStepMode(stack: ItemStack) = StepMode.values().getWrapping(getStepModeIdx(stack))
144133

145134
private fun getStepModeIdx(stack: ItemStack) = stack.getInt(STEP_MODE_TAG)
146135

@@ -171,10 +160,10 @@ class ItemDebugger(properties: Properties) : ItemPackagedHex(properties) {
171160
DEBUG_STATE_PREDICATE to ClampedItemPropertyFunction { _, _, entity, _ ->
172161
// don't show the active icon for debuggers held by other players, on the ground, etc
173162
val state = if (entity is LocalPlayer) debugState else DebugState.NOT_DEBUGGING
174-
state.itemPredicate
163+
state.itemPredicate(DebugState.values())
175164
},
176165
STEP_MODE_PREDICATE to ClampedItemPropertyFunction { stack, _, _, _ ->
177-
item.getStepMode(stack).itemPredicate
166+
item.getStepMode(stack).itemPredicate(StepMode.values())
178167
},
179168
HAS_HEX_PREDICATE to ClampedItemPropertyFunction { stack, _, _, _ ->
180169
if (item.hasHex(stack)) 1f else 0f

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import gay.`object`.hexdebug.casting.actions.OpIsDebugging
1414
import net.minecraft.resources.ResourceLocation
1515

1616
object HexDebugActions {
17+
private val patterns = mutableMapOf<ResourceLocation, Pair<HexPattern, () -> Action>>()
18+
1719
val IS_DEBUGGING = make("const/debugging", HexDir.EAST, "qqqqqewaa", OpIsDebugging)
1820

1921
val BREAKPOINT_BEFORE = make("breakpoint/before", HexDir.SOUTH_WEST, "awqdeew", OpBreakpoint(true))
@@ -24,10 +26,6 @@ object HexDebugActions {
2426
OpMakePackagedSpell(HexDebugItems.DEBUGGER.value as ItemPackagedHex, 10 * MediaConstants.CRYSTAL_UNIT)
2527
}
2628

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

Common/src/main/kotlin/gay/object/hexdebug/utils/Extensions.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package gay.`object`.hexdebug.utils
22

33
import net.minecraft.world.InteractionHand
44
import java.util.concurrent.CompletableFuture
5-
import kotlin.enums.enumEntries
65
import kotlin.math.ceil
76
import kotlin.math.log
87
import kotlin.math.pow
@@ -36,11 +35,10 @@ val InteractionHand.otherHand get() = when (this) {
3635
}
3736

3837
// ceil the denominator to a power of 2 so we don't have issues with eg. 1/3
39-
@OptIn(ExperimentalStdlibApi::class)
40-
inline val <reified T : Enum<T>> T.itemPredicate get() =
41-
ordinal.toFloat() / (ceil(enumEntries<T>().lastIndex.toFloat() / 2f) * 2f)
38+
inline fun <reified T : Enum<T>> T.itemPredicate(entries: Array<T>) =
39+
ordinal.toFloat() / (ceil(entries.lastIndex.toFloat() / 2f) * 2f)
4240

43-
inline fun <reified T> List<T>.getWrapping(idx: Int) = this[idx.mod(size)]
41+
inline fun <reified T> Array<T>.getWrapping(idx: Int) = this[idx.mod(size)]
4442

4543
/** Rounds `this` up to the next power of `base`. */
4644
fun Number.ceilToPow(base: Number): Int = toDouble().ceilToPow(base.toDouble())

Fabric/build.gradle.kts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ hexdebugModDependencies {
3434
requires("modmenu")
3535
}
3636

37-
repositories {
38-
flatDir { dir("libs") }
39-
}
40-
4137
dependencies {
4238
modApi(libs.fabric.api)
4339
modImplementation(libs.fabric.loader)
@@ -52,24 +48,27 @@ dependencies {
5248
modImplementation(libs.hexcasting.fabric) {
5349
// If not excluded here, calls a nonexistent method and crashes the dev client
5450
exclude(module = "phosphor")
51+
exclude(module = "pehkui")
5552
}
5653
modImplementation(libs.paucal.fabric)
5754
modImplementation(libs.patchouli.fabric)
5855
modImplementation(libs.cardinalComponents)
5956
modImplementation(libs.serializationHooks)
57+
modImplementation(libs.entityReach)
6058
modImplementation(libs.trinkets)
6159

6260
implementation(libs.mixinExtras)
6361

6462
modApi(libs.clothConfig.fabric) {
65-
exclude(group = "net.fabricmc.fabric-debugger")
63+
exclude(group = "net.fabricmc.fabric-api")
6664
}
6765
modApi(libs.modMenu)
6866

6967
implementation(libs.bundles.lsp4j)
7068
implementation(libs.ktor.network)
7169

7270
include(libs.serializationHooks)
71+
include(libs.entityReach)
7372
include(libs.mixinExtras)
7473
include(libs.bundles.lsp4j)
7574
include(libs.bundles.ktor)
-40.2 KB
Binary file not shown.

Forge/src/main/kotlin/gay/object/hexdebug/forge/ForgeHexDebug.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import dev.architectury.platform.forge.EventBuses
44
import gay.`object`.hexdebug.HexDebug
55
import gay.`object`.hexdebug.forge.datagen.HexDebugModels
66
import gay.`object`.hexdebug.forge.datagen.HexDebugRecipes
7-
import net.minecraft.data.DataProvider.Factory
87
import net.minecraftforge.data.event.GatherDataEvent
98
import net.minecraftforge.fml.common.Mod
109
import thedarkcolour.kotlinforforge.forge.MOD_BUS
@@ -27,8 +26,8 @@ class HexDebugForge {
2726
private fun gatherData(event: GatherDataEvent) {
2827
val efh = event.existingFileHelper
2928
event.generator.apply {
30-
addProvider(event.includeClient(), Factory { HexDebugModels(it, efh) })
31-
addProvider(event.includeServer(), Factory { HexDebugRecipes(it) })
29+
addProvider(event.includeClient(), HexDebugModels(this, efh))
30+
addProvider(event.includeServer(), HexDebugRecipes(this))
3231
}
3332
}
3433
}

Forge/src/main/kotlin/gay/object/hexdebug/forge/datagen/HexDebugModels.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import gay.`object`.hexdebug.items.ItemDebugger.DebugState
88
import gay.`object`.hexdebug.items.ItemDebugger.StepMode
99
import gay.`object`.hexdebug.registry.HexDebugItems
1010
import gay.`object`.hexdebug.utils.itemPredicate
11-
import net.minecraft.data.PackOutput
11+
import net.minecraft.data.DataGenerator
1212
import net.minecraft.resources.ResourceLocation
1313
import net.minecraftforge.client.model.generators.ItemModelProvider
1414
import net.minecraftforge.client.model.generators.ModelBuilder
1515
import net.minecraftforge.common.data.ExistingFileHelper
1616

17-
class HexDebugModels(output: PackOutput, efh: ExistingFileHelper) : ItemModelProvider(output, HexDebug.MODID, efh) {
17+
class HexDebugModels(gen: DataGenerator, efh: ExistingFileHelper) : ItemModelProvider(gen, HexDebug.MODID, efh) {
1818
override fun registerModels() {
1919
debugger(HexDebugItems.DEBUGGER.id)
2020
}
@@ -23,10 +23,10 @@ class HexDebugModels(output: PackOutput, efh: ExistingFileHelper) : ItemModelPro
2323
val baseModel = basicItem(item)
2424
val basePath = baseModel.location.path
2525

26-
for (debugState in DebugState.entries) {
26+
for (debugState in DebugState.values()) {
2727
val debugStateName = debugState.name.lowercase()
2828

29-
for (stepMode in StepMode.entries) {
29+
for (stepMode in StepMode.values()) {
3030
val stepModeName = stepMode.name.lowercase()
3131

3232
for ((hasHex, hasHexName) in mapOf(0f to "empty", 1f to "full")) {
@@ -41,8 +41,8 @@ class HexDebugModels(output: PackOutput, efh: ExistingFileHelper) : ItemModelPro
4141

4242
baseModel.override()
4343
.model(model)
44-
.predicate(ItemDebugger.DEBUG_STATE_PREDICATE, debugState.itemPredicate)
45-
.predicate(ItemDebugger.STEP_MODE_PREDICATE, stepMode.itemPredicate)
44+
.predicate(ItemDebugger.DEBUG_STATE_PREDICATE, debugState.itemPredicate(DebugState.values()))
45+
.predicate(ItemDebugger.STEP_MODE_PREDICATE, stepMode.itemPredicate(StepMode.values()))
4646
.predicate(ItemDebugger.HAS_HEX_PREDICATE, hasHex)
4747
}
4848
}

Forge/src/main/kotlin/gay/object/hexdebug/forge/datagen/HexDebugRecipes.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ import at.petrak.hexcasting.common.lib.HexItems
55
import at.petrak.paucal.api.datagen.PaucalRecipeProvider
66
import gay.`object`.hexdebug.HexDebug
77
import gay.`object`.hexdebug.registry.HexDebugItems
8-
import net.minecraft.data.PackOutput
8+
import net.minecraft.data.DataGenerator
99
import net.minecraft.data.recipes.FinishedRecipe
10-
import net.minecraft.data.recipes.RecipeCategory
1110
import net.minecraft.data.recipes.ShapedRecipeBuilder
1211
import net.minecraft.world.item.Items
1312
import java.util.function.Consumer
1413

15-
class HexDebugRecipes(output: PackOutput) : PaucalRecipeProvider(output, HexDebug.MODID) {
16-
override fun buildRecipes(writer: Consumer<FinishedRecipe>) {
17-
ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, HexDebugItems.DEBUGGER.value)
14+
class HexDebugRecipes(gen: DataGenerator) : PaucalRecipeProvider(gen, HexDebug.MODID) {
15+
override fun makeRecipes(writer: Consumer<FinishedRecipe>) {
16+
ShapedRecipeBuilder.shaped(HexDebugItems.DEBUGGER.value)
1817
.define('G', Items.GOLD_INGOT)
1918
.define('A', HexItems.ARTIFACT)
2019
.define('C', HexItems.CHARGED_AMETHYST)

0 commit comments

Comments
 (0)