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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

- Updated to Minecraft 1.21.1 ([#985](https://github.com/FallingColors/HexMod/pull/985)) @SuperKnux @slava110

### Changed

- The media cost of Impulse now scales linearly rather than quadratically ([#1145](https://github.com/FallingColors/HexMod/pull/1145)) @Robotgiggle

### Fixed

- Fixed Entity Iota comparison to use `equals` on entity IDs instead of reference equality ([#1101](https://github.com/FallingColors/HexMod/pull/1101)) @IridescentVoid
Expand Down
2 changes: 0 additions & 2 deletions Common/src/main/java/at/petrak/hexcasting/api/HexAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ default ArmorMaterial robesMaterial() {
*/
String RAVENMIND_USERDATA = modLoc("ravenmind").toString();

String MARKED_MOVED_USERDATA = modLoc("impulsed").toString();

static HexAPI instance() {
return INSTANCE.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,5 @@ data class CastingImage(
CastingImage(a, b, c, d, e, f)
}
)

@JvmStatic
fun checkAndMarkGivenMotion(userData: CompoundTag, entity: Entity): Boolean {
val marked = userData.getOrCreateCompound(HexAPI.MARKED_MOVED_USERDATA)
return if (marked.contains(entity.stringUUID)) {
true
} else {
marked.putBoolean(entity.stringUUID, true)
userData.putCompound(HexAPI.MARKED_MOVED_USERDATA, marked)
false
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import at.petrak.hexcasting.api.casting.ParticleSpray
import at.petrak.hexcasting.api.casting.RenderedSpell
import at.petrak.hexcasting.api.casting.castables.SpellAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.eval.vm.CastingImage
import at.petrak.hexcasting.api.casting.getEntity
import at.petrak.hexcasting.api.casting.getVec3
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.misc.MediaConstants
import net.minecraft.nbt.CompoundTag
import net.minecraft.world.entity.Entity
import net.minecraft.world.phys.Vec3
import kotlin.math.roundToLong

object OpAddMotion : SpellAction {
override val argc: Int
Expand All @@ -20,26 +19,19 @@ object OpAddMotion : SpellAction {
// for bug #387
val MAX_MOTION: Double = 8192.0

override fun executeWithUserdata(
args: List<Iota>,
env: CastingEnvironment,
userData: CompoundTag
): SpellAction.Result {
override fun execute(args: List<Iota>, env: CastingEnvironment): SpellAction.Result {
val target = args.getEntity(env.world, 0, argc)
val motion = args.getVec3(1, argc)
env.assertEntityInRange(target)

var motionForCost = motion.lengthSqr()
if (CastingImage.checkAndMarkGivenMotion(userData, target))
motionForCost++

val shrunkMotion = if (motion.lengthSqr() > MAX_MOTION * MAX_MOTION)
motion.normalize().scale(MAX_MOTION)
else
motion

return SpellAction.Result(
Spell(target, shrunkMotion),
(motionForCost * MediaConstants.DUST_UNIT).toLong(),
(2 * motion.length() * MediaConstants.DUST_UNIT).roundToLong(),
listOf(
ParticleSpray(
target.position().add(0.0, target.eyeHeight / 2.0, 0.0),
Expand All @@ -51,10 +43,6 @@ object OpAddMotion : SpellAction {
)
}

override fun execute(args: List<Iota>, env: CastingEnvironment): SpellAction.Result {
throw IllegalStateException()
}

private data class Spell(val target: Entity, val motion: Vec3) : RenderedSpell {
override fun cast(env: CastingEnvironment) {
target.push(motion.x, motion.y, motion.z)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2042,7 +2042,7 @@
"explode.fire.1": "Remove a number and vector from the stack, then create a fiery explosion at the given location with the given power.",
"explode.fire.2": "Costs one $(l:items/amethyst)$(item)Amethyst Dust/$, plus about 3 extra $(l:items/amethyst)$(item)Amethyst Dust/$s per point of explosion power. Otherwise, the same as $(l:patterns/spells/basic#hexcasting:explode)$(action)Explosion/$, except with fire.",

add_motion: "Remove an entity and direction from the stack, then give a shove to the given entity in the given direction. The strength of the impulse is determined by the length of the vector.$(br)Costs units of $(l:items/amethyst)$(item)Amethyst Dust/$ equal to the square of the length of the vector, plus one for every Impulse except the first targeting an entity.",
add_motion: "Remove an entity and direction from the stack, then give a shove to the given entity in the given direction. The strength of the impulse is determined by the length of the vector.$(br)Costs $(l:items/amethyst)$(item)Amethyst Dust/$ equal to twice the length of the vector.",
blink: "Remove an entity and length from the stack, then teleport the given entity along its look vector by the given length.$(br)Costs about one $(l:items/amethyst)$(item)Amethyst Shard/$ per two blocks travelled.",

"beep.1": "Remove a vector and two numbers from the stack. Plays an $(thing)instrument/$ defined by the first number at the given location, with a $(thing)note/$ defined by the second number. Costs a negligible amount of _media.",
Expand Down
Loading