craft fix

This commit is contained in:
2026-01-31 18:49:08 -05:00
parent 80bbfbe58e
commit 9acd38c94b
9 changed files with 1535 additions and 102 deletions

View File

@@ -138,16 +138,24 @@ class Craft{
// Move these into openCrating function
let windowOnce = (event)=> new Promise((resolve, reject)=> window.once(event, resolve));
let inventory = ()=> window.slots.slice(window.inventoryStart, window.inventoryEnd)
let inventory = window.slots.slice(window.inventoryStart, window.inventoryEnd);
// Move the items into the crafting grid
// Keep track of used inventory slots to avoid reusing the same slot
let usedInventorySlots = new Set();
let slotCount = 1;
for(let shapeRow of recipe.inShape){
for(let shape of shapeRow){
this.bot.bot.moveSlotItem(
inventory().find((element)=> element && element.type === shape.id).slot,
slotCount
let inventorySlot = inventory.findIndex((element, index) =>
element && element.type === shape.id && !usedInventorySlots.has(index)
);
if (inventorySlot === -1) {
throw new Error(`Not enough items of type ${shape.id} in inventory`);
}
let actualSlot = window.inventoryStart + inventorySlot;
usedInventorySlots.add(inventorySlot);
this.bot.bot.moveSlotItem(actualSlot, slotCount);
await windowOnce(`updateSlot:${slotCount}`);
slotCount++;
}