mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-25 21:40:05 +00:00
Paced treasure chest interactions
- Chest activations respect the server interaction rate limit - Stationary clients finish idle ticks every fifty milliseconds - Missing inventory windows fail within thirty seconds
This commit is contained in:
1 parent
f17a9e0977
commit
718b13df46
1 file changed
+12
-2
@@ -31,10 +31,16 @@ const traceMovement = context => {
|
|||||||
return write.call(this, name, packet, ...rest)
|
return write.call(this, name, packet, ...rest)
|
||||||
}
|
}
|
||||||
context.expect(context.bot.supportFeature('sendsClientTickEndPacket'), 'Fixture client supports tick delimiters')
|
context.expect(context.bot.supportFeature('sendsClientTickEndPacket'), 'Fixture client supports tick delimiters')
|
||||||
const finishTick = () => client.write('tick_end', {})
|
let tickTimer
|
||||||
|
const finishTick = () => {
|
||||||
|
clearTimeout(tickTimer)
|
||||||
|
client.write('tick_end', {})
|
||||||
|
tickTimer = setTimeout(finishTick, 50)
|
||||||
|
}
|
||||||
context.bot.on('move', finishTick)
|
context.bot.on('move', finishTick)
|
||||||
finishTick()
|
finishTick()
|
||||||
context.signal.addEventListener('abort', () => {
|
context.signal.addEventListener('abort', () => {
|
||||||
|
clearTimeout(tickTimer)
|
||||||
client.write = write
|
client.write = write
|
||||||
client.removeListener('position', incoming)
|
client.removeListener('position', incoming)
|
||||||
client.removeListener('player_rotation', rotation)
|
client.removeListener('player_rotation', rotation)
|
||||||
@@ -63,13 +69,17 @@ export default {
|
|||||||
await action()
|
await action()
|
||||||
return true
|
return true
|
||||||
}, { label, timeoutMs: 10000 })
|
}, { label, timeoutMs: 10000 })
|
||||||
|
let lastActivation = 0
|
||||||
const openChest = async material => {
|
const openChest = async material => {
|
||||||
const position = context.bot.entity.position.clone().set(2, 161, 2)
|
const position = context.bot.entity.position.clone().set(2, 161, 2)
|
||||||
await context.waitUntil(() => context.bot.blockAt(position)?.name === material, {
|
await context.waitUntil(() => context.bot.blockAt(position)?.name === material, {
|
||||||
label: `${material} reached the client`, timeoutMs: 10000
|
label: `${material} reached the client`, timeoutMs: 10000
|
||||||
})
|
})
|
||||||
const opened = context.waitForEvent('windowOpen', undefined, 120000)
|
const delay = 150 - (performance.now() - lastActivation)
|
||||||
|
if (delay > 0) await context.sleep(delay)
|
||||||
|
const opened = context.waitForEvent('windowOpen', undefined, 30000)
|
||||||
await bounded(`Activate ${material}`, () => context.bot.activateBlock(context.bot.blockAt(position)))
|
await bounded(`Activate ${material}`, () => context.bot.activateBlock(context.bot.blockAt(position)))
|
||||||
|
lastActivation = performance.now()
|
||||||
const [window] = await opened
|
const [window] = await opened
|
||||||
return window
|
return window
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user