@@ -1358,3 +1358,343 @@ Each item in the array is a key-value pair list object `Object`, and the Attribu
1358
1358
| bad_omen | 28 |
1359
1359
| village_hero | 29 |
1360
1360
| darkness | 30 |
1361
+
1362
+ ### Determine whether it is a simulated player
1363
+
1364
+ ` pl.isSimulatedPlayer() `
1365
+
1366
+ - Return value: Is player a simulated player
1367
+ - Return type: ` Boolean `
1368
+
1369
+
1370
+
1371
+ ## Simulated player (due to too much overlap with the player API, no new simulated player class was generated)
1372
+
1373
+ ### Create a simulated player
1374
+
1375
+ ` mc.spawnSimulatedPlayer(name,pos) `
1376
+ ` mc.spawnSimulatedPlayer(name,x,y,z,dimid) `
1377
+
1378
+ - Parameters:
1379
+ - name : ` String `
1380
+ Name of simulted player
1381
+ - pos : ` IntPos ` / ` FloatPos `
1382
+ The coordinate object of the position of the spawned creature (or use x, y, z, dimid to determine the spawning position)
1383
+ - Return value: Generated (simulated) player object
1384
+ - Return type: ` Player `
1385
+ - If the return value is ` Null ` , it means the generation failed.
1386
+
1387
+ ### Simulated Player - Functions
1388
+
1389
+ Each simulated player object contains some member functions (member methods) that can be executed. For a specific simulated player object ` sp ` , you can use the following functions to perform some operations on this simulated player.
1390
+
1391
+ #### Simulate Respawn
1392
+
1393
+ ` sp.simulateRespawn() `
1394
+
1395
+ - Return value: Whether the simulation operation was successful
1396
+ - Return type: ` Boolean `
1397
+
1398
+ Reference: [ mojang-gametest docs] ( https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server-gametest/simulatedplayer?view=minecraft-bedrock-experimental#respawn )
1399
+
1400
+ #### Simulate Attack
1401
+
1402
+ ` sp.simulateAttack([target]) `
1403
+
1404
+ - Parameters:
1405
+
1406
+ - target : ` Entity `
1407
+ (Optional parameter) Attack target, default is the entity in the line of sight
1408
+
1409
+ - Return value: Whether the simulation operation was successful
1410
+ - Return type: ` Boolean `
1411
+
1412
+ Reference: [ mojang-gametest docs] ( https://docs.microsoft.com/en-us/minecraft/creator/scriptapi/mojang-gametest/simulatedplayer#attack )
1413
+
1414
+
1415
+ #### Simulate Destroy
1416
+
1417
+ ` sp.simulateDestroy([pos,face]) `
1418
+ ` sp.simulateDestroy([block,face]) `
1419
+ - Parameters:
1420
+
1421
+ - pos :` IntPos `
1422
+ (Optional parameter) The coordinates of the block to be destroyed, default is the block in the line of sight
1423
+ - block :` Block `
1424
+ (Optional parameter) The block to be destroyed, default is the block in the line of sight
1425
+ - face :` Integer `
1426
+ (Optional parameter) Which face to destroy from
1427
+
1428
+ - Return value: Whether the simulation operation was successful
1429
+ - Return type: ` Boolean `
1430
+
1431
+ Reference: [ mojang-gametest docs] ( https://docs.microsoft.com/en-us/minecraft/creator/scriptapi/mojang-gametest/simulatedplayer#breakblock )
1432
+
1433
+
1434
+ #### Simulate Disconnect
1435
+
1436
+ ` sp.simulateDisconnect() `
1437
+
1438
+ - Return value: Whether the simulation operation was successful
1439
+ - Return type: ` Boolean `
1440
+
1441
+ #### Simulate Interact
1442
+ ` sp.simulateInteract([target]) `
1443
+ ` sp.simulateInteract([pos,face]) `
1444
+ ` sp.simulateInteract([block,face]) `
1445
+
1446
+ - Parameters:
1447
+
1448
+ - target : ` Entity `
1449
+ (Optional parameter) Simulated interaction target, default is the block or entity in the line of sight
1450
+ - pos :` IntPos `
1451
+ (Optional parameter) Simulated interaction target, default is the block or entity in the line of sight
1452
+ - block :` Block `
1453
+ (Optional parameter) Simulated interaction target, default is the block or entity in the line of sight
1454
+ - face :` Number `
1455
+ (Optional parameter) Simulated interaction target block face
1456
+
1457
+ - Return value: Whether the simulation operation was successful
1458
+ - Return type: ` Boolean `
1459
+
1460
+ Reference: [ mojang-gametest docs] ( https://docs.microsoft.com/en-us/minecraft/creator/scriptapi/mojang-gametest/simulatedplayer#interact )
1461
+
1462
+
1463
+ #### Simulate Jump
1464
+
1465
+ ` sp.simulateJump() `
1466
+
1467
+ - Return value: Whether the simulation operation was successful
1468
+ - Return type: ` Boolean `
1469
+
1470
+ Reference: [ mojang-gametest docs] ( https://docs.microsoft.com/en-us/minecraft/creator/scriptapi/mojang-gametest/simulatedplayer#jump )
1471
+
1472
+
1473
+ #### Simulate Look At a Block or Entity
1474
+
1475
+ ` sp.simulateLookAt(pos) `
1476
+ ` sp.simulateLookAt(entity) `
1477
+ ` sp.simulateLookAt(block) `
1478
+
1479
+ - Parameters:
1480
+
1481
+ - target : ` Entity `
1482
+ The entity to look at
1483
+ - pos :` IntPos ` / ` FloatPos `
1484
+ The coordinates to look at
1485
+ - block :` Block `
1486
+ The block to look at
1487
+
1488
+ - Return value: Whether the simulation operation was successful
1489
+ - Return type: ` Boolean `
1490
+
1491
+ Reference: [ mojang-gametest docs] ( https://docs.microsoft.com/en-us/minecraft/creator/scriptapi/mojang-gametest/simulatedplayer#lookatblock )
1492
+
1493
+
1494
+ #### Simulate Set Body Rotation
1495
+
1496
+ ` sp.simulateSetBodyRotation(rot) `
1497
+
1498
+ - Parameters:
1499
+
1500
+ - rot : ` Number `
1501
+ The angle to set
1502
+
1503
+ - Return value: Whether the simulation operation was successful
1504
+ - Return type: ` Boolean `
1505
+
1506
+ Reference: [ mojang-gametest docs] ( https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server-gametest/simulatedplayer?view=minecraft-bedrock-experimental#rotatebody )
1507
+
1508
+
1509
+ #### Move Relative to Player Coordinate System
1510
+
1511
+ ` sp.simulateLocalMove() `
1512
+
1513
+ - Parameters:
1514
+ - pos : ` IntPos ` / ` FloatPos `
1515
+ Move direction
1516
+ - speed : ` Number `
1517
+ (Optional parameter) Move speed, default is 1
1518
+
1519
+ - Return value: Whether the move request was successful
1520
+ - Return type: ` Boolean `
1521
+
1522
+
1523
+ #### Move Relative to World Coordinate System
1524
+
1525
+ ` sp.simulateWorldMove() `
1526
+
1527
+ - Parameters:
1528
+ - pos : ` IntPos ` / ` FloatPos `
1529
+ Move direction
1530
+ - speed : ` Number `
1531
+ (Optional parameter) Move speed, default is 1
1532
+
1533
+ - Return value: Whether the move request was successful
1534
+ - Return type: ` Boolean `
1535
+
1536
+
1537
+ #### Move Straight to Coordinate
1538
+
1539
+ ` sp.simulateMoveTo() `
1540
+
1541
+ - Parameters:
1542
+ - pos : ` IntPos ` / ` FloatPos `
1543
+ Target position
1544
+ - speed : ` Number `
1545
+ (Optional parameter) Move speed, default is 1
1546
+
1547
+ - Return value: Whether the move request was successful
1548
+ - Return type: ` Boolean `
1549
+
1550
+ Reference: [ mojang-gametest docs] ( https://docs.microsoft.com/en-us/minecraft/creator/scriptapi/mojang-gametest/simulatedplayer#movetolocation )
1551
+ Note: If you need automatic pathfinding, consider using ` Simulate Navigate Move `
1552
+
1553
+ #### Simulate Navigate Move
1554
+
1555
+ ` sp.simulateNavigateTo(entity[,speed) `
1556
+ ` sp.simulateNavigateTo(pos[,speed]) `
1557
+
1558
+ - Parameters:
1559
+
1560
+ - entity : ` Entity `
1561
+ Navigation target
1562
+ - pos : ` IntPos ` / ` FloatPos `
1563
+ Navigation target
1564
+ - speed : ` Number `
1565
+ (Optional parameter) Move speed, default is 1
1566
+
1567
+ - Return value: Whether the specified location can be reached and the navigation path, structure: {isFullPath:` Boolean ` ,path:` Number[3][] ` }
1568
+ - Return type: ` Object `
1569
+
1570
+ Reference: [ mojang-gametest docs] ( https://docs.microsoft.com/en-us/minecraft/creator/scriptapi/mojang-gametest/simulatedplayer#navigatetoblock )
1571
+ Return value example:
1572
+ ``` js
1573
+ {
1574
+ isFullPath: false ,
1575
+ path: [
1576
+ [
1577
+ - 8 ,
1578
+ 0 ,
1579
+ - 3
1580
+ ],
1581
+ [
1582
+ - 7 ,
1583
+ 0 ,
1584
+ - 2
1585
+ ],
1586
+ [
1587
+ - 6 ,
1588
+ 0 ,
1589
+ - 2
1590
+ ],
1591
+ [
1592
+ - 5 ,
1593
+ 0 ,
1594
+ - 2
1595
+ ],
1596
+ [
1597
+ - 4 ,
1598
+ 0 ,
1599
+ - 1
1600
+ ],
1601
+ [
1602
+ - 3 ,
1603
+ 0 ,
1604
+ - 1
1605
+ ],
1606
+ [
1607
+ - 2 ,
1608
+ 0 ,
1609
+ - 1
1610
+ ],
1611
+ [
1612
+ - 1 ,
1613
+ 0 ,
1614
+ 0
1615
+ ]
1616
+ ]
1617
+ }
1618
+ ```
1619
+ This data has a target coordinate of (0,2,0), and the path endpoint is (-1,0,0), so isFullPath is false, but since the path is not empty, the simulated player will move to the (-1,0,0) coordinate.
1620
+
1621
+
1622
+ #### Simulate Navigate Move (Multiple Targets)
1623
+
1624
+ ` sp.simulateNavigateTo(posArray[,speed]) `
1625
+
1626
+ - Parameters:
1627
+
1628
+ - posArray : ` IntPos[] ` / ` FloatPos[] `
1629
+ Navigation targets
1630
+ - speed : ` Number `
1631
+ (Optional parameter) Move speed, default is 1
1632
+
1633
+ - Return value: Whether the simulation operation was successful
1634
+ - Return type: ` Boolean `
1635
+
1636
+ Reference: [ mojang-gametest docs] ( https://docs.microsoft.com/en-us/minecraft/creator/scriptapi/mojang-gametest/simulatedplayer#navigatetolocations )
1637
+
1638
+
1639
+ #### Simulate Use Item
1640
+
1641
+ ` sp.simulateUseItem([slot,pos,face,relative]) `
1642
+ ` sp.simulateUseItem([item,pos,face,relative]) `
1643
+
1644
+ - Parameters:
1645
+
1646
+ - item : ` Item `
1647
+ (Optional parameter) The item to use, default is the selected item
1648
+ - slot : ` Number `
1649
+ (Optional parameter) The slot where the item is located, default is the selected item
1650
+ - pos : ` IntPos `
1651
+ (Optional parameter) Target coordinate, default is the facing block coordinate
1652
+ - face : ` Number `
1653
+ (Optional parameter) Target block face, default is 0
1654
+ - relative : ` FloatPos `
1655
+ (Optional parameter) Relative block offset coordinate, default is {0.5,0.5,0.5}
1656
+
1657
+ - Return value: Whether the simulation operation was successful
1658
+ - Return type: ` Boolean `
1659
+
1660
+ Reference: [ mojang-gametest docs] ( https://docs.microsoft.com/en-us/minecraft/creator/scriptapi/mojang-gametest/simulatedplayer#useitem )
1661
+
1662
+
1663
+ #### Simulate Stop Destroying Block
1664
+
1665
+ ` sp.simulateStopDestroyingBlock() `
1666
+
1667
+ - Return value: Whether the simulation operation was successful
1668
+ - Return type: ` Boolean `
1669
+
1670
+ Reference: [ mojang-gametest docs] ( https://docs.microsoft.com/en-us/minecraft/creator/scriptapi/mojang-gametest/simulatedplayer#stopbreakingblock )
1671
+
1672
+
1673
+ #### Simulate Stop Interacting
1674
+
1675
+ ` sp.simulateStopInteracting() `
1676
+
1677
+ - Return value: Whether the simulation operation was successful
1678
+ - Return type: ` Boolean `
1679
+
1680
+ Reference: [ mojang-gametest docs] ( https://docs.microsoft.com/en-us/minecraft/creator/scriptapi/mojang-gametest/simulatedplayer#stopinteracting )
1681
+
1682
+
1683
+ #### Simulate Stop Moving
1684
+
1685
+ ` sp.simulateStopMoving() `
1686
+
1687
+ - Return value: Whether the simulation operation was successful
1688
+ - Return type: ` Boolean `
1689
+
1690
+ Reference: [ mojang-gametest docs] ( https://docs.microsoft.com/en-us/minecraft/creator/scriptapi/mojang-gametest/simulatedplayer#stopmoving )
1691
+
1692
+
1693
+ #### Simulate Stop Using Item
1694
+
1695
+ ` sp.simulateStopUsingItem() `
1696
+
1697
+ - Return value: Whether the simulation operation was successful
1698
+ - Return type: ` Boolean `
1699
+
1700
+ Reference: [ mojang-gametest docs] ( https://docs.microsoft.com/en-us/minecraft/creator/scriptapi/mojang-gametest/simulatedplayer#stopusingitem )
0 commit comments