From 23f660783785263b5dacb91108afd1fd15a8186e Mon Sep 17 00:00:00 2001 From: radmanplays <95340057+radmanplays@users.noreply.github.com> Date: Mon, 30 Sep 2024 16:00:28 +0330 Subject: [PATCH] Update mobnpcspawner.js --- examplemods/mobnpcspawner.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examplemods/mobnpcspawner.js b/examplemods/mobnpcspawner.js index b16caff..e46ea77 100644 --- a/examplemods/mobnpcspawner.js +++ b/examplemods/mobnpcspawner.js @@ -1,6 +1,8 @@ (() => { PluginAPI.dedicatedServer.appendCode(function () { PluginAPI.addEventListener("processcommand", (event) => { + // Check if the sender is a player + if (!ModAPI.reflect.getClassById("net.minecraft.entity.player.EntityPlayerMP").instanceOf(event.sender.getRef())) { return; } // Check if the command is "/spawnnpc" if (event.command.toLowerCase().startsWith("/spawnnpc")) { @@ -9,7 +11,7 @@ // Create a sheep entity const EntitySheepClass = ModAPI.reflect.getClassById("net.minecraft.entity.passive.EntitySheep"); - const sheep = EntitySheepClass.constructors[1](world.getRef()); + const sheep = EntitySheepClass.constructors[0](world.getRef()); // Set sheep's position to player's position sheep.setPosition(senderPos.getX(), senderPos.getY(), senderPos.getZ());