Just Another Spawner

Just Another Spawner

665k Downloads

[Question/Suggestion] Spawn media besides air and water

Taschenmogul opened this issue ยท 6 comments

commented

I hope I am not missing something here, but I saw the "Spawn medium" element in the CreatureType config file (JAS 0.15+) and tried changing it, to no avail; it always was reset to the default value "air".
A cursory look at the source code here made it seem that whenever a spawn medium that is not air or water would be entered, it would be reset to air.

My question now is - is this correct or did I indeed miss something?
And if this is correct, then my suggestion kicks in: Make other spawn media valid, so people can spawn mobs in those media.
If I understand the issue correctly this would then make it easily possible to achieve spawn functionality like that of the inferno mobs of Lycanite's Mobs, where mobs only spawn in fire or lava.

commented

It is looking like 0.17 will be removing the spawn medium string and expect it to be user configurable as part of the spawn MVEL expression.

And the functions already defined support all available materials.

commented

So is it possible to have a name represent an MVEL expression in CreatureType.cfg?
Ie. have basic expressions for SOLID, AIR, WATER, LAVA already set up, such that users can simply enter that term and have it represent - or translate into - an MVEL expression under the hood?
..I should really have asked if it's possible to have a word represent an expression, and have it be &&ed.

commented

Details currently in flux, obviously.

So is it possible to have a name represent an MVEL expression in CreatureType.cfg?

LivingHandler will looks something like this by default:

this.canSpawn = "!(modspawn || sp.clearBounding || obj.Material().equals('AIR')))";
this.canDspwn = "false";
this.shouldInstantDspwn = "sp.plyrDist < 128";
this.dieOfAge = "!(ent.age > 600 && util.random(1+40/3,0,0))";
this.resetAge = "sp.plyrDist > 32";
this.postSpawn = "";

AIR can easily bu subbed out for "water", "fire", "lava", "sand", "grass", "ground", "wood", "rock", "iron", "anvil", "leaves", etc.

have basic expressions for SOLID, AIR, WATER, LAVA already set up, such that users can simply enter that term and have it represent - or translate into - an MVEL expression under the hood?

Pretty much. If we end it with () it'd be a function that returns boolean. Internal doing something like obj.Material().equals('AIR'). I wouldn't want to clutter the main tag object so we'd need a prefix for it. Like mat.AIR(), mat.GRASS.

Offish-topic but, MVEL is the expression parser. How JAS uses it is it exposes an object I pass to it.
If you look at https://github.com/ProjectZulu/JustAnotherSpawner/blob/master/src/main/java/jas/common/spawner/Tags.java
you'll see all the MVEL functions talked about that don't require a prefix. You'll notice the prefixes lgcy, util are public final fields at the top.
The LegacyTags named 'lgcy'. Every time you prefix with 'lgcy.' MVEL looks inside the 'lgcy' object to find the function/field you're looking for.

..I should really have asked if it's possible to have a word represent an expression, and have it be &&ed.
No, or at least not in the way you'd expect. But they don't need to return a string

commented

ah I'm bookmarking that link. I should've gone hunting for that earlier. Ta again.
and, yes, that answers my question - and then some. ..I think. I'm confused about the logical or operator in the spawn tags. I feel like a sausage for raising this with my rudimentary understanding of (all logic) but won't that return true if any of those variables are true? So the entity could spawn simply by having a clear bounding box. My illogic says && it. But it also tells me to apologise in advance in case that's me making an ass of myself and/or you

commented

Yes. I believe you are correct.

The linked was just to hopefully give a better idea of how MVEL is used and the possibilities or restrictions therein.

commented

lol I failed to mention the part about liking it a lot, sorry. It's definitely a lot more intuitive but at the same time it seems (at least to me) to be a lot more powerful.