Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ram.talia.hexal.api.casting.mishaps

import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.mishaps.Mishap
import at.petrak.hexcasting.api.pigment.FrozenPigment
import net.minecraft.network.chat.Component
import net.minecraft.world.item.DyeColor
import ram.talia.hexal.api.casting.iota.GateIota


class MishapNoEntity(val gate: GateIota) : Mishap() {
override fun accentColor(env: CastingEnvironment, errorCtx: Context): FrozenPigment = dyeColor(DyeColor.YELLOW)

override fun errorMessage(env: CastingEnvironment, errorCtx: Context): Component = error("entity_gate_with_no_entity", gate.display())

override fun execute(env: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import at.petrak.hexcasting.api.casting.eval.env.PlayerBasedCastEnv
import at.petrak.hexcasting.api.casting.getVec3
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.mishaps.MishapBadLocation
import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.entity.Entity
import net.minecraft.world.item.enchantment.EnchantmentHelper
Expand All @@ -19,6 +18,8 @@ import ram.talia.hexal.api.getGate
import ram.talia.hexal.api.minus
import ram.talia.hexal.api.casting.castables.VarargSpellAction
import ram.talia.hexal.api.casting.iota.GateIota
import ram.talia.hexal.api.casting.mishaps.MishapNoEntity
import kotlin.jvm.optionals.getOrNull

object OpCloseGate : VarargSpellAction {
override fun argc(stack: List<Iota>): Int {
Expand All @@ -32,10 +33,24 @@ object OpCloseGate : VarargSpellAction {

override fun execute(args: List<Iota>, argc: Int, env: CastingEnvironment): SpellAction.Result {
val gate = args.getGate(0, argc)
val targetPos = if (gate.isDrifting) args.getVec3(1, argc) else gate.getTargetPos(env.world)
?: throw IllegalStateException("non-drifting gates should always have a target pos.")



val targetPos = (
if (gate.isDrifting) {
args.getVec3(1, argc)
}
else if(gate.isLocationAnchored){
gate.getTargetPos(env.world)
?: throw IllegalStateException("Location Anchored gates should always have a target position.")
}
else { //gate.isEntityAnchored
gate.getTargetPos(env.world)
?: when (val entityAnchor = gate.getTarget()?.right()?.getOrNull()) {
null -> throw IllegalStateException("Entity Anchored gate's target is computed as a Drifting gate.")
else -> throw MishapNoEntity(gate)
}
}
)

// only check if in ambit when the gate is drifting.
if (gate.isDrifting)
env.assertVecInRange(targetPos)
Expand All @@ -58,9 +73,9 @@ object OpCloseGate : VarargSpellAction {
burst.add(ParticleSpray.burst(targetPos.add(0.0, meanEyeHeight / 2.0, 0.0), 2.0))

return SpellAction.Result(
Spell(gatees, targetPos, gate.isDrifting),
cost,
burst
Spell(gatees, targetPos, gate.isDrifting),
cost,
burst
)
}

Expand Down Expand Up @@ -137,10 +152,14 @@ object OpCloseGate : VarargSpellAction {
fun aboveStackRoot(toCheck: Entity, allTeleportees: Set<Entity>): Boolean {
val lowerVehicle = toCheck.vehicle?.vehicle
val vehicleGated = allTeleportees.contains(toCheck.vehicle)
if (lowerVehicle == null) {
return vehicleGated
} else {
return vehicleGated || (allTeleportees.contains(lowerVehicle) && lowerVehicle.type.`is`(HexTags.Entities.STICKY_TELEPORTERS))
}

return (
if (lowerVehicle == null) {
vehicleGated
}
else {
vehicleGated || (allTeleportees.contains(lowerVehicle) && lowerVehicle.type.`is`(HexTags.Entities.STICKY_TELEPORTERS))
}
)
}
}
1 change: 1 addition & 0 deletions Common/src/main/resources/assets/hexal/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"hexcasting.mishap.storage_unloaded": "Bound Mote Nexus is unloaded.",
"hexcasting.mishap.excessive_reproduction": "Wisp %s tried to reproduce excessively; only 1 child per tick.",
"hexcasting.mishap.illegal_interworld_iota": "Attempted to bring iota %s interworld, this type of iota cannot be added to the Everbook.",
"hexcasting.mishap.entity_gate_with_no_entity" : "%s is anchored to an entity that doesn't exist.",

"hexcasting.mishap.bad_block.phaseable": "a phaseable block",

Expand Down