Skip to content

Commit

Permalink
Ancient cyphers (#838)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamsTheNerd authored Feb 3, 2025
2 parents 4a47698 + 5976e24 commit 1d3a855
Show file tree
Hide file tree
Showing 67 changed files with 1,034 additions and 362 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2023-12-24T17:59:13.7584156 Item Models: hexcasting
// 1.20.1 2024-12-10T14:26:44.916295 Item Models: hexcasting
2fc68dcd6d73da3deaa6a33240dd9160a2b79592 assets/hexcasting/models/block/deco/quenched_allay_bricks_0.json
d59af7a48b20b210240b26115fb172d6202f9254 assets/hexcasting/models/block/deco/quenched_allay_bricks_1.json
a62eeebbca2d145c22f25725bd848ed4d673cefa assets/hexcasting/models/block/deco/quenched_allay_bricks_2.json
Expand All @@ -19,6 +19,22 @@ f2156b3a7041cf99891b528393db64c6b9ca1a4f assets/hexcasting/models/item/abacus.js
19730853397b109cfedd0c3bbda83d5de6cd15b9 assets/hexcasting/models/item/akashic_record.json
8c735feff09d46d00ed681311f46f61a50cfdc9b assets/hexcasting/models/item/amethyst_dust.json
fbb8706993fbc3246c56b9f3eb274ff8968b70f8 assets/hexcasting/models/item/amethyst_pillar.json
533a859174052a332de069b2ffeaf0106d132b9a assets/hexcasting/models/item/ancient_cypher.json
71a7968e43fbb872ee52315a3ee738d0b3fd1a69 assets/hexcasting/models/item/ancient_cypher_0_filled.json
0f0c627d7ed0e8a7e3666ca80ddc13b280d6ce9f assets/hexcasting/models/item/ancient_cypher_1.json
097b8ecfb34df710ca4b396d3a5df7722ecc3596 assets/hexcasting/models/item/ancient_cypher_1_filled.json
9fdde927e7e8b06221aef34a6a6b22d0b790f297 assets/hexcasting/models/item/ancient_cypher_2.json
93257ad393b751931539a5641d4430a4631e95f9 assets/hexcasting/models/item/ancient_cypher_2_filled.json
4af6234e24031ee0989282c8435fe07e85b02771 assets/hexcasting/models/item/ancient_cypher_3.json
41760f3c89d8dc94c515b0ab8220ecf996710a3c assets/hexcasting/models/item/ancient_cypher_3_filled.json
4df83ae775400ca2d480bfb3621abcf58d4d7352 assets/hexcasting/models/item/ancient_cypher_4.json
d21eb7093c0231015808a8b51b27857da1748431 assets/hexcasting/models/item/ancient_cypher_4_filled.json
e2b4e2ac4ad4fa4b490e1774a565a26fb840c474 assets/hexcasting/models/item/ancient_cypher_5.json
4555e5de80047ffa4e72a4a98eb51437a95e7291 assets/hexcasting/models/item/ancient_cypher_5_filled.json
420840b5761fcddbdd10186f3127bc7589badc46 assets/hexcasting/models/item/ancient_cypher_6.json
55c08581a2e8c7134d63b38226bddafff0fba3ae assets/hexcasting/models/item/ancient_cypher_6_filled.json
2731192f0c7a9a8d45ba4fcd8d1de60bade0b49e assets/hexcasting/models/item/ancient_cypher_7.json
7ba3015d79601f1c8238dbac4a45e525e3589f16 assets/hexcasting/models/item/ancient_cypher_7_filled.json
87e7ee44cdd0808a3dd72babfd1db716df2bcdfe assets/hexcasting/models/item/artifact.json
1cd1b4d002d1a9a044ceab7cca842e4a2b7bd2f4 assets/hexcasting/models/item/artifact_0_filled.json
4709e65d8e74cf45b3ba014bdf70373728cccc78 assets/hexcasting/models/item/artifact_1.json
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"parent": "minecraft:item/generated",
"overrides": [
{
"model": "hexcasting:item/ancient_cypher",
"predicate": {
"hexcasting:has_patterns": -0.01,
"hexcasting:variant": 0.0
}
},
{
"model": "hexcasting:item/ancient_cypher_0_filled",
"predicate": {
"hexcasting:has_patterns": 0.99,
"hexcasting:variant": 0.0
}
},
{
"model": "hexcasting:item/ancient_cypher_1",
"predicate": {
"hexcasting:has_patterns": -0.01,
"hexcasting:variant": 1.0
}
},
{
"model": "hexcasting:item/ancient_cypher_1_filled",
"predicate": {
"hexcasting:has_patterns": 0.99,
"hexcasting:variant": 1.0
}
},
{
"model": "hexcasting:item/ancient_cypher_2",
"predicate": {
"hexcasting:has_patterns": -0.01,
"hexcasting:variant": 2.0
}
},
{
"model": "hexcasting:item/ancient_cypher_2_filled",
"predicate": {
"hexcasting:has_patterns": 0.99,
"hexcasting:variant": 2.0
}
},
{
"model": "hexcasting:item/ancient_cypher_3",
"predicate": {
"hexcasting:has_patterns": -0.01,
"hexcasting:variant": 3.0
}
},
{
"model": "hexcasting:item/ancient_cypher_3_filled",
"predicate": {
"hexcasting:has_patterns": 0.99,
"hexcasting:variant": 3.0
}
},
{
"model": "hexcasting:item/ancient_cypher_4",
"predicate": {
"hexcasting:has_patterns": -0.01,
"hexcasting:variant": 4.0
}
},
{
"model": "hexcasting:item/ancient_cypher_4_filled",
"predicate": {
"hexcasting:has_patterns": 0.99,
"hexcasting:variant": 4.0
}
},
{
"model": "hexcasting:item/ancient_cypher_5",
"predicate": {
"hexcasting:has_patterns": -0.01,
"hexcasting:variant": 5.0
}
},
{
"model": "hexcasting:item/ancient_cypher_5_filled",
"predicate": {
"hexcasting:has_patterns": 0.99,
"hexcasting:variant": 5.0
}
},
{
"model": "hexcasting:item/ancient_cypher_6",
"predicate": {
"hexcasting:has_patterns": -0.01,
"hexcasting:variant": 6.0
}
},
{
"model": "hexcasting:item/ancient_cypher_6_filled",
"predicate": {
"hexcasting:has_patterns": 0.99,
"hexcasting:variant": 6.0
}
},
{
"model": "hexcasting:item/ancient_cypher_7",
"predicate": {
"hexcasting:has_patterns": -0.01,
"hexcasting:variant": 7.0
}
},
{
"model": "hexcasting:item/ancient_cypher_7_filled",
"predicate": {
"hexcasting:has_patterns": 0.99,
"hexcasting:variant": 7.0
}
}
],
"textures": {
"layer0": "hexcasting:item/cad/0_ancient_cypher"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexcasting:item/cad/0_ancient_cypher",
"layer1": "hexcasting:item/cad/0_ancient_cypher_overlay"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexcasting:item/cad/1_ancient_cypher"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexcasting:item/cad/1_ancient_cypher",
"layer1": "hexcasting:item/cad/1_ancient_cypher_overlay"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexcasting:item/cad/2_ancient_cypher"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexcasting:item/cad/2_ancient_cypher",
"layer1": "hexcasting:item/cad/2_ancient_cypher_overlay"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexcasting:item/cad/3_ancient_cypher"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexcasting:item/cad/3_ancient_cypher",
"layer1": "hexcasting:item/cad/3_ancient_cypher_overlay"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexcasting:item/cad/4_ancient_cypher"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexcasting:item/cad/4_ancient_cypher",
"layer1": "hexcasting:item/cad/4_ancient_cypher_overlay"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexcasting:item/cad/5_ancient_cypher"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexcasting:item/cad/5_ancient_cypher",
"layer1": "hexcasting:item/cad/5_ancient_cypher_overlay"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexcasting:item/cad/6_ancient_cypher"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexcasting:item/cad/6_ancient_cypher",
"layer1": "hexcasting:item/cad/6_ancient_cypher_overlay"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexcasting:item/cad/7_ancient_cypher"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexcasting:item/cad/7_ancient_cypher",
"layer1": "hexcasting:item/cad/7_ancient_cypher_overlay"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public static void init() {
ItemSpellbook::isSealed);
registerVariantOverrides(HexItems.FOCUS, HexItems.FOCUS::getVariant);
registerVariantOverrides(HexItems.SPELLBOOK, HexItems.SPELLBOOK::getVariant);
registerVariantOverrides(HexItems.ANCIENT_CYPHER, HexItems.ANCIENT_CYPHER::getVariant);
registerVariantOverrides(HexItems.CYPHER, HexItems.CYPHER::getVariant);
registerVariantOverrides(HexItems.TRINKET, HexItems.TRINKET::getVariant);
registerVariantOverrides(HexItems.ARTIFACT, HexItems.ARTIFACT::getVariant);
Expand All @@ -75,6 +76,7 @@ public static void init() {
}
});

registerPackagedSpellOverrides(HexItems.ANCIENT_CYPHER);
registerPackagedSpellOverrides(HexItems.CYPHER);
registerPackagedSpellOverrides(HexItems.TRINKET);
registerPackagedSpellOverrides(HexItems.ARTIFACT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.entity.item.ItemEntity
import net.minecraft.world.item.ItemStack
import net.minecraft.network.chat.Component
import java.util.function.Predicate;

// TODO: How to handle in circles
class OpMakePackagedSpell<T : ItemPackagedHex>(val itemType: T, val cost: Long) : SpellAction {
class OpMakePackagedSpell(val isValid: Predicate<ItemStack>, val expectedTypeDesc: Component, val cost: Long) : SpellAction {
constructor(itemType: ItemPackagedHex, cost: Long) : this({s -> s.`is`(itemType)}, itemType.description, cost) {}

override val argc = 2
override fun execute(
args: List<Iota>,
Expand All @@ -30,13 +34,13 @@ class OpMakePackagedSpell<T : ItemPackagedHex>(val itemType: T, val cost: Long)

val (handStack) = env.getHeldItemToOperateOn {
val hexHolder = IXplatAbstractions.INSTANCE.findHexHolder(it)
it.`is`(itemType) && hexHolder != null && !hexHolder.hasHex()
isValid.test(it) && hexHolder != null && !hexHolder.hasHex()
}
?: throw MishapBadOffhandItem(ItemStack.EMPTY.copy(), itemType.description) // TODO: hack
?: throw MishapBadOffhandItem(ItemStack.EMPTY.copy(), expectedTypeDesc) // TODO: hack

val hexHolder = IXplatAbstractions.INSTANCE.findHexHolder(handStack)
if (!handStack.`is`(itemType)) {
throw MishapBadOffhandItem(handStack, itemType.description)
if (!isValid.test(handStack)) {
throw MishapBadOffhandItem(handStack, expectedTypeDesc)
} else if (hexHolder == null || hexHolder.hasHex()) {
throw MishapBadOffhandItem.of(handStack, "iota.write")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package at.petrak.hexcasting.common.items.magic;

import at.petrak.hexcasting.api.casting.iota.IotaType;
import at.petrak.hexcasting.api.utils.NBTHelper;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class ItemAncientCypher extends ItemCypher {
public static final String TAG_PATTERNS = "patterns";
public static final String TAG_HEX_NAME = "hex_name";

public ItemAncientCypher(Properties pProperties) {
super(pProperties);
}

@Override
public void clearHex(ItemStack stack) {
super.clearHex(stack);
NBTHelper.remove(stack, TAG_HEX_NAME);
}

@Override
public Component getName(ItemStack pStack) {
var descID = this.getDescriptionId(pStack);
var hexName = NBTHelper.getString(pStack, TAG_HEX_NAME);
if (hexName != null) {
return Component.translatable(descID + ".preset", Component.translatable(hexName));
} else {
return Component.translatable(descID);
}
}

@Override
public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List<Component> pTooltipComponents,
TooltipFlag pIsAdvanced) {
// display media fullness as usual
super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced);

// also show contained spell
var patternsTag = NBTHelper.getList(pStack, TAG_PATTERNS, Tag.TAG_COMPOUND);
if (patternsTag != null) {
var storedHex = Component.translatable("hexcasting.tooltip.stored_hex");
for (var iotaTag : patternsTag) {
var iotaTagC = NBTHelper.getAsCompound(iotaTag);
var iotaComponent = IotaType.getDisplay(iotaTagC).copy();
storedHex.append(iotaComponent.withStyle(ChatFormatting.DARK_PURPLE));
}
pTooltipComponents.add(storedHex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public static void registerItemCreativeTab(CreativeModeTab.Output r, CreativeMod
public static final ItemFocus FOCUS = make("focus", new ItemFocus(unstackable()));
public static final ItemSpellbook SPELLBOOK = make("spellbook", new ItemSpellbook(unstackable()));

public static final ItemCypher ANCIENT_CYPHER = make("ancient_cypher", new ItemAncientCypher(unstackable()));
public static final ItemCypher CYPHER = make("cypher", new ItemCypher(unstackable()));
public static final ItemTrinket TRINKET = make("trinket", new ItemTrinket(unstackable().rarity(Rarity.UNCOMMON)));
public static final ItemArtifact ARTIFACT = make("artifact", new ItemArtifact(unstackable().rarity(Rarity.RARE)));
Expand Down
Loading

0 comments on commit 1d3a855

Please sign in to comment.