partial summon/dispel rain impl, need to figure out how to make it actually work all the time instead of sometimes

This commit is contained in:
Noobulus 2022-01-31 23:29:03 -06:00
parent 53e813506b
commit e13cf4e3b4
5 changed files with 88 additions and 25 deletions

View file

@ -15,10 +15,7 @@ import at.petrak.hexcasting.common.casting.operators.selectors.OpGetCaster;
import at.petrak.hexcasting.common.casting.operators.selectors.OpGetEntitiesBy;
import at.petrak.hexcasting.common.casting.operators.selectors.OpGetEntityAt;
import at.petrak.hexcasting.common.casting.operators.spells.*;
import at.petrak.hexcasting.common.casting.operators.spells.great.OpCreateLava;
import at.petrak.hexcasting.common.casting.operators.spells.great.OpFlight;
import at.petrak.hexcasting.common.casting.operators.spells.great.OpLightning;
import at.petrak.hexcasting.common.casting.operators.spells.great.OpTeleport;
import at.petrak.hexcasting.common.casting.operators.spells.great.*;
import at.petrak.hexcasting.common.casting.operators.spells.sentinel.OpCreateSentinel;
import at.petrak.hexcasting.common.casting.operators.spells.sentinel.OpDestroySentinel;
import at.petrak.hexcasting.common.casting.operators.spells.sentinel.OpGetSentinelPos;
@ -34,8 +31,6 @@ import net.minecraft.world.phys.Vec3;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import java.util.regex.Pattern;
import static at.petrak.hexcasting.common.lib.RegisterHelper.prefix;
public class RegisterPatterns {
@ -194,6 +189,12 @@ public class RegisterPatterns {
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waeawaeqqqwqwqqwq", HexDir.EAST),
prefix("sentinel/create/great"),
new OpCreateSentinel(true), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeewwweeewwaqqddqdqd", HexDir.EAST),
prefix("dispel_rain"),
new OpWeather(false), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wwweeewwweewdawdwad", HexDir.WEST),
prefix("summon_rain"),
new OpWeather(true), true);
// == Meta stuff ==

View file

@ -0,0 +1,42 @@
package at.petrak.hexcasting.common.casting.operators.spells.great
import at.petrak.hexcasting.api.OperationResult
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.OperatorSideEffect
import net.minecraft.world.phys.Vec3
class OpWeather(val rain: Boolean) : SpellOperator {
override val argc = 0
override val isGreat = true
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): Triple<RenderedSpell, Int, List<Vec3>> {
return Triple(Spell(true), ((if (this.rain) 2 else 1) * 50_000), listOf()) // return an empty list for shits and gigs ig
}
private data class Spell(val rain: Boolean) : RenderedSpell {
override fun cast(ctx: CastingContext) {
ctx.world.levelData.isRaining = rain // i bless the rains down in minecraftia
}
}
override fun operate(stack: MutableList<SpellDatum<*>>, ctx: CastingContext): OperationResult {
val args = stack.takeLast(this.argc)
for (_i in 0 until this.argc) stack.removeLast()
val (spell, mana, particlePoses) = this.execute(args, ctx)
val sideEffects = mutableListOf(
OperatorSideEffect.ConsumeMana(mana),
OperatorSideEffect.AttemptSpell(spell, this.isGreat)
)
for (pos in particlePoses) {
sideEffects.add(OperatorSideEffect.Particles(pos))
}
return OperationResult(stack, sideEffects)
}
}

View file

@ -144,6 +144,8 @@
"hexcasting.spell.hexcasting:potion/strength": "Green Sun's Zenith",
"hexcasting.spell.hexcasting:flight": "Flight",
"hexcasting.spell.hexcasting:lightning": "Summon Lightning",
"hexcasting.spell.hexcasting:summon_rain": "Summon Rain",
"hexcasting.spell.hexcasting:dispel_rain": "Dispel Rain",
"hexcasting.spell.hexcasting:create_lava": "Create Lava",
"hexcasting.spell.hexcasting:teleport": "Greater Teleport",
"hexcasting.spell.hexcasting:sentinel/create/great": "Summon Greater Sentinel",

View file

@ -1,19 +0,0 @@
{
"name": "hexcasting.spell.hexcasting:lightning",
"category": "hexcasting:patterns/great_spells",
"icon": "minecraft:lightning_rod",
"sortnum": 1,
"advancement": "hexcasting:root",
"read_by_default": true,
"pages": [
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:lightning",
"anchor": "hexcasting:lightning",
"input": "vector",
"output": "",
"hex_size": 6,
"text": "I command the heavens! This spell will summon a bolt of lightning to strike the earth where I direct it. Costs about 3 $(item)Amethyst Shard/$s."
}
]
}

View file

@ -0,0 +1,37 @@
{
"name": "Weather Manipulation",
"category": "hexcasting:patterns/great_spells",
"icon": "minecraft:textures/mob_effect/levitation.png",
"sortnum": 1,
"advancement": "hexcasting:root",
"read_by_default": true,
"pages": [
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:lightning",
"anchor": "hexcasting:lightning",
"input": "vector",
"output": "",
"hex_size": 6,
"text": "I command the heavens! This spell will summon a bolt of lightning to strike the earth where I direct it. Costs about 3 $(item)Amethyst Shard/$s."
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:summon_rain",
"anchor": "hexcasting:summon_rain",
"input": "",
"output": "",
"hex_size": 6,
"text": "I control the clouds! This spell will summon rain across the world I cast it upon. Costs about 2 $(item)Amethyst Shard/$s. Does nothing if it is already raining."
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:dispel_rain",
"anchor": "hexcasting:dispel_rain",
"input": "",
"output": "",
"hex_size": 6,
"text": "A counterpart to summoning rain. This spell will dispel rain across the world I cast it upon. Costs about 1 $(item)Amethyst Shard/$. Does nothing if the skies are already clear."
}
]
}