コード例 #1
0
 private void doSalvage() {
   IPowerModule module = targetModule.getSelectedModule().getModule();
   MusePacket newpacket =
       new MusePacketSalvageModuleRequest(
           (Player) player, targetItem.getSelectedItem().inventorySlot, module.getName());
   player.sendQueue.addToSendQueue(newpacket.getPacket250());
 }
コード例 #2
0
  private void loadTweaks(ItemStack stack, IPowerModule module) {
    NBTTagCompound itemTag = MuseItemUtils.getMuseItemTag(stack);
    NBTTagCompound moduleTag = itemTag.getCompoundTag(module.getName());

    propertyStrings = new HashMap();
    Set<String> tweaks = new HashSet<String>();

    Map<String, List<IPropertyModifier>> propertyModifiers = module.getPropertyModifiers();
    for (Map.Entry<String, List<IPropertyModifier>> property : propertyModifiers.entrySet()) {
      double currValue = 0;
      for (IPropertyModifier modifier : property.getValue()) {
        currValue = modifier.applyModifier(moduleTag, currValue);
        if (modifier instanceof PropertyModifierLinearAdditive) {
          tweaks.add(((PropertyModifierLinearAdditive) modifier).getTradeoffName());
        }
      }
      propertyStrings.put(property.getKey(), currValue);
    }

    sliders = new LinkedList();
    int y = 0;
    for (String tweak : tweaks) {
      y += 24;
      ClickableSlider slider =
          new ClickableSlider(
              new MusePoint2D((border.left() + border.right()) / 2, border.top() + y),
              border.right() - border.left() - 8,
              moduleTag,
              tweak);
      sliders.add(slider);
    }
  }
コード例 #3
0
 /**
  * Performs all the functions associated with the install button. This requires communicating with
  * the server.
  */
 private void doInstall() {
   ItemStack stack = targetItem.getSelectedItem().getItem();
   IPowerModule module = targetModule.getSelectedModule().getModule();
   if (player.capabilities.isCreativeMode
       || MuseItemUtils.hasInInventory(module.getInstallCost(), player.inventory)) {
     Musique.playClientSound(SoundLoader.SOUND_GUI_INSTALL, 1);
     // Now send request to server to make it legit
     MusePacket newpacket =
         new MusePacketInstallModuleRequest(
             (Player) player, targetItem.getSelectedItem().inventorySlot, module.getName());
     player.sendQueue.addToSendQueue(newpacket.getPacket250());
   }
 }
コード例 #4
0
  private void drawButtons() {
    ItemStack stack = targetItem.getSelectedItem().getItem();
    IPowerModule module = targetModule.getSelectedModule().getModule();
    if (!MuseItemUtils.itemHasModule(stack, module.getName())) {

      installButton.setEnabled(
          player.capabilities.isCreativeMode
              || MuseItemUtils.hasInInventory(module.getInstallCost(), player.inventory));
      installButton.draw();
    } else {
      salvageButton.draw();
    }
  }
コード例 #5
0
 private void drawItems() {
   ItemStack stack = targetItem.getSelectedItem().getItem();
   IPowerModule module = targetModule.getSelectedModule().getModule();
   List<ItemStack> itemsToDraw = module.getInstallCost();
   double yoffset;
   if (!MuseItemUtils.itemHasModule(stack, module.getName())) {
     yoffset = border.top() + 4;
   } else {
     yoffset = border.bottom() - 20;
   }
   double xoffset = -8.0 * itemsToDraw.size() + (border.left() + border.right()) / 2;
   int i = 0;
   for (ItemStack costItem : itemsToDraw) {
     MuseRenderer.drawItemAt(16 * i++ + xoffset, yoffset, costItem);
   }
 }
コード例 #6
0
  @Override
  public void onMouseDown(double x, double y, int button) {
    ClickableItem selItem = targetItem.getSelectedItem();
    ClickableModule selModule = targetModule.getSelectedModule();
    if (selItem != null && selModule != null) {
      ItemStack stack = selItem.getItem();
      IPowerModule module = selModule.getModule();

      if (!MuseItemUtils.itemHasModule(stack, module.getName())) {
        if (installButton.hitBox(x, y)) {
          doInstall();
        }
      } else {
        if (salvageButton.hitBox(x, y)) {
          doSalvage();
        }
      }
    }
  }
コード例 #7
0
 @Override
 public void onMouseUp(double x, double y, int button) {
   if (selectedSlider != null
       && itemTarget.getSelectedItem() != null
       && moduleTarget.getSelectedModule() != null) {
     ClickableItem item = itemTarget.getSelectedItem();
     IPowerModule module = moduleTarget.getSelectedModule().getModule();
     MusePacket tweakRequest =
         new MusePacketTweakRequest(
             (Player) player,
             item.inventorySlot,
             module.getName(),
             selectedSlider.getName(),
             selectedSlider.getValue());
     player.sendQueue.addToSendQueue(tweakRequest.getPacket250());
   }
   if (button == 0) {
     selectedSlider = null;
   }
 }
コード例 #8
0
 @Override
 public List<String> getToolTip(int x, int y) {
   if (targetItem.getSelectedItem() != null && targetModule.getSelectedModule() != null) {
     ItemStack stack = targetItem.getSelectedItem().getItem();
     IPowerModule module = targetModule.getSelectedModule().getModule();
     List<ItemStack> itemsToCheck = module.getInstallCost();
     double yoffset;
     if (!MuseItemUtils.itemHasModule(stack, module.getName())) {
       yoffset = border.top() + 4;
     } else {
       yoffset = border.bottom() - 20;
     }
     if (yoffset + 16 > y && yoffset < y) {
       double xoffset = -8.0 * itemsToCheck.size() + (border.left() + border.right()) / 2;
       if (xoffset + 16 * itemsToCheck.size() > x && xoffset < x) {
         int index = (int) (x - xoffset) / 16;
         List<String> tip = itemsToCheck.get(index).getTooltip(player, false);
         return tip;
       }
     }
   }
   return null;
 }