public void takeCraftingResult(Id id, int craftedCount) throws MinecraftException { // TODO: check curr. inventory type currentInventory.setSlot((byte) 0, (byte) 0, id.getValue(), (byte) 0, (byte) craftedCount); Id idResult = currentInventory.getSlot((short) 0).getId(); short availableIndex = getFirstEmptyIndex(); moveItem((short) 0, availableIndex, craftedCount); }
public void moveItem(short startIndex, short endIndex, int count) { System.out.println("MOVING ITEM, start index: " + startIndex + " endIndex: " + endIndex); Slot oldStartIndexSlot = currentInventory.getSlot(startIndex); Slot oldEndIndexSlot = currentInventory.getSlot(endIndex); leftClickWindow(startIndex); for (int i = 0; i < count; i++) { rightClickWindow(endIndex); Slot slotEndIndex = currentInventory.getSlot(endIndex); if (slotEndIndex == null) { currentInventory.setSlot( (byte) 0, (byte) endIndex, oldStartIndexSlot.getId().getValue(), (byte) 0, (byte) 1); } else { currentInventory.getSlot(endIndex).incCountBy(1); } } leftClickWindowForceEmpty(startIndex); if (currentInventory.getSlot(startIndex).getCount() - count > 0) currentInventory.getSlot(startIndex).decCountBy(count); else currentInventory.setSlotEmpty(startIndex); // if (oldStartIndexSlot != null) { // Slot newStartIndexSlot = new Slot(startIndex, // oldStartIndexSlot.getId().getValue(), (byte)oldStartIndexSlot.getCount()); // refreshSlotInMyInventory(startIndex, newStartIndexSlot); // } // if(oldEndIndexSlot != null) { // Slot newEndIndexSlot = new Slot(endIndex, oldEndIndexSlot.getId().getValue(), // (byte)(oldEndIndexSlot.getCount() + 1)); // refreshSlotInMyInventory(endIndex, newEndIndexSlot); // } else { // Slot newEndIndexSlot = new Slot(endIndex, oldStartIndexSlot.getId().getValue(), // (byte)1); // refreshSlotInMyInventory(endIndex, newEndIndexSlot); // } }