Skip to content

Commit

Permalink
More grimoire stuff!
Browse files Browse the repository at this point in the history
  • Loading branch information
miyucomics committed Mar 9, 2024
1 parent 07aed5d commit d72af73
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 56 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package miyucomics.hexical.casting.patterns.spells.grimoire

import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.spell.*
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.math.HexPattern
import at.petrak.hexcasting.api.spell.mishaps.MishapOthersName
import miyucomics.hexical.items.GrimoireItem
import net.minecraft.item.ItemStack

class OpGrimoireErase : SpellAction {
override val argc = 1

override fun execute(args: List<Iota>, ctx: CastingContext): Triple<RenderedSpell, Int, List<ParticleSpray>> {
val pattern = args.getPattern(0, argc);
val (stack, _) = ctx.getHeldItemToOperateOn { it.item is GrimoireItem }
return Triple(Spell(pattern, stack), 0, listOf())
}

private data class Spell(val pattern: HexPattern, val stack: ItemStack) : RenderedSpell {
override fun cast(ctx: CastingContext) {
GrimoireItem.eraseInGrimoire(stack, pattern)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
package miyucomics.hexical.casting.patterns.spells
package miyucomics.hexical.casting.patterns.spells.grimoire

import at.petrak.hexcasting.api.misc.DiscoveryHandlers
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.spell.*
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.math.HexPattern
import at.petrak.hexcasting.api.spell.mishaps.MishapLocationTooFarAway
import at.petrak.hexcasting.api.spell.mishaps.MishapOthersName
import miyucomics.hexical.items.GrimoireItem
import miyucomics.hexical.registry.HexicalItems
import net.minecraft.item.ItemStack
import net.minecraft.item.Items
import net.minecraft.server.network.ServerPlayerEntity
import net.minecraft.util.math.Vec3d

class OpInscribeInGrimoire : SpellAction {
class OpGrimoireWrite : SpellAction {
override val argc = 2

override fun execute(args: List<Iota>, ctx: CastingContext): Triple<RenderedSpell, Int, List<ParticleSpray>> {
Expand All @@ -25,7 +19,7 @@ class OpInscribeInGrimoire : SpellAction {
val trueName = MishapOthersName.getTrueNameFromArgs(hex, ctx.caster)
if (trueName != null)
throw MishapOthersName(trueName)
return Triple(Spell(pattern, hex, stack), MediaConstants.SHARD_UNIT, listOf())
return Triple(Spell(pattern, hex, stack), 0, listOf())
}

private data class Spell(val pattern: HexPattern, val hex: List<Iota>, val stack: ItemStack) : RenderedSpell {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import net.minecraft.nbt.NbtElement
import net.minecraft.nbt.NbtList
import net.minecraft.server.world.ServerWorld


class GrimoireItem : Item(Settings().maxCount(1)) {
companion object {
fun writeToGrimoire (stack: ItemStack, key: HexPattern, information: List<Iota>) {
Expand All @@ -21,6 +20,10 @@ class GrimoireItem : Item(Settings().maxCount(1)) {
stack.orCreateNbt.putList(key.anglesSignature(), patterns)
}

fun eraseInGrimoire (stack: ItemStack, key: HexPattern) {
stack.orCreateNbt.remove(key.anglesSignature())
}

fun getPatternInGrimoire (stack: ItemStack, key: HexPattern, world: ServerWorld): List<Iota>? {
val patsTag = stack.orCreateNbt.getList(key.anglesSignature(), NbtElement.COMPOUND_TYPE.toInt())
if (patsTag.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import at.petrak.hexcasting.api.spell.iota.PatternIota;
import at.petrak.hexcasting.api.spell.math.HexDir;
import at.petrak.hexcasting.api.spell.math.HexPattern;
import at.petrak.hexcasting.common.lib.HexSounds;
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import com.llamalad7.mixinextras.injector.WrapWithCondition;
Expand Down Expand Up @@ -76,9 +77,11 @@ private void expandGrimoire (Iota iota, ServerWorld world, CallbackInfoReturnabl
return;
if (!hexical$harness.getEscapeNext() && iota.getType() == HexIotaTypes.PATTERN && !((PatternIota) iota).getPattern().sigsEqual(HexPattern.fromAngles("qqqaw", HexDir.EAST))) {
HexPattern pattern = ((PatternIota) iota).getPattern();
toExecute = CastingUtils.Companion.grimoireLookup(ctx.getCaster(), pattern, DiscoveryHandlers.collectItemSlots(ctx));
if (toExecute == null)
toExecute = new ArrayList<>(Collections.singleton(iota));
List<Iota> lookupResult = CastingUtils.Companion.grimoireLookup(ctx.getCaster(), pattern, DiscoveryHandlers.collectItemSlots(ctx));
if (lookupResult != null) {
toExecute = lookupResult;
ctx.getCaster().playSound(HexSounds.CAST_HERMES, SoundCategory.MASTER, 0.25f, 1.25f);
}
}
cir.setReturnValue(hexical$harness.executeIotas(toExecute, world));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import miyucomics.hexical.casting.patterns.operators.lamp.OpGetArchLampData
import miyucomics.hexical.casting.patterns.operators.lamp.OpGetLampData
import miyucomics.hexical.casting.patterns.operators.lamp.OpIsUsingArchLamp
import miyucomics.hexical.casting.patterns.spells.*
import miyucomics.hexical.casting.patterns.spells.grimoire.OpGrimoireErase
import miyucomics.hexical.casting.patterns.spells.grimoire.OpGrimoireWrite
import net.minecraft.util.Identifier

object HexicalPatterns {
Expand All @@ -38,7 +40,8 @@ object HexicalPatterns {
var ENTITY_WET: HexPattern = register(HexPattern.fromAngles("qqqqwaadq", HexDir.SOUTH_WEST), "is_wet", OpGetEntityWet())
var PLAYER_SPRINTING: HexPattern = register(HexPattern.fromAngles("eaq", HexDir.WEST), "is_sprinting", OpGetPlayerSprinting())

var WRITE_TO_GRIMOIRE: HexPattern = register(HexPattern.fromAngles("waqwa", HexDir.SOUTH_WEST), "write_grimoire", OpInscribeInGrimoire())
var WRITE_TO_GRIMOIRE: HexPattern = register(HexPattern.fromAngles("waqwa", HexDir.SOUTH_WEST), "write_grimoire", OpGrimoireWrite())
var ERASE_GRIMOIRE: HexPattern = register(HexPattern.fromAngles("wedwe", HexDir.SOUTH_WEST), "erase_grimoire", OpGrimoireErase())

var PROGRAM_LAMP: HexPattern = register(HexPattern.fromAngles("wwqqqqq", HexDir.EAST), "program_lamp", OpProgramLamp())
var LAMP_POSITION: HexPattern = register(HexPattern.fromAngles("qwddedqdd", HexDir.SOUTH_WEST), "get_lamp_position", OpGetLampData(0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class CastingUtils {
if (stack.item != HexicalItems.GRIMOIRE_ITEM)
continue
val value = GrimoireItem.getPatternInGrimoire(stack, pattern, player.getWorld())
player.sendMessage(Text.literal(value.toString()))
if (value != null)
return value
}
Expand Down
9 changes: 9 additions & 0 deletions common/src/main/resources/assets/hexical/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"subtitles.hexical.lamp_deactivate": "Lamp deactivates",

"hexcasting.spell.hexical:write_grimoire": "Write Grimoire",
"hexcasting.spell.hexical:erase_grimoire": "Erase Grimoire",
"hexcasting.spell.hexical:program_lamp": "Educate Genie",
"hexcasting.spell.hexical:get_lamp_position": "Genie Refl.: Spatial",
"hexcasting.spell.hexical:get_lamp_rotation": "Genie Refl.: Rotational",
Expand Down Expand Up @@ -45,6 +46,14 @@
"hexical.page.hexical_changes.0": "I feel strangely more receptive of the ambient media around me. It feels $(o)friendlier$() somehow... I can even feel it responding to certain actions, as if suggesting new spells to me. I also notice I require less concentration with my staff and can move around while using it. Unfortunately, Nature has not become more forgiving of my mishaps.",
"hexical.page.hexical_changes.1": "The media has also become more malleable, letting me manipulate it precisely into specific specialized effects. I can also interface with my abacus using Scribe's Gambit.",

"hexical.page.grimoire.title": "Grimoire",
"hexical.page.grimoire.0": "By encrusting my spellbook with charged amethyst and edified wood, it traps media within the pages like an echo chamber. I can then introduce a pattern-to-pattern-list association, or a binding, for the grimoire to keep bouncing endlessly inside.",
"hexical.page.grimoire.1": "When I then cast the pattern associated with a pattern list with my staff and the grimoire in my inventory, it empowers the pattern, allowing it to break free from the grimoire's pages with a faint sound of a hex being cast. This allows me to create $(o)shortcuts$() for my staff by associating a short pattern with a common task, such as the raycast mantra.",
"hexical.page.grimoire.2": "While stable with only a few abstract strands of media wizzing around inside, a single grimoire can not hold more than sixteen pattern associations. When attempting to introduce more, the grimoire simply rejects it and throws itself onto the ground with a shower of blue sparks.",
"hexical.page.grimoire.3": "I can also mark a pattern inside the grimoire as volatile, meaning it destroys itself after a certain number of uses. I shall find this aspect of the grimoire quite useful if I ever need to lend out my true name. I can simply give them a grimoire a set number of references to my name.",
"hexical.page.write_grimoire": "Writes a pattern-to-pattern-list binding into the grimoire in my offhand.",
"hexical.page.erase_grimoire": "Erases the pattern-list binding to the pattern in the grimoire in my offhand if it exists.",

"hexical.category.lamp": "Genieless Lamp",
"hexical.category.lamp.desc": "I have heard tales from the villagers about a magical artifact. Legends say it contains a spirit that grants wishes, but I suspect that is just embellishment evolved over centuries of storytelling. Regardless, I dedicate this chapter to my pursuit and research of it.",

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "hexical.page.grimoire.title",
"icon": "hexical:grimoire",
"category": "hexcasting:items",
"pages": [
{
"type": "patchouli:text",
"text": "hexical.page.grimoire.0"
},
{
"type": "patchouli:text",
"text": "hexical.page.grimoire.1"
},
{
"type": "patchouli:text",
"text": "hexical.page.grimoire.2"
},
{
"type": "patchouli:text",
"text": "hexical.page.grimoire.3"
},
{
"type": "hexcasting:pattern",
"op_id": "hexical:write_grimoire",
"anchor": "hexical:write_grimoire",
"input": "pattern, [pattern]",
"output": "",
"text": "hexical.page.write_grimoire"
},
{
"type": "hexcasting:pattern",
"op_id": "hexical:erase_grimoire",
"anchor": "hexical:erase_grimoire",
"input": "pattern",
"output": "",
"text": "hexical.page.erase_grimoire"
}
]
}

0 comments on commit d72af73

Please sign in to comment.