Skip to content

Commit

Permalink
Preparation for diving gambit
Browse files Browse the repository at this point in the history
  • Loading branch information
miyucomics committed Feb 20, 2024
1 parent dd9b7d2 commit eedd256
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ConjuredBouncyBlock(properties: Settings?) : BlockConjured(properties) {
}

override fun <T : BlockEntity?> getTicker(pLevel: World, pState: BlockState?, pBlockEntityType: BlockEntityType<T>?): BlockEntityTicker<T>? {
return if (pLevel.isClient) BlockEntityTicker { level: World?, blockPos: BlockPos?, blockState: BlockState?, t: T -> tick(level, blockPos, blockState, t) } else null
return if (pLevel.isClient) BlockEntityTicker { _, _, _, blockEntity: T -> tick(blockEntity) } else null
}

override fun onSteppedOn(pLevel: World, pPos: BlockPos, pState: BlockState, pEntity: Entity) {
Expand All @@ -34,9 +34,9 @@ class ConjuredBouncyBlock(properties: Settings?) : BlockConjured(properties) {
}

companion object {
fun <T> tick(level: World?, blockPos: BlockPos?, blockState: BlockState?, t: T) {
if (t is ConjuredBouncyBlockEntity)
t.particleEffect()
fun <T> tick(blockEntity: T) {
if (blockEntity is ConjuredBouncyBlockEntity)
blockEntity.particleEffect()
}

fun setColor(pLevel: WorldAccess, pPos: BlockPos, colorizer: FrozenColorizer) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package miyucomics.hexical.casting.patterns.operators.eval

import at.petrak.hexcasting.api.spell.*
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.casting.eval.SpellContinuation
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs

object OpDiver : Action {
override fun operate(continuation: SpellContinuation, stack: MutableList<Iota>, ravenmind: Iota?, ctx: CastingContext): OperationResult {
if (stack.size < 2)
throw MishapNotEnoughArgs(2, stack.size)
val instructions = stack.getList(stack.lastIndex - 1)
val diveAmount = stack.getPositiveIntUnderInclusive(0, stack.size - 1)
stack.removeLastOrNull()
stack.removeLastOrNull()

val output = mutableListOf<Iota>()
output.addAll(stack.takeLast(diveAmount))
for (i in 0 until diveAmount)
stack.removeLast()

// cast pattern list??

output.reverse()
for (iota in output)
stack.add(iota)

return OperationResult(continuation, stack, ravenmind, listOf())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import net.minecraft.util.registry.Registry

object HexicalBlocks {
private val BLOCKS: DeferredRegister<Block> = DeferredRegister.create(Hexical.MOD_ID, Registry.BLOCK_KEY)
private val BLOCK_ENTITIES: DeferredRegister<BlockEntityType<*>> = DeferredRegister.create(Hexical.MOD_ID, Registry.BLOCK_ENTITY_TYPE_KEY)
val CONJURED_BOUNCY_BLOCK: Block = ConjuredBouncyBlock(
AbstractBlock.Settings
.of(Material.ORGANIC_PRODUCT)
Expand All @@ -32,6 +33,8 @@ object HexicalBlocks {
@JvmStatic
fun init() {
BLOCKS.register("conjured_bouncy_block") { CONJURED_BOUNCY_BLOCK }
BLOCK_ENTITIES.register("conjured_bouncy_block") { CONJURED_BOUNCY_BLOCK_ENTITY }
BLOCK_ENTITIES.register()
BLOCKS.register()
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
package miyucomics.hexical.registry

import at.petrak.hexcasting.api.PatternRegistry
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.spell.Action
import at.petrak.hexcasting.api.spell.math.HexDir
import at.petrak.hexcasting.api.spell.math.HexPattern
import at.petrak.hexcasting.common.casting.operators.spells.OpMakePackagedSpell
import at.petrak.hexcasting.common.casting.operators.eval.OpEval
import miyucomics.hexical.Hexical
import miyucomics.hexical.casting.patterns.operators.eval.OpDiver
import miyucomics.hexical.casting.patterns.spells.OpChorusBlink
import miyucomics.hexical.casting.patterns.spells.OpConjureBouncyBlock
import miyucomics.hexical.casting.patterns.spells.OpPing
import miyucomics.hexical.casting.patterns.spells.OpProgramLamp
import miyucomics.hexical.items.LampItem
import net.minecraft.util.Identifier


object HexicalPatterns {
private var PATTERNS: MutableList<Triple<HexPattern, Identifier, Action>> = ArrayList()
private var PER_WORLD_PATTERNS: MutableList<Triple<HexPattern, Identifier, Action>> = ArrayList()

var DIVER_GAMBIT = register(HexPattern.fromAngles("deaqqdq", HexDir.SOUTH_EAST), "dive", OpDiver);

var CHORUS_BLINK: HexPattern = register(HexPattern.fromAngles("aawqqqq", HexDir.SOUTH_EAST), "chorus_blink", OpChorusBlink())
var CONJURE_BOUNCY_BLOCK: HexPattern = register(HexPattern.fromAngles("dee", HexDir.NORTH_WEST), "conjure_bouncy_block", OpConjureBouncyBlock())
var PROGRAM_LAMP: HexPattern = register(HexPattern.fromAngles("wwqqqqq", HexDir.EAST), "program_lamp", OpProgramLamp())
Expand Down

0 comments on commit eedd256

Please sign in to comment.