-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added pattern for fetching lamp data
- Loading branch information
1 parent
a9f0dc3
commit 848301c
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
common/src/main/java/miyucomics/hexical/casting/mishaps/MishapNeedLamp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package miyucomics.hexical.casting.mishaps | ||
|
||
class MishapNeedLamp { | ||
} |
29 changes: 29 additions & 0 deletions
29
common/src/main/java/miyucomics/hexical/casting/patterns/operators/lamp/OpGetLampData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package miyucomics.hexical.casting.patterns.operators.lamp | ||
|
||
import at.petrak.hexcasting.api.spell.ConstMediaAction | ||
import at.petrak.hexcasting.api.spell.iota.Iota | ||
import at.petrak.hexcasting.api.spell.casting.CastingContext | ||
import at.petrak.hexcasting.api.spell.iota.DoubleIota | ||
import at.petrak.hexcasting.api.spell.iota.NullIota | ||
import at.petrak.hexcasting.api.spell.iota.Vec3Iota | ||
import miyucomics.hexical.casting.mishaps.MishapNeedLamp | ||
import miyucomics.hexical.registry.HexicalItems | ||
import at.petrak.hexcasting.api.utils.vecFromNBT | ||
|
||
class OpGetLampStartData(private val mode: Int) : ConstMediaAction { | ||
override val argc = 0 | ||
|
||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> { | ||
if (!(ctx.caster.activeItem.item == HexicalItems.LAMP_ITEM.asItem() && ctx.source == CastingContext.CastSource.PACKAGED_HEX)) | ||
throw MishapNeedLamp() | ||
|
||
val rodNbt = ctx.caster.activeItem.nbt ?: return listOf(NullIota()) | ||
when (mode) { | ||
1 -> return listOf(Vec3Iota(vecFromNBT(rodNbt.getLongArray("startPosition")))) | ||
2 -> return listOf(Vec3Iota(vecFromNBT(rodNbt.getLongArray("startRotation")))) | ||
3 -> return listOf(DoubleIota(ctx.world.time - rodNbt.getDouble("startTime"))) | ||
} | ||
|
||
return listOf(NullIota()) | ||
} | ||
} |