Skip to content

NPCCommandUtils

Package: com.hypixel.hytale.server.npc.commands

public class NPCCommandUtils

Shared utility class for resolving a target NPC entity from command context. Used by commands that need to resolve an NPC either from an explicit entity argument or by raycasting from the player’s view direction.

@Nullable
public static Pair<Ref<EntityStore>, NPCEntity> getTargetNpc(@Nonnull CommandContext context, @Nonnull EntityWrappedArg arg, @Nonnull Store<EntityStore> store)

Resolves a target NPC entity. If the entity argument is provided, uses it directly. Otherwise, requires the sender to be a player and uses TargetUtil.getTargetEntity() to find the entity the player is looking at. Returns null with an error message if:

  • The sender is not a player and no entity argument was provided.
  • No entity is in the player’s view.
  • The resolved entity does not have an NPCEntity component (not an NPC).

Returns a Pair of the entity reference and its NPCEntity component on success.

Hydex is an independent community resource. Hytale is a trademark of Hypixel Studios. Hydex is not affiliated with or endorsed by Hypixel Studios.