Skip to content

Npc

Namespace Mc.Scripting · Kind class (sealed)

public sealed class Npc : IDisposable, IPluginResource

A fake player that stands in the world: the players see it with a name, a skin, equipment and an arm that swings, and a click on it fires {{cref:M:Mc.Scripting.Npcs.OnInteract(System.Action{Mc.Scripting.NpcInteraction})}}. Nothing of it exists on the server (it has no physics and no AI). Create it with Npcs.Create; it disappears for every viewer when the plugin unloads or when Npc.Remove is called.

Member Description
ulong Handle { get; } The handle the engine gives a click on this NPC (see NpcInteraction.Handle).
bool IsActive { get; } Whether the NPC still exists.
string Name { get; } The profile name above its head.
float Pitch { get; } The vertical look, degrees.
Vec3d Position { get; } Where it stands.
float Yaw { get; } The horizontal look, degrees.
public ulong Handle { get; }

The handle the engine gives a click on this NPC (see NpcInteraction.Handle).

public bool IsActive { get; }

Whether the NPC still exists.

public string Name { get; }

The profile name above its head.

public float Pitch { get; }

The vertical look, degrees.

public Vec3d Position { get; }

Where it stands.

public float Yaw { get; }

The horizontal look, degrees.

Member Description
void Dispose()
Npc HideFrom(Player player) Hides the NPC from one player (while it is shown to everybody).
Npc HideFromAll() Hides the NPC from everybody.
Npc Look(float yaw, float pitch) Turns the NPC where it stands.
Npc Move(Vec3d position, float yaw, float pitch) Moves the NPC (within its world) and turns it.
void Remove() Removes the NPC from every viewer (and from the tab list) and deletes it.
Npc SetEquipment(NpcSlot slot, ItemStack item) Sets what a slot of the NPC holds or wears (an empty stack clears it).
Npc SetPose(NpcPose pose) Changes the pose (standing or sneaking).
Npc ShowTo(Player player) Shows the NPC to one player (after Npc.HideFromAll), or hides it from one player while it is shown to everybody.
Npc ShowToAll() Shows the NPC to everybody again.
Npc Swing(bool offhand = false) Swings an arm.
public void Dispose()
public Npc HideFrom(Player player)

Hides the NPC from one player (while it is shown to everybody).

Parameters

Name Type Description
player Player The player.

Returns Npc: This NPC.

public Npc HideFromAll()

Hides the NPC from everybody.

Returns Npc: This NPC.

public Npc Look(float yaw, float pitch)

Turns the NPC where it stands.

Parameters

Name Type Description
yaw float The horizontal look, degrees.
pitch float The vertical look, degrees.

Returns Npc: This NPC.

public Npc Move(Vec3d position, float yaw, float pitch)

Moves the NPC (within its world) and turns it.

Parameters

Name Type Description
position Vec3d The new position.
yaw float The horizontal look, degrees.
pitch float The vertical look, degrees.

Returns Npc: This NPC.

public void Remove()

Removes the NPC from every viewer (and from the tab list) and deletes it.

public Npc SetEquipment(NpcSlot slot, ItemStack item)

Sets what a slot of the NPC holds or wears (an empty stack clears it).

Parameters

Name Type Description
slot NpcSlot The slot.
item ItemStack The stack.

Returns Npc: This NPC.

public Npc SetPose(NpcPose pose)

Changes the pose (standing or sneaking).

Parameters

Name Type Description
pose NpcPose The pose.

Returns Npc: This NPC.

public Npc ShowTo(Player player)

Shows the NPC to one player (after Npc.HideFromAll), or hides it from one player while it is shown to everybody.

Parameters

Name Type Description
player Player The player.

Returns Npc: This NPC.

public Npc ShowToAll()

Shows the NPC to everybody again.

Returns Npc: This NPC.

public Npc Swing(bool offhand = false)

Swings an arm.

Parameters

Name Type Description
offhand bool = false The off hand instead of the main hand.

Returns Npc: This NPC.

IPluginResource · ItemStack · NpcPose · NpcSlot · Player · Vec3d