made it better

This commit is contained in:
Hexugory 2023-03-13 21:05:01 -05:00
parent 0ea442a09c
commit 1dbec07458
6 changed files with 11 additions and 83 deletions

View File

@ -11,7 +11,6 @@ import at.petrak.hexcasting.common.casting.operators.selectors.*
import net.minecraft.resources.ResourceLocation
import net.touhoudiscord.hexucasting.api.HexucastingAPI.modLoc
import net.touhoudiscord.hexucasting.common.casting.actions.spells.OpDaylightAction
import net.touhoudiscord.hexucasting.common.casting.actions.spells.OpStarlightAction
object Patterns {
@ -40,8 +39,6 @@ object Patterns {
@JvmField
val DAYLIGHT = make(HexPattern.fromAngles("wewewewewewaaweedeewedeewedeewedeewedeee", HexDir.EAST), modLoc("spells/daylight"), OpDaylightAction, true)
@JvmField
val STARLIGHT = make(HexPattern.fromAngles("wwwwwdwewwwewaqaeewaqddqaweeaqwadqwwqda", HexDir.EAST), modLoc("spells/starlight"), OpStarlightAction, true)
private fun make (pattern: HexPattern, location: ResourceLocation, operator: Action, isPerWorld: Boolean = false): PatternIota {
val triple = Triple(pattern, location, operator)

View File

@ -1,11 +1,8 @@
package net.touhoudiscord.hexucasting.common.casting.actions.spells
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.spell.ParticleSpray
import at.petrak.hexcasting.api.spell.RenderedSpell
import at.petrak.hexcasting.api.spell.SpellAction
import at.petrak.hexcasting.api.spell.*
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getVec3
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.core.BlockPos
@ -18,7 +15,7 @@ object OpDaylightAction : SpellAction {
/**
* The number of arguments from the stack that this action requires.
*/
override val argc = 0
override val argc = 1
/**
* The method called when this Action is actually executed. Accepts the [args]
@ -34,8 +31,10 @@ object OpDaylightAction : SpellAction {
* etc.) should be in the private [Spell] data class below.
*/
override fun execute(args: List<Iota>, ctx: CastingContext): Triple<RenderedSpell, Int, List<ParticleSpray>> {
val time = minOf(args.getPositiveInt(0, argc), 24000)
return Triple(
Spell(),
Spell(time),
MediaConstants.CRYSTAL_UNIT*2,
listOf()
)
@ -46,14 +45,14 @@ object OpDaylightAction : SpellAction {
* define where/what it should affect (for this example the parameter is [vec]), and the
* [cast] method within is responsible for using that data to alter the world.
*/
private data class Spell(val thisisgivingmeanerrorifidontputsomethinghere: Int = 0) : RenderedSpell {
private data class Spell(val time: Int) : RenderedSpell {
override fun cast(ctx: CastingContext) {
val w = ctx.world
val relativeTime = w.dayTime%24000
if (relativeTime > 23459) {
if (relativeTime > time) {
w.dayTime += 24000
}
w.dayTime = w.dayTime-relativeTime+23459
w.dayTime = w.dayTime-relativeTime+time
}
}
}

View File

@ -1,59 +0,0 @@
package net.touhoudiscord.hexucasting.common.casting.actions.spells
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.spell.ParticleSpray
import at.petrak.hexcasting.api.spell.RenderedSpell
import at.petrak.hexcasting.api.spell.SpellAction
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getVec3
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.core.BlockPos
import net.minecraft.world.level.block.Blocks
import net.minecraft.world.phys.Vec3
import net.touhoudiscord.hexucasting.api.config.HexucastingConfig
import net.touhoudiscord.hexucasting.common.casting.actions.OpExampleConstMediaAction.argc
object OpStarlightAction : SpellAction {
/**
* The number of arguments from the stack that this action requires.
*/
override val argc = 0
/**
* The method called when this Action is actually executed. Accepts the [args]
* that were on the stack (there will be [argc] of them), and the [ctx],
* which contains things like references to the caster, the ServerLevel,
* methods to determine whether locations and entities are in ambit, etc.
* Returns a triple of things. The [RenderedSpell] is responsible for the spell actually
* doing things in the world, the [Int] is how much media the spell should cost,
* and the [List] of [ParticleSpray] renders particle effects for the result of the SpellAction.
*
* The [execute] method should only contain code to find the targets of the spell and validate
* them. All the code that actually makes changes to the world (breaking blocks, teleporting things,
* etc.) should be in the private [Spell] data class below.
*/
override fun execute(args: List<Iota>, ctx: CastingContext): Triple<RenderedSpell, Int, List<ParticleSpray>> {
return Triple(
Spell(),
MediaConstants.CRYSTAL_UNIT,
listOf()
)
}
/**
* This class is responsible for actually making changes to the world. It accepts parameters to
* define where/what it should affect (for this example the parameter is [vec]), and the
* [cast] method within is responsible for using that data to alter the world.
*/
private data class Spell(val thisisgivingmeanerrorifidontputsomethinghere: Int = 0) : RenderedSpell {
override fun cast(ctx: CastingContext) {
val w = ctx.world
val relativeTime = w.dayTime%24000
if (relativeTime > 12542) {
w.dayTime += 24000
}
w.dayTime = w.dayTime-relativeTime+12542
}
}
}

View File

@ -6,8 +6,7 @@
"hexcasting.spell.book.hexucasting:spells/starlight": "Starlight",
"hexucasting.entry.daytime_manip": "Daytime Manipulation",
"hexucasting.page.daytime_manip.spells/daylight": "This spell will cast time forward to day in the world I cast it upon. Costs two $(l:items/amethyst)$(item)Charged Amethyst/$",
"hexucasting.page.daytime_manip.spells/starlight": "This spell will cast time forward to night in the world I cast it upon. Costs two $(l:items/amethyst)$(item)Charged Amethyst/$",
"hexucasting.page.daytime_manip.spells/daylight": "This spell will cast time forward to the relative time given in ticks in the world I cast it upon. Costs two $(l:items/amethyst)$(item)Charged Amethyst/$",
"_comment": "Config Entries",
"text.autoconfig.hexucasting.title": "Your Mod Configs",

View File

@ -10,17 +10,9 @@
"type": "hexcasting:pattern",
"op_id": "hexucasting:spells/daylight",
"anchor": "hexucasting:spells/daylight",
"input": "",
"input": "number",
"output": "",
"text": "hexucasting.page.daytime_manip.spells/daylight"
},
{
"type": "hexcasting:pattern",
"op_id": "hexucasting:spells/starlight",
"anchor": "hexucasting:spells/starlight",
"input": "",
"output": "",
"text": "hexucasting.page.daytime_manip.spells/starlight"
}
]
}

View File

@ -10,7 +10,7 @@ jetbrainsAnnotationsVersion=23.0.0
minecraftVersion=1.19.2
kotlinVersion=1.7.20
modVersion=1.0.0
modVersion=1.1.0
paucalVersion=0.5.0
hexcastingVersion=0.10.3