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

32 lines
1.3 KiB
Kotlin
Raw Normal View History

package at.petrak.hexcasting.api.casting.mishaps
2022-03-26 17:45:31 +01:00
2023-01-22 03:29:09 +01:00
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.pigment.FrozenPigment
import at.petrak.hexcasting.api.utils.asTranslatedComponent
2022-03-26 17:45:31 +01:00
import net.minecraft.network.chat.Component
import net.minecraft.world.InteractionHand
2022-03-26 17:45:31 +01:00
import net.minecraft.world.item.DyeColor
import net.minecraft.world.item.ItemStack
class MishapBadOffhandItem(val item: ItemStack, val hand: InteractionHand?, val wanted: Component) : Mishap() {
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
2022-03-26 17:45:31 +01:00
dyeColor(DyeColor.BROWN)
2023-01-22 03:29:09 +01:00
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
2023-02-15 07:26:28 +01:00
ctx.mishapEnvironment.dropHeldItems()
2022-03-26 17:45:31 +01:00
}
2023-01-22 03:29:09 +01:00
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = if (item.isEmpty)
error("no_item.offhand", wanted)
else
error("bad_item.offhand", wanted, item.count, item.displayName)
2022-03-26 17:45:31 +01:00
companion object {
@JvmStatic
fun of(item: ItemStack, hand: InteractionHand?, stub: String, vararg args: Any): MishapBadOffhandItem {
return MishapBadOffhandItem(item, hand, "hexcasting.mishap.bad_item.$stub".asTranslatedComponent(*args))
}
}
2022-04-09 18:42:38 +02:00
}