mineflayer 4.29.0 → 4.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/api.md +4 -4
- package/docs/br/api_br.md +1 -1
- package/docs/es/api_es.md +2 -2
- package/docs/history.md +5 -0
- package/docs/ru/api_ru.md +4 -4
- package/docs/zh/api.md +4 -4
- package/lib/conversions.js +1 -1
- package/lib/plugins/block_actions.js +1 -1
- package/lib/plugins/chat.js +1 -1
- package/lib/plugins/entities.js +94 -156
- package/lib/plugins/physics.js +16 -18
- package/lib/plugins/ray_trace.js +0 -1
- package/lib/plugins/sound.js +15 -10
- package/package.json +3 -3
package/docs/api.md
CHANGED
|
@@ -764,11 +764,11 @@ Determines what color the boss bar color is, one of `pink`, `blue`, `red`, `gree
|
|
|
764
764
|
|
|
765
765
|
#### Particle.id
|
|
766
766
|
|
|
767
|
-
Particle ID, as defined in the [protocol](https://wiki
|
|
767
|
+
Particle ID, as defined in the [protocol](https://minecraft.wiki/w/Protocol#Particle)
|
|
768
768
|
|
|
769
769
|
#### Particle.name
|
|
770
770
|
|
|
771
|
-
Particle Name, as defined in the [protocol](https://wiki
|
|
771
|
+
Particle Name, as defined in the [protocol](https://minecraft.wiki/w/Protocol#Particle)
|
|
772
772
|
|
|
773
773
|
#### Particle.position
|
|
774
774
|
|
|
@@ -1139,7 +1139,7 @@ All scoreboards known to the bot in an object scoreboard displaySlot -> scoreboa
|
|
|
1139
1139
|
* `belowName` - scoreboard placed in belowName
|
|
1140
1140
|
* `sidebar` - scoreboard placed in sidebar
|
|
1141
1141
|
* `list` - scoreboard placed in list
|
|
1142
|
-
* `0-18` - slots defined in [protocol](https://wiki
|
|
1142
|
+
* `0-18` - slots defined in [protocol](https://minecraft.wiki/w/Protocol#Display_Scoreboard)
|
|
1143
1143
|
|
|
1144
1144
|
#### bot.teams
|
|
1145
1145
|
|
|
@@ -2158,7 +2158,7 @@ mode support:
|
|
|
2158
2158
|
- drag clicks (5)
|
|
2159
2159
|
- double clicks (6)
|
|
2160
2160
|
|
|
2161
|
-
Click on the current window. See details at https://wiki
|
|
2161
|
+
Click on the current window. See details at https://minecraft.wiki/w/Protocol#Click_Container
|
|
2162
2162
|
|
|
2163
2163
|
Prefer using bot.simpleClick.*
|
|
2164
2164
|
|
package/docs/br/api_br.md
CHANGED
|
@@ -1920,7 +1920,7 @@ Esses são métodos de nível mais baixo para o inventário e podem ser úteis e
|
|
|
1920
1920
|
|
|
1921
1921
|
Esta função também retorna uma `Promise`, com `void` como argumento quando concluída.
|
|
1922
1922
|
|
|
1923
|
-
Clique na janela/interface atual; os detalhes estão em https://wiki
|
|
1923
|
+
Clique na janela/interface atual; os detalhes estão em https://minecraft.wiki/w/Protocol#Click_Window
|
|
1924
1924
|
* slot - número que representa a posição na janela
|
|
1925
1925
|
* mouseButton - 0 para clique esquerdo e 1 para clique direito
|
|
1926
1926
|
* mode - mineflayer só tem o modo 0 disponível
|
package/docs/es/api_es.md
CHANGED
|
@@ -993,7 +993,7 @@ Todos los scoreboards que el bot conoce en un object de forma casilla de visuali
|
|
|
993
993
|
* `belowName` - scoreboard que está debajo del nombre
|
|
994
994
|
* `sidebar` - scoreboard que está en la barra del lado
|
|
995
995
|
* `list` - scoreboard que está en la lista
|
|
996
|
-
* `0-18` - casillas definidas en el [protocol](https://wiki
|
|
996
|
+
* `0-18` - casillas definidas en el [protocol](https://minecraft.wiki/w/Protocol#Display_Scoreboard)
|
|
997
997
|
|
|
998
998
|
#### bot.controlState
|
|
999
999
|
|
|
@@ -1931,7 +1931,7 @@ Estos son métodos de un nivel más bajo para el inventario, pueden ser útils a
|
|
|
1931
1931
|
|
|
1932
1932
|
Esta función también devueve un `Promise`, con `void` como argumento al finalizar.
|
|
1933
1933
|
|
|
1934
|
-
Hacer click en la ventana/interfaz actual, los detalles están en https://wiki
|
|
1934
|
+
Hacer click en la ventana/interfaz actual, los detalles están en https://minecraft.wiki/w/Protocol#Click_Window
|
|
1935
1935
|
* slot - número que representa la casilla de la ventan
|
|
1936
1936
|
* mouseButton - 0 para click izquierdo, y 1 para click derecho
|
|
1937
1937
|
* mode - mineflayer solo tiene disponible el modo 0
|
package/docs/history.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
## 4.30.0
|
|
2
|
+
* [Update player_info handling (#3689)](https://github.com/PrismarineJS/mineflayer/commit/3f2fd6d393bc39167410df5a292759c93c9b249f) (thanks @extremeheat)
|
|
3
|
+
* [Bump @types/node from 22.15.33 to 24.0.6 (#3686)](https://github.com/PrismarineJS/mineflayer/commit/12e50a2e2d0a921d075ebae8aa835437672a2b29) (thanks @dependabot[bot])
|
|
4
|
+
* [Replace wiki.vg by minecraft.wiki. Close #3596](https://github.com/PrismarineJS/mineflayer/commit/c2794e43da71b346278818ff68acb690ec66a4fb) (thanks @rom1504)
|
|
5
|
+
|
|
1
6
|
## 4.29.0
|
|
2
7
|
* [Sound test (#3657)](https://github.com/PrismarineJS/mineflayer/commit/51495665bbc3789ddc4284403c1ef288fea18ddc) (thanks @rom1504)
|
|
3
8
|
* [Add boss bar test (#3655)](https://github.com/PrismarineJS/mineflayer/commit/b6950e9c42324c0f6fba6f2f802d0c87973a8c92) (thanks @rom1504)
|
package/docs/ru/api_ru.md
CHANGED
|
@@ -773,11 +773,11 @@ UUID существа, который определяется боссом.
|
|
|
773
773
|
|
|
774
774
|
#### Particle.id
|
|
775
775
|
|
|
776
|
-
Идентификатор частицы, который прописан в [протоколе](https://wiki
|
|
776
|
+
Идентификатор частицы, который прописан в [протоколе](https://minecraft.wiki/w/Protocol#Particle).
|
|
777
777
|
|
|
778
778
|
#### Particle.name
|
|
779
779
|
|
|
780
|
-
Название частицы, которое прописано в [протоколе](https://wiki
|
|
780
|
+
Название частицы, которое прописано в [протоколе](https://minecraft.wiki/w/Protocol#Particle).
|
|
781
781
|
|
|
782
782
|
#### Particle.position
|
|
783
783
|
|
|
@@ -1170,7 +1170,7 @@ UUID существа, который определяется боссом.
|
|
|
1170
1170
|
* `belowName` - Cкорборд размещен снизу никнейма.
|
|
1171
1171
|
* `sidebar` - Cкорборд размещен на боковой панели.
|
|
1172
1172
|
* `list` - Cкорборд помещен в список игроков.
|
|
1173
|
-
* `0-18` - Cлоты, определённые в [протоколе](https://wiki
|
|
1173
|
+
* `0-18` - Cлоты, определённые в [протоколе](https://minecraft.wiki/w/Protocol#Display_Scoreboard).
|
|
1174
1174
|
|
|
1175
1175
|
#### bot.teams
|
|
1176
1176
|
|
|
@@ -2120,7 +2120,7 @@ bot.once('login', () => {
|
|
|
2120
2120
|
|
|
2121
2121
|
Единственное действительное значение для `mode` - 0. Нажатие с шифтом или перемещение через мышь не реализовано.
|
|
2122
2122
|
|
|
2123
|
-
Нажимает на текущее окно. Подробнее - https://wiki
|
|
2123
|
+
Нажимает на текущее окно. Подробнее - https://minecraft.wiki/w/Protocol#Click_Container
|
|
2124
2124
|
|
|
2125
2125
|
Рекомендуется использовать `bot.simpleClick.*`
|
|
2126
2126
|
|
package/docs/zh/api.md
CHANGED
|
@@ -737,8 +737,8 @@ Determines what color the boss bar color is, `pink`, `blue`, `red`, `green`, `y
|
|
|
737
737
|
* port : 端口,默认为 25565
|
|
738
738
|
* password : 可以省略 (如果token也被省略,那么它将尝试以离线模式连接)
|
|
739
739
|
* host : 默认为 localhost
|
|
740
|
-
* version :
|
|
741
|
-
* auth :
|
|
740
|
+
* version : 默认为自动猜测服务器的版本。值示例:"1.12.2"
|
|
741
|
+
* auth : 默认为"mojang",也可以是"microsoft"
|
|
742
742
|
* clientToken : 如果给定密码,则生成
|
|
743
743
|
* accessToken : 如果给定密码,则生成
|
|
744
744
|
* logErrors : 默认情况下为true,捕获错误并记录它们
|
|
@@ -1041,7 +1041,7 @@ All scoreboards known to the bot in an object scoreboard displaySlot -> scoreboa
|
|
|
1041
1041
|
* `belowName` - scoreboard placed in belowName
|
|
1042
1042
|
* `sidebar` - scoreboard placed in sidebar
|
|
1043
1043
|
* `list` - scoreboard placed in list
|
|
1044
|
-
* `0-18` - slots defined in [protocol](https://wiki
|
|
1044
|
+
* `0-18` - slots defined in [protocol](https://minecraft.wiki/w/Protocol#Display_Scoreboard)
|
|
1045
1045
|
|
|
1046
1046
|
#### bot.teams
|
|
1047
1047
|
|
|
@@ -2022,7 +2022,7 @@ These are lower level methods for the inventory, they can be useful sometimes bu
|
|
|
2022
2022
|
|
|
2023
2023
|
This function also returns a `Promise`, with `void` as its argument upon completion.
|
|
2024
2024
|
|
|
2025
|
-
Click on the current window. See details at https://wiki
|
|
2025
|
+
Click on the current window. See details at https://minecraft.wiki/w/Protocol#Click_Window
|
|
2026
2026
|
|
|
2027
2027
|
#### bot.putSelectedItemRange(start, end, window, slot)
|
|
2028
2028
|
|
package/lib/conversions.js
CHANGED
|
@@ -6,7 +6,7 @@ const PI_2 = Math.PI * 2
|
|
|
6
6
|
const TO_RAD = PI / 180
|
|
7
7
|
const TO_DEG = 1 / TO_RAD
|
|
8
8
|
const FROM_NOTCH_BYTE = 360 / 256
|
|
9
|
-
// From wiki
|
|
9
|
+
// From minecraft.wiki: Velocity is believed to be in units of 1/8000 of a block per server tick (50ms)
|
|
10
10
|
const FROM_NOTCH_VEL = 1 / 8000
|
|
11
11
|
|
|
12
12
|
exports.toRadians = toRadians
|
|
@@ -103,7 +103,7 @@ function inject (bot) {
|
|
|
103
103
|
const entity = bot.entities[packet.entityId]
|
|
104
104
|
|
|
105
105
|
if (destroyStage < 0 || destroyStage > 9) {
|
|
106
|
-
// http://wiki
|
|
106
|
+
// http://minecraft.wiki/w/Protocol#Block_Break_Progress
|
|
107
107
|
// "0-9 to set it, any other value to remove it"
|
|
108
108
|
bot.emit('blockBreakProgressEnd', block, entity)
|
|
109
109
|
} else {
|
package/lib/plugins/chat.js
CHANGED
|
@@ -118,7 +118,7 @@ function inject (bot, options) {
|
|
|
118
118
|
target: data.targetName ? JSON.parse(data.targetName) : undefined,
|
|
119
119
|
content: message ? JSON.parse(message) : { text: data.plainMessage }
|
|
120
120
|
}
|
|
121
|
-
const registryIndex = data.type.
|
|
121
|
+
const registryIndex = data.type.chatType != null ? data.type.chatType : data.type
|
|
122
122
|
msg = ChatMessage.fromNetwork(registryIndex, parameters)
|
|
123
123
|
|
|
124
124
|
if (data.unsignedContent) {
|
package/lib/plugins/entities.js
CHANGED
|
@@ -599,201 +599,139 @@ function inject (bot) {
|
|
|
599
599
|
bot.emit('entitySpawn', bot.entity)
|
|
600
600
|
})
|
|
601
601
|
|
|
602
|
-
|
|
603
|
-
|
|
602
|
+
function handlePlayerInfoBitfield (packet) {
|
|
603
|
+
for (const item of packet.data) {
|
|
604
|
+
let player = bot._playerFromUUID(item.uuid)
|
|
605
|
+
const newPlayer = !player
|
|
604
606
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
let player = bot.uuidToUsername[update.uuid] ? bot.players[bot.uuidToUsername[update.uuid]] : null
|
|
609
|
-
let newPlayer = false
|
|
610
|
-
|
|
611
|
-
const obj = {
|
|
612
|
-
uuid: update.uuid
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
if (!player) newPlayer = true
|
|
616
|
-
|
|
617
|
-
player ||= obj
|
|
618
|
-
|
|
619
|
-
if (packet.action.add_player) {
|
|
620
|
-
obj.username = update.player.name
|
|
621
|
-
obj.displayName = player.displayName || new ChatMessage({ text: '', extra: [{ text: update.player.name }] })
|
|
622
|
-
obj.skinData = extractSkinInformation(update.player.properties)
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
if (packet.action.update_game_mode) {
|
|
626
|
-
obj.gamemode = update.gamemode
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
if (packet.action.update_latency) {
|
|
630
|
-
obj.ping = update.latency
|
|
631
|
-
}
|
|
607
|
+
if (newPlayer) {
|
|
608
|
+
player = { uuid: item.uuid }
|
|
609
|
+
}
|
|
632
610
|
|
|
633
|
-
|
|
634
|
-
|
|
611
|
+
if (packet.action.add_player) {
|
|
612
|
+
player.username = item.player.name
|
|
613
|
+
player.displayName = new ChatMessage({ text: '', extra: [{ text: item.player.name }] })
|
|
614
|
+
player.skinData = extractSkinInformation(item.player.properties)
|
|
615
|
+
}
|
|
616
|
+
if (packet.action.initialize_chat && item.chatSession) {
|
|
617
|
+
player.chatSession = {
|
|
618
|
+
publicKey: item.chatSession.publicKey,
|
|
619
|
+
sessionUuid: item.chatSession.uuid
|
|
635
620
|
}
|
|
621
|
+
}
|
|
622
|
+
if (packet.action.update_game_mode) {
|
|
623
|
+
player.gamemode = item.gamemode
|
|
624
|
+
}
|
|
625
|
+
if (packet.action.update_listed) {
|
|
626
|
+
player.listed = item.listed
|
|
627
|
+
}
|
|
628
|
+
if (packet.action.update_latency) {
|
|
629
|
+
player.ping = item.latency
|
|
630
|
+
}
|
|
631
|
+
if (packet.action.update_display_name) {
|
|
632
|
+
player.displayName = item.displayName ? ChatMessage.fromNotch(item.displayName) : new ChatMessage({ text: '', extra: [{ text: player.username }] })
|
|
633
|
+
}
|
|
636
634
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
Object.assign(player, obj)
|
|
643
|
-
}
|
|
635
|
+
if (newPlayer) {
|
|
636
|
+
if (!player.username) continue // Should be unreachable if add_player is always sent for new players
|
|
637
|
+
bot.players[player.username] = player
|
|
638
|
+
bot.uuidToUsername[player.uuid] = player.username
|
|
639
|
+
}
|
|
644
640
|
|
|
645
|
-
|
|
646
|
-
|
|
641
|
+
const playerEntity = Object.values(bot.entities).find(e => e.type === 'player' && e.username === player.username)
|
|
642
|
+
player.entity = playerEntity
|
|
647
643
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
644
|
+
if (playerEntity === bot.entity) {
|
|
645
|
+
bot.player = player
|
|
646
|
+
}
|
|
651
647
|
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
}
|
|
648
|
+
if (newPlayer) {
|
|
649
|
+
bot.emit('playerJoined', player)
|
|
650
|
+
} else {
|
|
651
|
+
bot.emit('playerUpdated', player)
|
|
657
652
|
}
|
|
658
|
-
return
|
|
659
653
|
}
|
|
654
|
+
}
|
|
660
655
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
let newPlayer = false
|
|
665
|
-
|
|
666
|
-
const obj = {
|
|
667
|
-
uuid: item.uuid
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
if (!player) newPlayer = true
|
|
671
|
-
|
|
672
|
-
player = player || obj
|
|
673
|
-
|
|
674
|
-
if (packet.action & 1) {
|
|
675
|
-
obj.username = item.player.name
|
|
676
|
-
obj.displayName = player.displayName || new ChatMessage({ text: '', extra: [{ text: item.player.name }] })
|
|
677
|
-
obj.skinData = extractSkinInformation(item.player.properties)
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
if (packet.action & 4) {
|
|
681
|
-
obj.gamemode = item.gamemode
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
if (packet.action & 16) {
|
|
685
|
-
obj.ping = item.latency
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
if (item.displayName) {
|
|
689
|
-
obj.displayName = ChatMessage.fromNotch(item.displayName)
|
|
690
|
-
} else if (packet.action & 32) obj.displayName = new ChatMessage({ text: '', extra: [{ text: player.username || obj.username }] })
|
|
691
|
-
|
|
692
|
-
if (newPlayer) {
|
|
693
|
-
if (!obj.username) continue // Should be unreachable
|
|
694
|
-
player = bot.players[obj.username] = obj
|
|
695
|
-
bot.uuidToUsername[obj.uuid] = obj.username
|
|
696
|
-
} else {
|
|
697
|
-
Object.assign(player, obj)
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
const playerEntity = Object.values(bot.entities).find(e => e.type === 'player' && e.username === player.username)
|
|
701
|
-
player.entity = playerEntity
|
|
702
|
-
|
|
703
|
-
if (playerEntity === bot.entity) {
|
|
704
|
-
bot.player = player
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
if (newPlayer) {
|
|
708
|
-
bot.emit('playerJoined', player)
|
|
709
|
-
} else {
|
|
710
|
-
bot.emit('playerUpdated', player)
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
} else {
|
|
714
|
-
for (const item of packet.data) {
|
|
715
|
-
let player = bot.uuidToUsername[item.UUID] ? bot.players[bot.uuidToUsername[item.UUID]] : null
|
|
716
|
-
if (packet.action === 0) {
|
|
717
|
-
let newPlayer = false
|
|
656
|
+
function handlePlayerInfoLegacy (packet) {
|
|
657
|
+
for (const item of packet.data) {
|
|
658
|
+
let player = bot._playerFromUUID(item.uuid)
|
|
718
659
|
|
|
719
|
-
|
|
720
|
-
|
|
660
|
+
switch (packet.action) {
|
|
661
|
+
case 'add_player': {
|
|
662
|
+
const newPlayer = !player
|
|
663
|
+
if (newPlayer) {
|
|
721
664
|
player = bot.players[item.name] = {
|
|
722
665
|
username: item.name,
|
|
723
|
-
|
|
724
|
-
uuid: item.UUID,
|
|
725
|
-
displayName: new ChatMessage({ text: '', extra: [{ text: item.name }] }),
|
|
726
|
-
skinData: extractSkinInformation(item.properties),
|
|
727
|
-
profileKeys: item.crypto
|
|
728
|
-
? {
|
|
729
|
-
publicKey: item.crypto.publicKey, // DER-encoded public key
|
|
730
|
-
signature: item.crypto.signature // Signature
|
|
731
|
-
}
|
|
732
|
-
: null
|
|
666
|
+
uuid: item.uuid
|
|
733
667
|
}
|
|
668
|
+
bot.uuidToUsername[item.uuid] = item.name
|
|
669
|
+
}
|
|
734
670
|
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
// Just an Update
|
|
740
|
-
player.gamemode = item.gamemode
|
|
741
|
-
player.ping = item.ping
|
|
671
|
+
player.ping = item.ping
|
|
672
|
+
player.gamemode = item.gamemode
|
|
673
|
+
player.displayName = item.displayName ? ChatMessage.fromNotch(item.displayName) : new ChatMessage({ text: '', extra: [{ text: item.name }] })
|
|
674
|
+
if (item.properties) {
|
|
742
675
|
player.skinData = extractSkinInformation(item.properties)
|
|
743
|
-
if (item.crypto) {
|
|
744
|
-
player.profileKeys = {
|
|
745
|
-
publicKey: item.crypto.publicKey,
|
|
746
|
-
signature: item.crypto.signature
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
676
|
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
677
|
+
if (item.crypto) {
|
|
678
|
+
player.profileKeys = {
|
|
679
|
+
publicKey: item.crypto.publicKey,
|
|
680
|
+
signature: item.crypto.signature
|
|
681
|
+
}
|
|
753
682
|
}
|
|
754
683
|
|
|
755
684
|
const playerEntity = Object.values(bot.entities).find(e => e.type === 'player' && e.username === item.name)
|
|
756
685
|
player.entity = playerEntity
|
|
757
|
-
|
|
758
686
|
if (playerEntity === bot.entity) {
|
|
759
687
|
bot.player = player
|
|
760
688
|
}
|
|
761
689
|
|
|
762
|
-
if (
|
|
690
|
+
if (newPlayer) bot.emit('playerJoined', player)
|
|
691
|
+
else bot.emit('playerUpdated', player)
|
|
692
|
+
break
|
|
693
|
+
}
|
|
694
|
+
case 'update_gamemode': {
|
|
695
|
+
if (player) {
|
|
696
|
+
player.gamemode = item.gamemode
|
|
763
697
|
bot.emit('playerUpdated', player)
|
|
764
698
|
}
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
699
|
+
break
|
|
700
|
+
}
|
|
701
|
+
case 'update_latency': {
|
|
702
|
+
if (player) {
|
|
769
703
|
player.ping = item.ping
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
704
|
+
bot.emit('playerUpdated', player)
|
|
705
|
+
}
|
|
706
|
+
break
|
|
707
|
+
}
|
|
708
|
+
case 'update_display_name': {
|
|
709
|
+
if (player) {
|
|
710
|
+
player.displayName = item.displayName ? ChatMessage.fromNotch(item.displayName) : new ChatMessage({ text: '', extra: [{ text: player.username }] })
|
|
711
|
+
bot.emit('playerUpdated', player)
|
|
712
|
+
}
|
|
713
|
+
break
|
|
714
|
+
}
|
|
715
|
+
case 'remove_player': {
|
|
716
|
+
if (player) {
|
|
775
717
|
if (player.entity === bot.entity) continue
|
|
776
|
-
|
|
777
718
|
player.entity = null
|
|
778
719
|
delete bot.players[player.username]
|
|
779
|
-
delete bot.uuidToUsername[item.
|
|
720
|
+
delete bot.uuidToUsername[item.uuid]
|
|
780
721
|
bot.emit('playerLeft', player)
|
|
781
|
-
continue
|
|
782
|
-
} else {
|
|
783
|
-
continue
|
|
784
722
|
}
|
|
785
|
-
|
|
786
|
-
bot.emit('playerUpdated', player)
|
|
723
|
+
break
|
|
787
724
|
}
|
|
788
725
|
}
|
|
789
726
|
}
|
|
790
|
-
}
|
|
727
|
+
}
|
|
791
728
|
|
|
792
|
-
|
|
729
|
+
bot._client.on('player_info', bot.supportFeature('playerInfoActionIsBitfield') ? handlePlayerInfoBitfield : handlePlayerInfoLegacy)
|
|
730
|
+
|
|
731
|
+
// 1.19.3+ - player(s) leave the game
|
|
793
732
|
bot._client.on('player_remove', (packet) => {
|
|
794
733
|
for (const uuid of packet.players) {
|
|
795
|
-
const player = bot.
|
|
796
|
-
|
|
734
|
+
const player = bot._playerFromUUID(uuid)
|
|
797
735
|
if (!player || player.entity === bot.entity) continue
|
|
798
736
|
|
|
799
737
|
player.entity = null
|
package/lib/plugins/physics.js
CHANGED
|
@@ -354,38 +354,36 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
|
|
|
354
354
|
// e.g. when crouching/crawling/swimming. Can someone confirm?
|
|
355
355
|
bot.entity.height = 1.8
|
|
356
356
|
|
|
357
|
-
// Velocity is reset if the x, y, z flags are not set
|
|
358
357
|
const vel = bot.entity.velocity
|
|
359
|
-
// If the x, y, z flags are not set, the position is absolute
|
|
360
358
|
const pos = bot.entity.position
|
|
361
|
-
|
|
362
|
-
// TODO: this current mineflayer logic maybe incorrect. New (maybe even older) versions of minecraft have flag values for
|
|
363
|
-
// dx/dy/dz but mineflayer is assuming that 0b111 applies for both velocity and position.
|
|
364
|
-
|
|
365
359
|
let newYaw, newPitch
|
|
366
360
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
//
|
|
370
|
-
|
|
361
|
+
// Note: 1.20.5+ uses a bitflags object, older versions use a bitmask number
|
|
362
|
+
if (typeof packet.flags === 'object') {
|
|
363
|
+
// Modern path with bitflags object
|
|
364
|
+
// Velocity is only set to 0 if the flag is not set, otherwise keep current velocity
|
|
371
365
|
vel.set(
|
|
372
|
-
flags.x ? vel.x : 0,
|
|
373
|
-
flags.y ? vel.y : 0,
|
|
374
|
-
flags.z ? vel.z : 0
|
|
366
|
+
packet.flags.x ? vel.x : 0,
|
|
367
|
+
packet.flags.y ? vel.y : 0,
|
|
368
|
+
packet.flags.z ? vel.z : 0
|
|
375
369
|
)
|
|
370
|
+
// If flag is set, then the corresponding value is relative, else it is absolute
|
|
376
371
|
pos.set(
|
|
377
|
-
flags.x ? (pos.x + packet.x) : packet.x,
|
|
378
|
-
flags.y ? (pos.y + packet.y) : packet.y,
|
|
379
|
-
flags.z ? (pos.z + packet.z) : packet.z
|
|
372
|
+
packet.flags.x ? (pos.x + packet.x) : packet.x,
|
|
373
|
+
packet.flags.y ? (pos.y + packet.y) : packet.y,
|
|
374
|
+
packet.flags.z ? (pos.z + packet.z) : packet.z
|
|
380
375
|
)
|
|
381
|
-
newYaw = (flags.yaw ? conv.toNotchianYaw(bot.entity.yaw) : 0) + packet.yaw
|
|
382
|
-
newPitch = (flags.pitch ? conv.toNotchianPitch(bot.entity.pitch) : 0) + packet.pitch
|
|
376
|
+
newYaw = (packet.flags.yaw ? conv.toNotchianYaw(bot.entity.yaw) : 0) + packet.yaw
|
|
377
|
+
newPitch = (packet.flags.pitch ? conv.toNotchianPitch(bot.entity.pitch) : 0) + packet.pitch
|
|
383
378
|
} else {
|
|
379
|
+
// Legacy path with bitmask number
|
|
380
|
+
// Velocity is only set to 0 if the flag is not set, otherwise keep current velocity
|
|
384
381
|
vel.set(
|
|
385
382
|
packet.flags & 1 ? vel.x : 0,
|
|
386
383
|
packet.flags & 2 ? vel.y : 0,
|
|
387
384
|
packet.flags & 4 ? vel.z : 0
|
|
388
385
|
)
|
|
386
|
+
// If flag is set, then the corresponding value is relative, else it is absolute
|
|
389
387
|
pos.set(
|
|
390
388
|
packet.flags & 1 ? (pos.x + packet.x) : packet.x,
|
|
391
389
|
packet.flags & 2 ? (pos.y + packet.y) : packet.y,
|
package/lib/plugins/ray_trace.js
CHANGED
package/lib/plugins/sound.js
CHANGED
|
@@ -3,8 +3,6 @@ const { Vec3 } = require('vec3')
|
|
|
3
3
|
module.exports = inject
|
|
4
4
|
|
|
5
5
|
function inject (bot) {
|
|
6
|
-
const mcData = require('minecraft-data')(bot.version)
|
|
7
|
-
|
|
8
6
|
bot._client.on('named_sound_effect', (packet) => {
|
|
9
7
|
const soundName = packet.soundName
|
|
10
8
|
const pt = new Vec3(packet.x / 8, packet.y / 8, packet.z / 8)
|
|
@@ -24,20 +22,27 @@ function inject (bot) {
|
|
|
24
22
|
})
|
|
25
23
|
|
|
26
24
|
bot._client.on('sound_effect', (packet) => {
|
|
27
|
-
const soundId = packet.soundId
|
|
28
25
|
const soundCategory = packet.soundCategory
|
|
29
26
|
const pt = new Vec3(packet.x / 8, packet.y / 8, packet.z / 8)
|
|
30
27
|
const volume = packet.volume
|
|
31
28
|
const pitch = packet.pitch
|
|
32
29
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
soundName =
|
|
30
|
+
let soundId, soundName
|
|
31
|
+
|
|
32
|
+
if (packet.sound) { // ItemSoundHolder
|
|
33
|
+
if (packet.sound.data) soundName = packet.sound.data.soundName
|
|
34
|
+
else soundId = packet.sound.soundId // Sound specified by ID (registry reference)
|
|
35
|
+
} else { // Legacy packet
|
|
36
|
+
soundId = packet.soundId
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
//
|
|
40
|
-
bot.
|
|
41
|
-
|
|
39
|
+
// If we have an ID but no name yet, try to look it up in the registry
|
|
40
|
+
soundName ??= bot.registry?.sounds?.[soundId]?.name
|
|
41
|
+
|
|
42
|
+
if (soundName) {
|
|
43
|
+
bot.emit('soundEffectHeard', soundName, pt, volume, pitch)
|
|
44
|
+
} else if (soundId !== null) {
|
|
45
|
+
bot.emit('hardcodedSoundEffectHeard', soundId, soundCategory, pt, volume, pitch)
|
|
46
|
+
}
|
|
42
47
|
})
|
|
43
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mineflayer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.30.0",
|
|
4
4
|
"description": "create minecraft bots with a stable, high level API",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"minecraft-data": "^3.76.0",
|
|
25
|
-
"minecraft-protocol": "^1.
|
|
25
|
+
"minecraft-protocol": "^1.58.0",
|
|
26
26
|
"prismarine-biome": "^1.1.1",
|
|
27
27
|
"prismarine-block": "^1.17.0",
|
|
28
28
|
"prismarine-chat": "^1.7.1",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"vec3": "^0.1.7"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@types/node": "^
|
|
43
|
+
"@types/node": "^24.0.6",
|
|
44
44
|
"doctoc": "^2.0.1",
|
|
45
45
|
"minecraft-wrap": "^1.3.0",
|
|
46
46
|
"mineflayer": "file:",
|