Skip to content

Commit 8a71cb5

Browse files
committed
Make out of media actually withdraw as much as possible
1 parent 6ef02d7 commit 8a71cb5

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

Common/src/main/java/at/petrak/hexcasting/api/casting/castables/ConstMediaAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ interface ConstMediaAction : Action {
2929
val stack = image.stack.toMutableList()
3030

3131
if (env.extractMedia(this.mediaCost, true) > 0)
32-
throw MishapNotEnoughMedia()
32+
throw MishapNotEnoughMedia(this.mediaCost)
3333
if (this.argc > stack.size)
3434
throw MishapNotEnoughArgs(this.argc, stack.size)
3535
val args = stack.takeLast(this.argc)

Common/src/main/java/at/petrak/hexcasting/api/casting/castables/SpellAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ interface SpellAction : Action {
4646
val sideEffects = mutableListOf<OperatorSideEffect>()
4747

4848
if (env.extractMedia(result.cost, true) > 0)
49-
throw MishapNotEnoughMedia()
49+
throw MishapNotEnoughMedia(result.cost)
5050
if (result.cost > 0)
5151
sideEffects.add(OperatorSideEffect.ConsumeMedia(result.cost))
5252

Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapNotEnoughMedia.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import at.petrak.hexcasting.api.pigment.FrozenPigment
77
import at.petrak.hexcasting.api.utils.asTranslatedComponent
88
import net.minecraft.world.item.DyeColor
99

10-
class MishapNotEnoughMedia : Mishap() {
10+
class MishapNotEnoughMedia(private val cost: Long) : Mishap() {
1111
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
1212
dyeColor(DyeColor.RED)
1313

1414
override fun resolutionType(ctx: CastingEnvironment) = ResolvedPatternType.ERRORED
1515

1616
override fun execute(env: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
17+
env.extractMedia(cost, false)
1718
}
1819

1920
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = "hexcasting.message.cant_overcast".asTranslatedComponent

0 commit comments

Comments
 (0)