menu PN X 第四章 运动控制器 - 处理实体运动的核心
Switch Language
  1. PowerNukkitX
  2. Get Started
  3. Config

    1. server.properties
    2. nukkit.yml
    3. pnx-cli-config.ini
    4. Anti-xray
    5. Resource Encryption
    6. Compression Acceleration
    7. PNX with WaterDogPE
    8. Flat World
  4. FAQ

    1. To Newcomers
    2. How to use PNX-CLI
    3. Common Questions
    4. Terra Questions
    5. Spawn-point Questions
    6. Convert Worlds
  5. For Devs

    1. Java

      1. Goto JavaDoc
      2. Mod API

        1. Custom Block
        2. Custom Item
        3. Custom Entity
        4. Custom Enchantment
      3. Entity AI

        1. Behavior
        2. Memory
        3. Sensor
        4. Motion Controller
        5. Navigator
        6. Behavior Group
        7. Work Cycle
    2. JavaScript

      1. setup dev env
      2. Base LLSELib dev
      3. Hello World
      4. Basic knowledge
      5. Event Listener
      6. FAQ
    3. Resources

      1. Event List
      2. IDs(block & item)

第四章 运动控制器 - 处理实体运动的核心

author: daoge_cmd

The translation made by AzaleeX contributed to the PowerNukkitX documentation

1.0 Control entity movement

Motion controllers are used to control the behavior of entities, such as the specific implementation of movement, jumping, attacking, and so on.

For different entities, different controllers can be provided to achieve special implementations of the above behaviors.

1.1 Workflow

The controller is very simple and its interface has only one method:


controlmethod will be called once per gt to handle entity movement

1.2 Control controller via operating memory

The controller does its job by reading a specific memory

Take the example of a sheep, which uses two controllersLookController,WalkControllerThe following memories are used:

MemoryType<Vector3> LOOK_TARGET = new MemoryType<>("minecraft:look_target");
MemoryType<Vector3> MOVE_TARGET = new MemoryType<>("minecraft:move_target");
MemoryType<Vector3> MOVE_DIRECTION_START = new MemoryType<>("minecraft:move_direction_start");
MemoryType<Vector3> MOVE_DIRECTION_END = new MemoryType<>("minecraft:move_direction_end");
MemoryType<Boolean> SHOULD_UPDATE_MOVE_DIRECTION = new MemoryType<>("minecraft:should_update_move_direction", false);
MemoryType<Boolean> ENABLE_PITCH = new MemoryType<>("minecraft:enable_pitch", true);

1.3 Introduction: Several controllers by default

The core already comes with several controllers, which in most cases you can use directly:

© PowerNukkitX Dev team