Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
kineticneticat authored Oct 17, 2024
2 parents 2f883ce + 5f583f3 commit d6441ef
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ 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.getBlockPos
import at.petrak.hexcasting.api.casting.getEntity
import at.petrak.hexcasting.api.casting.iota.EntityIota
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.iota.Vec3Iota
import at.petrak.hexcasting.api.casting.mishaps.MishapInvalidIota
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.ktxt.UseOnContext
import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.InteractionHand
import net.minecraft.world.entity.Entity
import net.minecraft.world.item.Item
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
Expand All @@ -25,17 +30,30 @@ object OpIgnite : SpellAction {
args: List<Iota>,
env: CastingEnvironment
): SpellAction.Result {
val target = args.getBlockPos(0, argc)
env.assertPosInRangeForEditing(target)

return SpellAction.Result(
Spell(target),
MediaConstants.DUST_UNIT,
listOf(ParticleSpray.burst(Vec3.atCenterOf(BlockPos(target)), 1.0))
)
when (val target = args[0]) {
is EntityIota -> {
val entity = args.getEntity(0, argc)
env.assertEntityInRange(entity)
return SpellAction.Result(
EntitySpell(entity),
MediaConstants.DUST_UNIT,
listOf(ParticleSpray.burst(entity.position(), 1.0))
)
}
is Vec3Iota -> {
val block = args.getBlockPos(0, argc)
env.assertPosInRangeForEditing(block)
return SpellAction.Result(
BlockSpell(block),
MediaConstants.DUST_UNIT,
listOf(ParticleSpray.burst(Vec3.atCenterOf(BlockPos(block)), 1.0))
)
}
else -> throw MishapInvalidIota.ofType(target, 0, "entity_or_vector")
}
}

private data class Spell(val pos: BlockPos) : RenderedSpell {
private data class BlockSpell(val pos: BlockPos) : RenderedSpell {
override fun cast(env: CastingEnvironment) {
// help
if (!tryToClick(env, pos, Items.FIRE_CHARGE)) {
Expand All @@ -56,4 +74,10 @@ object OpIgnite : SpellAction {
).consumesAction()
}
}
}

private data class EntitySpell(val entity: Entity) : RenderedSpell {
override fun cast(env: CastingEnvironment) {
entity.setSecondsOnFire(8)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@
erase: "Erase Item",
create_water: "Create Water",
destroy_water: "Destroy Liquid",
ignite: "Ignite Block",
ignite: "Ignite",
extinguish: "Extinguish Area",
conjure_block: "Conjure Block",
conjure_light: "Conjure Light",
Expand Down Expand Up @@ -929,6 +929,8 @@
living: "a living entity",
},

entity_or_vector: "an entity or a vector",

unknown: "(unknown, uh-oh, this is a bug)",
},

Expand Down Expand Up @@ -1834,7 +1836,7 @@
conjure_light: "Conjure a magical light that softly glows with my pigment at the given position. Costs about one $(l:items/amethyst)$(item)Amethyst Dust/$.",
bonemeal: "Encourage a plant or sapling at the target position to grow, as if $(item)Bonemeal/$ was applied. Costs a bit more than one $(l:items/amethyst)$(item)Amethyst Dust/$.",
edify: "Forcibly infuse _media into the sapling at the target position, causing it to grow into an $(l:items/edified)$(thing)Edified Tree/$. Costs about one $(l:items/amethyst)$(item)Charged Amethyst/$.",
ignite: "Start a fire on top of the given location, as if a $(item)Fire Charge/$ was applied. Costs about one $(l:items/amethyst)$(item)Amethyst Dust/$.",
ignite: "Start a fire on top of the given location, as if a $(item)Fire Charge/$ was applied, or sets fire to a creature. Costs about one $(l:items/amethyst)$(item)Amethyst Dust/$.",
extinguish: "Extinguish blocks in a large area. Costs about six $(l:items/amethyst)$(item)Amethyst Dust/$.",
},

Expand Down
Loading

0 comments on commit d6441ef

Please sign in to comment.