Hello, I am having trouble making custom spells for Irons. Right now, I am just trying to make copies of the existing spells for practice, but I've come across multiple problems as the spells are written in java and kubejs is well in javascript. Before I state my problems, I should preface this that I'm not that well-versed in javascript and its quirks, so the limits of my knowledge is basically the wiki. At the end of the day, I would just like examples of custom spells using kubejs as I learn best reading from examples (I would also prefer if they were in the style of the way the wiki does it.) To continue, my problem is that I don't know how to get the targetEntity from the spell. Iron Spells does it like this in Java:
public void onCast(Level world, int spellLevel, LivingEntity entity, CastSource castSource, MagicData playerMagicData) {
if (playerMagicData.getAdditionalCastData() instanceof TargetEntityCastData targetData) {
var targetEntity = targetData.getTarget((ServerLevel) world);
This is a problem because as far as I know javascript cant create a variable using instanceof like this and playerMagicData.getAdditionalCastData() gives a ICastData instance which cant be cast into a TargetEntityCastData. I was trying to see if there was another way to get the targetData, but I can't seem to find a way.