Skip to content
On this page

๐ŸŽจ Basic Game API

The following APIs provide the ability to modify and extension game content.

Obviously, the game element interface is at the core of the entire plug-in system, which is related to the ability to control and expand game content.
LSE provides a rich and powerful interface of game elements to facilitate your creativity.

๐Ÿ”ฎ Game Element Objects

For the indexing of game elements, LSE uses a special type of variable to keep track of each game element, and calls it "xx objects", such as "player objects" or "block objects".
You can think of it as a unique identifier for a game element.

Currently, LSE has the following game element objects:

Object Type NameObject NamePurpose of Object
IntPosInteger Coordinate ObjectIdentifies integer location (like block coordinates)
FloatPosFloating Point Coordinate ObjectIdentifies a floating point position (like entity coordinates)
DirectionAngleDirection ObjectIdentifies angle information (such as the direction a player is facing)
PlayerPlayer ObjectIdentify player or access player attributes
EntityEntity ObjectIdentify entity or access entity attributes
BlockBlock ObjectIdentify Block or access block attributes
ItemItem ObjectIdentifies an item in an inventory
ContainerContainer ObjectIdentifies a container that can store items
BlockEntityBlock Entity ObjectIdentifies a block entity
ObjectiveScoring Item ObjectiveIdentifies the scoring items of a scoreboard system

You will come across them frequently in subsequent documentation.

๐ŸŽฏ Coordinate Object

In games, numerous APIs require coordinates. The engine uses objects of type IntPos and FloatPos to indicate coordinates, called "coordinate objects". Each member of the coordinate object is readable and writable.

  1. IntPos object Its members are all integers, which are mostly used to represent block coordinates and other positions represented by integers. For a variable pos of type IntPos, there are the following members:
MemberMeaningData Type
pos.xx coordinateInteger
pos.yy coordinateInteger
pos.zz coordinateInteger
pos.dimDimension nameString
pos.dimidDimension IDInteger
Text Only
Among them, the value of the **dimension ID** attribute is: `0` represents the Main World, `1` represents The Nether, and `2` represents The End.

**Dimension text name:** The values of the attributes are: "Main World", "Nether", "End".

If in some cases the dimension is invalid, or cannot be obtained, you will find that the value of dimid is -1.

  1. FloatPosobject Its members are all floating point numbers, which are mostly used to represent entity coordinates and other positions that cannot be represented by integers
    For a variable pos of type FloatPos, there are the following members:
MemberMeaningData Type
pos.xx coordinateFloat
pos.yy coordinateFloat
pos.zz coordinateFloat
pos.dimDimension NameString
pos.dimidDimension IDInteger

Among them, the value of the dimension ID attribute is: 0 represents The Main World, 1 represents The Nether, and 2 represents The End.

Dimension text name: The values of the attributes are: "Main World", "Nether", "End"

If in some case the dimension is invalid, or cannot be obtained, you will find that the value of dimid is -1.

Coordinate Object Auxiliary Interface

For scripting languages โ€‹โ€‹that naturally support object-oriented, you can directly construct the coordinate object and pass in the x, y, z, dimid parameters. For some languages โ€‹โ€‹that support general object orientation, LSE also provides auxiliary interfaces to help generate a coordinate object more easily.

Generate an Integer Coordinate Object

[JavaScript] new IntPos(x,y,z,dimid)
[Lua] IntPos(x,y,z,dimid)

  • Parameters:
  • x : Integer
    x coordinate
  • y : Integer
    y coordinate
  • z : Integer
    z coordinate
  • dimid : Integer
    Dimension ID: 0 representing the overworld, 1 represents The Nether, 2 represents The End.
  • Return value: An Integer coordinate object.
  • Return value type: IntPos

Generate a Floating Point Coordinate Object

[JavaScript] new FloatPos(x,y,z,dimid)
[Lua] FloatPos(x,y,z,dimid)

  • Parameters:
  • x : Float
    x coordinate
  • y : Float
    y coordinate
  • z : Float
    z coordinate
  • dimid : Integer
    Dimension ID: 0 representing the overworld, 1 represents The Nether, 2 represents The End.
  • Return value: A floating point coordinate object.
  • Return value type: FloatPos

๐Ÿ“ Bearing Angle Object

The engine uses a DirectionAngle object to denote an Euler angle, called a "direction angle object". Its two members are floating point numbers, which are mostly used to represent the direction data such as the orientation of the entity. Each member of the direction angle object is readable and writable.

For a DirectionAngle type variable ang, there are the following members:

MemberMeaningData Type
ang.pitchPitch angle (-90ยฐ ~ 90ยฐ)Float
ang.yawYaw angle (rotation angle)Float

Since there is no concept of rotation in the entity system of MC, there is no data related to the rollover angle.

Create Direction Angle

[JavaScript] new DirectionAngle(pitch, yaw)
[Lua] DirectionAngle(pitch, yaw)

  • Parameters:
  • pitch : Float
    pitch angle
  • yaw : Float
    yaw angle
  • Return value: A floating point coordinate object.
  • Return value type: FloatPos
Convert Direction Angle to Base Heading

ang.toFacing()

  • Return value: The basic orientation indicated by the current bearing object.
  • Return value type: Integer

The return value is 0-3, representing the four basic orientations of North, East, South, West. Used to quickly determine the general direction an entity is facing.

Get Structure NBT

mc.getStructure(pos1, pos2, ignoreBlocks = false, ignoreEntities = false)

  • Parameters:

  • pos1 : IntPos diagonal coordinate 1, filled in similarly to the from parameter of the fill command

  • pos2 : IntPos diagonal coordinate 2, filled in similarly to the to parameter of the fill command

  • ignoreBlocks : Boolean Ignore blocks

  • ignoreEntities : Boolean Ignore entities

  • Return value type : NbtCompound

Set Structure NBT

mc.setStructure(nbt, pos, mirror = 0, rotation = 0)

  • Parameters:

  • nbt : NbtCompound

  • pos : IntPos place coordinates

  • mirror : Integer mirror mode

    • 0: no mirror 1: X-axis 2: Z-axis 3: XZ-axis
  • rotation : Integer rotation angle

    • 0: no rotation 1: rotation 90ยฐ 2: rotation 180ยฐ 3: rotation 270ยฐ
  • Return value type : Boolean