go absolutely ham impling list utils
This commit is contained in:
parent
1f6a49d98a
commit
45fc0aae66
7 changed files with 81 additions and 14 deletions
|
@ -5,22 +5,13 @@ import at.petrak.hexcasting.api.Operator;
|
|||
import at.petrak.hexcasting.api.PatternRegistry;
|
||||
import at.petrak.hexcasting.api.SpellDatum;
|
||||
import at.petrak.hexcasting.common.casting.operators.*;
|
||||
import at.petrak.hexcasting.common.casting.operators.eval.OpEvalDelay;
|
||||
import at.petrak.hexcasting.common.casting.operators.eval.OpForEach;
|
||||
import at.petrak.hexcasting.common.casting.operators.lists.OpAppend;
|
||||
import at.petrak.hexcasting.common.casting.operators.lists.OpConcat;
|
||||
import at.petrak.hexcasting.common.casting.operators.lists.OpIndex;
|
||||
import at.petrak.hexcasting.common.casting.operators.eval.*;
|
||||
import at.petrak.hexcasting.common.casting.operators.lists.*;
|
||||
import at.petrak.hexcasting.common.casting.operators.math.*;
|
||||
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.selectors.*;
|
||||
import at.petrak.hexcasting.common.casting.operators.spells.*;
|
||||
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;
|
||||
import at.petrak.hexcasting.common.casting.operators.spells.sentinel.OpGetSentinelWayfind;
|
||||
import at.petrak.hexcasting.common.casting.operators.eval.*;
|
||||
import at.petrak.hexcasting.common.casting.operators.spells.sentinel.*;
|
||||
import at.petrak.hexcasting.common.items.magic.ItemArtifact;
|
||||
import at.petrak.hexcasting.common.items.magic.ItemCypher;
|
||||
import at.petrak.hexcasting.common.items.magic.ItemTrinket;
|
||||
|
@ -31,6 +22,8 @@ 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 {
|
||||
|
@ -293,6 +286,12 @@ public class RegisterPatterns {
|
|||
OpIndex.INSTANCE);
|
||||
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dadad", HexDir.NORTH_EAST), prefix("for_each"),
|
||||
OpForEach.INSTANCE);
|
||||
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aqaeaq", HexDir.EAST), prefix("list_size"),
|
||||
OpListSize.INSTANCE);
|
||||
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("adeeed", HexDir.EAST), prefix("singleton"),
|
||||
OpSingleton.INSTANCE);
|
||||
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqaeaae", HexDir.NORTH_EAST), prefix("empty_list"),
|
||||
OpEmptyList.INSTANCE);
|
||||
|
||||
} catch (PatternRegistry.RegisterPatternException exn) {
|
||||
exn.printStackTrace();
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package at.petrak.hexcasting.common.casting.operators.lists
|
||||
|
||||
import at.petrak.hexcasting.api.ConstManaOperator
|
||||
import at.petrak.hexcasting.api.Operator.Companion.spellListOf
|
||||
import at.petrak.hexcasting.api.SpellDatum
|
||||
import at.petrak.hexcasting.common.casting.CastingContext
|
||||
|
||||
object OpEmptyList : ConstManaOperator {
|
||||
override val argc = 0
|
||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
||||
return spellListOf(emptyList<SpellDatum<*>>()) // sorry for taking all the easy impls, hudeler
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package at.petrak.hexcasting.common.casting.operators.lists
|
||||
|
||||
import at.petrak.hexcasting.api.ConstManaOperator
|
||||
import at.petrak.hexcasting.api.Operator.Companion.getChecked
|
||||
import at.petrak.hexcasting.api.Operator.Companion.spellListOf
|
||||
import at.petrak.hexcasting.api.SpellDatum
|
||||
import at.petrak.hexcasting.common.casting.CastingContext
|
||||
|
||||
// it's still called beancounter's distillation in my heart
|
||||
object OpListSize : ConstManaOperator {
|
||||
override val argc = 1
|
||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
||||
return spellListOf(args.getChecked<List<SpellDatum<*>>>(0).toList().size.toDouble()) // mmm one-liner
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package at.petrak.hexcasting.common.casting.operators.lists
|
||||
|
||||
import at.petrak.hexcasting.api.ConstManaOperator
|
||||
import at.petrak.hexcasting.api.Operator.Companion.spellListOf
|
||||
import at.petrak.hexcasting.api.SpellDatum
|
||||
import at.petrak.hexcasting.common.casting.CastingContext
|
||||
|
||||
object OpSingleton : ConstManaOperator {
|
||||
override val argc = 1
|
||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
||||
return spellListOf(listOf(args[0])) // god i love one-liners
|
||||
}
|
||||
}
|
|
@ -20,7 +20,7 @@ class OpWeather(val rain: Boolean) : SpellOperator {
|
|||
override fun cast(ctx: CastingContext) {
|
||||
val w = ctx.world
|
||||
if (w.isRaining != rain) {
|
||||
w.levelData.isRaining = rain // i bless the rains down in minecraftia
|
||||
w.levelData.isRaining = rain // i hex the rains down in minecraftia
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,9 @@
|
|||
"hexcasting.spell.hexcasting:concat": "Combination Distillation",
|
||||
"hexcasting.spell.hexcasting:index": "Selection Distillation",
|
||||
"hexcasting.spell.hexcasting:for_each": "Thoth's Gambit",
|
||||
"hexcasting.spell.hexcasting:list_size": "Numerologist's Purification",
|
||||
"hexcasting.spell.hexcasting:singleton": "Single's Purification",
|
||||
"hexcasting.spell.hexcasting:empty_list": "Vacant Reflection",
|
||||
"hexcasting.spell.hexcasting:get_entity": "Entity Purification",
|
||||
"hexcasting.spell.hexcasting:get_entity/animal": "Entity Prfn.: Animal",
|
||||
"hexcasting.spell.hexcasting:get_entity/monster": "Entity Prfn.: Monster",
|
||||
|
|
|
@ -29,6 +29,30 @@
|
|||
"input": "list, list",
|
||||
"output": "list",
|
||||
"text": "Remove the list at the top of the stack, then add all its elements to the end of the list at the top of the stack."
|
||||
},
|
||||
{
|
||||
"type": "hexcasting:pattern",
|
||||
"op_id": "hexcasting:empty_list",
|
||||
"anchor": "hexcasting:empty_list",
|
||||
"input": "",
|
||||
"output": "list",
|
||||
"text": "Push an empty list to the top of the stack."
|
||||
},
|
||||
{
|
||||
"type": "hexcasting:pattern",
|
||||
"op_id": "hexcasting:singleton",
|
||||
"anchor": "hexcasting:singleton",
|
||||
"input": "any",
|
||||
"output": "list",
|
||||
"text": "Remove the top of the stack, then push a list containing only that element."
|
||||
},
|
||||
{
|
||||
"type": "hexcasting:pattern",
|
||||
"op_id": "hexcasting:list_size",
|
||||
"anchor": "hexcasting:list_size",
|
||||
"input": "list",
|
||||
"output": "num",
|
||||
"text": "Remove the list at the top of the stack, then push the number of elements in the list to the stack."
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue