Exemplo n.º 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);
   }
 }
Exemplo n.º 2
0
 public void shiftClick(short slot) {
   Slot slotData = currentInventory.getSlot(slot);
   if (slotData != null) {
     System.out.println("SHIFT CLICK");
     out0EClickWindow.sendMessage(
         currentInventory.getWindowId(), slot, (byte) 1, (byte) 1, slotData);
   }
 }
Exemplo n.º 3
0
  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);
  }
Exemplo n.º 4
0
 public boolean isMyInventoryEmpty() {
   for (int i = currentInventory.getStartIndexMainInventory();
       i < currentInventory.getStartIndexMainInventory() + 36;
       i++) {
     if (currentInventory.getSlot((short) i) != null) return false;
   }
   return true;
 }
Exemplo n.º 5
0
 public void rightClickWindow(short slot) {
   Slot slotData = currentInventory.getSlot(slot);
   // System.out.println("WINID: " + currentInventory.getWindowId() + " SLOTDATA: ID: " +
   // slotData.getId());
   if (slotData != null) {
     System.out.println("NOT EMPTY RIGHT CLICK");
     out0EClickWindow.sendMessage(
         currentInventory.getWindowId(), slot, (byte) 1, (byte) 0, slotData);
   } else {
     System.out.println("EMPTY RIGHT CLICK");
     out0EClickWindow.sendMessageForceEmpty(
         currentInventory.getWindowId(), slot, (byte) 1, (byte) 0);
   }
   // in32ConfirmTransaction.newClick(new Out0EClickWindowInfo(currentInventory.getWindowId(),
   // slot, slotData, out0EClickWindow.getActionNumber()));
 }
Exemplo n.º 6
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);
    //        }

  }