예제 #1
0
 public void dropItemAt(int index) {
   Slot slot = currentInventory.getSlot((short) index);
   if (slot != null) {
     out0EClickWindow.sendMessageForceEmpty(
         currentInventory.getWindowId(), (short) index, (byte) 1, (byte) 4);
     currentInventory.setSlotEmpty(index);
   }
 }
예제 #2
0
  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);
    //        }

  }