diff --git a/CHANGELOG.md b/CHANGELOG.md index d401546f7..5025c91a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Common/src/main/java/at/petrak/hexcasting/api/HexAPI.java b/Common/src/main/java/at/petrak/hexcasting/api/HexAPI.java index fcdc94b92..c0023ece4 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/HexAPI.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/HexAPI.java @@ -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(); } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/CastingImage.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/CastingImage.kt index c8658157f..5bf396b48 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/CastingImage.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/CastingImage.kt @@ -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 - } - } } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/OpAddMotion.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/OpAddMotion.kt index 90c1d15a0..c77d7381d 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/OpAddMotion.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/OpAddMotion.kt @@ -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 @@ -20,26 +19,19 @@ object OpAddMotion : SpellAction { // for bug #387 val MAX_MOTION: Double = 8192.0 - override fun executeWithUserdata( - args: List, - env: CastingEnvironment, - userData: CompoundTag - ): SpellAction.Result { + override fun execute(args: List, 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), @@ -51,10 +43,6 @@ object OpAddMotion : SpellAction { ) } - override fun execute(args: List, 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) diff --git a/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 b/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 index 528f82646..9e89df94a 100644 --- a/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 +++ b/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 @@ -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.",