Пример #1
0
  private void sendItemWidgetClicked(final int mouseX, final int mouseY, final int mouseButton) {
    for (int index = 0; index < this.widgetCount; ++index) {
      WidgetAEItem currentWidget = this.itemWidgets.get(index);

      if (currentWidget.isMouseOverWidget(mouseX, mouseY)) {
        IAEItemStack widgetStack = currentWidget.getItemStack();

        if (widgetStack != null) {
          if (widgetStack.getStackSize() == 0) {
            if (widgetStack.isCraftable()) {
              // new PacketChiselingTerminalServer().createRequestAutoCraft( this.player,
              // widgetStack ).sendPacketToServer();
            }
          } else {
            boolean isShiftHeld =
                Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);

            new PacketChiselingTerminalServer()
                .createRequestExtract(this.entityPlayer, widgetStack, mouseButton, isShiftHeld)
                .sendPacketToServer();
          }
        }

        return;
      }
    }
  }
Пример #2
0
        @Override
        public int compare(IAEItemStack o1, IAEItemStack o2) {
          // Logger.info("Comparing by EMC");
          int itememc1 = EMCHelper.getEmcValue(o1.getItemStack());
          BigInteger stack1 =
              BigInteger.valueOf(itememc1).multiply(BigInteger.valueOf(o1.getStackSize()));
          // Logger.info(o1.getItemStack().getDisplayName() +
          // stack1.toString());
          int stackemc1;
          if (stack1.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) >= 0) {
            // Logger.info("Value is bigger than Integer.MAX_VALUE");
            stackemc1 = Integer.MAX_VALUE;
            // Logger.info(String.valueOf(stackemc1));
          } else {
            stackemc1 = stack1.intValue();
          }
          int itememc2 = EMCHelper.getEmcValue(o2.getItemStack());
          BigInteger stack2 =
              BigInteger.valueOf(itememc2).multiply(BigInteger.valueOf(o2.getStackSize()));
          int stackemc2;
          if (stack2.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) >= 0) {
            stackemc2 = Integer.MAX_VALUE;
          } else {
            stackemc2 = stack2.intValue();
          }

          // Logger.info("FirstStack:" + String.valueOf(stackemc1));
          // Logger.info("SecondStack:" + String.valueOf(stackemc2));

          if (Direction == SortDir.ASCENDING) {
            // Logger.info(String.valueOf(compareInt(stackemc2,
            // stackemc1)));
            // return compareInt(stackemc2, stackemc1);
            return this.secondarySort(compareInt(stackemc2, stackemc1), o1, o2);
          }
          // Logger.info(String.valueOf(compareInt(stackemc1, stackemc2)));
          // return compareInt(stackemc1, stackemc2);
          return this.secondarySort(compareInt(stackemc1, stackemc2), o2, o1);
        }
Пример #3
0
  private void updateMEWidgets() {
    int repoIndex = 0;

    for (int index = 0; index < this.widgetCount; ++index) {
      IAEItemStack stack = this.itemRepo.getReferenceItem(repoIndex++);

      if (stack != null) {
        if (stack.getStackSize() == 0) {
          index--;
          continue;
        }

        this.itemWidgets.get(index).setItemStack(stack);
      } else {
        this.itemWidgets.get(index).setItemStack(null);
      }
    }
  }
  @Override
  protected void handleMouseClick(
      final Slot slot, final int slotIdx, final int ctrlDown, final int key) {
    final EntityPlayer player = Minecraft.getMinecraft().thePlayer;

    if (slot instanceof SlotFake) {
      final InventoryAction action =
          ctrlDown == 1
              ? InventoryAction.SPLIT_OR_PLACE_SINGLE
              : InventoryAction.PICKUP_OR_SET_DOWN;

      if (this.drag_click.size() > 1) {
        return;
      }

      final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
      NetworkHandler.instance.sendToServer(p);

      return;
    }

    if (slot instanceof SlotPatternTerm) {
      if (key == 6) {
        return; // prevent weird double clicks..
      }

      try {
        NetworkHandler.instance.sendToServer(((SlotPatternTerm) slot).getRequest(key == 1));
      } catch (final IOException e) {
        AELog.debug(e);
      }
    } else if (slot instanceof SlotCraftingTerm) {
      if (key == 6) {
        return; // prevent weird double clicks..
      }

      InventoryAction action = null;
      if (key == 1) {
        action = InventoryAction.CRAFT_SHIFT;
      } else {
        action = ctrlDown == 1 ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;
      }

      final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
      NetworkHandler.instance.sendToServer(p);

      return;
    }

    if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
      if (this.enableSpaceClicking()) {
        IAEItemStack stack = null;
        if (slot instanceof SlotME) {
          stack = ((SlotME) slot).getAEStack();
        }

        int slotNum = this.getInventorySlots().size();

        if (!(slot instanceof SlotME) && slot != null) {
          slotNum = slot.slotNumber;
        }

        ((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
        final PacketInventoryAction p =
            new PacketInventoryAction(InventoryAction.MOVE_REGION, slotNum, 0);
        NetworkHandler.instance.sendToServer(p);
        return;
      }
    }

    if (slot instanceof SlotDisconnected) {
      InventoryAction action = null;

      switch (key) {
        case 0: // pickup / set-down.
          action =
              ctrlDown == 1
                  ? InventoryAction.SPLIT_OR_PLACE_SINGLE
                  : InventoryAction.PICKUP_OR_SET_DOWN;
          break;
        case 1:
          action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
          break;

        case 3: // creative dupe:
          if (player.capabilities.isCreativeMode) {
            action = InventoryAction.CREATIVE_DUPLICATE;
          }

          break;

        default:
        case 4: // drop item:
        case 6:
      }

      if (action != null) {
        final PacketInventoryAction p =
            new PacketInventoryAction(
                action, slot.getSlotIndex(), ((SlotDisconnected) slot).getSlot().getId());
        NetworkHandler.instance.sendToServer(p);
      }

      return;
    }

    if (slot instanceof SlotME) {
      InventoryAction action = null;
      IAEItemStack stack = null;

      switch (key) {
        case 0: // pickup / set-down.
          action =
              ctrlDown == 1
                  ? InventoryAction.SPLIT_OR_PLACE_SINGLE
                  : InventoryAction.PICKUP_OR_SET_DOWN;
          stack = ((SlotME) slot).getAEStack();

          if (stack != null
              && action == InventoryAction.PICKUP_OR_SET_DOWN
              && stack.getStackSize() == 0
              && player.inventory.getItemStack() == null) {
            action = InventoryAction.AUTO_CRAFT;
          }

          break;
        case 1:
          action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
          stack = ((SlotME) slot).getAEStack();
          break;

        case 3: // creative dupe:
          stack = ((SlotME) slot).getAEStack();
          if (stack != null && stack.isCraftable()) {
            action = InventoryAction.AUTO_CRAFT;
          } else if (player.capabilities.isCreativeMode) {
            final IAEItemStack slotItem = ((SlotME) slot).getAEStack();
            if (slotItem != null) {
              action = InventoryAction.CREATIVE_DUPLICATE;
            }
          }
          break;

        default:
        case 4: // drop item:
        case 6:
      }

      if (action != null) {
        ((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
        final PacketInventoryAction p =
            new PacketInventoryAction(action, this.getInventorySlots().size(), 0);
        NetworkHandler.instance.sendToServer(p);
      }

      return;
    }

    if (!this.disableShiftClick && isShiftKeyDown()) {
      this.disableShiftClick = true;

      if (this.dbl_whichItem == null
          || this.bl_clicked != slot
          || this.dbl_clickTimer.elapsed(TimeUnit.MILLISECONDS) > 150) {
        // some simple double click logic.
        this.bl_clicked = slot;
        this.dbl_clickTimer = Stopwatch.createStarted();
        if (slot != null) {
          this.dbl_whichItem = slot.getHasStack() ? slot.getStack().copy() : null;
        } else {
          this.dbl_whichItem = null;
        }
      } else if (this.dbl_whichItem != null) {
        // a replica of the weird broken vanilla feature.

        final List<Slot> slots = this.getInventorySlots();
        for (final Slot inventorySlot : slots) {
          if (inventorySlot != null
              && inventorySlot.canTakeStack(this.mc.thePlayer)
              && inventorySlot.getHasStack()
              && inventorySlot.inventory == slot.inventory
              && Container.func_94527_a(inventorySlot, this.dbl_whichItem, true)) {
            this.handleMouseClick(inventorySlot, inventorySlot.slotNumber, ctrlDown, 1);
          }
        }
      }

      this.disableShiftClick = false;
    }

    super.handleMouseClick(slot, slotIdx, ctrlDown, key);
  }