-
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.
- Loading branch information
1 parent
3b7d199
commit 01a4b34
Showing
8 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
common/src/main/java/miyucomics/hexical/casting/patterns/spells/OpInscribeInGrimoire.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,36 @@ | ||
package miyucomics.hexical.casting.patterns.spells | ||
|
||
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 { | ||
override val argc = 2 | ||
|
||
override fun execute(args: List<Iota>, ctx: CastingContext): Triple<RenderedSpell, Int, List<ParticleSpray>> { | ||
val pattern = args.getPattern(0, argc); | ||
val hex = args.getList(1, argc).toList(); | ||
val (stack, _) = ctx.getHeldItemToOperateOn { it.item is GrimoireItem } | ||
val trueName = MishapOthersName.getTrueNameFromArgs(hex, ctx.caster) | ||
if (trueName != null) | ||
throw MishapOthersName(trueName) | ||
return Triple(Spell(pattern, hex, stack), MediaConstants.SHARD_UNIT, listOf()) | ||
} | ||
|
||
private data class Spell(val pattern: HexPattern, val hex: List<Iota>, val stack: ItemStack) : RenderedSpell { | ||
override fun cast(ctx: CastingContext) { | ||
GrimoireItem.writeToGrimoire(stack, pattern, hex) | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
common/src/main/java/miyucomics/hexical/items/GrimoireItem.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,32 @@ | ||
package miyucomics.hexical.items | ||
|
||
import at.petrak.hexcasting.api.spell.iota.Iota | ||
import at.petrak.hexcasting.api.spell.math.HexPattern | ||
import at.petrak.hexcasting.api.utils.putList | ||
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes | ||
import net.minecraft.item.Item | ||
import net.minecraft.item.ItemStack | ||
import net.minecraft.nbt.NbtCompound | ||
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>) { | ||
val patterns = NbtList() | ||
for (iota in information) | ||
patterns.add(HexIotaTypes.serialize(iota)); | ||
stack.orCreateNbt.putList(key.anglesSignature(), patterns) | ||
} | ||
|
||
fun getPatternInGrimoire (stack: ItemStack, key: HexPattern, world: ServerWorld): List<Iota>? { | ||
val patsTag = stack.orCreateNbt.getList(key.anglesSignature(), NbtElement.COMPOUND_TYPE.toInt()) ?: return null; | ||
val out = ArrayList<Iota>() | ||
for (patTag in patsTag) | ||
out.add(HexIotaTypes.deserialize(patTag as NbtCompound, world)); | ||
return out; | ||
} | ||
} | ||
} |
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
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
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
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
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
6 changes: 6 additions & 0 deletions
6
common/src/main/resources/assets/hexical/models/item/grimoire.json
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,6 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "minecraft:item/knowledge_book" | ||
} | ||
} |