diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadCaster.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadCaster.kt new file mode 100644 index 0000000000..99199f9561 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadCaster.kt @@ -0,0 +1,17 @@ +package at.petrak.hexcasting.api.casting.mishaps + +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.pigment.FrozenPigment +import net.minecraft.world.item.DyeColor + +class MishapBadCaster: Mishap() { + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment = + dyeColor(DyeColor.RED) + + override fun execute(env: CastingEnvironment, errorCtx: Context, stack: MutableList) { + } + + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = + error("bad_caster") +} \ No newline at end of file diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/sentinel/OpCreateSentinel.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/sentinel/OpCreateSentinel.kt index 1c0b2793cd..3b45740587 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/sentinel/OpCreateSentinel.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/sentinel/OpCreateSentinel.kt @@ -6,6 +6,7 @@ import at.petrak.hexcasting.api.casting.castables.SpellAction import at.petrak.hexcasting.api.casting.eval.CastingEnvironment import at.petrak.hexcasting.api.casting.getVec3 import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.mishaps.MishapBadCaster import at.petrak.hexcasting.api.misc.MediaConstants import at.petrak.hexcasting.api.player.Sentinel import at.petrak.hexcasting.xplat.IXplatAbstractions @@ -19,6 +20,9 @@ class OpCreateSentinel(val extendsRange: Boolean) : SpellAction { args: List, env: CastingEnvironment ): SpellAction.Result { + if (env.castingEntity !is ServerPlayer) + throw MishapBadCaster() + val target = args.getVec3(0, argc) env.assertVecInRange(target) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/sentinel/OpDestroySentinel.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/sentinel/OpDestroySentinel.kt index 97aaf692c4..43785a2adb 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/sentinel/OpDestroySentinel.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/sentinel/OpDestroySentinel.kt @@ -5,6 +5,7 @@ import at.petrak.hexcasting.api.casting.RenderedSpell import at.petrak.hexcasting.api.casting.castables.SpellAction import at.petrak.hexcasting.api.casting.eval.CastingEnvironment import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.mishaps.MishapBadCaster import at.petrak.hexcasting.api.casting.mishaps.MishapLocationInWrongDimension import at.petrak.hexcasting.api.misc.MediaConstants import at.petrak.hexcasting.xplat.IXplatAbstractions @@ -16,6 +17,9 @@ object OpDestroySentinel : SpellAction { args: List, env: CastingEnvironment ): SpellAction.Result { + if (env.castingEntity !is ServerPlayer) + throw MishapBadCaster() + val sentinel = IXplatAbstractions.INSTANCE.getSentinel(env.castingEntity as? ServerPlayer) // TODO why can't you remove things from other dimensions? diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/sentinel/OpGetSentinelPos.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/sentinel/OpGetSentinelPos.kt index b038aa92bf..fa56812ca5 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/sentinel/OpGetSentinelPos.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/sentinel/OpGetSentinelPos.kt @@ -5,6 +5,7 @@ import at.petrak.hexcasting.api.casting.castables.ConstMediaAction import at.petrak.hexcasting.api.casting.eval.CastingEnvironment import at.petrak.hexcasting.api.casting.iota.Iota import at.petrak.hexcasting.api.casting.iota.NullIota +import at.petrak.hexcasting.api.casting.mishaps.MishapBadCaster import at.petrak.hexcasting.api.casting.mishaps.MishapLocationInWrongDimension import at.petrak.hexcasting.api.misc.MediaConstants import at.petrak.hexcasting.xplat.IXplatAbstractions @@ -14,6 +15,9 @@ object OpGetSentinelPos : ConstMediaAction { override val argc = 0 override val mediaCost: Long = MediaConstants.DUST_UNIT / 10 override fun execute(args: List, env: CastingEnvironment): List { + if (env.castingEntity !is ServerPlayer) + throw MishapBadCaster() + val sentinel = IXplatAbstractions.INSTANCE.getSentinel(env.castingEntity as? ServerPlayer) ?: return listOf(NullIota()) if (sentinel.dimension != env.world.dimension()) throw MishapLocationInWrongDimension(sentinel.dimension.location()) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/sentinel/OpGetSentinelWayfind.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/sentinel/OpGetSentinelWayfind.kt index 87eb1547cb..cad52447ed 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/sentinel/OpGetSentinelWayfind.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/sentinel/OpGetSentinelWayfind.kt @@ -6,6 +6,7 @@ import at.petrak.hexcasting.api.casting.eval.CastingEnvironment import at.petrak.hexcasting.api.casting.getVec3 import at.petrak.hexcasting.api.casting.iota.Iota import at.petrak.hexcasting.api.casting.iota.NullIota +import at.petrak.hexcasting.api.casting.mishaps.MishapBadCaster import at.petrak.hexcasting.api.casting.mishaps.MishapLocationInWrongDimension import at.petrak.hexcasting.api.misc.MediaConstants import at.petrak.hexcasting.xplat.IXplatAbstractions @@ -17,6 +18,9 @@ object OpGetSentinelWayfind : ConstMediaAction { override val argc = 1 override val mediaCost: Long = MediaConstants.DUST_UNIT / 10 override fun execute(args: List, env: CastingEnvironment): List { + if (env.castingEntity !is ServerPlayer) + throw MishapBadCaster() + val from = args.getVec3(0, argc) val sentinel = IXplatAbstractions.INSTANCE.getSentinel(env.castingEntity as? ServerPlayer) ?: return listOf(NullIota()) diff --git a/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 b/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 index 7b98d7825d..7807a6e802 100644 --- a/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 +++ b/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 @@ -921,6 +921,7 @@ invalid_spell_datum_type: "Tried to use a value of invalid type as a SpellDatum: %s (class %s). This is a bug in the mod.", unknown: "threw an exception (%s). This is a bug in the mod.", stack_size: "Exceeded the size limit of the stack", + bad_caster: "Tried to execute a pattern that requires a greater mind", invalid_value: { "": "expected %s at index %s of the stack, but got %s",