-
-
Notifications
You must be signed in to change notification settings - Fork 953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed the enchantment table "ready" event, which has been broken for years. #3120
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
43e4b15
Update enchantment_table.js
zisis912 e7cb4b8
Update enchantment_table.js
zisis912 64aeef6
Update enchantment_table.js
zisis912 919deb4
Update enchantment_table.js
zisis912 00173ca
Update enchantment_table.js
zisis912 eae93d7
reverted structure change
zisis912 8be78e1
Merge branch 'master' into master
rom1504 2a6505e
Merge branch 'master' into master
rom1504 c700a21
Update enchantment_table.js
zisis912 ba16c30
Update enchantment_table.js
zisis912 bd3998e
Update enchantment_table.js
zisis912 5ac3372
Update enchantment_table.js
zisis912 d144456
Update enchantment_table.js
zisis912 39b030d
Merge branch 'master' into master
rom1504 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,32 +27,65 @@ function inject (bot) { | |
|
||
return enchantmentTable | ||
|
||
|
||
function onUpdateWindowProperty (packet) { | ||
if (packet.windowId !== enchantmentTable.id) return | ||
assert.ok(packet.property >= 0) | ||
|
||
const slots = enchantmentTable.enchantments | ||
|
||
if (bot.majorVersion !== "1.8"){ | ||
if (packet.property === 4){ | ||
for (let i=0;i<3;i++) { | ||
// console.log('setting appropriate slots') | ||
if (slots[i].level === 0) { | ||
slots[i].level = 0 | ||
slots[i].expected.enchant = null | ||
slots[i].expected.level = 0 | ||
} | ||
} | ||
}} | ||
|
||
// console.log(packet.property) | ||
// console.log(packet.value) | ||
if (packet.property < 3) { | ||
const slot = slots[packet.property] | ||
slot.level = packet.value | ||
} else if (packet.property === 3) { | ||
enchantmentTable.xpseed = packet.value | ||
} else if (packet.property < 7) { | ||
const slot = slots[packet.property - 4] | ||
slot.expected.enchant = packet.value | ||
if (bot.majorVersion === "1.8" ) { slot.expected.enchant = packet.value } | ||
else { | ||
|
||
if (packet.value === -1) { slot.expected.enchant = null } | ||
else { slot.expected.enchant = bot.registry.enchantments[packet.value].name } | ||
|
||
} | ||
} else if (packet.property < 10) { | ||
const slot = slots[packet.property - 7] | ||
slot.expected.level = packet.value | ||
} | ||
|
||
if (slots[0].level >= 0 && slots[1].level >= 0 && slots[2].level >= 0) { | ||
let readycheck; | ||
|
||
if (bot.majorVersion === "1.8") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use support feature |
||
readyCheck = slots[0].level >= 0 && slots[1].level >= 0 && slots[2].level >= 0 | ||
} else | ||
{ | ||
readyCheck = slots[0].expected.level > 0 && slots[1].expected.level >= 0 && slots[2].expected.level >=0 | ||
} | ||
|
||
// console.log(slots) | ||
if (readyCheck) { | ||
if (!ready) { | ||
ready = true | ||
enchantmentTable.emit('ready') | ||
//console.log('emitted ready') | ||
//console.log(slots) | ||
enchantmentTable.emit('ready') | ||
} | ||
} else { | ||
ready = false | ||
ready = false | ||
} | ||
} | ||
|
||
|
@@ -75,6 +108,10 @@ function inject (bot) { | |
if (!ready) await once(enchantmentTable, 'ready') | ||
choice = parseInt(choice, 10) // allow string argument | ||
assert.notStrictEqual(enchantmentTable.enchantments[choice].level, -1) | ||
|
||
// if (enchantmentTable.enchantments[choice].level>bot.experience.level) throw new Error('insufficient xp to enchant') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove commented code |
||
|
||
// console.log('enchanting choice '+choice) | ||
bot._client.write('enchant_item', { | ||
windowId: enchantmentTable.id, | ||
enchantment: choice | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented code