cyphers are no longer useless

This commit is contained in:
yrsegal@gmail.com 2022-04-16 14:41:10 -04:00
parent b954e4f09b
commit 40f96fd37b
8 changed files with 21 additions and 9 deletions

View file

@ -11,6 +11,7 @@ public interface ManaHolderItem {
void setMana(ItemStack stack, int mana);
boolean manaProvider(ItemStack stack);
boolean canRecharge(ItemStack stack);
default float getManaFullness(ItemStack stack) {
int max = getMaxMana(stack);

View file

@ -13,7 +13,7 @@ public class ItemArtifact extends ItemPackagedSpell {
}
@Override
public boolean singleUse() {
public boolean breakAfterDepletion() {
return false;
}
}

View file

@ -13,7 +13,7 @@ public class ItemCypher extends ItemPackagedSpell {
}
@Override
public boolean singleUse() {
public boolean breakAfterDepletion() {
return true;
}
}

View file

@ -16,4 +16,9 @@ public class ItemManaBattery extends ItemManaHolder {
public boolean manaProvider(ItemStack stack) {
return true;
}
@Override
public boolean canRecharge(ItemStack stack) {
return true;
}
}

View file

@ -36,7 +36,12 @@ public abstract class ItemPackagedSpell extends ItemManaHolder implements SpellH
super(pProperties);
}
public abstract boolean singleUse();
public abstract boolean breakAfterDepletion();
@Override
public boolean canRecharge(ItemStack stack) {
return !breakAfterDepletion();
}
@Override
public boolean manaProvider(ItemStack stack) {
@ -79,7 +84,6 @@ public abstract class ItemPackagedSpell extends ItemManaHolder implements SpellH
@Override
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand usedHand) {
var stack = player.getItemInHand(usedHand);
var tag = stack.getOrCreateTag();
List<HexPattern> patterns = getPatterns(stack);
if (patterns == null) {
return InteractionResultHolder.fail(stack);
@ -98,8 +102,10 @@ public abstract class ItemPackagedSpell extends ItemManaHolder implements SpellH
}
}
boolean broken = breakAfterDepletion() && getMana(stack) == 0;
Stat<?> stat;
if (singleUse()) {
if (broken) {
stat = Stats.ITEM_BROKEN.get(this);
} else {
stat = Stats.ITEM_USED.get(this);
@ -111,7 +117,7 @@ public abstract class ItemPackagedSpell extends ItemManaHolder implements SpellH
HexSounds.ACTUALLY_CAST.get(), SoundSource.PLAYERS, 1f,
1f + ((float) Math.random() - 0.5f) * 0.2f);
if (singleUse()) {
if (broken) {
stack.shrink(1);
return InteractionResultHolder.consume(stack);
} else {

View file

@ -13,7 +13,7 @@ public class ItemTrinket extends ItemPackagedSpell {
}
@Override
public boolean singleUse() {
public boolean breakAfterDepletion() {
return false;
}
}

View file

@ -164,7 +164,7 @@ public class HexCapabilityHandler {
@Override
public boolean canRecharge() {
return true;
return holder.canRecharge(stack);
}
@Override

View file

@ -550,7 +550,7 @@
"hexcasting.entry.hexcasting": "Hexcasting Items",
"hexcasting.page.hexcasting.1": "Although the flexibility that casting _Hexes \"on the go\" with my $(l:items/staff)$(item)Staff/$ is quite helpful, it's a huge pain to have to wave it around repeatedly just to accomplish a common task. If I could save a common spell for later reuse, it would simplify things a lot-- and allow me to share my _Hexes with friends, too.",
"hexcasting.page.hexcasting.2": "To do this, I can craft one of three types of magic items: $(item)Cypher/$s, $(item)Trinket/$s, or $(item)Artifact/$s. All of them hold the patterns of a given _Hex inside, along with a small battery containing _media.$(br2)Simply holding one and pressing $(thing)$(k:use)/$ will cast the patterns inside, as if the holder had cast them out of a staff, using its internal battery.",
"hexcasting.page.hexcasting.3": "Each item has its own quirks:$(br2)$(item)Cypher/$s are single-use, destroyed after the _Hex is cast;$(br2)$(item)Trinket/$s can be cast as much as the holder likes, as long as there's enough _media left, but become useless afterwards;",
"hexcasting.page.hexcasting.3": "Each item has its own quirks:$(br2)$(item)Cypher/$s are fragile, destroyed after their internal _media reserves are gone, and cannot be recharged;$(br2)$(item)Trinket/$s can be cast as much as the holder likes, as long as there's enough _media left, but become useless afterwards until recharged;",
"hexcasting.page.hexcasting.4": "$(item)Artifact/$s are the most powerful of all-- after their _media is depleted, they can use $(l:items/amethyst)$(item)Amethyst/$ from the holder's inventory to pay for the _Hex, just as I do when casting with a $(item)Staff/$. Of course, this also means the spell might consume their mind if there's not enough $(item)Amethyst/$.$(br2)Once I've made an empty magic item in a mundane crafting bench, I infuse the _Hex into it using (what else but) a spell appropriate to the item. $(l:patterns/spells/hexcasting)I've catalogued the patterns here./$",
"hexcasting.page.hexcasting.5": "Each infusion spell requires an entity and a list of patterns on the stack. The entity must be a _media-holding item entity (i.e. amethyst crystals, dropped on the ground); the entity is consumed and forms the battery.$(br2)Usefully, it seems that the _media in the battery is not consumed in chunks as it is when casting with a $(item)Staff/$-- rather, the _media \"melts down\" into one continuous pool. Thus, if I store a _Hex that only costs one $(item)Amethyst Dust/$'s worth of mana, a $(item)Charged Crystal/$ used as the battery will allow me to cast it 10 times.",
"hexcasting.page.hexcasting.6": "$(italic)We have a saying in our field: \"Magic isn't\". It doesn't \"just work,\" it doesn't respond to your thoughts, you can't throw fireballs or create a roast dinner from thin air or turn a bunch of muggers into frogs and snails./$",