close #378
This commit is contained in:
parent
57b415e025
commit
8b0a01e825
|
@ -35,18 +35,34 @@ public interface HexAPI {
|
|||
* Special handlers should be calling {@link SpecialHandler#getName()}
|
||||
*/
|
||||
default String getActionI18nKey(ResourceKey<ActionRegistryEntry> action) {
|
||||
return "hexcasting.spell.%s".formatted(action.location());
|
||||
return "hexcasting.action.%s".formatted(action.location().toString());
|
||||
}
|
||||
|
||||
default String getActionI18nKey(ResourceLocation action) {
|
||||
return "hexcasting.spell.%s".formatted(action.toString());
|
||||
default String getSpecialHandlerI18nKey(ResourceKey<SpecialHandler.Factory<?>> action) {
|
||||
return "hexcasting.special.%s".formatted(action.location().toString());
|
||||
}
|
||||
|
||||
default Component getActionI18(ResourceLocation key, boolean isGreat) {
|
||||
/**
|
||||
* Currently introspection/retrospection/consideration are hardcoded, but at least their names won't be
|
||||
*/
|
||||
default String getRawHookI18nKey(ResourceLocation name) {
|
||||
return "hexcasting.rawhook.%s".formatted(name);
|
||||
}
|
||||
|
||||
default Component getActionI18n(ResourceKey<ActionRegistryEntry> key, boolean isGreat) {
|
||||
return Component.translatable(getActionI18nKey(key))
|
||||
.withStyle(isGreat ? ChatFormatting.GOLD : ChatFormatting.LIGHT_PURPLE);
|
||||
}
|
||||
|
||||
default Component getSpecialHandlerI18n(ResourceKey<SpecialHandler.Factory<?>> key) {
|
||||
return Component.translatable(getSpecialHandlerI18nKey(key))
|
||||
.withStyle(ChatFormatting.LIGHT_PURPLE);
|
||||
}
|
||||
|
||||
default Component getRawHookI18n(ResourceLocation name) {
|
||||
return Component.translatable(getRawHookI18nKey(name)).withStyle(ChatFormatting.LIGHT_PURPLE);
|
||||
}
|
||||
|
||||
static HexAPI instance() {
|
||||
return INSTANCE.get();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
|||
import at.petrak.hexcasting.api.misc.MediaConstants;
|
||||
import at.petrak.hexcasting.api.mod.HexConfig;
|
||||
import at.petrak.hexcasting.api.casting.ParticleSpray;
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext;
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment;
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingHarness;
|
||||
import at.petrak.hexcasting.api.casting.eval.SpellCircleContext;
|
||||
import at.petrak.hexcasting.api.casting.iota.PatternIota;
|
||||
|
@ -282,7 +282,7 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
|
|||
if (player instanceof ServerPlayer splayer) {
|
||||
var bounds = getBounds(this.trackedBlocks);
|
||||
|
||||
var ctx = new CastingContext(splayer, InteractionHand.MAIN_HAND,
|
||||
var ctx = new CastingEnvironment(splayer, InteractionHand.MAIN_HAND,
|
||||
new SpellCircleContext(this.getBlockPos(), bounds, this.activatorAlwaysInRange()));
|
||||
var harness = new CastingHarness(ctx);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.api.casting
|
||||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
|
||||
interface RenderedSpell {
|
||||
fun cast(ctx: CastingContext)
|
||||
fun cast(ctx: CastingEnvironment)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.api.casting.castables
|
||||
|
||||
import at.petrak.hexcasting.api.casting.OperationResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
@ -32,7 +32,7 @@ interface Action {
|
|||
continuation: SpellContinuation,
|
||||
stack: MutableList<Iota>,
|
||||
ravenmind: Iota?,
|
||||
ctx: CastingContext
|
||||
ctx: CastingEnvironment
|
||||
): OperationResult
|
||||
|
||||
companion object {
|
||||
|
@ -49,7 +49,7 @@ interface Action {
|
|||
override val argc: Int
|
||||
get() = 0
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> =
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> =
|
||||
listOf(x)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.api.casting.castables
|
||||
|
||||
import at.petrak.hexcasting.api.casting.OperationResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
|
||||
import at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
@ -15,13 +15,13 @@ interface ConstMediaAction : Action {
|
|||
val mediaCost: Int
|
||||
get() = 0
|
||||
|
||||
fun execute(args: List<Iota>, ctx: CastingContext): List<Iota>
|
||||
fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota>
|
||||
|
||||
override fun operate(
|
||||
continuation: SpellContinuation,
|
||||
stack: MutableList<Iota>,
|
||||
ravenmind: Iota?,
|
||||
ctx: CastingContext
|
||||
ctx: CastingEnvironment
|
||||
): OperationResult {
|
||||
if (this.argc > stack.size)
|
||||
throw MishapNotEnoughArgs(this.argc, stack.size)
|
||||
|
|
|
@ -3,7 +3,7 @@ package at.petrak.hexcasting.api.casting.castables
|
|||
import at.petrak.hexcasting.api.casting.OperationResult
|
||||
import at.petrak.hexcasting.api.casting.ParticleSpray
|
||||
import at.petrak.hexcasting.api.casting.RenderedSpell
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect
|
||||
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
@ -12,20 +12,20 @@ import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs
|
|||
interface SpellAction : Action {
|
||||
val argc: Int
|
||||
|
||||
fun hasCastingSound(ctx: CastingContext): Boolean = true
|
||||
fun hasCastingSound(ctx: CastingEnvironment): Boolean = true
|
||||
|
||||
fun awardsCastingStat(ctx: CastingContext): Boolean = true
|
||||
fun awardsCastingStat(ctx: CastingEnvironment): Boolean = true
|
||||
|
||||
fun execute(
|
||||
args: List<Iota>,
|
||||
ctx: CastingContext
|
||||
ctx: CastingEnvironment
|
||||
): Triple<RenderedSpell, Int, List<ParticleSpray>>?
|
||||
|
||||
override fun operate(
|
||||
continuation: SpellContinuation,
|
||||
stack: MutableList<Iota>,
|
||||
ravenmind: Iota?,
|
||||
ctx: CastingContext
|
||||
ctx: CastingEnvironment
|
||||
): OperationResult {
|
||||
if (this.argc > stack.size)
|
||||
throw MishapNotEnoughArgs(this.argc, stack.size)
|
||||
|
|
|
@ -25,7 +25,7 @@ import kotlin.math.min
|
|||
/**
|
||||
* Transient info about the moment the spell started being cast.
|
||||
*/
|
||||
data class CastingContext(
|
||||
data class CastingEnvironment(
|
||||
val caster: ServerPlayer,
|
||||
val castingHand: InteractionHand,
|
||||
val source: CastSource,
|
|
@ -54,13 +54,13 @@ class CastingHarness private constructor(
|
|||
var parenCount: Int,
|
||||
var parenthesized: List<Iota>,
|
||||
var escapeNext: Boolean,
|
||||
val ctx: CastingContext,
|
||||
val ctx: CastingEnvironment,
|
||||
val prepackagedColorizer: FrozenColorizer? // for trinkets with colorizers
|
||||
) {
|
||||
|
||||
@JvmOverloads
|
||||
constructor(
|
||||
ctx: CastingContext,
|
||||
ctx: CastingEnvironment,
|
||||
prepackagedColorizer: FrozenColorizer? = null
|
||||
) : this(mutableListOf(), null, 0, mutableListOf(), false, ctx, prepackagedColorizer)
|
||||
|
||||
|
@ -160,7 +160,7 @@ class CastingHarness private constructor(
|
|||
e,
|
||||
Mishap.Context(
|
||||
(iota as? PatternIota)?.pattern ?: HexPattern(HexDir.WEST),
|
||||
HexAPI.instance().getActionI18(HexAPI.modLoc("retrospection"), false)
|
||||
HexAPI.instance().getRawHookI18n(HexAPI.modLoc("close_paren"))
|
||||
)
|
||||
)
|
||||
),
|
||||
|
@ -224,7 +224,7 @@ class CastingHarness private constructor(
|
|||
val reqsEnlightenment = isOfTag(IXplatAbstractions.INSTANCE.actionRegistry, key, HexTags.Actions.REQUIRES_ENLIGHTENMENT)
|
||||
val canEnlighten = isOfTag(IXplatAbstractions.INSTANCE.actionRegistry, key, HexTags.Actions.CAN_START_ENLIGHTEN)
|
||||
|
||||
castedName = HexAPI.instance().getActionI18(key.location(), reqsEnlightenment)
|
||||
castedName = HexAPI.instance().getActionI18n(key, reqsEnlightenment)
|
||||
|
||||
if (!ctx.isCasterEnlightened && reqsEnlightenment) {
|
||||
Either.right(listOf(OperatorSideEffect.RequiredEnlightenment(canEnlighten)))
|
||||
|
@ -291,7 +291,7 @@ class CastingHarness private constructor(
|
|||
}
|
||||
|
||||
// TODO again this should be per VM
|
||||
var soundType = if (this.ctx.source == CastingContext.CastSource.STAFF) {
|
||||
var soundType = if (this.ctx.source == CastingEnvironment.CastSource.STAFF) {
|
||||
HexEvalSounds.OPERATOR
|
||||
} else {
|
||||
HexEvalSounds.NOTHING
|
||||
|
@ -623,7 +623,7 @@ class CastingHarness private constructor(
|
|||
}
|
||||
|
||||
@JvmStatic
|
||||
fun fromNBT(nbt: CompoundTag, ctx: CastingContext): CastingHarness {
|
||||
fun fromNBT(nbt: CompoundTag, ctx: CastingEnvironment): CastingHarness {
|
||||
return try {
|
||||
val stack = mutableListOf<Iota>()
|
||||
val stackTag = nbt.getList(TAG_STACK, Tag.TAG_COMPOUND)
|
||||
|
|
|
@ -6,7 +6,7 @@ import net.minecraft.nbt.CompoundTag
|
|||
import net.minecraft.world.phys.AABB
|
||||
|
||||
/**
|
||||
* Optional field on a [CastingContext] for the spell circle
|
||||
* Optional field on a [CastingEnvironment] for the spell circle
|
||||
*/
|
||||
data class SpellCircleContext(val impetusPos: BlockPos, val aabb: AABB, val activatorAlwaysInRange: Boolean) {
|
||||
fun serializeToNBT() = NBTBuilder {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.casting.ParticleSpray
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.math.HexPattern
|
||||
|
@ -25,29 +25,29 @@ import net.minecraft.world.phys.Vec3
|
|||
|
||||
abstract class Mishap : Throwable() {
|
||||
/** Mishaps spray half-red, half-this-color. */
|
||||
abstract fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer
|
||||
abstract fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer
|
||||
|
||||
open fun particleSpray(ctx: CastingContext): ParticleSpray {
|
||||
open fun particleSpray(ctx: CastingEnvironment): ParticleSpray {
|
||||
return ParticleSpray(ctx.position.add(0.0, 0.2, 0.0), Vec3(0.0, 2.0, 0.0), 0.2, Math.PI / 4, 40)
|
||||
}
|
||||
|
||||
open fun resolutionType(ctx: CastingContext): ResolvedPatternType = ResolvedPatternType.ERRORED
|
||||
open fun resolutionType(ctx: CastingEnvironment): ResolvedPatternType = ResolvedPatternType.ERRORED
|
||||
|
||||
/**
|
||||
* Execute the actual effect, not any sfx.
|
||||
*
|
||||
* You can also mess up the stack with this.
|
||||
*/
|
||||
abstract fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>)
|
||||
abstract fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>)
|
||||
|
||||
abstract protected fun errorMessage(ctx: CastingContext, errorCtx: Context): Component
|
||||
abstract protected fun errorMessage(ctx: CastingEnvironment, errorCtx: Context): Component
|
||||
|
||||
/**
|
||||
* Every error message should be prefixed with the name of the action...
|
||||
*/
|
||||
public fun errorMessageWithName(ctx: CastingContext, errorCtx: Context): Component {
|
||||
public fun errorMessageWithName(ctx: CastingEnvironment, errorCtx: Context): Component {
|
||||
return if (errorCtx.name != null) {
|
||||
errorCtx.name.copy().append(": ").append(this.errorMessage(ctx, errorCtx))
|
||||
"hexcasting.mishap".asTranslatedComponent(errorCtx.name, this.errorMessage(ctx, errorCtx))
|
||||
} else {
|
||||
this.errorMessage(ctx, errorCtx)
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ abstract class Mishap : Throwable() {
|
|||
protected fun actionName(name: Component?): Component =
|
||||
name ?: "hexcasting.spell.null".asTranslatedComponent.lightPurple
|
||||
|
||||
protected fun yeetHeldItemsTowards(ctx: CastingContext, targetPos: Vec3) {
|
||||
protected fun yeetHeldItemsTowards(ctx: CastingEnvironment, targetPos: Vec3) {
|
||||
// Knock the player's items out of their hands
|
||||
val items = mutableListOf<ItemStack>()
|
||||
for (hand in InteractionHand.values()) {
|
||||
|
@ -84,7 +84,7 @@ abstract class Mishap : Throwable() {
|
|||
}
|
||||
}
|
||||
|
||||
protected fun yeetHeldItem(ctx: CastingContext, hand: InteractionHand) {
|
||||
protected fun yeetHeldItem(ctx: CastingEnvironment, hand: InteractionHand) {
|
||||
val item = ctx.caster.getItemInHand(hand).copy()
|
||||
if (hand == ctx.castingHand && IXplatAbstractions.INSTANCE.findHexHolder(item) != null)
|
||||
return
|
||||
|
@ -94,7 +94,7 @@ abstract class Mishap : Throwable() {
|
|||
yeetItem(item, ctx, delta)
|
||||
}
|
||||
|
||||
protected fun yeetItem(stack: ItemStack, ctx: CastingContext, delta: Vec3) {
|
||||
protected fun yeetItem(stack: ItemStack, ctx: CastingEnvironment, delta: Vec3) {
|
||||
val entity = ItemEntity(
|
||||
ctx.world,
|
||||
ctx.position.x, ctx.position.y, ctx.position.z,
|
||||
|
@ -107,7 +107,7 @@ abstract class Mishap : Throwable() {
|
|||
ctx.world.addWithUUID(entity)
|
||||
}
|
||||
|
||||
protected fun blockAtPos(ctx: CastingContext, pos: BlockPos): Component {
|
||||
protected fun blockAtPos(ctx: CastingEnvironment, pos: BlockPos): Component {
|
||||
return ctx.world.getBlockState(pos).block.name
|
||||
}
|
||||
|
||||
|
|
|
@ -3,23 +3,23 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.misc.HexDamageSources
|
||||
import at.petrak.hexcasting.api.casting.ParticleSpray
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import net.minecraft.world.entity.Mob
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapAlreadyBrainswept(val mob: Mob) : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.GREEN)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
mob.hurt(HexDamageSources.overcastDamageFrom(ctx.caster), mob.health)
|
||||
}
|
||||
|
||||
override fun particleSpray(ctx: CastingContext) =
|
||||
override fun particleSpray(ctx: CastingEnvironment) =
|
||||
ParticleSpray.burst(mob.eyePosition, 1.0)
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
|
||||
error("already_brainswept")
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.casting.ParticleSpray
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.network.chat.Component
|
||||
|
@ -12,17 +12,17 @@ import net.minecraft.world.level.Explosion
|
|||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class MishapBadBlock(val pos: BlockPos, val expected: Component) : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.LIME)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
ctx.world.explode(null, pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, 0.25f, Explosion.BlockInteraction.NONE)
|
||||
}
|
||||
|
||||
override fun particleSpray(ctx: CastingContext) =
|
||||
override fun particleSpray(ctx: CastingEnvironment) =
|
||||
ParticleSpray.burst(Vec3.atCenterOf(pos), 1.0)
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
|
||||
error("bad_block", expected, this.pos.toShortString(), blockAtPos(ctx, this.pos))
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -3,7 +3,7 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.misc.HexDamageSources
|
||||
import at.petrak.hexcasting.api.casting.ParticleSpray
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.entity.Mob
|
||||
|
@ -11,17 +11,17 @@ import net.minecraft.world.item.DyeColor
|
|||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class MishapBadBrainsweep(val mob: Mob, val pos: BlockPos) : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.GREEN)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
trulyHurt(mob, HexDamageSources.overcastDamageFrom(ctx.caster), mob.health)
|
||||
}
|
||||
|
||||
override fun particleSpray(ctx: CastingContext): ParticleSpray {
|
||||
override fun particleSpray(ctx: CastingEnvironment): ParticleSpray {
|
||||
return ParticleSpray.burst(Vec3.atCenterOf(pos), 1.0)
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
|
||||
error("bad_brainsweep", blockAtPos(ctx, this.pos))
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.utils.aqua
|
||||
|
@ -11,14 +11,14 @@ import net.minecraft.world.entity.item.ItemEntity
|
|||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapBadEntity(val entity: Entity, val wanted: Component) : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.BROWN)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
yeetHeldItemsTowards(ctx, entity.position())
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
|
||||
error("bad_entity", wanted, entity.displayName.plainCopy().aqua)
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
|
@ -9,14 +9,14 @@ import net.minecraft.world.entity.item.ItemEntity
|
|||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapBadItem(val item: ItemEntity, val wanted: Component) : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.BROWN)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
item.deltaMovement = item.deltaMovement.add((Math.random() - 0.5) * 0.05, 0.75, (Math.random() - 0.5) * 0.05)
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) = if (item.item.isEmpty)
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = if (item.item.isEmpty)
|
||||
error("no_item", wanted)
|
||||
else
|
||||
error("bad_item", wanted, item.item.count, item.item.displayName)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
|
@ -10,14 +10,14 @@ 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: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.BROWN)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
yeetHeldItem(ctx, hand)
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) = if (item.isEmpty)
|
||||
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)
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapDisallowedSpell(val type: String = "disallowed") : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.BLACK)
|
||||
|
||||
override fun resolutionType(ctx: CastingContext) = ResolvedPatternType.INVALID
|
||||
override fun resolutionType(ctx: CastingEnvironment) = ResolvedPatternType.INVALID
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
|
||||
error(type)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.misc.HexDamageSources
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.DoubleIota
|
||||
import at.petrak.hexcasting.api.casting.iota.GarbageIota
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
@ -14,15 +14,15 @@ import net.minecraft.world.phys.Vec3
|
|||
|
||||
class MishapDivideByZero(val operand1: Component, val operand2: Component, val suffix: String = "divide") : Mishap() {
|
||||
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.RED)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
stack.add(GarbageIota())
|
||||
trulyHurt(ctx.caster, HexDamageSources.OVERCAST, ctx.caster.health / 2)
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
|
||||
error("divide_by_zero.$suffix", operand1, operand2)
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import net.minecraft.network.chat.Component
|
||||
|
@ -8,14 +8,14 @@ import net.minecraft.world.entity.Entity
|
|||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapEntityTooFarAway(val entity: Entity) : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.PINK)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
// Knock the player's items out of their hands
|
||||
yeetHeldItemsTowards(ctx, entity.position())
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context): Component =
|
||||
error("entity_too_far", entity.displayName)
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapError(val exception: Exception) : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.BLACK)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
|
||||
error("unknown", exception)
|
||||
}
|
||||
|
|
|
@ -2,17 +2,17 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapEvalTooDeep : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.BLUE)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
ctx.caster.airSupply -= 290
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
|
||||
error("eval_too_deep")
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.utils.aqua
|
||||
|
@ -8,13 +8,13 @@ import net.minecraft.world.entity.Entity
|
|||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapImmuneEntity(val entity: Entity) : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.BLUE)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
yeetHeldItemsTowards(ctx, entity.position())
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
|
||||
error("immune_entity", entity.displayName.plainCopy().aqua)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.GarbageIota
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
|
@ -18,14 +18,14 @@ class MishapInvalidIota(
|
|||
val reverseIdx: Int,
|
||||
val expected: Component
|
||||
) : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.GRAY)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
stack[stack.size - 1 - reverseIdx] = GarbageIota();
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
|
||||
error(
|
||||
"invalid_value", expected, reverseIdx,
|
||||
perpetrator.display()
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType
|
||||
import at.petrak.hexcasting.api.casting.iota.GarbageIota
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapInvalidPattern : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.YELLOW)
|
||||
|
||||
override fun resolutionType(ctx: CastingContext) = ResolvedPatternType.INVALID
|
||||
override fun resolutionType(ctx: CastingEnvironment) = ResolvedPatternType.INVALID
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
stack.add(GarbageIota())
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
|
||||
error("invalid_pattern")
|
||||
}
|
||||
|
|
|
@ -2,20 +2,20 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
/**
|
||||
* this is bad
|
||||
*/
|
||||
class MishapInvalidSpellDatumType(val perpetrator: Any) : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.BLACK)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
|
||||
error("invalid_spell_datum_type", this.perpetrator.toString(), this.perpetrator.javaClass.typeName)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.GarbageIota
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
|
@ -9,14 +9,14 @@ import net.minecraft.resources.ResourceLocation
|
|||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapLocationInWrongDimension(val properDimension: ResourceLocation) : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.MAGENTA)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
stack.add(GarbageIota())
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context): Component =
|
||||
error(
|
||||
"wrong_dimension", properDimension.toString(),
|
||||
ctx.world.dimension().location().toString()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.iota.Vec3Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
|
@ -9,13 +9,13 @@ import net.minecraft.world.item.DyeColor
|
|||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class MishapLocationTooFarAway(val location: Vec3, val type: String = "too_far") : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.MAGENTA)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
yeetHeldItemsTowards(ctx, location)
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context): Component =
|
||||
error("location_$type", Vec3Iota.display(location))
|
||||
}
|
||||
|
|
|
@ -2,18 +2,18 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapNoAkashicRecord(val pos: BlockPos) : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.PURPLE)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
ctx.caster.giveExperiencePoints(-100)
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
|
||||
error("no_akashic_record", pos.toShortString())
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import net.minecraft.world.entity.player.Player
|
||||
|
@ -9,7 +9,7 @@ import net.minecraft.world.item.ItemStack
|
|||
import net.minecraft.world.item.enchantment.EnchantmentHelper
|
||||
|
||||
class MishapNoSpellCircle : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.LIGHT_BLUE)
|
||||
|
||||
private inline fun dropAll(player: Player, stacks: MutableList<ItemStack>, filter: (ItemStack) -> Boolean = { true }) {
|
||||
|
@ -22,7 +22,7 @@ class MishapNoSpellCircle : Mishap() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
dropAll(ctx.caster, ctx.caster.inventory.items)
|
||||
dropAll(ctx.caster, ctx.caster.inventory.offhand)
|
||||
dropAll(ctx.caster, ctx.caster.inventory.armor) {
|
||||
|
@ -30,6 +30,6 @@ class MishapNoSpellCircle : Mishap() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
|
||||
error("no_spell_circle")
|
||||
}
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.GarbageIota
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapNotEnoughArgs(val expected: Int, val got: Int) : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.LIGHT_GRAY)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
repeat(expected - got) { stack.add(GarbageIota()) }
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
|
||||
if (got == 0)
|
||||
error("no_args", expected)
|
||||
else
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.EntityIota
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.iota.ListIota
|
||||
|
@ -14,15 +14,15 @@ import net.minecraft.world.item.DyeColor
|
|||
* Also throwable for your *own* name, for cases like Chronicler's Gambit
|
||||
*/
|
||||
class MishapOthersName(val confidant: Player) : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.BLACK)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
val seconds = if (this.confidant == ctx.caster) 5 else 60;
|
||||
ctx.caster.addEffect(MobEffectInstance(MobEffects.BLINDNESS, seconds * 20))
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
|
||||
if (this.confidant == ctx.caster)
|
||||
error("others_name.self")
|
||||
else
|
||||
|
|
|
@ -2,17 +2,17 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.misc.HexDamageSources
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapShameOnYou() : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.BLACK)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
Mishap.trulyHurt(ctx.caster, HexDamageSources.SHAME, 69420f)
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) = error("shame")
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = error("shame")
|
||||
}
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.iota.PatternIota
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapTooManyCloseParens : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.ORANGE)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
// TODO this is a kinda shitty mishap
|
||||
stack.add(PatternIota(errorCtx.pattern))
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
|
||||
error("too_many_close_parens")
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
/**
|
||||
|
@ -11,10 +11,10 @@ import net.minecraft.world.item.DyeColor
|
|||
class MishapUnescapedValue(
|
||||
val perpetrator: Iota
|
||||
) : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.GRAY)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
// TODO
|
||||
/*
|
||||
val idx = stack.indexOfLast { it.getType() == DatumType.LIST }
|
||||
|
@ -30,6 +30,6 @@ class MishapUnescapedValue(
|
|||
*/
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
|
||||
error("unescaped", perpetrator.display())
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.api.misc;
|
||||
|
||||
import at.petrak.hexcasting.api.addldata.ADMediaHolder;
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext;
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment;
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingHarness;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -17,8 +17,8 @@ public class DiscoveryHandlers {
|
|||
private static final List<Predicate<Player>> HAS_LENS_PREDICATE = new ArrayList<>();
|
||||
private static final List<Function<CastingHarness, List<ADMediaHolder>>> MEDIA_HOLDER_DISCOVERY = new ArrayList<>();
|
||||
private static final List<FunctionToFloat<Player>> GRID_SCALE_MODIFIERS = new ArrayList<>();
|
||||
private static final List<Function<CastingContext, List<ItemStack>>> ITEM_SLOT_DISCOVERER = new ArrayList<>();
|
||||
private static final List<Function<CastingContext, List<ItemStack>>> OPERATIVE_SLOT_DISCOVERER = new ArrayList<>();
|
||||
private static final List<Function<CastingEnvironment, List<ItemStack>>> ITEM_SLOT_DISCOVERER = new ArrayList<>();
|
||||
private static final List<Function<CastingEnvironment, List<ItemStack>>> OPERATIVE_SLOT_DISCOVERER = new ArrayList<>();
|
||||
private static final List<BiFunction<Player, String, ItemStack>> DEBUG_DISCOVERER = new ArrayList<>();
|
||||
|
||||
public static boolean hasLens(Player player) {
|
||||
|
@ -46,7 +46,7 @@ public class DiscoveryHandlers {
|
|||
return mod;
|
||||
}
|
||||
|
||||
public static List<ItemStack> collectItemSlots(CastingContext ctx) {
|
||||
public static List<ItemStack> collectItemSlots(CastingEnvironment ctx) {
|
||||
List<ItemStack> stacks = Lists.newArrayList();
|
||||
for (var discoverer : ITEM_SLOT_DISCOVERER) {
|
||||
stacks.addAll(discoverer.apply(ctx));
|
||||
|
@ -54,7 +54,7 @@ public class DiscoveryHandlers {
|
|||
return stacks;
|
||||
}
|
||||
|
||||
public static List<ItemStack> collectOperableSlots(CastingContext ctx) {
|
||||
public static List<ItemStack> collectOperableSlots(CastingEnvironment ctx) {
|
||||
List<ItemStack> stacks = Lists.newArrayList();
|
||||
for (var discoverer : OPERATIVE_SLOT_DISCOVERER) {
|
||||
stacks.addAll(discoverer.apply(ctx));
|
||||
|
@ -84,11 +84,11 @@ public class DiscoveryHandlers {
|
|||
GRID_SCALE_MODIFIERS.add(modifier);
|
||||
}
|
||||
|
||||
public static void addItemSlotDiscoverer(Function<CastingContext, List<ItemStack>> discoverer) {
|
||||
public static void addItemSlotDiscoverer(Function<CastingEnvironment, List<ItemStack>> discoverer) {
|
||||
ITEM_SLOT_DISCOVERER.add(discoverer);
|
||||
}
|
||||
|
||||
public static void addOperativeSlotDiscoverer(Function<CastingContext, List<ItemStack>> discoverer) {
|
||||
public static void addOperativeSlotDiscoverer(Function<CastingEnvironment, List<ItemStack>> discoverer) {
|
||||
OPERATIVE_SLOT_DISCOVERER.add(discoverer);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.misc.MediaConstants
|
|||
import at.petrak.hexcasting.api.casting.castables.Action
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
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
|
||||
|
@ -15,7 +15,7 @@ import net.minecraft.world.phys.Vec3
|
|||
object OpBlockAxisRaycast : ConstMediaAction {
|
||||
override val argc = 2
|
||||
override val mediaCost = MediaConstants.DUST_UNIT / 100
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val origin = args.getVec3(0, argc)
|
||||
val look = args.getVec3(1, argc)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.misc.MediaConstants
|
|||
import at.petrak.hexcasting.api.casting.castables.Action
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
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
|
||||
|
@ -15,7 +15,7 @@ import net.minecraft.world.phys.Vec3
|
|||
object OpBlockRaycast : ConstMediaAction {
|
||||
override val argc = 2
|
||||
override val mediaCost = MediaConstants.DUST_UNIT / 100
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val origin = args.getVec3(0, argc)
|
||||
val look = args.getVec3(1, argc)
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@ package at.petrak.hexcasting.common.casting.operators
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getEntity
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpEntityHeight : ConstMediaAction {
|
||||
override val argc = 1
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val e = args.getEntity(0, argc)
|
||||
ctx.assertEntityInRange(e)
|
||||
return e.bbHeight.asActionResult
|
||||
|
|
|
@ -2,14 +2,14 @@ package at.petrak.hexcasting.common.casting.operators
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getEntity
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpEntityLook : ConstMediaAction {
|
||||
override val argc = 1
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val e = args.getEntity(0, argc)
|
||||
ctx.assertEntityInRange(e)
|
||||
return e.lookAngle.asActionResult
|
||||
|
|
|
@ -2,14 +2,14 @@ package at.petrak.hexcasting.common.casting.operators
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getEntity
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
class OpEntityPos(val feet: Boolean) : ConstMediaAction {
|
||||
override val argc = 1
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val e = args.getEntity(0, argc)
|
||||
ctx.assertEntityInRange(e)
|
||||
return (if (this.feet) e.position() else e.eyePosition).asActionResult
|
||||
|
|
|
@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.misc.MediaConstants
|
|||
import at.petrak.hexcasting.api.casting.castables.Action
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
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
|
||||
|
@ -14,7 +14,7 @@ import net.minecraft.world.phys.AABB
|
|||
object OpEntityRaycast : ConstMediaAction {
|
||||
override val argc = 2
|
||||
override val mediaCost = MediaConstants.DUST_UNIT / 100
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val origin = args.getVec3(0, argc)
|
||||
val look = args.getVec3(1, argc)
|
||||
val endp = Action.raycastEnd(origin, look)
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getEntity
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.common.misc.PlayerPositionRecorder
|
||||
|
@ -11,7 +11,7 @@ import net.minecraft.server.level.ServerPlayer
|
|||
object OpEntityVelocity : ConstMediaAction {
|
||||
override val argc = 1
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val e = args.getEntity(0, argc)
|
||||
ctx.assertEntityInRange(e)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.akashic
|
|||
|
||||
import at.petrak.hexcasting.api.misc.MediaConstants
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getBlockPos
|
||||
import at.petrak.hexcasting.api.casting.getPattern
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
@ -14,7 +14,7 @@ object OpAkashicRead : ConstMediaAction {
|
|||
override val argc = 2
|
||||
override val mediaCost = MediaConstants.DUST_UNIT
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val pos = args.getBlockPos(0, argc)
|
||||
val key = args.getPattern(1, argc)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.akashic
|
|||
|
||||
import at.petrak.hexcasting.api.casting.*
|
||||
import at.petrak.hexcasting.api.casting.castables.SpellAction
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.math.HexPattern
|
||||
import at.petrak.hexcasting.api.casting.mishaps.MishapNoAkashicRecord
|
||||
|
@ -18,7 +18,7 @@ object OpAkashicWrite : SpellAction {
|
|||
|
||||
override fun execute(
|
||||
args: List<Iota>,
|
||||
ctx: CastingContext
|
||||
ctx: CastingEnvironment
|
||||
): Triple<RenderedSpell, Int, List<ParticleSpray>> {
|
||||
val pos = args.getBlockPos(0, argc)
|
||||
val key = args.getPattern(1, argc)
|
||||
|
@ -49,7 +49,7 @@ object OpAkashicWrite : SpellAction {
|
|||
val datum: Iota
|
||||
) :
|
||||
RenderedSpell {
|
||||
override fun cast(ctx: CastingContext) {
|
||||
override fun cast(ctx: CastingEnvironment) {
|
||||
record.addNewDatum(recordPos, ctx.world, key, datum)
|
||||
|
||||
ctx.world.playSound(
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.circles
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.mishaps.MishapNoSpellCircle
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
@ -10,7 +10,7 @@ import net.minecraft.world.phys.Vec3
|
|||
class OpCircleBounds(val max: Boolean) : ConstMediaAction {
|
||||
override val argc = 0
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
if (ctx.spellCircle == null)
|
||||
throw MishapNoSpellCircle()
|
||||
|
||||
|
|
|
@ -3,14 +3,14 @@ package at.petrak.hexcasting.common.casting.operators.circles
|
|||
import at.petrak.hexcasting.api.block.circle.BlockAbstractImpetus
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.mishaps.MishapNoSpellCircle
|
||||
|
||||
object OpImpetusDir : ConstMediaAction {
|
||||
override val argc = 0
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
if (ctx.spellCircle == null)
|
||||
throw MishapNoSpellCircle()
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@ package at.petrak.hexcasting.common.casting.operators.circles
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.mishaps.MishapNoSpellCircle
|
||||
|
||||
object OpImpetusPos : ConstMediaAction {
|
||||
override val argc = 0
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
if (ctx.spellCircle == null)
|
||||
throw MishapNoSpellCircle()
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package at.petrak.hexcasting.common.casting.operators.eval
|
|||
import at.petrak.hexcasting.api.casting.castables.Action
|
||||
import at.petrak.hexcasting.api.casting.OperationResult
|
||||
import at.petrak.hexcasting.api.casting.SpellList
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.eval.vm.FrameEvaluate
|
||||
import at.petrak.hexcasting.api.casting.eval.vm.FrameFinishEval
|
||||
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
|
||||
|
@ -17,7 +17,7 @@ object OpEval : Action {
|
|||
continuation: SpellContinuation,
|
||||
stack: MutableList<Iota>,
|
||||
ravenmind: Iota?,
|
||||
ctx: CastingContext
|
||||
ctx: CastingEnvironment
|
||||
): OperationResult {
|
||||
val datum = stack.removeLastOrNull() ?: throw MishapNotEnoughArgs(1, 0)
|
||||
val instrs = evaluatable(datum, 0)
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.eval
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.Action
|
||||
import at.petrak.hexcasting.api.casting.OperationResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.eval.vm.FrameForEach
|
||||
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
|
||||
import at.petrak.hexcasting.api.casting.getList
|
||||
|
@ -14,7 +14,7 @@ object OpForEach : Action {
|
|||
continuation: SpellContinuation,
|
||||
stack: MutableList<Iota>,
|
||||
ravenmind: Iota?,
|
||||
ctx: CastingContext
|
||||
ctx: CastingEnvironment
|
||||
): OperationResult {
|
||||
if (stack.size < 2)
|
||||
throw MishapNotEnoughArgs(2, stack.size)
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.eval
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.Action
|
||||
import at.petrak.hexcasting.api.casting.OperationResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
|
@ -11,7 +11,7 @@ object OpHalt : Action {
|
|||
continuation: SpellContinuation,
|
||||
stack: MutableList<Iota>,
|
||||
ravenmind: Iota?,
|
||||
ctx: CastingContext
|
||||
ctx: CastingEnvironment
|
||||
): OperationResult {
|
||||
var newStack = stack.toList()
|
||||
var done = false
|
||||
|
|
|
@ -2,13 +2,13 @@ package at.petrak.hexcasting.common.casting.operators.lists
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getList
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpAppend : ConstMediaAction {
|
||||
override val argc = 2
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val list = args.getList(0, argc).toMutableList()
|
||||
val datum = args[1]
|
||||
list.add(datum)
|
||||
|
|
|
@ -2,13 +2,13 @@ package at.petrak.hexcasting.common.casting.operators.lists
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getList
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpConcat : ConstMediaAction {
|
||||
override val argc = 2
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val lhs = args.getList(0, argc).toMutableList()
|
||||
val rhs = args.getList(1, argc)
|
||||
lhs.addAll(rhs)
|
||||
|
|
|
@ -3,13 +3,13 @@ package at.petrak.hexcasting.common.casting.operators.lists
|
|||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.SpellList
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getList
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpCons : ConstMediaAction {
|
||||
override val argc = 2
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val bottom = args.getList(0, argc)
|
||||
val top = args[1]
|
||||
return SpellList.LPair(top, bottom).asActionResult
|
||||
|
|
|
@ -3,11 +3,11 @@ package at.petrak.hexcasting.common.casting.operators.lists
|
|||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
|
||||
object OpEmptyList : ConstMediaAction {
|
||||
override val argc = 0
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
return emptyList<Iota>().asActionResult // sorry for taking all the easy impls, hudeler
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.common.casting.operators.lists
|
||||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getDouble
|
||||
import at.petrak.hexcasting.api.casting.getList
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
@ -10,7 +10,7 @@ import kotlin.math.roundToInt
|
|||
|
||||
object OpIndex : ConstMediaAction {
|
||||
override val argc = 2
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val list = args.getList(0, argc).toMutableList()
|
||||
val index = args.getDouble(1, argc)
|
||||
val x = list.getOrElse(index.roundToInt()) { NullIota() }
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.lists
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getList
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
|
@ -10,7 +10,7 @@ object OpIndexOf : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 2
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val list = args.getList(0, argc).toMutableList()
|
||||
val value = args[1]
|
||||
return list.indexOfFirst { Iota.tolerates(value, it) }.asActionResult
|
||||
|
|
|
@ -3,7 +3,7 @@ package at.petrak.hexcasting.common.casting.operators.lists
|
|||
import at.petrak.hexcasting.api.casting.castables.Action
|
||||
import at.petrak.hexcasting.api.casting.OperationResult
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
|
||||
import at.petrak.hexcasting.api.casting.getPositiveIntUnderInclusive
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
@ -14,7 +14,7 @@ object OpLastNToList : Action {
|
|||
continuation: SpellContinuation,
|
||||
stack: MutableList<Iota>,
|
||||
ravenmind: Iota?,
|
||||
ctx: CastingContext
|
||||
ctx: CastingEnvironment
|
||||
): OperationResult {
|
||||
if (stack.isEmpty())
|
||||
throw MishapNotEnoughArgs(1, 0)
|
||||
|
|
|
@ -2,14 +2,14 @@ package at.petrak.hexcasting.common.casting.operators.lists
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getList
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
// it's still called beancounter's distillation in my heart
|
||||
object OpListSize : ConstMediaAction {
|
||||
override val argc = 1
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
return args.getList(0, argc).toList().size.asActionResult // mmm one-liner
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@ package at.petrak.hexcasting.common.casting.operators.lists
|
|||
|
||||
import at.petrak.hexcasting.api.casting.*
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpModifyInPlace : ConstMediaAction {
|
||||
override val argc = 3
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val list = args.getList(0, argc)
|
||||
val index = args.getPositiveIntUnder(1, list.size(), argc)
|
||||
val iota = args[2]
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.lists
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getInt
|
||||
import at.petrak.hexcasting.api.casting.getList
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
@ -11,7 +11,7 @@ object OpRemove : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 2
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val list = args.getList(0, argc).toMutableList()
|
||||
val index = args.getInt(1, argc)
|
||||
if (index < 0 || index >= list.size)
|
||||
|
|
|
@ -2,13 +2,13 @@ package at.petrak.hexcasting.common.casting.operators.lists
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getList
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpReverski : ConstMediaAction {
|
||||
override val argc = 1
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
return args.getList(0, argc).toList().asReversed().asActionResult // okay kotlin kinda pogged for this
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@ package at.petrak.hexcasting.common.casting.operators.lists
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpSingleton : ConstMediaAction {
|
||||
override val argc = 1
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
return listOf(args[0]).asActionResult // god i love one-liners
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.lists
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getList
|
||||
import at.petrak.hexcasting.api.casting.getPositiveIntUnderInclusive
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
@ -11,7 +11,7 @@ import kotlin.math.min
|
|||
|
||||
object OpSlice : ConstMediaAction {
|
||||
override val argc = 3
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val list = args.getList(0, argc).toList()
|
||||
val index1 = args.getPositiveIntUnderInclusive(1, list.size, argc)
|
||||
val index2 = args.getPositiveIntUnderInclusive(2, list.size, argc)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.common.casting.operators.lists
|
||||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getList
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
|
@ -9,6 +9,6 @@ object OpSplat : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 1
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> =
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> =
|
||||
args.getList(0, argc).toList()
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.common.casting.operators.lists
|
||||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getList
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.iota.ListIota
|
||||
|
@ -9,7 +9,7 @@ import at.petrak.hexcasting.api.casting.iota.NullIota
|
|||
|
||||
object OpUnCons : ConstMediaAction {
|
||||
override val argc = 1
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val list = args.getList(0, argc)
|
||||
if (list.nonEmpty) {
|
||||
return listOf(ListIota(list.cdr), list.car)
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.local
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.Action
|
||||
import at.petrak.hexcasting.api.casting.OperationResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.orNull
|
||||
|
@ -12,7 +12,7 @@ object OpPeekLocal : Action {
|
|||
continuation: SpellContinuation,
|
||||
stack: MutableList<Iota>,
|
||||
ravenmind: Iota?,
|
||||
ctx: CastingContext
|
||||
ctx: CastingEnvironment
|
||||
): OperationResult {
|
||||
stack.add(ravenmind.orNull())
|
||||
return OperationResult(continuation, stack, ravenmind, listOf())
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.local
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.Action
|
||||
import at.petrak.hexcasting.api.casting.OperationResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs
|
||||
|
@ -12,7 +12,7 @@ object OpPushLocal : Action {
|
|||
continuation: SpellContinuation,
|
||||
stack: MutableList<Iota>,
|
||||
ravenmind: Iota?,
|
||||
ctx: CastingContext
|
||||
ctx: CastingEnvironment
|
||||
): OperationResult {
|
||||
if (stack.isEmpty())
|
||||
throw MishapNotEnoughArgs(1, 0)
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getNumOrVec
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import kotlin.math.absoluteValue
|
||||
|
@ -11,7 +11,7 @@ object OpAbsLen : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 1
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val x = args.getNumOrVec(0, argc)
|
||||
|
||||
return x.map({ num -> num.absoluteValue }, { vec -> vec.length() }).asActionResult
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getNumOrVec
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
|
@ -10,7 +10,7 @@ object OpAdd : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 2
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val lhs = args.getNumOrVec(0, argc)
|
||||
val rhs = args.getNumOrVec(1, argc)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.aplKinnie
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getNumOrVec
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import kotlin.math.ceil
|
||||
|
@ -11,7 +11,7 @@ object OpCeil : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 1
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val value = args.getNumOrVec(0, argc)
|
||||
// i hate this fucking syntax what the hell is ::ceil are you a goddamn homestuck ::c
|
||||
return listOf(aplKinnie(value, ::ceil))
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getVec3
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import net.minecraft.core.Direction
|
||||
|
@ -12,7 +12,7 @@ object OpCoerceToAxial : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 1
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val vec = args.getVec3(0, argc)
|
||||
if (vec == Vec3.ZERO)
|
||||
return vec.asActionResult
|
||||
|
|
|
@ -2,14 +2,14 @@ package at.petrak.hexcasting.common.casting.operators.math
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getDouble
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
object OpConstructVec : ConstMediaAction {
|
||||
override val argc = 3
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val x = args.getDouble(0, argc)
|
||||
val y = args.getDouble(1, argc)
|
||||
val z = args.getDouble(2, argc)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package at.petrak.hexcasting.common.casting.operators.math
|
||||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getVec3
|
||||
import at.petrak.hexcasting.api.casting.iota.DoubleIota
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpDeconstructVec : ConstMediaAction {
|
||||
override val argc = 1
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val v = args.getVec3(0, argc)
|
||||
return listOf(DoubleIota(v.x), DoubleIota(v.y), DoubleIota(v.z))
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getNumOrVec
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.mishaps.MishapDivideByZero
|
||||
|
@ -12,7 +12,7 @@ object OpDivCross : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 2
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val lhs = args.getNumOrVec(0, argc)
|
||||
val rhs = args.getNumOrVec(1, argc)
|
||||
val theMishap = MishapDivideByZero.of(args[0], args[1])
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.aplKinnie
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getNumOrVec
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import kotlin.math.floor
|
||||
|
@ -11,7 +11,7 @@ object OpFloor : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 1
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val value = args.getNumOrVec(0, argc)
|
||||
return listOf(aplKinnie(value, ::floor))
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getDouble
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.mishaps.MishapDivideByZero
|
||||
|
@ -12,7 +12,7 @@ object OpLog : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 2
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val value = args.getDouble(0, argc)
|
||||
val base = args.getDouble(1, argc)
|
||||
if (value <= 0.0 || base <= 0.0 || base == 1.0)
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getDouble
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.mishaps.MishapDivideByZero
|
||||
|
@ -11,7 +11,7 @@ object OpModulo : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 2
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
// TODO: some wAckY vector operation to go in the vector x vector overload
|
||||
val l = args.getDouble(0, argc)
|
||||
val r = args.getDouble(1, argc)
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getNumOrVec
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
|
@ -10,7 +10,7 @@ object OpMulDot : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 2
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val lhs = args.getNumOrVec(0, OpAdd.argc)
|
||||
val rhs = args.getNumOrVec(1, OpAdd.argc)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getNumOrVec
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.mishaps.MishapDivideByZero
|
||||
|
@ -13,7 +13,7 @@ object OpPowProj : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 2
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val lhs = args.getNumOrVec(0, OpAdd.argc)
|
||||
val rhs = args.getNumOrVec(1, OpAdd.argc)
|
||||
val theMishap = MishapDivideByZero.of(args[0], args[1], "exponent")
|
||||
|
|
|
@ -2,14 +2,14 @@ package at.petrak.hexcasting.common.casting.operators.math
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpRandom : ConstMediaAction {
|
||||
override val argc: Int
|
||||
get() = 0
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
return ctx.world.random.nextDouble().asActionResult
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getNumOrVec
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
@ -11,7 +11,7 @@ object OpSub : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 2
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val lhs = args.getNumOrVec(0, OpAdd.argc)
|
||||
val rhs = args.getNumOrVec(1, OpAdd.argc)
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package at.petrak.hexcasting.common.casting.operators.math
|
||||
|
||||
import at.petrak.hexcasting.api.HexAPI
|
||||
import at.petrak.hexcasting.api.HexAPI.modLoc
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.castables.Action
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.castables.SpecialHandler
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.math.HexPattern
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import at.petrak.hexcasting.api.utils.lightPurple
|
||||
import at.petrak.hexcasting.common.lib.hex.HexSpecialHandlers
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
|
||||
class SpecialHandlerNumberLiteral(val x: Double) : SpecialHandler {
|
||||
override fun act(): Action {
|
||||
|
@ -20,14 +20,15 @@ class SpecialHandlerNumberLiteral(val x: Double) : SpecialHandler {
|
|||
}
|
||||
|
||||
override fun getName(): Component {
|
||||
return HexAPI.instance().getActionI18nKey(NAME)
|
||||
val key = IXplatAbstractions.INSTANCE.specialHandlerRegistry.getResourceKey(HexSpecialHandlers.NUMBER).get()
|
||||
return HexAPI.instance().getSpecialHandlerI18nKey(key)
|
||||
.asTranslatedComponent(Action.DOUBLE_FORMATTER.format(x)).lightPurple
|
||||
}
|
||||
|
||||
class InnerAction(val x: Double) : ConstMediaAction {
|
||||
override val argc = 0
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
return this.x.asActionResult
|
||||
}
|
||||
}
|
||||
|
@ -74,8 +75,4 @@ class SpecialHandlerNumberLiteral(val x: Double) : SpecialHandler {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
public val NAME: ResourceLocation = modLoc("number")
|
||||
}
|
||||
}
|
|
@ -2,13 +2,13 @@ package at.petrak.hexcasting.common.casting.operators.math.bit
|
|||
|
||||
import at.petrak.hexcasting.api.casting.*
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpAnd : ConstMediaAction {
|
||||
override val argc = 2
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val firstParam = args.getLongOrList(0, argc)
|
||||
|
||||
return firstParam.map(
|
||||
|
|
|
@ -2,14 +2,14 @@ package at.petrak.hexcasting.common.casting.operators.math.bit
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getLong
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpNot : ConstMediaAction {
|
||||
override val argc = 1
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val num = args.getLong(0, argc)
|
||||
return num.inv().asActionResult
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@ package at.petrak.hexcasting.common.casting.operators.math.bit
|
|||
|
||||
import at.petrak.hexcasting.api.casting.*
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpOr : ConstMediaAction {
|
||||
override val argc = 2
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val firstParam = args.getLongOrList(0, argc)
|
||||
|
||||
return firstParam.map(
|
||||
|
|
|
@ -2,14 +2,14 @@ package at.petrak.hexcasting.common.casting.operators.math.bit
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getList
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpToSet : ConstMediaAction {
|
||||
override val argc = 1
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val list = args.getList(0, argc)
|
||||
val out = mutableListOf<Iota>()
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@ package at.petrak.hexcasting.common.casting.operators.math.bit
|
|||
|
||||
import at.petrak.hexcasting.api.casting.*
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpXor : ConstMediaAction {
|
||||
override val argc = 2
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val firstParam = args.getLongOrList(0, argc)
|
||||
|
||||
return firstParam.map(
|
||||
|
|
|
@ -2,14 +2,14 @@ package at.petrak.hexcasting.common.casting.operators.math.logic
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getBool
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpBoolAnd : ConstMediaAction {
|
||||
override val argc = 2
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val lhs = args.getBool(0, argc)
|
||||
val rhs = args.getBool(1, argc)
|
||||
return (lhs && rhs).asActionResult
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package at.petrak.hexcasting.common.casting.operators.math.logic
|
||||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getBool
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpBoolIf : ConstMediaAction {
|
||||
override val argc = 3
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val cond = args.getBool(0, argc)
|
||||
val t = args[1]
|
||||
val f = args[2]
|
||||
|
|
|
@ -2,14 +2,14 @@ package at.petrak.hexcasting.common.casting.operators.math.logic
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getBool
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpBoolNot : ConstMediaAction {
|
||||
override val argc = 1
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val b = args.getBool(0, argc)
|
||||
return (!b).asActionResult
|
||||
}
|
||||
|
|
|
@ -2,14 +2,14 @@ package at.petrak.hexcasting.common.casting.operators.math.logic
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getBool
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpBoolOr : ConstMediaAction {
|
||||
override val argc = 2
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val lhs = args.getBool(0, argc)
|
||||
val rhs = args.getBool(1, argc)
|
||||
return (lhs || rhs).asActionResult
|
||||
|
|
|
@ -2,14 +2,14 @@ package at.petrak.hexcasting.common.casting.operators.math.logic
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getBool
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpBoolXor : ConstMediaAction {
|
||||
override val argc = 2
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val lhs = args.getBool(0, argc)
|
||||
val rhs = args.getBool(1, argc)
|
||||
return (lhs xor rhs).asActionResult
|
||||
|
|
|
@ -2,13 +2,13 @@ package at.petrak.hexcasting.common.casting.operators.math.logic
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
object OpCoerceToBool : ConstMediaAction {
|
||||
override val argc = 1
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
return (args[0].isTruthy).asActionResult
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math.logic
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getDouble
|
||||
import at.petrak.hexcasting.api.casting.iota.DoubleIota
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
@ -11,7 +11,7 @@ import java.util.function.BiPredicate
|
|||
class OpCompare(val acceptsEqual: Boolean, val cmp: BiPredicate<Double, Double>) : ConstMediaAction {
|
||||
override val argc = 2
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val lhs = args.getDouble(0, argc)
|
||||
val rhs = args.getDouble(1, argc)
|
||||
if (DoubleIota.tolerates(lhs, rhs))
|
||||
|
|
|
@ -2,13 +2,13 @@ package at.petrak.hexcasting.common.casting.operators.math.logic
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
||||
class OpEquality(val invert: Boolean) : ConstMediaAction {
|
||||
override val argc = 2
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val lhs = args[0]
|
||||
val rhs = args[1]
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math.trig
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getDoubleBetween
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import kotlin.math.acos
|
||||
|
@ -11,7 +11,7 @@ object OpArcCos : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 1
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val value = args.getDoubleBetween(0, -1.0, 1.0, argc)
|
||||
return acos(value).asActionResult
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math.trig
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getDoubleBetween
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import kotlin.math.asin
|
||||
|
@ -11,7 +11,7 @@ object OpArcSin : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 1
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val value = args.getDoubleBetween(0, -1.0, 1.0, OpArcCos.argc)
|
||||
return asin(value).asActionResult
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math.trig
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getDouble
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import kotlin.math.atan
|
||||
|
@ -11,7 +11,7 @@ object OpArcTan : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 1
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val value = args.getDouble(0, argc)
|
||||
return atan(value).asActionResult
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math.trig
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getDouble
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import kotlin.math.atan2
|
||||
|
@ -11,7 +11,7 @@ object OpArcTan2 : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 2
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val y = args.getDouble(0, argc)
|
||||
val x = args.getDouble(1, argc)
|
||||
return atan2(y, x).asActionResult
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math.trig
|
|||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingContext
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getDouble
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import kotlin.math.cos
|
||||
|
@ -11,7 +11,7 @@ object OpCos : ConstMediaAction {
|
|||
override val argc: Int
|
||||
get() = 1
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val angle = args.getDouble(0, argc)
|
||||
return cos(angle).asActionResult
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue