actually make it so you can't write other people to foci

This commit is contained in:
gamma-delta 2022-03-25 11:51:19 -05:00
parent 20f74d5762
commit 92cb8ff917
3 changed files with 11 additions and 1 deletions

View file

@ -108,6 +108,11 @@ class CastException(val reason: Reason, vararg val data: Any) : Exception() {
* No spell circles??
*/
NO_SPELL_CIRCLE,
/**
* No writing someone else's name!
*/
NO_WRITING_OTHER_NAMES
}
override val message: String
@ -126,5 +131,6 @@ class CastException(val reason: Reason, vararg val data: Any) : Exception() {
Reason.REQUIRES_INVENTORY -> "required an inventory at ${this.data[0] as BlockPos}"
Reason.RECIPE_DIDNT_WORK -> "bad recipe"
Reason.NO_SPELL_CIRCLE -> "requires a spell circle to cast"
Reason.NO_WRITING_OTHER_NAMES -> "can't write someone else's Name"
}
}

View file

@ -62,7 +62,7 @@ sealed class OperatorSideEffect {
data class Mishap(val exn: CastException) : OperatorSideEffect() {
override fun performEffect(harness: CastingHarness): Boolean {
harness.ctx.caster.sendMessage(
TextComponent(exn.toString()),
TextComponent(exn.message),
Util.NIL_UUID
)

View file

@ -11,6 +11,7 @@ import at.petrak.hexcasting.common.items.HexItems
import at.petrak.hexcasting.common.items.ItemDataHolder
import at.petrak.hexcasting.common.items.ItemScroll
import at.petrak.hexcasting.hexmath.HexPattern
import net.minecraft.world.entity.player.Player
// we make this a spell cause imo it's a little ... anticlimactic for it to just make no noise
object OpWrite : SpellOperator {
@ -45,6 +46,9 @@ object OpWrite : SpellOperator {
if (!canWrite)
throw CastException(CastException.Reason.BAD_OFFHAND_ITEM, ItemDataHolder::class.java, handStack)
if (datum.payload is Player && datum.payload != ctx.caster)
throw CastException(CastException.Reason.NO_WRITING_OTHER_NAMES)
return Triple(
Spell(datum),
0,