Пример #1
0
 private void updateBuffIcons(EntityStats stats) {
   buffIcons.clear();
   int buffX = BUFF_SPACING;
   int buffY = mc.currentScreen.height - HEIGHT - GuiBuff.BUFF_FRAME_SIZE - BUFF_SPACING;
   for (BuffInstance buffInst : stats.getAppliedBuffs()) {
     if (buffInst.buff.isDisplayed) {
       buffIcons.add(new GuiBuff(buffInst, buffX, buffY));
       buffX += GuiBuff.BUFF_FRAME_SIZE + BUFF_SPACING;
       if (buffX > WIDTH - GuiBuff.BUFF_FRAME_SIZE) {
         buffX = BUFF_SPACING;
         buffY -= GuiBuff.BUFF_FRAME_SIZE + BUFF_SPACING;
       }
     }
   }
 }
Пример #2
0
  @Override
  public void render() {
    int left = 0;
    int top = mc.currentScreen.height - HEIGHT;
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_LIGHTING);
    mc.renderEngine.bindTexture(texture);
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(left + WIDTH, top + HEIGHT, 0, 1, 1);
    tessellator.addVertexWithUV(left + WIDTH, top, 0, 1, 0);
    tessellator.addVertexWithUV(left, top, 0, 0, 0);
    tessellator.addVertexWithUV(left, top + HEIGHT, 0, 0, 1);
    tessellator.draw();

    EntityStats stats = Dota2Items.stats.getOrCreateEntityStats(mc.thePlayer);
    StringBuilder sb = new StringBuilder();

    float baseDmg = 1;
    boolean isMelee = true;
    ItemStack item = mc.thePlayer.getCurrentEquippedItem();
    if (item != null) {
      // Get player damage output. Not accounting for enchantments yet!
      /*HashMultimap map = (HashMultimap)item.getAttributeModifiers();
      Set<AttributeModifier> damageModifierSet = map.get(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName());
      for (AttributeModifier modifier : damageModifierSet) {
      	baseDmg += (float) modifier.getAmount();
      }*/
      // The following line works correctly on the "server" side, but always returns 1 on the
      // "client".
      baseDmg =
          (float)
              mc.thePlayer
                  .getEntityAttribute(SharedMonsterAttributes.attackDamage)
                  .getAttributeValue();
      if (item.itemID == Item.bow.itemID) {
        isMelee = false;
        // Assume the damage of an arrow at average charge: 6
        if (mc.thePlayer.inventory.hasItem(Item.arrow.itemID)) {
          baseDmg = 6;
        }
      } else if (item.itemID == Config.daedalus.getID()) {
        isMelee = false;
        if (mc.thePlayer.inventory.hasItem(Item.arrow.itemID)) {
          baseDmg = 10; // maximum arrow damage
        }
      }
    }
    baseDmg *= AttackHandler.DOTA_VS_MINECRAFT_DAMAGE;
    float improvedDmg = stats.getDamage(baseDmg, isMelee);
    int baseValue = MathHelper.floor_float(baseDmg);
    int bonus = MathHelper.floor_float(improvedDmg) - baseValue;
    formatStat(sb, baseValue, bonus);
    int strlen = mc.fontRenderer.getStringWidth(sb.toString());
    mc.fontRenderer.drawString(sb.toString(), left + 32 - strlen / 2, top + 8, COLOR_REGULAR);

    sb = new StringBuilder();
    baseValue =
        stats.baseArmor
            + MathHelper.floor_float((float) stats.getAgility() * EntityStats.ARMOR_PER_AGI);
    bonus = stats.getArmor() - baseValue;
    formatStat(sb, baseValue, bonus);
    strlen = mc.fontRenderer.getStringWidth(sb.toString());
    mc.fontRenderer.drawString(sb.toString(), left + 18 - strlen / 2, top + 44, COLOR_REGULAR);

    String ms = String.valueOf(stats.getDotaMovementSpeed());
    strlen = mc.fontRenderer.getStringWidth(ms);
    mc.fontRenderer.drawString(ms, left + 45 - strlen / 2, top + 44, COLOR_REGULAR);

    sb = new StringBuilder();
    baseValue = stats.getBaseStrength();
    bonus = stats.getStrength() - baseValue;
    formatStat(sb, baseValue, bonus);
    strlen = mc.fontRenderer.getStringWidth(sb.toString());
    mc.fontRenderer.drawString(sb.toString(), left + 93 - strlen / 2, top + 11, COLOR_REGULAR);

    sb = new StringBuilder();
    baseValue = stats.getBaseAgility();
    bonus = stats.getAgility() - baseValue;
    formatStat(sb, baseValue, bonus);
    strlen = mc.fontRenderer.getStringWidth(sb.toString());
    mc.fontRenderer.drawString(sb.toString(), left + 93 - strlen / 2, top + 27, COLOR_REGULAR);

    sb = new StringBuilder();
    baseValue = stats.getBaseIntelligence();
    bonus = stats.getIntelligence() - baseValue;
    formatStat(sb, baseValue, bonus);
    strlen = mc.fontRenderer.getStringWidth(sb.toString());
    mc.fontRenderer.drawString(sb.toString(), left + 93 - strlen / 2, top + 44, COLOR_REGULAR);

    // Render active buffs and debuffs:
    if (lastUpdateTick != mc.thePlayer.ticksExisted) {
      lastUpdateTick = mc.thePlayer.ticksExisted;
      updateBuffIcons(stats);
    }
    for (GuiBuff buffIcon : buffIcons) {
      buffIcon.render();
    }
    // Draw hovering text description of the buff:
    int mouseX = Mouse.getEventX() * mc.currentScreen.width / mc.displayWidth;
    int mouseY =
        mc.currentScreen.height
            - Mouse.getEventY() * mc.currentScreen.height / mc.displayHeight
            - 1;
    for (GuiBuff buffIcon : buffIcons) {
      if (buffIcon.isMouseOver(mouseX, mouseY)) {
        List<String> hoverStrings = Arrays.asList(buffIcon.buffInst.buff.name);
        RenderHelper.drawHoveringText(hoverStrings, mouseX, mouseY, mc.fontRenderer);
        break;
      }
    }
  }