mineflayer 4.1.0 → 4.2.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 +20 -3
- package/docs/history.md +10 -0
- package/docs/ru/README_RU.md +1 -2
- package/examples/inventory.js +1 -1
- package/index.d.ts +6 -2
- package/lib/bossbar.js +1 -1
- package/lib/loader.js +4 -4
- package/lib/plugins/bed.js +1 -2
- package/lib/plugins/block_actions.js +2 -2
- package/lib/plugins/book.js +4 -5
- package/lib/plugins/chat.js +2 -2
- package/lib/plugins/chest.js +2 -2
- package/lib/plugins/craft.js +2 -2
- package/lib/plugins/creative.js +13 -11
- package/lib/plugins/entities.js +6 -7
- package/lib/plugins/fishing.js +2 -4
- package/lib/plugins/game.js +4 -1
- package/lib/plugins/generic_place.js +2 -2
- package/lib/plugins/inventory.js +6 -10
- package/lib/plugins/physics.js +1 -3
- package/lib/plugins/place_entity.js +2 -2
- package/lib/plugins/settings.js +1 -1
- package/lib/plugins/tablist.js +1 -1
- package/lib/plugins/villager.js +3 -3
- package/lib/scoreboard.js +1 -1
- package/lib/team.js +2 -2
- package/package.json +3 -2
- package/lib/features.json +0 -337
- package/lib/supportFeature.js +0 -27
package/docs/api.md
CHANGED
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
- [Bot](#bot)
|
|
79
79
|
- [mineflayer.createBot(options)](#mineflayercreatebotoptions)
|
|
80
80
|
- [Properties](#properties)
|
|
81
|
+
- [bot.registry](#botregistry)
|
|
81
82
|
- [bot.world](#botworld)
|
|
82
83
|
- [world "blockUpdate" (oldBlock, newBlock)](#world-blockupdate-oldblock-newblock)
|
|
83
84
|
- [world "blockUpdate:(x, y, z)" (oldBlock, newBlock)](#world-blockupdatex-y-z-oldblock-newblock)
|
|
@@ -758,6 +759,10 @@ Create and return an instance of the class bot.
|
|
|
758
759
|
|
|
759
760
|
### Properties
|
|
760
761
|
|
|
762
|
+
#### bot.registry
|
|
763
|
+
|
|
764
|
+
Instance of minecraft-data used by the bot. Pass this to constructors that expect an instance of minecraft-data, such as prismarine-block.
|
|
765
|
+
|
|
761
766
|
#### bot.world
|
|
762
767
|
|
|
763
768
|
A sync representation of the world. Check the doc at http://github.com/PrismarineJS/prismarine-world
|
|
@@ -1859,13 +1864,13 @@ use shears.
|
|
|
1859
1864
|
Attack a player or a mob.
|
|
1860
1865
|
|
|
1861
1866
|
* `entity` is a type of entity. To get a specific entity use [bot.nearestEntity()](#botnearestentitymatch--entity---return-true-) or [bot.entities](#botentities).
|
|
1862
|
-
* `swing` Default `true`. If false the bot does not swing
|
|
1867
|
+
* `swing` Default to `true`. If false the bot does not swing its arm when attacking.
|
|
1863
1868
|
|
|
1864
1869
|
#### bot.swingArm([hand], showHand)
|
|
1865
1870
|
|
|
1866
1871
|
Play an arm swing animation.
|
|
1867
1872
|
|
|
1868
|
-
* `hand` can take `left` or `right` which is arm that is animated. Default: `right`
|
|
1873
|
+
* `hand` can take `left` or `right` which is the arm that is animated. Default: `right`
|
|
1869
1874
|
* `showHand` is a boolean whether to add the hand to the packet, Default: `true`
|
|
1870
1875
|
|
|
1871
1876
|
#### bot.mount(entity)
|
|
@@ -2051,7 +2056,7 @@ but it is assumed and often required that the bot be in creative mode for these
|
|
|
2051
2056
|
|
|
2052
2057
|
#### bot.creative.setInventorySlot(slot, item)
|
|
2053
2058
|
|
|
2054
|
-
This function returns a `Promise`, with `void` as its argument when gets fired when the
|
|
2059
|
+
This function returns a `Promise`, with `void` as its argument when gets fired when the server sets the slot.
|
|
2055
2060
|
|
|
2056
2061
|
Gives the bot the specified item in the specified inventory slot.
|
|
2057
2062
|
|
|
@@ -2061,6 +2066,18 @@ Gives the bot the specified item in the specified inventory slot.
|
|
|
2061
2066
|
|
|
2062
2067
|
If this method changes anything, you can be notified via `bot.inventory.on("updateSlot")`.
|
|
2063
2068
|
|
|
2069
|
+
#### bot.creative.clearSlot(slot)
|
|
2070
|
+
|
|
2071
|
+
This function returns a `Promise`, with `void` as its argument when gets fired when the server clears the slot.
|
|
2072
|
+
|
|
2073
|
+
Makes the sets the item in the slot given to null.
|
|
2074
|
+
|
|
2075
|
+
* `slot` is in inventory window coordinates (where 36 is the first quickbar slot, etc.).
|
|
2076
|
+
|
|
2077
|
+
#### bot.creative.clearInventory()
|
|
2078
|
+
|
|
2079
|
+
This function returns a `Promise`, with `void` as its argument when gets fired when the server clears the slot.
|
|
2080
|
+
|
|
2064
2081
|
#### bot.creative.flyTo(destination)
|
|
2065
2082
|
|
|
2066
2083
|
This function returns a `Promise`, with `void` as its argument when the bot arrives at the destination.
|
package/docs/history.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 4.2.0
|
|
2
|
+
|
|
3
|
+
* add missing extraInfos argument to Bot.blockAt function (@dumbasPL)
|
|
4
|
+
* Emit window close event AFTER updating the inventory (@imharvol)
|
|
5
|
+
* Move supportFeature to mcdata (@U9G)
|
|
6
|
+
* Update lib/ and test/ to use prismarine-registry (@extremeheat)
|
|
7
|
+
* only open chests with openContainer (@U9G)
|
|
8
|
+
* Add bot.creative.clearSlot and bot.creative.clearInventory (@U9G)
|
|
9
|
+
* remove transaction warning
|
|
10
|
+
|
|
1
11
|
## 4.1.0
|
|
2
12
|
|
|
3
13
|
* 1.18.2 support
|
package/docs/ru/README_RU.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
## Возможности
|
|
20
20
|
|
|
21
|
-
* Поддержка 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15 и 1.
|
|
21
|
+
* Поддержка 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17 и 1.18
|
|
22
22
|
* Поддержка энтити и их отслеживание
|
|
23
23
|
* Вы можете полностью взаимодействовать с миром. Миллисекунды на поиск любого блока
|
|
24
24
|
* Физика и управление
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
| -------------------------------------------------------------------------- | ------------------------------------- |
|
|
47
47
|
| [Обучение](tutorial.md) | Знакомство с Node.js и Mineflayer |
|
|
48
48
|
| [FAQ](FAQ_RU.md) | Появился вопрос? Найдите ответ здесь. |
|
|
49
|
-
| [API](api_ru.md) | Методы API |
|
|
50
49
|
| [Нестабильное API](unstable_api_ru.md) | Нестабильные методы API |
|
|
51
50
|
| [Обновления](history.md) | Список изменений в обновлениях |
|
|
52
51
|
| [Примеры](https://github.com/PrismarineJS/mineflayer/tree/master/examples) | Примеры использования Mineflayer |
|
package/examples/inventory.js
CHANGED
|
@@ -129,7 +129,7 @@ async function craftItem (name, amount) {
|
|
|
129
129
|
amount = parseInt(amount, 10)
|
|
130
130
|
const mcData = require('minecraft-data')(bot.version)
|
|
131
131
|
|
|
132
|
-
const item = mcData.
|
|
132
|
+
const item = mcData.itemsByName[name]
|
|
133
133
|
const craftingTableID = mcData.blocksByName.crafting_table.id
|
|
134
134
|
|
|
135
135
|
const craftingTable = bot.findBlock({
|
package/index.d.ts
CHANGED
|
@@ -197,7 +197,7 @@ export interface Bot extends TypedEmitter<BotEvents> {
|
|
|
197
197
|
|
|
198
198
|
end: (reason?: string) => void
|
|
199
199
|
|
|
200
|
-
blockAt: (point: Vec3) => Block | null
|
|
200
|
+
blockAt: (point: Vec3, extraInfos?: boolean) => Block | null
|
|
201
201
|
|
|
202
202
|
blockInSight: (maxSteps: number, vectorLength: number) => Block | null
|
|
203
203
|
|
|
@@ -294,7 +294,7 @@ export interface Bot extends TypedEmitter<BotEvents> {
|
|
|
294
294
|
|
|
295
295
|
digTime: (block: Block) => number
|
|
296
296
|
|
|
297
|
-
placeBlock: (referenceBlock: Block, faceVector: Vec3
|
|
297
|
+
placeBlock: (referenceBlock: Block, faceVector: Vec3) => Promise<void>
|
|
298
298
|
|
|
299
299
|
placeEntity: (referenceBlock: Block, faceVector: Vec3) => Promise<Entity>
|
|
300
300
|
|
|
@@ -571,6 +571,10 @@ export interface creativeMethods {
|
|
|
571
571
|
item: Item | null
|
|
572
572
|
) => Promise<void>
|
|
573
573
|
|
|
574
|
+
clearSlot: (slot: number) => Promise<void>
|
|
575
|
+
|
|
576
|
+
clearInventory: () => Promise<void>
|
|
577
|
+
|
|
574
578
|
flyTo: (destination: Vec3) => Promise<void>
|
|
575
579
|
|
|
576
580
|
startFlying: () => void
|
package/lib/bossbar.js
CHANGED
|
@@ -5,7 +5,7 @@ const divisions = [0, 6, 10, 12, 20]
|
|
|
5
5
|
module.exports = loader
|
|
6
6
|
|
|
7
7
|
function loader (mcVersion) {
|
|
8
|
-
ChatMessage = require('prismarine-chat')(mcVersion)
|
|
8
|
+
ChatMessage = require('prismarine-chat')(mcVersion) // TODO: update for prismarine-registry
|
|
9
9
|
return BossBar
|
|
10
10
|
}
|
|
11
11
|
|
package/lib/loader.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const mc = require('minecraft-protocol')
|
|
2
2
|
const { EventEmitter } = require('events')
|
|
3
3
|
const pluginLoader = require('./plugin_loader')
|
|
4
|
-
const supportFeature = require('./supportFeature')
|
|
5
4
|
const plugins = {
|
|
6
5
|
bed: require('./plugins/bed'),
|
|
7
6
|
title: require('./plugins/title'),
|
|
@@ -56,7 +55,7 @@ module.exports = {
|
|
|
56
55
|
BossBar: require('./bossbar'),
|
|
57
56
|
supportedVersions,
|
|
58
57
|
testedVersions,
|
|
59
|
-
supportFeature
|
|
58
|
+
supportFeature: (feature, version) => require('minecraft-data')(version).supportFeature(feature)
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
function createBot (options = {}) {
|
|
@@ -105,7 +104,8 @@ function createBot (options = {}) {
|
|
|
105
104
|
if (!bot._client.wait_connect) next()
|
|
106
105
|
else bot._client.once('connect_allowed', next)
|
|
107
106
|
function next () {
|
|
108
|
-
|
|
107
|
+
bot.registry = require('prismarine-registry')(bot._client.version)
|
|
108
|
+
const version = bot.registry.version
|
|
109
109
|
if (supportedVersions.indexOf(version.majorVersion) === -1) {
|
|
110
110
|
throw new Error(`Version ${version.minecraftVersion} is not supported.`)
|
|
111
111
|
}
|
|
@@ -120,7 +120,7 @@ function createBot (options = {}) {
|
|
|
120
120
|
bot.majorVersion = version.majorVersion
|
|
121
121
|
bot.version = version.minecraftVersion
|
|
122
122
|
options.version = version.minecraftVersion
|
|
123
|
-
bot.supportFeature =
|
|
123
|
+
bot.supportFeature = bot.registry.supportFeature
|
|
124
124
|
bot.emit('inject_allowed')
|
|
125
125
|
}
|
|
126
126
|
return bot
|
package/lib/plugins/bed.js
CHANGED
|
@@ -6,7 +6,6 @@ const CARDINAL_DIRECTIONS = ['south', 'west', 'north', 'east']
|
|
|
6
6
|
|
|
7
7
|
function inject (bot) {
|
|
8
8
|
bot.isSleeping = false
|
|
9
|
-
const mcData = require('minecraft-data')(bot.version)
|
|
10
9
|
|
|
11
10
|
const beds = new Set(['white_bed', 'orange_bed', 'magenta_bed', 'light_blue_bed', 'yellow_bed', 'lime_bed', 'pink_bed', 'gray_bed',
|
|
12
11
|
'light_gray_bed', 'cyan_bed', 'purple_bed', 'blue_bed', 'brown_bed', 'green_bed', 'red_bed', 'black_bed', 'bed'])
|
|
@@ -24,7 +23,7 @@ function inject (bot) {
|
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
if (bot.supportFeature('blockStateId')) {
|
|
27
|
-
const state = bedBlock.stateId -
|
|
26
|
+
const state = bedBlock.stateId - bot.registry.blocksByStateId[bedBlock.stateId].minStateId
|
|
28
27
|
const bitMetadata = state.toString(2).padStart(4, '0') // FACING (first 2 bits), PART (3rd bit), OCCUPIED (4th bit)
|
|
29
28
|
metadata.part = bitMetadata[3] === '0'
|
|
30
29
|
metadata.occupied = bitMetadata[2] === '0'
|
|
@@ -16,8 +16,8 @@ const FACING_MAP = {
|
|
|
16
16
|
east: { north: 'right', south: 'left' }
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
function inject (bot
|
|
20
|
-
const { instruments, blocks } =
|
|
19
|
+
function inject (bot) {
|
|
20
|
+
const { instruments, blocks } = bot.registry
|
|
21
21
|
|
|
22
22
|
// Stores how many players have currently open a container at a certain position
|
|
23
23
|
const openCountByPos = {}
|
package/lib/plugins/book.js
CHANGED
|
@@ -3,9 +3,8 @@ const { once } = require('events')
|
|
|
3
3
|
|
|
4
4
|
module.exports = inject
|
|
5
5
|
|
|
6
|
-
function inject (bot
|
|
7
|
-
const
|
|
8
|
-
const Item = require('prismarine-item')(version)
|
|
6
|
+
function inject (bot) {
|
|
7
|
+
const Item = require('prismarine-item')(bot.version)
|
|
9
8
|
|
|
10
9
|
let editBook
|
|
11
10
|
if (bot.supportFeature('editBookIsPluginChannel')) {
|
|
@@ -28,7 +27,7 @@ function inject (bot, { version }) {
|
|
|
28
27
|
async function write (slot, pages, author, title, signing) {
|
|
29
28
|
assert.ok(slot >= 0 && slot <= 44, 'slot out of inventory range')
|
|
30
29
|
const book = bot.inventory.slots[slot]
|
|
31
|
-
assert.ok(book && book.type ===
|
|
30
|
+
assert.ok(book && book.type === bot.registry.itemsByName.writable_book.id, `no book found in slot ${slot}`)
|
|
32
31
|
const quickBarSlot = bot.quickBarSlot
|
|
33
32
|
const moveToQuickBar = slot < 36
|
|
34
33
|
|
|
@@ -60,7 +59,7 @@ function inject (bot, { version }) {
|
|
|
60
59
|
}
|
|
61
60
|
if (signing) {
|
|
62
61
|
if (bot.supportFeature('clientUpdateBookIdWhenSign')) {
|
|
63
|
-
book.type =
|
|
62
|
+
book.type = bot.registry.itemsByName.written_book.id
|
|
64
63
|
}
|
|
65
64
|
book.nbt.value.author = {
|
|
66
65
|
type: 'string',
|
package/lib/plugins/chat.js
CHANGED
|
@@ -33,7 +33,7 @@ function inject (bot, options) {
|
|
|
33
33
|
bot.addChatPattern = (name, pattern, opts = {}) => {
|
|
34
34
|
if (!(pattern instanceof RegExp)) throw new Error('Pattern parameter should be of type RegExp')
|
|
35
35
|
const { repeat = true, deprecated = false, parse = false } = opts
|
|
36
|
-
_patterns[_length
|
|
36
|
+
_patterns[_length] = {
|
|
37
37
|
name,
|
|
38
38
|
patterns: [pattern],
|
|
39
39
|
position: 0,
|
|
@@ -43,7 +43,7 @@ function inject (bot, options) {
|
|
|
43
43
|
repeat,
|
|
44
44
|
parse
|
|
45
45
|
}
|
|
46
|
-
return _length
|
|
46
|
+
return _length++ // increment length after we give it back to the user
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
bot.removeChatPattern = name => {
|
package/lib/plugins/chest.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
module.exports = inject
|
|
3
3
|
|
|
4
4
|
function inject (bot) {
|
|
5
|
-
const allowedWindowTypes = ['minecraft:generic', 'minecraft:chest', 'minecraft:dispenser', 'minecraft:shulker_box', 'minecraft:hopper', 'minecraft:container', 'minecraft:dropper']
|
|
5
|
+
const allowedWindowTypes = ['minecraft:generic', 'minecraft:chest', 'minecraft:dispenser', 'minecraft:shulker_box', 'minecraft:hopper', 'minecraft:container', 'minecraft:dropper', 'minecraft:trapped_chest']
|
|
6
6
|
|
|
7
7
|
function matchWindowType (window) {
|
|
8
8
|
for (const type of allowedWindowTypes) {
|
|
@@ -13,7 +13,7 @@ function inject (bot) {
|
|
|
13
13
|
|
|
14
14
|
async function openContainer (containerToOpen) {
|
|
15
15
|
let chest
|
|
16
|
-
if (containerToOpen.constructor.name === 'Block') {
|
|
16
|
+
if (containerToOpen.constructor.name === 'Block' && allowedWindowTypes.map(name => name.replace('minecraft:', '')).includes(containerToOpen.name)) {
|
|
17
17
|
chest = await bot.openBlock(containerToOpen)
|
|
18
18
|
} else if (containerToOpen.constructor.name === 'Entity') {
|
|
19
19
|
chest = await bot.openEntity(containerToOpen)
|
package/lib/plugins/craft.js
CHANGED
|
@@ -4,8 +4,8 @@ const { once } = require('events')
|
|
|
4
4
|
module.exports = inject
|
|
5
5
|
|
|
6
6
|
function inject (bot, { version }) {
|
|
7
|
-
const Item = require('prismarine-item')(version)
|
|
8
|
-
const Recipe = require('prismarine-recipe')(version).Recipe
|
|
7
|
+
const Item = require('prismarine-item')(bot.version)
|
|
8
|
+
const Recipe = require('prismarine-recipe')(version).Recipe // TODO: update for prismarine-registry
|
|
9
9
|
|
|
10
10
|
async function craft (recipe, count, craftingTable) {
|
|
11
11
|
assert.ok(recipe)
|
package/lib/plugins/creative.js
CHANGED
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
2
|
const { Vec3 } = require('vec3')
|
|
3
|
-
const { sleep } = require('../promise_utils')
|
|
3
|
+
const { sleep, onceWithCleanup } = require('../promise_utils')
|
|
4
4
|
const { once } = require('events')
|
|
5
5
|
|
|
6
6
|
module.exports = inject
|
|
7
7
|
|
|
8
|
-
function inject (bot
|
|
9
|
-
const Item = require('prismarine-item')(version)
|
|
8
|
+
function inject (bot) {
|
|
9
|
+
const Item = require('prismarine-item')(bot.version)
|
|
10
10
|
|
|
11
11
|
// these features only work when you are in creative mode.
|
|
12
12
|
bot.creative = {
|
|
13
|
-
setInventorySlot
|
|
13
|
+
setInventorySlot,
|
|
14
14
|
flyTo: flyTo,
|
|
15
15
|
startFlying,
|
|
16
|
-
stopFlying
|
|
16
|
+
stopFlying,
|
|
17
|
+
clearSlot: slotNum => setInventorySlot(slotNum, null),
|
|
18
|
+
clearInventory
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
const creativeSlotsUpdates = []
|
|
20
|
-
bot._client.on('set_slot', ({ windowId, slot, item }) => {
|
|
21
|
-
if (windowId === 0 && creativeSlotsUpdates[slot]) {
|
|
22
|
-
bot.emit(`set_creative_slot_${slot}`)
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
22
|
|
|
26
23
|
// WARN: This method should not be called twice on the same slot before first promise succeeds
|
|
27
24
|
async function setInventorySlot (slot, item) {
|
|
28
25
|
assert(slot >= 0 && slot <= 44)
|
|
29
26
|
|
|
27
|
+
if (Item.equal(bot.inventory.slots[slot], item, true)) return
|
|
30
28
|
if (creativeSlotsUpdates[slot]) {
|
|
31
29
|
throw new Error(`Setting slot ${slot} cancelled due to calling bot.creative.setInventorySlot(${slot}, ...) again`)
|
|
32
30
|
}
|
|
@@ -37,10 +35,14 @@ function inject (bot, { version }) {
|
|
|
37
35
|
item: Item.toNotch(item)
|
|
38
36
|
})
|
|
39
37
|
|
|
40
|
-
await
|
|
38
|
+
await onceWithCleanup(bot.inventory, `updateSlot:${slot}`, { checkCondition: (oldItem, newItem) => item === null ? newItem === null : newItem?.name === item.name && newItem?.count === item.count && newItem?.metadata === item.metadata })
|
|
41
39
|
creativeSlotsUpdates[slot] = false
|
|
42
40
|
}
|
|
43
41
|
|
|
42
|
+
async function clearInventory () {
|
|
43
|
+
return Promise.all(bot.inventory.slots.filter(item => item).map(item => setInventorySlot(item.slot, null)))
|
|
44
|
+
}
|
|
45
|
+
|
|
44
46
|
let normalGravity = null
|
|
45
47
|
const flyingSpeedPerUpdate = 0.5
|
|
46
48
|
|
package/lib/plugins/entities.js
CHANGED
|
@@ -24,13 +24,12 @@ const entityStatusEvents = {
|
|
|
24
24
|
10: 'entityEatingGrass'
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
function inject (bot
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const ChatMessage = require('prismarine-chat')(version)
|
|
27
|
+
function inject (bot) {
|
|
28
|
+
const { objects, mobs, entitiesArray } = bot.registry
|
|
29
|
+
const Entity = require('prismarine-entity')(bot.version) // TODO: update for prismarine-registry
|
|
30
|
+
const Item = require('prismarine-item')(bot.version)
|
|
31
|
+
const ChatMessage = require('prismarine-chat')(bot.version) // TODO: update for prismarine-registry
|
|
32
|
+
|
|
34
33
|
// ONLY 1.17 has this destroy_entity packet which is the same thing as entity_destroy packet except the entity is singular
|
|
35
34
|
// 1.17.1 reverted this change so this is just a simpler fix
|
|
36
35
|
bot._client.on('destroy_entity', (packet) => {
|
package/lib/plugins/fishing.js
CHANGED
|
@@ -4,14 +4,12 @@ const { createDoneTask, createTask } = require('../promise_utils')
|
|
|
4
4
|
module.exports = inject
|
|
5
5
|
|
|
6
6
|
function inject (bot) {
|
|
7
|
-
const mcData = require('minecraft-data')(bot.version)
|
|
8
|
-
|
|
9
7
|
let bobberId = 90
|
|
10
8
|
// Before 1.14 the bobber entity keep changing name at each version (but the id stays 90)
|
|
11
9
|
// 1.14 changes the id, but hopefully we can stick with the name: fishing_bobber
|
|
12
10
|
// the alternative would be to rename it in all version of mcData
|
|
13
11
|
if (bot.supportFeature('fishingBobberCorrectlyNamed')) {
|
|
14
|
-
bobberId =
|
|
12
|
+
bobberId = bot.registry.entitiesByName.fishing_bobber.id
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
let fishingTask = createDoneTask()
|
|
@@ -27,7 +25,7 @@ function inject (bot) {
|
|
|
27
25
|
if (!lastBobber || fishingTask.done) return
|
|
28
26
|
|
|
29
27
|
const pos = lastBobber.position
|
|
30
|
-
const parts =
|
|
28
|
+
const parts = bot.registry.particlesByName
|
|
31
29
|
if (packet.particleId === (parts?.fishing ?? parts.bubble).id && packet.particles === 6 && pos.distanceTo(new Vec3(packet.x, pos.y, packet.z)) <= 1.23) {
|
|
32
30
|
bot.activateItem()
|
|
33
31
|
lastBobber = undefined
|
package/lib/plugins/game.js
CHANGED
|
@@ -67,10 +67,13 @@ function inject (bot, options) {
|
|
|
67
67
|
|
|
68
68
|
bot.emit('login')
|
|
69
69
|
bot.emit('game')
|
|
70
|
-
bot._client.write('held_item_slot', { slotId: 0 })
|
|
71
70
|
|
|
72
71
|
// varint length-prefixed string as data
|
|
73
72
|
bot._client.writeChannel(brandChannel, options.brand)
|
|
73
|
+
|
|
74
|
+
if (packet.dimensionCodec) {
|
|
75
|
+
bot.registry.loadDimensionCodec(packet.dimensionCodec)
|
|
76
|
+
}
|
|
74
77
|
})
|
|
75
78
|
|
|
76
79
|
bot._client.on('respawn', (packet) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
2
|
module.exports = inject
|
|
3
3
|
|
|
4
|
-
function inject (bot
|
|
5
|
-
const Item = require('prismarine-item')(version)
|
|
4
|
+
function inject (bot) {
|
|
5
|
+
const Item = require('prismarine-item')(bot.version)
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
8
|
* @param {import('prismarine-block').Block} referenceBlock
|
package/lib/plugins/inventory.js
CHANGED
|
@@ -20,10 +20,9 @@ const ALWAYS_CONSUMABLES = [
|
|
|
20
20
|
'golden_apple'
|
|
21
21
|
]
|
|
22
22
|
|
|
23
|
-
function inject (bot, {
|
|
24
|
-
const Item = require('prismarine-item')(version)
|
|
25
|
-
const windows = require('prismarine-windows')(version)
|
|
26
|
-
const mcData = require('minecraft-data')(version)
|
|
23
|
+
function inject (bot, { hideErrors }) {
|
|
24
|
+
const Item = require('prismarine-item')(bot.version)
|
|
25
|
+
const windows = require('prismarine-windows')(bot.version) // TODO: update for prismarine-registry
|
|
27
26
|
|
|
28
27
|
let eatingTask = createDoneTask()
|
|
29
28
|
|
|
@@ -251,7 +250,7 @@ function inject (bot, { version, hideErrors }) {
|
|
|
251
250
|
(nbt != null && window.selectedItem.nbt !== nbt)) {
|
|
252
251
|
// we are not holding the item we need. click it.
|
|
253
252
|
const sourceItem = window.findItemRange(sourceStart, sourceEnd, itemType, metadata, false, nbt)
|
|
254
|
-
const mcDataEntry =
|
|
253
|
+
const mcDataEntry = bot.registry.itemsArray.find(x => x.id === itemType)
|
|
255
254
|
assert(mcDataEntry, 'Invalid itemType')
|
|
256
255
|
if (!sourceItem) throw new Error(`Can't find ${mcDataEntry.name} in slots [${sourceStart} - ${sourceEnd}], (item id: ${itemType})`)
|
|
257
256
|
if (firstSourceSlot === null) firstSourceSlot = sourceItem.slot
|
|
@@ -303,8 +302,8 @@ function inject (bot, { version, hideErrors }) {
|
|
|
303
302
|
|
|
304
303
|
function extendWindow (window) {
|
|
305
304
|
window.close = () => {
|
|
306
|
-
window.emit('close')
|
|
307
305
|
closeWindow(window)
|
|
306
|
+
window.emit('close')
|
|
308
307
|
}
|
|
309
308
|
|
|
310
309
|
window.withdraw = async (itemType, metadata, count, nbt) => {
|
|
@@ -382,7 +381,7 @@ function inject (bot, { version, hideErrors }) {
|
|
|
382
381
|
if (item) {
|
|
383
382
|
item.slot = slot
|
|
384
383
|
}
|
|
385
|
-
bot.inventory.slots[slot]
|
|
384
|
+
if (!Item.equal(bot.inventory.slots[slot], item, true)) bot.inventory.updateSlot(slot, item)
|
|
386
385
|
}
|
|
387
386
|
}
|
|
388
387
|
|
|
@@ -439,9 +438,6 @@ function inject (bot, { version, hideErrors }) {
|
|
|
439
438
|
accepted: true
|
|
440
439
|
// bot.emit(`confirmTransaction${click.id}`, false)
|
|
441
440
|
})
|
|
442
|
-
if (!hideErrors) {
|
|
443
|
-
console.log(`WARNING : unknown transaction confirmation for window ${windowId}, action ${actionId} and accepted ${accepted}`)
|
|
444
|
-
}
|
|
445
441
|
return
|
|
446
442
|
}
|
|
447
443
|
// shift it later if packets are sent out of order
|
package/lib/plugins/physics.js
CHANGED
|
@@ -15,10 +15,8 @@ const PHYSICS_INTERVAL_MS = 50
|
|
|
15
15
|
const PHYSICS_TIMESTEP = PHYSICS_INTERVAL_MS / 1000
|
|
16
16
|
|
|
17
17
|
function inject (bot, { physicsEnabled }) {
|
|
18
|
-
const mcData = require('minecraft-data')(bot.version)
|
|
19
|
-
|
|
20
18
|
const world = { getBlock: (pos) => { return bot.blockAt(pos, false) } }
|
|
21
|
-
const physics = Physics(
|
|
19
|
+
const physics = Physics(bot.registry, world)
|
|
22
20
|
|
|
23
21
|
bot.jumpQueued = false
|
|
24
22
|
bot.jumpTicks = 0 // autojump cooldown
|
package/lib/plugins/settings.js
CHANGED
package/lib/plugins/tablist.js
CHANGED
|
@@ -5,7 +5,7 @@ const escapeValueNewlines = str => {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
function inject (bot) {
|
|
8
|
-
const ChatMessage = require('prismarine-chat')(bot.version)
|
|
8
|
+
const ChatMessage = require('prismarine-chat')(bot.version) // TODO: update for prismarine-registry
|
|
9
9
|
|
|
10
10
|
bot.tablist = {
|
|
11
11
|
header: new ChatMessage(''),
|
package/lib/plugins/villager.js
CHANGED
|
@@ -4,8 +4,8 @@ const { once } = require('events')
|
|
|
4
4
|
module.exports = inject
|
|
5
5
|
|
|
6
6
|
function inject (bot, { version }) {
|
|
7
|
-
const
|
|
8
|
-
const Item = require('prismarine-item')(version)
|
|
7
|
+
const { entitiesByName } = bot.registry
|
|
8
|
+
const Item = require('prismarine-item')(bot.version)
|
|
9
9
|
|
|
10
10
|
let selectTrade
|
|
11
11
|
if (bot.supportFeature('useMCTrSel')) {
|
|
@@ -70,7 +70,7 @@ function inject (bot, { version }) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
async function openVillager (villagerEntity) {
|
|
73
|
-
const villagerType =
|
|
73
|
+
const villagerType = entitiesByName.villager ? entitiesByName.villager.id : entitiesByName.Villager.id
|
|
74
74
|
assert.strictEqual(villagerEntity.entityType, villagerType)
|
|
75
75
|
let ready = false
|
|
76
76
|
|
package/lib/scoreboard.js
CHANGED
|
@@ -5,7 +5,7 @@ const sortItems = (a, b) => {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
module.exports = (bot) => {
|
|
8
|
-
const ChatMessage = require('prismarine-chat')(bot.version)
|
|
8
|
+
const ChatMessage = require('prismarine-chat')(bot.version) // TODO: update for prismarine-registry
|
|
9
9
|
|
|
10
10
|
class ScoreBoard {
|
|
11
11
|
constructor (packet) {
|
package/lib/team.js
CHANGED
|
@@ -3,8 +3,8 @@ let MessageBuilder
|
|
|
3
3
|
|
|
4
4
|
module.exports = loader
|
|
5
5
|
|
|
6
|
-
function loader (
|
|
7
|
-
ChatMessage = require('prismarine-chat')(
|
|
6
|
+
function loader (version) {
|
|
7
|
+
ChatMessage = require('prismarine-chat')(version) // TODO: update for prismarine-registry
|
|
8
8
|
MessageBuilder = ChatMessage.MessageBuilder
|
|
9
9
|
return Team
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mineflayer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "create minecraft bots with a stable, high level API",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"minecraft-data": "^2.
|
|
24
|
+
"minecraft-data": "^2.115.1",
|
|
25
25
|
"minecraft-protocol": "^1.31.0",
|
|
26
26
|
"prismarine-biome": "^1.1.1",
|
|
27
27
|
"prismarine-block": "^1.13.1",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"prismarine-nbt": "^2.0.0",
|
|
33
33
|
"prismarine-physics": "^1.3.1",
|
|
34
34
|
"prismarine-recipe": "^1.1.0",
|
|
35
|
+
"prismarine-registry": "^1.0.0",
|
|
35
36
|
"prismarine-windows": "^2.4.2",
|
|
36
37
|
"prismarine-world": "^3.6.0",
|
|
37
38
|
"protodef": "^1.14.0",
|
package/lib/features.json
DELETED
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"name": "mobSpawner",
|
|
4
|
-
"description": "spawner is called mob_spawner",
|
|
5
|
-
"versions": ["1.8", "1.12.2"]
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
"name": "spawner",
|
|
9
|
-
"description": "spawner is called spawner",
|
|
10
|
-
"versions": ["1.13", "1.18.2"]
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"name": "blockMetadata",
|
|
14
|
-
"description": "block metadata is encoded in a separate metadata",
|
|
15
|
-
"versions": ["1.8", "1.12.2"]
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"name": "blockStateId",
|
|
19
|
-
"description": "block metadata is encoded as state id",
|
|
20
|
-
"versions": ["1.13", "1.18.2"]
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"name": "creativeSleepNearMobs",
|
|
24
|
-
"description": "can sleep near mobs in creative",
|
|
25
|
-
"versions": ["1.13", "1.18.2"]
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"name": "fixedPointPosition",
|
|
29
|
-
"description": "Entity positions are represented with fixed point numbers",
|
|
30
|
-
"versions": ["1.8", "1.8.9"]
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"name": "doublePosition",
|
|
34
|
-
"description": "Entity positions are represented with double",
|
|
35
|
-
"versions": ["1.9", "1.18.2"]
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"name": "fixedPointDelta",
|
|
39
|
-
"description": "Delta of position are represented with fixed point numbers",
|
|
40
|
-
"versions": ["1.8", "1.8.9"]
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"name": "fixedPointDelta128",
|
|
44
|
-
"description": "Delta of position are represented with fixed point numbers times 128",
|
|
45
|
-
"versions": ["1.9", "1.18.2"]
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"name": "customChannelMCPrefixed",
|
|
49
|
-
"description": "custom channel are prefixed by MC|",
|
|
50
|
-
"versions": ["1.8", "1.12.2"]
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"name": "customChannelIdentifier",
|
|
54
|
-
"description": "custom channel is an identifier starting in minecraft namespace",
|
|
55
|
-
"versions": ["1.13", "1.18.2"]
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
"name": "dimensionDataIsAvailable",
|
|
59
|
-
"description": "dimensionData is available, providing an additional information about the current dimension",
|
|
60
|
-
"versions": ["1.17", "1.18.2"]
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
"name": "useItemWithBlockPlace",
|
|
64
|
-
"description": "use item is done with block place packet",
|
|
65
|
-
"versions": ["1.8", "1.8.9"]
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"name": "useItemWithOwnPacket",
|
|
69
|
-
"description": "use item is done with its own packet",
|
|
70
|
-
"versions": ["1.9", "1.18.2"]
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
"name": "blockPlaceHasHeldItem",
|
|
74
|
-
"description": "block_place packet has heldItem",
|
|
75
|
-
"versions": ["1.8", "1.8.9"]
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
"name": "blockPlaceHasHandAndIntCursor",
|
|
79
|
-
"description": "block_place packet has hand and int cursor",
|
|
80
|
-
"versions": ["1.9", "1.10.2"]
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"name": "blockPlaceHasHandAndFloatCursor",
|
|
84
|
-
"description": "block_place packet has hand and float cursor",
|
|
85
|
-
"versions": ["1.11", "1.13.2"]
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
"name": "blockPlaceHasInsideBlock",
|
|
89
|
-
"description": "block_place packet has inside block",
|
|
90
|
-
"versions": ["1.14", "1.18.2"]
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
"name": "teleportUsesPositionPacket",
|
|
94
|
-
"description": "teleport is done using position packet",
|
|
95
|
-
"versions": ["1.8", "1.8.9"]
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
"name": "positionUpdateSentEveryTick",
|
|
99
|
-
"description": "",
|
|
100
|
-
"versions": ["1.8", "1.11.2"]
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
"name": "teleportUsesOwnPacket",
|
|
104
|
-
"description": "teleport is done using its own packet",
|
|
105
|
-
"versions": ["1.9", "1.18.2"]
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
"name": "oneBlockForSeveralVariations",
|
|
109
|
-
"description": "one block of several variations",
|
|
110
|
-
"versions": ["1.8", "1.12.2"]
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
"name": "blockSchemeIsFlat",
|
|
114
|
-
"description": "all variations of a packet have their own id",
|
|
115
|
-
"versions": ["1.13", "1.18.2"]
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
"name": "tabCompleteHasNoToolTip",
|
|
119
|
-
"description": "tab complete doesn't have a tool tip",
|
|
120
|
-
"versions": ["1.8", "1.12.2"]
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
"name": "tabCompleteHasAToolTip",
|
|
124
|
-
"description": "tab complete has a tool tip",
|
|
125
|
-
"versions": ["1.13", "1.18.2"]
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
"name": "effectAreMinecraftPrefixed",
|
|
129
|
-
"description": "effect are prefixed by minecraft:",
|
|
130
|
-
"versions": ["1.8", "1.12.2"]
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
"name": "effectAreNotPrefixed",
|
|
134
|
-
"description": "effect are not prefixed",
|
|
135
|
-
"versions": ["1.13", "1.18.2"]
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
"name": "itemsAreAlsoBlocks",
|
|
139
|
-
"description": "items are also blocks",
|
|
140
|
-
"versions": ["1.8", "1.12.2"]
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
"name": "itemsAreNotBlocks",
|
|
144
|
-
"description": "items are not block",
|
|
145
|
-
"versions": ["1.13", "1.18.2"]
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
"name": "fishingBobberCorrectlyNamed",
|
|
149
|
-
"description": "the fishing hook entity is named fishing_bobber",
|
|
150
|
-
"versions": ["1.14", "1.18.2"]
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
"name": "editBookIsPluginChannel",
|
|
154
|
-
"description": "book editing is handled through plugin channels",
|
|
155
|
-
"versions": ["1.8", "1.12.2"]
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
"name": "hasEditBookPacket",
|
|
159
|
-
"description": "book editing is handled through a packet",
|
|
160
|
-
"versions": ["1.13", "1.18.2"]
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
"name": "clientUpdateBookIdWhenSign",
|
|
164
|
-
"description": "when sending MC|BSign, item type should be written_book",
|
|
165
|
-
"versions": ["1.8", "1.8.9"]
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
"name": "useMCTrSel",
|
|
169
|
-
"description": "select trade through plugin channel MC|TrSel",
|
|
170
|
-
"versions": ["1.8", "1.12.2"]
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
"name": "useMCTrList",
|
|
174
|
-
"description": "receive trade list through plugin channel MC|TrList",
|
|
175
|
-
"versions": ["1.8", "1.12.2"]
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
"name": "usetraderlist",
|
|
179
|
-
"description": "receive trade list through plugin channel usetrader_list",
|
|
180
|
-
"versions": ["1.13", "1.13.2"]
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
"name": "doesntHaveOffHandSlot",
|
|
184
|
-
"description": "doesn't have an off-hand slot",
|
|
185
|
-
"versions": ["1.8", "1.8.9"]
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
"name": "dimensionIsAnInt",
|
|
189
|
-
"description": "description is an int (an enum)",
|
|
190
|
-
"versions": ["1.8", "1.15.2"]
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
"name": "dimensionIsAString",
|
|
194
|
-
"description": "description is a string",
|
|
195
|
-
"versions": ["1.16", "1.16.1"]
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
"name": "dimensionIsAWorld",
|
|
199
|
-
"description": "description is a world name (string)",
|
|
200
|
-
"versions": ["1.16.2", "1.18.2"]
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
"name": "dimensionDataIsAvailable",
|
|
204
|
-
"description": "dimensionData is available, describing additional dimension information",
|
|
205
|
-
"versions": ["1.17", "1.18.2"]
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
"name": "doesntHaveChestType",
|
|
209
|
-
"description": "chests don't have a type property",
|
|
210
|
-
"versions": ["1.8", "1.12.2"]
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
"name": "usesAdvCdm",
|
|
214
|
-
"description": "packet MC|AdvCmd was incorrectly spelled in 1.8 as MC|AdvCdm",
|
|
215
|
-
"versions": ["1.8", "1.8.9"]
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
"name": "usesAdvCmd",
|
|
219
|
-
"description": "uses MC|AdvCmd to set command block information",
|
|
220
|
-
"versions": ["1.9", "1.12.2"]
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
"name": "indexesVillagerRecipes",
|
|
224
|
-
"description": "gives a index for each trade in a villagers metadata",
|
|
225
|
-
"versions": ["1.8", "1.11.2"]
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
"name": "hasAttackCooldown",
|
|
229
|
-
"description": "if there is a cooldown after attacks to deal full damage",
|
|
230
|
-
"versions": ["1.9", "1.18.2"]
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
"name": "usesLoginPacket",
|
|
234
|
-
"description": "uses the login packet as defined in mcData",
|
|
235
|
-
"versions": ["1.16", "1.18.2"]
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
"name": "usesMultiblockSingleLong",
|
|
239
|
-
"description": "in the multi_block_change packet is stored as a single number",
|
|
240
|
-
"versions": ["1.16.2", "1.18.2"]
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
"name": "usesMultiblock3DChunkCoords",
|
|
244
|
-
"description": "in the multi_block_change packet, all 3 axis coords are defined",
|
|
245
|
-
"versions": ["1.16.2", "1.18.2"]
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
"name": "setBlockUsesMetadataNumber",
|
|
249
|
-
"description": "the parameter metadata of the setblock command is a number",
|
|
250
|
-
"versions": ["1.8", "1.12.2"]
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
"name": "useMCItemName",
|
|
254
|
-
"description": "send item name for anvil using plugin channel MC|TrList",
|
|
255
|
-
"versions": ["1.8", "1.12.2"]
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
"name": "selectingTradeMovesItems",
|
|
259
|
-
"description": "selecting a trade automatically puts the required items into trading slots",
|
|
260
|
-
"versions": ["1.14", "1.18.2"]
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
"name": "resourcePackUsesHash",
|
|
264
|
-
"description": "resource pack uses hash validation",
|
|
265
|
-
"versions": ["1.8", "1.9.4"]
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
"name": "lessCharsInChat",
|
|
269
|
-
"description": "max chars in chat",
|
|
270
|
-
"versions": ["1.8", "1.10.2"]
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
"name": "teamUsesChatComponents",
|
|
274
|
-
"description": "teams use chatcomponents for formatting",
|
|
275
|
-
"versions": ["1.13", "1.18.2"]
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
"name": "teamUsesScoreboard",
|
|
279
|
-
"description": "teams use scoreboard_team packet",
|
|
280
|
-
"versions": ["1.8", "1.8.9"]
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
"name": "enderCrystalNameEndsInErNoCaps",
|
|
284
|
-
"description": "this is when the end_crystal's entity name is ender_crystal",
|
|
285
|
-
"versions": ["1.11", "1.12.2"]
|
|
286
|
-
},
|
|
287
|
-
{
|
|
288
|
-
"name": "enderCrystalNameNoCapsWithUnderscore",
|
|
289
|
-
"description": "this is when the end_crystal's entity name is end_crystal",
|
|
290
|
-
"versions": ["1.14", "1.18.2"]
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
"name": "entityNameUpperCaseNoUnderscore",
|
|
294
|
-
"description": "this is when some entities names would be captialized and appended without underscores like 'Boat' or 'ArmorStand'",
|
|
295
|
-
"versions": ["1.8", "1.10.2"]
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
"name": "entityNameLowerCaseNoUnderscore",
|
|
299
|
-
"description": "this is when some entity names are lowercase and appended without underscores like 'armorstand' or 'endercrystal'",
|
|
300
|
-
"versions": ["1.13", "1.13.2"]
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
"name": "transactionPacketExists",
|
|
304
|
-
"description": "this is when the description packet existed",
|
|
305
|
-
"versions": ["1.8", "1.16.5"]
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
"name": "stateIdUsed",
|
|
309
|
-
"description": "starting in 1.17.1, actionId has been replaced with stateId",
|
|
310
|
-
"versions": ["1.17.1", "1.18.2"]
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
"name": "actionIdUsed",
|
|
314
|
-
"description": "pre 1.17, actionId is used",
|
|
315
|
-
"versions": ["1.8", "1.16.5"]
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
"name": "setSlotAsTransaction",
|
|
319
|
-
"description": "use setslot as transaction instead of just hoping it'll work",
|
|
320
|
-
"versions": ["1.17", "1.18.2"]
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
"name": "armAnimationBeforeUse",
|
|
324
|
-
"description": "arm animation packet sent before use entity packet",
|
|
325
|
-
"versions": ["1.8", "1.8.9"]
|
|
326
|
-
},
|
|
327
|
-
{
|
|
328
|
-
"name": "tallWorld",
|
|
329
|
-
"description": "world starts at -64 and ends at 384",
|
|
330
|
-
"versions": ["1.18", "1.18.2"]
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
"name": "sendStringifiedSignText",
|
|
334
|
-
"description": "sign text send when updating signs is send as stringified strings",
|
|
335
|
-
"versions": ["1.8", "1.8.9"]
|
|
336
|
-
}
|
|
337
|
-
]
|
package/lib/supportFeature.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const features = require('./features')
|
|
2
|
-
|
|
3
|
-
const versionList = require('minecraft-data').versions.pc
|
|
4
|
-
const versionToIndex = Object.fromEntries(versionList.map((version, i) => [version.minecraftVersion, versionList.length - i]))
|
|
5
|
-
const nameToFeature = Object.fromEntries(features.map(feature => [feature.name, feature]))
|
|
6
|
-
|
|
7
|
-
module.exports = (featureName, minecraftVersion) => {
|
|
8
|
-
const feature = nameToFeature[featureName]
|
|
9
|
-
if (feature === undefined) {
|
|
10
|
-
throw new Error(`Feature ${feature} doesn't exist`)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const currentVer = versionToIndex[minecraftVersion]
|
|
14
|
-
const minVer = versionToIndex[feature.versions[0]]
|
|
15
|
-
const maxVer = versionToIndex[feature.versions[1]]
|
|
16
|
-
if (currentVer === undefined) {
|
|
17
|
-
throw new Error(`Version ${minecraftVersion} doesn't exist`)
|
|
18
|
-
}
|
|
19
|
-
if (minVer === undefined) {
|
|
20
|
-
throw new Error(`Version ${feature.versions[0]} doesn't exist`)
|
|
21
|
-
}
|
|
22
|
-
if (maxVer === undefined) {
|
|
23
|
-
throw new Error(`Version ${feature.versions[1]} doesn't exist`)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return minVer <= currentVer && currentVer <= maxVer
|
|
27
|
-
}
|