last bit before 0.4.0

This commit is contained in:
gamma-delta 2022-01-25 17:23:15 -06:00
parent 9d6b835165
commit 366e52b5d5
9 changed files with 133 additions and 61 deletions

View file

@ -113,6 +113,9 @@ public class RegisterPatterns {
prefix("destroy_water"), OpDestroyWater.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qaqqqqaq", HexDir.NORTH_EAST), prefix("bonemeal"),
OpTheOnlyReasonAnyoneDownloadedPsi.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqwaeaeaeaeaea", HexDir.NORTH_WEST),
prefix("recharge"),
OpRecharge.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqaqwawaw", HexDir.NORTH_WEST),
prefix("potion/weakness"),

View file

@ -9,7 +9,6 @@ import net.minecraft.world.effect.MobEffect
import net.minecraft.world.effect.MobEffectInstance
import net.minecraft.world.entity.LivingEntity
import kotlin.math.max
import kotlin.math.pow
class OpPotionEffect(val effect: MobEffect, val baseCost: Int, val potency: Boolean) : SpellOperator {
override val argc: Int
@ -22,7 +21,7 @@ class OpPotionEffect(val effect: MobEffect, val baseCost: Int, val potency: Bool
max(args.getChecked(2), 1.0)
else 1.0
val cost = (this.baseCost * duration).pow(potency)
val cost = this.baseCost * duration * potency
return Pair(
Spell(effect, target, duration, potency),
cost.toInt()
@ -32,7 +31,7 @@ class OpPotionEffect(val effect: MobEffect, val baseCost: Int, val potency: Bool
private class Spell(val effect: MobEffect, val target: LivingEntity, val duration: Double, val potency: Double) :
RenderedSpell {
override fun cast(ctx: CastingContext) {
val effectInst = MobEffectInstance(effect, (duration * 20).toInt(), potency.toInt())
val effectInst = MobEffectInstance(effect, (duration * 20).toInt(), potency.toInt() - 1)
target.addEffect(effectInst)
}
}

View file

@ -0,0 +1,47 @@
package at.petrak.hexcasting.common.casting.operators.spells
import at.petrak.hexcasting.api.Operator.Companion.getChecked
import at.petrak.hexcasting.api.RenderedSpell
import at.petrak.hexcasting.api.SpellDatum
import at.petrak.hexcasting.api.SpellOperator
import at.petrak.hexcasting.common.casting.CastException
import at.petrak.hexcasting.common.casting.CastingContext
import at.petrak.hexcasting.common.casting.ManaHelper
import at.petrak.hexcasting.common.items.magic.ItemPackagedSpell
import net.minecraft.util.Mth
import net.minecraft.world.entity.item.ItemEntity
object OpRecharge : SpellOperator {
override val argc = 1
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): Pair<RenderedSpell, Int> {
val otherHandItem = ctx.caster.getItemInHand(ctx.otherHand)
if (otherHandItem.item !is ItemPackagedSpell) {
throw CastException(CastException.Reason.BAD_OFFHAND_ITEM, ItemPackagedSpell::class.java, otherHandItem)
}
val entity = args.getChecked<ItemEntity>(0)
return Pair(Spell(entity), 100_000)
}
private data class Spell(val itemEntity: ItemEntity) : RenderedSpell {
override fun cast(ctx: CastingContext) {
val otherHandItem = ctx.caster.getItemInHand(ctx.otherHand)
if (otherHandItem.item is ItemPackagedSpell && itemEntity.isAlive) {
val manaAmt = ManaHelper.extractAllMana(itemEntity.item)
if (manaAmt != null) {
val tag = otherHandItem.orCreateTag
val maxMana = if (tag.contains(ItemPackagedSpell.TAG_START_MANA))
tag.getInt(ItemPackagedSpell.TAG_START_MANA)
else
Int.MAX_VALUE
val existingMana = if (tag.contains(ItemPackagedSpell.TAG_MANA))
tag.getInt(ItemPackagedSpell.TAG_MANA)
else
0
tag.putInt(ItemPackagedSpell.TAG_MANA, Mth.clamp(existingMana + manaAmt, 0, maxMana))
}
}
}
}
}

View file

@ -16,7 +16,7 @@ import net.minecraftforge.registries.RegistryObject;
public class HexItems {
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, HexMod.MOD_ID);
public static final CreativeModeTab TAB = new CreativeModeTab("hexcasting") {
public static final CreativeModeTab TAB = new CreativeModeTab(HexMod.MOD_ID) {
@Override
public ItemStack makeIcon() {
return new ItemStack(SPELLBOOK::get);
@ -46,7 +46,7 @@ public class HexItems {
() -> new Item(props()));
// I am very funny
public static final RegistryObject<Item> SUBMARINE_SANDWICH = ITEMS.register(LibItemNames.SUBMARINE_SANDWICH,
() -> new Item(props().food(new FoodProperties.Builder().nutrition(4).build())));
() -> new Item(props().food(new FoodProperties.Builder().nutrition(12).saturationMod(1.2f).build())));
public static final RegistryObject<Item> SCRYING_LENS = ITEMS.register(LibItemNames.LENS,
() -> new Item(unstackable()));
public static final RegistryObject<Item> SCROLL = ITEMS.register(LibItemNames.SCROLL,

View file

@ -4,6 +4,7 @@ import at.petrak.hexcasting.HexMod;
import at.petrak.hexcasting.common.casting.CastingContext;
import at.petrak.hexcasting.common.casting.CastingHarness;
import at.petrak.hexcasting.common.casting.ManaHelper;
import at.petrak.hexcasting.common.lib.HexSounds;
import at.petrak.hexcasting.hexmath.HexPattern;
import net.minecraft.Util;
import net.minecraft.nbt.CompoundTag;
@ -11,6 +12,7 @@ import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource;
import net.minecraft.stats.Stat;
import net.minecraft.stats.Stats;
import net.minecraft.world.InteractionHand;
@ -78,7 +80,10 @@ public abstract class ItemPackagedSpell extends Item {
}
player.awardStat(stat);
player.getCooldowns().addCooldown(this, 5);
sPlayer.getCooldowns().addCooldown(this, 5);
sPlayer.level.playSound(null, sPlayer.getX(), sPlayer.getY(), sPlayer.getZ(),
HexSounds.ACTUALLY_CAST.get(), SoundSource.PLAYERS, 1f,
1f + ((float) Math.random() - 0.5f) * 0.2f);
if (singleUse()) {
stack.shrink(1);

View file

@ -87,6 +87,7 @@
"hexcasting.spell.hexcasting:craft/cypher": "Craft Cypher",
"hexcasting.spell.hexcasting:craft/trinket": "Craft Trinket",
"hexcasting.spell.hexcasting:craft/artifact": "Craft Artifact",
"hexcasting.spell.hexcasting:recharge": "Recharge Item",
"hexcasting.spell.hexcasting:create_water": "Create Water",
"hexcasting.spell.hexcasting:destroy_water": "Destroy Water",
"hexcasting.spell.hexcasting:potion/weakness": "White Sun's Nadir",

View file

@ -1,40 +1,53 @@
{
"name": "Crafting Hexcasting Items",
"category": "hexcasting:patterns/spells",
"icon": "hexcasting:artifact{patterns:[]}",
"sortnum": 3,
"advancement": "hexcasting:root",
"read_by_default": true,
"pages": [
{
"type": "patchouli:text",
"text": "These three spells each create an item that casts a _Hex.$(br)They all require me to hold the empty item in my off-hand, and require two things: the list of patterns to be cast, and an entity representing a dropped stack of $(item)Amethyst/$ to form the item's battery.$(br2)See $(l:items/hexcasting)this entry/$ for more information."
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:craft/cypher",
"anchor": "hexcasting:craft/cypher",
"input": "entity, list of patterns",
"output": "",
"text": "Costs about one $(item)Charged Amethyst/$."
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:craft/trinket",
"anchor": "hexcasting:craft/trinket",
"input": "entity, list of patterns",
"output": "",
"text": "Costs about five $(item)Charged Amethyst/$s.",
"hex_size": 8
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:craft/artifact",
"anchor": "hexcasting:craft/artifact",
"input": "entity, list of patterns",
"output": "",
"text": "Costs about ten $(item)Charged Amethyst/$s.",
"hex_size": 5
}
]
"name": "Crafting Hexcasting Items",
"category": "hexcasting:patterns/spells",
"icon": "hexcasting:artifact{patterns:[]}",
"sortnum": 3,
"advancement": "hexcasting:root",
"read_by_default": true,
"pages": [
{
"type": "patchouli:text",
"text": "These three spells each create an item that casts a _Hex.$(br)They all require me to hold the empty item in my off-hand, and require two things: the list of patterns to be cast, and an entity representing a dropped stack of $(item)Amethyst/$ to form the item's battery.$(br2)See $(l:items/hexcasting)this entry/$ for more information."
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:craft/cypher",
"anchor": "hexcasting:craft/cypher",
"input": "entity, list of patterns",
"output": "",
"text": "Costs about one $(item)Charged Amethyst/$."
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:craft/trinket",
"anchor": "hexcasting:craft/trinket",
"input": "entity, list of patterns",
"output": "",
"text": "Costs about five $(item)Charged Amethyst/$s.",
"hex_size": 8
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:craft/artifact",
"anchor": "hexcasting:craft/artifact",
"input": "entity, list of patterns",
"output": "",
"text": "Costs about ten $(item)Charged Amethyst/$s.",
"hex_size": 5
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:recharge",
"anchor": "hexcasting:recharge",
"input": "entity",
"output": "",
"text": "Recharge a _media-containing item in my other hand. Costs about one $(item)Charged Amethyst/$."
},
{
"type": "patchouli:text",
"text": "This spell is cast in a similar method to the crafting spells; an entity representing a dropped stack of $(item)Amethyst/$ is provided, and recharges the _media battery of the item in my other hand.$(br2)This spell $(italic)cannot/$ recharge the item farther than its original battery size."
}
]
}

View file

@ -1,18 +1,22 @@
{
"name": "Working with Items",
"category": "hexcasting:patterns/spells",
"icon": "minecraft:item_frame",
"advancement": "hexcasting:root",
"priority": true,
"read_by_default": true,
"pages": [
{
"type": "patchouli:text",
"text": "Certain spells, such as $(l:hexcasting:patterns/spells/blockworks#OpPlaceBlock)$(action)Place Block/$, will consume additional items from my inventory. When this happens, the spell will first look for the item to use, and then draw from all such items in my inventory.$(br2)This process is called \"picking an item.\""
},
{
"type": "patchouli:text",
"text": "More specifically:$(li)First, the spell will search for the first valid item in my hotbar to the $(italic)right of my staff/$, wrapping around at the right-hand side, and starting at the first slot if my staff is in my off-hand.$(li)Second, the spell will draw that item from as $(italic)far back in my inventory/$ as possible, prioritizing the main inventory over the hotbar.$(br)This way, I can keep a \"chooser\" item on my hotbar to tell the spell what to use, and fill the rest of my inventory with that item to keep the spell well-stocked."
}
]
"name": "Working with Items",
"category": "hexcasting:patterns/spells",
"icon": "minecraft:item_frame",
"advancement": "hexcasting:root",
"priority": true,
"read_by_default": true,
"pages": [
{
"type": "patchouli:text",
"text": "Certain spells, such as $(l:hexcasting:patterns/spells/blockworks#OpPlaceBlock)$(action)Place Block/$, will consume additional items from my inventory. When this happens, the spell will first look for the item to use, and then draw from all such items in my inventory.$(br2)This process is called \"picking an item.\""
},
{
"type": "patchouli:text",
"text": "More specifically:$(li)First, the spell will search for the first valid item in my hotbar to the $(italic)right of my staff/$, wrapping around at the right-hand side, and starting at the first slot if my staff is in my off-hand.$(li)Second, the spell will draw that item from as $(italic)far back in my inventory/$ as possible, prioritizing the main inventory over the hotbar."
},
{
"type": "patchouli:text",
"text": "This way, I can keep a \"chooser\" item on my hotbar to tell the spell what to use, and fill the rest of my inventory with that item to keep the spell well-stocked."
}
]
}

View file

@ -8,7 +8,7 @@
"pages": [
{
"type": "patchouli:text",
"text": "This family of spells all impart a negative potion effect upon an entity. They all take an entity, the recipient, and one or two numbers, the first being the duration and the second, if present, being the potency (starting at 1).$(br2)Each one has a \"base cost;\" the actual cost is equal to that base cost, raised to the power of the potency if it is present."
"text": "This family of spells all impart a negative potion effect upon an entity. They all take an entity, the recipient, and one or two numbers, the first being the duration and the second, if present, being the potency (starting at 1).$(br2)Each one has a \"base cost;\" the actual cost is equal to that base cost, multiplied by the potency."
},
{
"type": "patchouli:text",