-
-
Notifications
You must be signed in to change notification settings - Fork 951
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
updating activateItem #3445
updating activateItem #3445
Changes from 3 commits
8b7c786
829089c
f78cebb
b109211
177e3ab
c7a814a
2a90169
a12030c
ccf2442
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ function inject (bot, { hideErrors }) { | |
const windows = require('prismarine-windows')(bot.version) | ||
|
||
let eatingTask = createDoneTask() | ||
let sequence = 0 | ||
|
||
let nextActionNumber = 0 // < 1.17 | ||
let stateId = -1 | ||
|
@@ -43,6 +44,7 @@ function inject (bot, { hideErrors }) { | |
bot.inventory = windows.createWindow(0, 'minecraft:inventory', 'Inventory') | ||
bot.currentWindow = null | ||
bot.usingHeldItem = false | ||
|
||
Object.defineProperty(bot, 'heldItem', { | ||
get: function () { | ||
return bot.inventory.slots[bot.QUICK_BAR_START + bot.quickBarSlot] | ||
|
@@ -122,17 +124,26 @@ function inject (bot, { hideErrors }) { | |
}) | ||
} else if (bot.supportFeature('useItemWithOwnPacket')) { | ||
bot._client.write('use_item', { | ||
hand: offHand ? 1 : 0 | ||
hand: offHand ? 1 : 0, | ||
sequence: ++sequence | ||
}) | ||
} | ||
} | ||
|
||
function deactivateItem () { | ||
bot._client.write('block_dig', { | ||
const body = { | ||
status: 5, | ||
location: new Vec3(0, 0, 0), | ||
face: 5 | ||
}) | ||
} | ||
|
||
if (bot.supportFeature('useItemWithOwnPacket')) { | ||
body.face = 0 | ||
body.sequence = 0 | ||
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. Note, you can supply extra fields on packets without any problems. If the field is not used on a particular version it will be ignored. I'm curious why the 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. It is just fixed to zero. I have no idea to be honest. It doesn't change the sequence count. I decided to add a feature support there since I wasn't sure if the face affected anything and just wanted to be as legitimate as possible without disrupting the original face (5)'s implementation. |
||
} | ||
|
||
bot._client.write('block_dig', body) | ||
|
||
bot.usingHeldItem = false | ||
} | ||
|
||
|
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.
Does this always increment? Can you put this increment operation up top as opposed to inside the packet body?
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.
Yes, to my knowledge it always increments. Decided to spam until it passed 8bit mark; I'm not going to continue doing so further.
I'll update the code, but personally I feel moving it upwards is unnecessary.