コード例 #1
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);
    }
  }
コード例 #2
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());
 }
コード例 #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;
 }
コード例 #9
0
  @Override
  public void tickEnd(EnumSet<TickType> type, Object... tickData) {
    EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
    if (player != null) {
      double currEnergy = ElectricItemUtils.getPlayerEnergy(player);
      double maxEnergy = ElectricItemUtils.getMaxEnergy(player);
      if (maxEnergy > 0) {
        String currStr = MuseStringUtils.formatNumberShort(currEnergy);
        String maxStr = MuseStringUtils.formatNumberShort(maxEnergy);
        MuseRenderer.drawString(currStr + '/' + maxStr + " J", 1, 1);
      }
    }
    if (Minecraft.getMinecraft().currentScreen == null) {
      Minecraft mc = Minecraft.getMinecraft();
      ScaledResolution screen =
          new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
      int i = player.inventory.currentItem;
      ItemStack stack = player.inventory.mainInventory[i];
      if (stack != null && stack.getItem() instanceof IModularItem) {
        MuseRenderer.blendingOn();
        NBTTagCompound itemTag = MuseItemUtils.getMuseItemTag(stack);
        int swapTime = (int) Math.min(System.currentTimeMillis() - lastSwapTime, SWAPTIME);
        Icon currentMode = null;
        Icon nextMode = null;
        Icon prevMode = null;
        List<String> modes = MuseItemUtils.getModes(stack, player);
        String mode = itemTag.getString("Mode");
        int modeIndex = modes.indexOf(mode);
        if (modeIndex > -1) {
          String prevModeName = modes.get((modeIndex + modes.size() - 1) % modes.size());
          String nextModeName = modes.get((modeIndex + 1) % modes.size());
          IPowerModule module = ModuleManager.getModule(mode);
          IPowerModule nextModule = ModuleManager.getModule(nextModeName);
          IPowerModule prevModule = ModuleManager.getModule(prevModeName);

          if (module != null) {
            currentMode = module.getIcon(stack);
            if (!nextModeName.equals(mode)) {
              nextMode = nextModule.getIcon(stack);
              prevMode = prevModule.getIcon(stack);
            }
          }
        }
        double prevX, prevY, currX, currY, nextX, nextY;
        double sw = screen.getScaledWidth_double();
        double baroffset = screen.getScaledHeight_double() - 40;
        if (!player.capabilities.isCreativeMode) {
          baroffset -= 16;
          if (ForgeHooks.getTotalArmorValue(player) > 0) {
            baroffset -= 8;
          }
        }
        // Root locations of the mode list
        prevX = sw / 2.0 - 105.0 + 20.0 * i;
        prevY = baroffset + 10;
        currX = sw / 2.0 - 89.0 + 20.0 * i;
        currY = baroffset;
        nextX = sw / 2.0 - 73.0 + 20.0 * i;
        nextY = baroffset + 10;
        if (swapTime == SWAPTIME || lastSwapDirection == 0) {
          drawIcon(prevX, prevY, prevMode, 0.4, 0, 0, 16, baroffset - prevY + 16);
          drawIcon(currX, currY, currentMode, 0.8, 0, 0, 16, baroffset - currY + 16);
          drawIcon(nextX, nextY, nextMode, 0.4, 0, 0, 16, baroffset - nextY + 16);
        } else {
          double r1 = 1 - swapTime / (double) SWAPTIME;
          double r2 = swapTime / (double) SWAPTIME;
          if (lastSwapDirection == -1) {
            nextX = (currX * r1 + nextX * r2);
            nextY = (currY * r1 + nextY * r2);
            currX = (prevX * r1 + currX * r2);
            currY = (prevY * r1 + currY * r2);
            drawIcon(currX, currY, currentMode, 0.8, 0, 0, 16, baroffset - currY + 16);
            drawIcon(nextX, nextY, nextMode, 0.8, 0, 0, 16, baroffset - nextY + 16);

          } else {
            prevX = (currX * r1 + prevX * r2);
            prevY = (currY * r1 + prevY * r2);
            currX = (nextX * r1 + currX * r2);
            currY = (nextY * r1 + currY * r2);
            // MuseRenderer
            drawIcon(prevX, prevY, prevMode, 0.8, 0, 0, 16, baroffset - prevY + 16);
            drawIcon(currX, currY, currentMode, 0.8, 0, 0, 16, baroffset - currY + 16);
          }
        }
        // MuseRenderer.blendingOff();
        GL11.glDisable(GL11.GL_LIGHTING);
        Colour.WHITE.doGL();
      }
    }
  }