mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-24 22:51:18 -09:00
Update mobnpcspawner.js
This commit is contained in:
parent
e9eba32417
commit
23f6607837
@ -1,6 +1,8 @@
|
|||||||
(() => {
|
(() => {
|
||||||
PluginAPI.dedicatedServer.appendCode(function () {
|
PluginAPI.dedicatedServer.appendCode(function () {
|
||||||
PluginAPI.addEventListener("processcommand", (event) => {
|
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"
|
// Check if the command is "/spawnnpc"
|
||||||
if (event.command.toLowerCase().startsWith("/spawnnpc")) {
|
if (event.command.toLowerCase().startsWith("/spawnnpc")) {
|
||||||
@ -9,7 +11,7 @@
|
|||||||
|
|
||||||
// Create a sheep entity
|
// Create a sheep entity
|
||||||
const EntitySheepClass = ModAPI.reflect.getClassById("net.minecraft.entity.passive.EntitySheep");
|
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
|
// Set sheep's position to player's position
|
||||||
sheep.setPosition(senderPos.getX(), senderPos.getY(), senderPos.getZ());
|
sheep.setPosition(senderPos.getX(), senderPos.getY(), senderPos.getZ());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user