Skip to content

Commit 8743fbd

Browse files
committed
Fix errors from 0.2.0 backport
1 parent 54eeb54 commit 8743fbd

File tree

10 files changed

+82
-71
lines changed

10 files changed

+82
-71
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"parent": "minecraft:recipes/root",
3+
"criteria": {
4+
"has_item": {
5+
"conditions": {
6+
"items": [
7+
{
8+
"tag": "hexcasting:staves"
9+
}
10+
]
11+
},
12+
"trigger": "minecraft:inventory_changed"
13+
},
14+
"has_the_recipe": {
15+
"conditions": {
16+
"recipe": "hexdebug:evaluator"
17+
},
18+
"trigger": "minecraft:recipe_unlocked"
19+
}
20+
},
21+
"requirements": [
22+
[
23+
"has_item",
24+
"has_the_recipe"
25+
]
26+
],
27+
"rewards": {
28+
"recipes": [
29+
"hexdebug:evaluator"
30+
]
31+
}
32+
}

Common/src/generated/resources/data/hexdebug/recipes/evaluator.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"type": "minecraft:crafting_shaped",
3-
"category": "equipment",
43
"key": {
54
"C": {
65
"item": "hexcasting:charged_amethyst"
@@ -19,6 +18,5 @@
1918
],
2019
"result": {
2120
"item": "hexdebug:evaluator"
22-
},
23-
"show_notification": true
21+
}
2422
}

Common/src/main/java/gay/object/hexdebug/mixin/MixinStaffCastEnv.java renamed to Common/src/main/java/gay/object/hexdebug/mixin/MixinMsgNewSpellPatternSyn.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package gay.object.hexdebug.mixin;
22

3-
import at.petrak.hexcasting.api.casting.eval.ResolvedPattern;
4-
import at.petrak.hexcasting.api.casting.eval.env.StaffCastEnv;
5-
import at.petrak.hexcasting.api.casting.math.HexCoord;
63
import at.petrak.hexcasting.api.mod.HexStatistics;
7-
import at.petrak.hexcasting.common.msgs.MsgNewSpellPatternC2S;
4+
import at.petrak.hexcasting.api.spell.casting.ResolvedPattern;
5+
import at.petrak.hexcasting.api.spell.math.HexCoord;
6+
import at.petrak.hexcasting.common.network.MsgNewSpellPatternSyn;
87
import gay.object.hexdebug.items.ItemEvaluator;
98
import gay.object.hexdebug.registry.HexDebugItems;
9+
import net.minecraft.server.MinecraftServer;
1010
import net.minecraft.server.level.ServerPlayer;
1111
import org.spongepowered.asm.mixin.Mixin;
1212
import org.spongepowered.asm.mixin.injection.At;
@@ -16,14 +16,17 @@
1616
import java.util.HashSet;
1717
import java.util.List;
1818

19-
@Mixin(StaffCastEnv.class)
20-
public abstract class MixinStaffCastEnv {
21-
@Inject(method = "handleNewPatternOnServer", at = @At("HEAD"), cancellable = true)
22-
private static void handleNewEvaluatorPatternOnServer$hexdebug(
19+
@Mixin(MsgNewSpellPatternSyn.class)
20+
public abstract class MixinMsgNewSpellPatternSyn {
21+
@SuppressWarnings("UnreachableCode")
22+
@Inject(method = "handle", at = @At("HEAD"), cancellable = true)
23+
private void handleNewEvaluatorPatternOnServer$hexdebug(
24+
MinecraftServer server,
2325
ServerPlayer sender,
24-
MsgNewSpellPatternC2S msg,
2526
CallbackInfo ci
2627
) {
28+
var msg = (MsgNewSpellPatternSyn) (Object) this;
29+
2730
var item = sender.getItemInHand(msg.handUsed()).getItem();
2831
if (item != HexDebugItems.EVALUATOR.getValue()) return;
2932

Common/src/main/kotlin/gay/object/hexdebug/adapter/DebugAdapter.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package gay.`object`.hexdebug.adapter
22

3-
import at.petrak.hexcasting.api.casting.SpellList
4-
import at.petrak.hexcasting.api.casting.eval.ExecutionClientView
5-
import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType
6-
import at.petrak.hexcasting.api.casting.iota.Iota
7-
import at.petrak.hexcasting.api.casting.iota.PatternIota
8-
import at.petrak.hexcasting.api.casting.math.HexPattern
9-
import at.petrak.hexcasting.common.msgs.MsgNewSpellPatternS2C
3+
import at.petrak.hexcasting.api.spell.SpellList
4+
import at.petrak.hexcasting.api.spell.casting.ControllerInfo
5+
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType
6+
import at.petrak.hexcasting.api.spell.iota.Iota
7+
import at.petrak.hexcasting.api.spell.iota.PatternIota
8+
import at.petrak.hexcasting.api.spell.math.HexPattern
9+
import at.petrak.hexcasting.common.network.MsgNewSpellPatternAck
1010
import at.petrak.hexcasting.xplat.IXplatAbstractions
1111
import gay.`object`.hexdebug.HexDebug
1212
import gay.`object`.hexdebug.adapter.DebugAdapterState.*
@@ -65,8 +65,8 @@ open class DebugAdapter(val player: ServerPlayer) : IDebugProtocolServer {
6565

6666
// close the debugger grid if we stopped debugging
6767
if (debuggerState == ItemDebugger.DebugState.NOT_DEBUGGING) {
68-
val info = ExecutionClientView(true, ResolvedPatternType.EVALUATED, listOf(), null)
69-
IXplatAbstractions.INSTANCE.sendPacketToPlayer(player, MsgNewSpellPatternS2C(info, -1))
68+
val info = ControllerInfo(true, ResolvedPatternType.EVALUATED, listOf(), listOf(), null, 0)
69+
IXplatAbstractions.INSTANCE.sendPacketToPlayer(player, MsgNewSpellPatternAck(info, -1))
7070
}
7171
}
7272

@@ -141,9 +141,9 @@ open class DebugAdapter(val player: ServerPlayer) : IDebugProtocolServer {
141141
?: ResponseError(ResponseErrorCode.InternalError, e.toString(), e.stackTraceToString())
142142
}
143143

144-
private fun handleDebuggerStep(result: DebugStepResult?): ExecutionClientView? {
144+
private fun handleDebuggerStep(result: DebugStepResult?): ControllerInfo? {
145145
val view = debugger?.getClientView()?.also {
146-
IXplatAbstractions.INSTANCE.sendPacketToPlayer(player, MsgNewSpellPatternS2C(it, -1))
146+
IXplatAbstractions.INSTANCE.sendPacketToPlayer(player, MsgNewSpellPatternAck(it, -1))
147147
}
148148

149149
if (result == null) {

Common/src/main/kotlin/gay/object/hexdebug/debugger/HexDebugger.kt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ package gay.`object`.hexdebug.debugger
33
import at.petrak.hexcasting.api.PatternRegistry
44
import at.petrak.hexcasting.api.spell.Action
55
import at.petrak.hexcasting.api.spell.SpellList
6-
import at.petrak.hexcasting.api.spell.casting.CastingHarness
6+
import at.petrak.hexcasting.api.spell.casting.*
77
import at.petrak.hexcasting.api.spell.casting.CastingHarness.CastResult
8-
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType
9-
import at.petrak.hexcasting.api.spell.casting.SpecialPatterns
108
import at.petrak.hexcasting.api.spell.casting.eval.*
119
import at.petrak.hexcasting.api.spell.casting.eval.SpellContinuation.Done
1210
import at.petrak.hexcasting.api.spell.casting.eval.SpellContinuation.NotDone
@@ -72,7 +70,7 @@ class HexDebugger(
7270

7371
val evaluatorUIPatterns = mutableListOf<ResolvedPattern>()
7472

75-
private var evaluatorResetData: Pair<SpellContinuation, CastingImage>? = null
73+
private var evaluatorResetData: Pair<SpellContinuation, FunctionalData>? = null
7674

7775
private var lastResolutionType = ResolvedPatternType.UNRESOLVED
7876

@@ -338,10 +336,10 @@ class HexDebugger(
338336
}
339337
}
340338

341-
fun getClientView(): ExecutionClientView {
342-
val (stackDescs, ravenmind) = vm.generateDescs()
339+
fun getClientView(): ControllerInfo {
340+
val (stackDescs, parenthesized, ravenmind) = vm.generateDescs()
343341
val isStackClear = nextContinuation is Done // only close the window if we're done evaluating
344-
return ExecutionClientView(isStackClear, lastResolutionType, stackDescs, ravenmind)
342+
return ControllerInfo(isStackClear, lastResolutionType, stackDescs, parenthesized, ravenmind, vm.parenCount)
345343
}
346344

347345
/**
@@ -350,7 +348,7 @@ class HexDebugger(
350348
internal fun evaluate(list: SpellList): DebugStepResult? {
351349
val startedEvaluating = evaluatorResetData == null
352350
if (startedEvaluating) {
353-
evaluatorResetData = Pair(nextContinuation, vm.image)
351+
evaluatorResetData = Pair(nextContinuation, vm.getFunctionalData())
354352
}
355353
nextContinuation = nextContinuation.pushFrame(FrameEvaluate(list, false))
356354
return executeOnce()?.copy(startedEvaluating = startedEvaluating)
@@ -362,7 +360,7 @@ class HexDebugger(
362360
internal fun resetEvaluator() {
363361
evaluatorResetData?.also { (continuation, image) ->
364362
nextContinuation = continuation
365-
vm.image = image
363+
vm.applyFunctionalData(image)
366364
evaluatorResetData = null
367365
}
368366
evaluatorUIPatterns.clear()

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

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

3-
import at.petrak.hexcasting.api.casting.ParticleSpray
43
import at.petrak.hexcasting.common.items.ItemStaff
54
import at.petrak.hexcasting.common.lib.HexSounds
6-
import at.petrak.hexcasting.common.msgs.*
5+
import at.petrak.hexcasting.common.network.MsgNewSpellPatternAck
6+
import at.petrak.hexcasting.common.network.MsgNewSpellPatternSyn
7+
import at.petrak.hexcasting.common.network.MsgOpenSpellGuiAck
78
import at.petrak.hexcasting.xplat.IXplatAbstractions
89
import gay.`object`.hexdebug.HexDebug
910
import gay.`object`.hexdebug.adapter.DebugAdapterManager
@@ -17,15 +18,14 @@ import net.minecraft.world.InteractionResultHolder
1718
import net.minecraft.world.entity.player.Player
1819
import net.minecraft.world.item.ItemStack
1920
import net.minecraft.world.level.Level
20-
import net.minecraft.world.phys.Vec3
2121

2222
class ItemEvaluator(properties: Properties) : ItemStaff(properties) {
2323
override fun use(world: Level, player: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
2424
val itemStack = player.getItemInHand(hand)
2525

2626
if (world.isClientSide) {
2727
if (player.isShiftKeyDown) {
28-
player.playSound(HexSounds.STAFF_RESET, 1f, 1f)
28+
player.playSound(HexSounds.FAIL_PATTERN, 1f, 1f)
2929
}
3030
return InteractionResultHolder.success(itemStack)
3131
}
@@ -40,16 +40,12 @@ class ItemEvaluator(properties: Properties) : ItemStaff(properties) {
4040

4141
if (player.isShiftKeyDown) {
4242
debugAdapter.resetEvaluator()
43-
MsgClearSpiralPatternsS2C(player.uuid).also {
44-
IXplatAbstractions.INSTANCE.sendPacketToPlayer(player, it)
45-
IXplatAbstractions.INSTANCE.sendPacketTracking(player, it)
46-
}
4743
}
4844

4945
val patterns = debugger.evaluatorUIPatterns
50-
val (stack, ravenmind) = debugger.vm.generateDescs()
46+
val (stack, parenthesized, ravenmind) = debugger.vm.generateDescs()
5147
IXplatAbstractions.INSTANCE.sendPacketToPlayer(
52-
player, MsgOpenSpellGuiS2C(hand, patterns, stack, ravenmind, 0)
48+
player, MsgOpenSpellGuiAck(hand, patterns, stack, parenthesized, ravenmind, debugger.vm.parenCount)
5349
)
5450

5551
player.awardStat(Stats.ITEM_USED[this])
@@ -66,16 +62,16 @@ class ItemEvaluator(properties: Properties) : ItemStaff(properties) {
6662
EVAL_STATE_PREDICATE to ClampedItemPropertyFunction { _, _, entity, _ ->
6763
// don't show the active icon for debuggers held by other players, on the ground, etc
6864
val state = if (entity is LocalPlayer) evalState else EvalState.DEFAULT
69-
state.itemPredicate
65+
state.itemPredicate(EvalState.values())
7066
},
7167
)
7268

7369
/**
74-
* Copy of [StaffCastEnv.handleNewPatternOnServer][at.petrak.hexcasting.api.casting.eval.env.StaffCastEnv.handleNewPatternOnServer]
70+
* Copy of [MsgNewSpellPatternSyn.handle][at.petrak.hexcasting.common.network.MsgNewSpellPatternSyn.handle]
7571
* for evaluating patterns in the active debugger, if any.
7672
*/
7773
@JvmStatic
78-
fun handleNewPatternOnServer(sender: ServerPlayer, msg: MsgNewSpellPatternC2S) {
74+
fun handleNewPatternOnServer(sender: ServerPlayer, msg: MsgNewSpellPatternSyn) {
7975
val debugAdapter = DebugAdapterManager[sender]
8076
val debugger = debugAdapter?.debugger
8177
if (debugAdapter == null || debugger == null) {
@@ -91,21 +87,8 @@ class ItemEvaluator(properties: Properties) : ItemStaff(properties) {
9187
}
9288

9389
IXplatAbstractions.INSTANCE.sendPacketToPlayer(
94-
sender, MsgNewSpellPatternS2C(clientInfo, msg.resolvedPatterns.size - 1)
90+
sender, MsgNewSpellPatternAck(clientInfo, msg.resolvedPatterns.size - 1)
9591
)
96-
97-
val packet = if (clientInfo.isStackClear) {
98-
MsgClearSpiralPatternsS2C(sender.uuid)
99-
} else {
100-
MsgNewSpiralPatternsS2C(sender.uuid, listOf(msg.pattern()), Integer.MAX_VALUE)
101-
}
102-
IXplatAbstractions.INSTANCE.sendPacketToPlayer(sender, packet)
103-
IXplatAbstractions.INSTANCE.sendPacketTracking(sender, packet)
104-
105-
if (clientInfo.resolutionType.success) {
106-
ParticleSpray(sender.position(), Vec3(0.0, 1.5, 0.0), 0.4, Math.PI / 3, 30)
107-
.sprayParticles(sender.serverLevel(), IXplatAbstractions.INSTANCE.getPigment(sender))
108-
}
10992
}
11093
}
11194

Common/src/main/resources/hexdebug-common.mixins.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"MixinMsgShiftScrollSyn",
1414
"MixinOpEval",
1515
"MixinOpPrintSpell",
16-
"MixinStaffCastEnv"
16+
"MixinMsgNewSpellPatternSyn"
1717
],
1818
"injectors": {
1919
"defaultRequire": 1

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class HexDebugForge {
3131
val efh = existingFileHelper
3232
addProvider(includeClient()) { HexDebugModels(it, efh) }
3333
addProvider(includeServer()) { HexDebugRecipes(it) }
34-
addProvider(includeServer()) { HexDebugItemTags(it, lookupProvider, efh) }
34+
addProvider(includeServer()) { HexDebugItemTags(it, efh) }
3535
}
3636
}
3737
}

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,17 @@ package gay.`object`.hexdebug.forge.datagen
33
import at.petrak.hexcasting.api.mod.HexTags
44
import gay.`object`.hexdebug.HexDebug
55
import gay.`object`.hexdebug.registry.HexDebugItems
6-
import net.minecraft.core.HolderLookup
7-
import net.minecraft.core.registries.Registries
8-
import net.minecraft.data.PackOutput
6+
import net.minecraft.core.Registry
7+
import net.minecraft.data.DataGenerator
98
import net.minecraft.data.tags.TagsProvider
109
import net.minecraft.world.item.Item
1110
import net.minecraftforge.common.data.ExistingFileHelper
12-
import java.util.concurrent.CompletableFuture
1311

1412
class HexDebugItemTags(
15-
output: PackOutput,
16-
registries: CompletableFuture<HolderLookup.Provider>,
13+
gen: DataGenerator,
1714
efh: ExistingFileHelper,
18-
) : TagsProvider<Item>(output, Registries.ITEM, registries, HexDebug.MODID, efh) {
19-
override fun addTags(provider: HolderLookup.Provider) {
15+
) : TagsProvider<Item>(gen, Registry.ITEM, HexDebug.MODID, efh) {
16+
override fun addTags() {
2017
tag(HexTags.Items.STAVES)
2118
.add(HexDebugItems.EVALUATOR.key)
2219
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class HexDebugModels(gen: DataGenerator, efh: ExistingFileHelper) : ItemModelPro
6767

6868
val basePath = baseModel.location.path
6969

70-
for (evalState in EvalState.entries) {
70+
for (evalState in EvalState.values()) {
7171
val evalStateName = evalState.name.lowercase()
7272

7373
val model = getBuilder("$basePath/$evalStateName")
@@ -79,7 +79,7 @@ class HexDebugModels(gen: DataGenerator, efh: ExistingFileHelper) : ItemModelPro
7979

8080
baseModel.override()
8181
.model(model)
82-
.predicate(ItemEvaluator.EVAL_STATE_PREDICATE, evalState.itemPredicate)
82+
.predicate(ItemEvaluator.EVAL_STATE_PREDICATE, evalState.itemPredicate(EvalState.values()))
8383
}
8484
}
8585
}

0 commit comments

Comments
 (0)