Esempio n. 1
0
 public void render() {
   // Draw frame with timer:
   RenderHelper.drawTextureRect(
       buffInst.isFriendly ? buffFrame : debuffFrame, x, y, BUFF_FRAME_SIZE, BUFF_FRAME_SIZE);
   // Draw timer shade, if the buff is not permanent:
   if (!buffInst.isPermanent()) {
     float elapsed = mc.theWorld.getTotalWorldTime() - buffInst.startTime;
     float duration = buffInst.getDuration();
     float angle = elapsed / duration * MathUtil._2_PI;
     RenderHelper.drawShadowClock(angle, x, y, BUFF_FRAME_SIZE, BUFF_FRAME_SIZE, 0.5f);
   }
   // Draw background:
   RenderHelper.drawTextureRect(buffBackground, x + BUFF_FRAME, y + BUFF_FRAME, 16, 16);
   // Draw buff icon, if any:
   if (buffInst.buff.iconTexture != null) {
     RenderHelper.drawTextureRect(
         buffInst.buff.iconTexture, x + BUFF_FRAME, y + BUFF_FRAME, 16, 16);
   }
 }
Esempio n. 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;
      }
    }
  }