Skip to content

Translation notice

This page was translated with machine translation and may contain inaccuracies. If you can help improve it, please open an issue or submit a pull request.

Cover

Summary of "MOT UAV Example Tutorial"

Adzuki Bean 8593

Adzuki Bean 8593

TIP

Applicable version: Minecraft Java Edition 1.21.4 Project architecture: MOT + MOT-Memory + MOT-Math3.1 + MOT-Perf + iframe Language: Minecraft function (mcfunction) + MOT template syntax + linear algebra library Goal: Build a remotely controlled, programmable, and scalable drone system from scratch, and support interaction between external devices and GUI.

Why am I writing this tutorial?

With the rise of related technologies such as item display entity (IDE), text display entity (TDE), and block display entity (BDE) updated in JAVA version 1.19.4, vanilla developers have encountered two urgent practical needs:

  • Clear modular management
  • High Performance Mathematical Computing

The former is represented by object-oriented technology, which is mainly used to encapsulate multiple display entities into a whole, manually specify object formats and object protocols, and realize communication between modules and objects.

The latter is represented by local coordinate system algorithm, quaternion algorithm, and automatic control algorithm. It is mainly used for the construction of three-dimensional object space models and the calculation of transformation posture to display entities, thereby achieving smooth, flexible, and interactive program animation.

What can you learn in this tutorial?


  • The practice of mcfunction object-oriented thinking
  • Module protocol and module communication
  • Using the mot program for templated project construction
  • Standardized testing practices

  • Quaternions and local coordinate systems
  • Kinematics and Physical Computation
  • Application of automatic control algorithms

How to get tutorials?

Warehouse address:https://github.com/xiaodou8593/mot_1.0

source_files is the mcfunction template auxiliary program source file (need to be used in this project)

example_tutorial is the markdown document of the tutorial (please press .mot_example.mdchapter1.mdchapter2.mdchapter3.md read sequentially)

example_datapack is the finished data pack (you can compare it if you encounter any doubts during the project construction process)


1. Project Overview

ModuleFunctionRemarks
mot_uavUAV bodyKinematics, dynamics, collision, static body optimization, GUI
mot_lampRedstone lampThree slots on the left and right, the switch status is synchronized
mot_scatterSix-barreled machine gunContinuous bullets + scattering angle + sound effects
mot_laserLaser gunCooling mechanism + penetrating damage
mot_moverblock moverread/place block+NBT save
mot_dropperBomb dropperOnly TNT allowed, automatic fuze
mot_boatTethered boatCreate leash with drone, support towing
mot_scenesExhibition scenesState machine arrangement, one-click demonstration of all equipment

2. Technical Highlights

CategoryImplementationDescription
KinematicsQuaternion + local coordinate system10000 fixed point decimal, angular velocity/linear velocity iteration
DynamicsImpulse-response systemSupports multiple collision points, normal vectors, and elastic coefficients
Static entity optimizationFreeze static entitySave computing power, flame graph verification
Device Protocol_sync_request / _sync_coord / _use_signalThree-slot plug-and-play
GUIiframe backpack replacementGaze tracking + permission item + button event
Control programState machine + combination programHeight/rotation/displacement/aim/wait/connect/disconnect
Bullet moduleSub-entity recursionParticles + damage + penetration block
Number poolModule levelfree_addrAvoid int upper limit and support dynamic registration/unregistration
Performanceperf pipeline integrationif_blockOnly 4~5 scoreboard overhead

3. Drone control program list

ProgramFunctionStatus
heightFixed height hover0/1/2
rotationYaw angle lock0/1/2
positionHorizontal displacement0/1/2
facingAim at target point0/1/2
composeMulti-program serial0/1/2
up / turn / forwardInstant incrementTransfer to the above program
left_connect / left_deconnect / left_useLeft Slot0/-1/2
down_* / right_*The other two slotsSame as above
waitingWait N momentsCountdown
landing / near_landingNear ground landingAutomatic altitude correction

4. External device slot coordinate

slotlocal coordinate (u,v,w)description
left(2500,0,0)0.25 blocks to the left of the drone
down(0,-2500,0)0.25 blocks below the drone
right(-2500,0,0)0.25 blocks to the right of the drone

The device only needs to implement_sync_request / _sync_coord / _use_signalcan be automatically recognized.


5. Generate device instance

Generate drone

mcfunction
# 导入数据模板
data modify storage mot_uav:io input set from storage mot_uav:class test
# 指定生成位置
tp @e[tag=math_marker,limit=1] 0 0 0
data modify storage mot_uav:io input.position set from entity @e[tag=math_marker,limit=1] Pos
# 解析数据模板,构造实例
function mot_uav:_new

spawn machine gun

mcfunction
# 导入数据模板
data modify storage mot_scatter:io input set from storage mot_scatter:class test
# 指定生成位置
tp @e[tag=math_marker,limit=1] 0 0 0
data modify storage mot_scatter:io input.position set from entity @e[tag=math_marker,limit=1] Pos
# 解析数据模板,构造实例
function mot_scatter:_new

The method of constructing other device instances is the same as above


Common test scenarios

mcfunction
function mot_uav:test/general/start

Target test scenarios

mcfunction
function mot_uav:test/facing/start

One-click exhibition scene

mcfunction
function mot_scenes:exhibition/start

Powered by VitePress and GitHub Pages