SiliconGhetto Engine API
    Preparing search index...

    Function createMobsAPI

    • Parameters

      • soundNameMap: Record<string, number>

      Returns {
          register(key: string, opts?: MobRegOpts): number;
          spawn(keyOrIndex: string | number, x: number, y: number, z: number): number;
          despawn(id: number): void;
          count(keyOrIndex: string | number): number;
          getPos(mobId: number): Vec3 | null;
          getHealth(mobId: number): number | null;
          damage(mobId: number, amount: number): number | null;
          heal(mobId: number, amount: number): number | null;
          setPos(mobId: number, x: number, y: number, z: number): void;
          setHealth(mobId: number, hp: number): void;
          list(): MobInfo[];
          enableNaturalSpawning(): void;
          disableNaturalSpawning(): void;
          clearAll(): void;
          tame(id: number): boolean;
          isTamed(id: number): boolean;
          setSitting(id: number, sitting: boolean): void;
          feed(id: number, foodItemId: number): boolean;
          isBaby(id: number): boolean;
          inLove(id: number): boolean;
      }

      • register: function
        • Register a custom mob type with the given key and options.

          Parameters

          • key: string

            Unique identifier for this mob type (e.g. "dragon", "goblin")

          • opts: MobRegOpts = {}

            Mob configuration (health, speed, hostile, model, drops, sounds, AI, etc.)

          Returns number

          The mob definition index, used internally to spawn this mob type

          game.mobs.register('skeleton', {
          health: 20, speed: 2, hostile: true,
          attackDamage: 3, burnsInSun: true,
          model: { body: { color: [0.8, 0.8, 0.8] } },
          drops: [{ item: 'bone', count: [1, 3] }],
          });
      • spawn: function
        • Spawn a mob instance at the given world coordinates.

          Parameters

          • keyOrIndex: string | number

            Mob type key (e.g. "zombie") or definition index from register()

          • x: number

            World X coordinate

          • y: number

            World Y coordinate

          • z: number

            World Z coordinate

          Returns number

          The spawned mob's runtime ID, or -1 if the mob type was not found

          const id = game.mobs.spawn('zombie', 100, 65, 100);
          
      • despawn: function
        • Remove a specific mob from the world.

          Parameters

          • id: number

            Runtime mob ID returned by spawn()

          Returns void

      • count: function
        • Get the number of living mobs of a given type.

          Parameters

          • keyOrIndex: string | number

            Mob type key or definition index

          Returns number

          Current count of this mob type in the world

      • getPos: function
        • Get the world position of a mob.

          Parameters

          • mobId: number

            Runtime mob ID

          Returns Vec3 | null

          Position as {x, y, z}, or null if the mob does not exist

      • getHealth: function
        • Get the current health of a mob.

          Parameters

          • mobId: number

            Runtime mob ID

          Returns number | null

          Current health, or null if the mob does not exist

      • damage: function
        • Deal damage to a mob, reducing its health.

          Parameters

          • mobId: number

            Runtime mob ID

          • amount: number

            Damage points to inflict

          Returns number | null

          Remaining health after damage, or null if the mob does not exist

      • heal: function
        • Heal a mob, increasing its health.

          Parameters

          • mobId: number

            Runtime mob ID

          • amount: number

            Health points to restore

          Returns number | null

          New health after healing, or null if the mob does not exist

      • setPos: function
        • Teleport a mob to a new position.

          Parameters

          • mobId: number

            Runtime mob ID

          • x: number

            World X coordinate

          • y: number

            World Y coordinate

          • z: number

            World Z coordinate

          Returns void

      • setHealth: function
        • Set a mob's health to an exact value.

          Parameters

          • mobId: number

            Runtime mob ID

          • hp: number

            New health value

          Returns void

      • list: function
        • Get a list of all living mobs in the world.

          Returns MobInfo[]

          Array of mob info objects with id, defIndex, position, and health

      • enableNaturalSpawning: function
        • Enable automatic mob spawning based on registered spawn rules.

          Returns void

      • disableNaturalSpawning: function
        • Disable automatic mob spawning (mobs already alive stay).

          Returns void

      • clearAll: function
      • tame: function
        • Tame a mob so it follows and defends the player.

          Parameters

          • id: number

            Runtime mob ID

          Returns boolean

          True if the mob was successfully tamed

      • isTamed: function
        • Check whether a mob is tamed.

          Parameters

          • id: number

            Runtime mob ID

          Returns boolean

          True if the mob is tamed

      • setSitting: function
        • Make a tamed mob sit or stand.

          Parameters

          • id: number

            Runtime mob ID

          • sitting: boolean

            True to sit, false to stand and follow

          Returns void

      • feed: function
        • Feed a mob with a food item (triggers breeding in love-mode mobs).

          Parameters

          • id: number

            Runtime mob ID

          • foodItemId: number

            Item type ID of the food

          Returns boolean

          True if the mob accepted the food

      • isBaby: function
        • Check whether a mob is a baby.

          Parameters

          • id: number

            Runtime mob ID

          Returns boolean

          True if the mob is a baby

      • inLove: function
        • Check whether a mob is in love mode (ready to breed).

          Parameters

          • id: number

            Runtime mob ID

          Returns boolean

          True if the mob is in love mode