MCPcopy
hub / github.com/PrismarineJS/mineflayer / createRandomLayout

Function createRandomLayout

test/externalTests/useChests.js:148–168  ·  view source on GitHub ↗
(window, slotPopulationFactor)

Source from the content-addressed store, hash-verified

146 }
147
148 async function createRandomLayout (window, slotPopulationFactor) {
149 await bot.test.becomeCreative()
150
151 for (let slot = 0; slot < window.inventoryStart; slot++) {
152 if (Math.random() < slotPopulationFactor) {
153 const randomItem = getRandomStackableItem()
154 const item = bot.registry.itemsByName[randomItem]
155 bot.chat(`/give ${bot.username} ${item.name} ${Math.ceil(Math.random() * item.stackSize)}`)
156 await onceWithCleanup(window, 'updateSlot', {
157 timeout: 5000,
158 checkCondition: (slot, oldItem, newItem) => slot === window.hotbarStart && newItem?.name === item.name
159 })
160
161 // await bot.clickWindow(slot, 0, 2)
162 await bot.moveSlotItem(window.hotbarStart, slot)
163 await bot.test.wait(100)
164 }
165 }
166
167 await bot.test.becomeSurvival()
168 }
169
170 async function testMouseClick (window, clicks) {
171 let iterations = 0

Callers 1

useChests.jsFile · 0.85

Calls 2

getRandomStackableItemFunction · 0.85
onceWithCleanupFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…