Hi.
I've been banging my head against my desk for a few weeks now trying to figure out making mods in ScriptCraft, mainly here recently:
I have a lot of coding experience, some familiarity with java and javascript, and I like learning, so I figured the learning curve for ScriptCraft wouldn't be _too_ painful, and I love the idea, but it's been a bit of a nightmare.
I managed to get a SpigotMC server going, ScriptCraft loaded, and a simple mod running successfully which uses and affects the in-game chat.
I've also got a working listener for block breaking, and I can change the block type that's being dropped and get the player who broke it.
I also have a working listener for mob death, and I can route code execution based on what type of mod died.
So I know ScriptCraft is working in some fashion.
I'm trying to add or change a mob's drop, get the player who killed the mob, or even just spawn an item at the dying mob's location rather than having the mob drop it.
I see there's no .getPlayer() or .player for the listener events.entityDeath(function_name); so I'm at a loss to know who killed the mob.
For adding or changing the drop...
I see .getDrops() returns List<ItemStack> but I don't see a .setDrops().
Finally I realized that the item stack returned is probably a pointer to the stack that can itself be altered and will then drop, regardless of having been gotten by .getDrops().
To that end, I see List has .add and I see ItemStack has .setType(Material type) and .setAmount(int amount).
So putting that all together, at first I thought maybe...
List<ItemStack> new_drop = {new ItemStack(Material.DIAMOND_BLOCK, 1)};
event.getDrops().add(new_drop);
I've tried a lot of variations and looked up JavaScript in more depth, but I guess I haven't hit on the right syntax.
This doesn't work and stops my mod in its tracks...
var player = getPlayerObject();
...and...
var player = player.getWorld();
var villager = world.spawnCreature(player.getLocation().add(1,0,0), org.bukkit.entity.EntityType.VILLAGER);
...which were adapted from the quest mod, which was recommended by the ScriptCraft website.
The quest mod in its entirety doesn't do anything when I add the file next to my mod's file, so maybe that's just due to being out of date code.
From the ScriptCraft API...
items.book(); // returns org.bukkit.Material.BOOK
...but I can't even assign it to a variable without breaking my mod.
var a_book = items.book();
Not sure if my problems are due to references being for old version of ScriptCraft, or if ScriptCraft documentation is out of date, or if I installed something wrong during setup maybe so ScriptCraft is only half working, or am I just not getting it?
Thinking about it, I'm pretty much burned out on ScriptCraft at this point, but I think it would be good for the developers/community if a way could be found to fill this gap so others don't fall in.
Thanks in advance.
HTH.
-Nathan