Skip to content

Commit e7c358d

Browse files
committed
feat: add minecraft-web-client:block-interactions-customization
1 parent fb39504 commit e7c358d

File tree

3 files changed

+42
-11
lines changed

3 files changed

+42
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
"mc-assets": "^0.2.62",
157157
"minecraft-inventory-gui": "github:zardoy/minecraft-inventory-gui#next",
158158
"mineflayer": "github:zardoy/mineflayer#gen-the-master",
159-
"mineflayer-mouse": "^0.1.14",
159+
"mineflayer-mouse": "^0.1.17",
160160
"mineflayer-pathfinder": "^2.4.4",
161161
"npm-run-all": "^4.1.5",
162162
"os-browserify": "^0.3.0",

pnpm-lock.yaml

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/customChannels.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default () => {
1515
registerMediaChannels()
1616
registerSectionAnimationChannels()
1717
registeredJeiChannel()
18+
registerBlockInteractionsCustomizationChannel()
1819
})
1920
}
2021

@@ -32,6 +33,36 @@ const registerChannel = (channelName: string, packetStructure: any[], handler: (
3233
console.debug(`registered custom channel ${channelName} channel`)
3334
}
3435

36+
const registerBlockInteractionsCustomizationChannel = () => {
37+
const CHANNEL_NAME = 'minecraft-web-client:block-interactions-customization'
38+
const packetStructure = [
39+
'container',
40+
[
41+
{
42+
name: 'newConfiguration',
43+
type: ['pstring', { countType: 'i16' }]
44+
},
45+
]
46+
]
47+
48+
registerChannel(CHANNEL_NAME, packetStructure, (data) => {
49+
const config = JSON.parse(data.newConfiguration)
50+
if (config.customBreakTime !== undefined && Object.values(config.customBreakTime).every(x => typeof x === 'number')) {
51+
bot.mouse.customBreakTime = config.customBreakTime
52+
}
53+
if (config.customBreakTimeToolAllowance !== undefined) {
54+
bot.mouse.customBreakTimeToolAllowance = new Set(config.customBreakTimeToolAllowance)
55+
}
56+
57+
if (config.blockPlacePrediction !== undefined) {
58+
bot.mouse.settings.blockPlacePrediction = config.blockPlacePrediction
59+
}
60+
if (config.blockPlacePredictionDelay !== undefined) {
61+
bot.mouse.settings.blockPlacePredictionDelay = config.blockPlacePredictionDelay
62+
}
63+
}, true)
64+
}
65+
3566
const registerBlockModelsChannel = () => {
3667
const CHANNEL_NAME = 'minecraft-web-client:blockmodels'
3768

0 commit comments

Comments
 (0)