Example #1
0
  @Override
  public void render(EntityPlayer player, Graphics g, double x, double y) {
    final float pitch = player.pitch;

    final int attackTime = player.getAttackTime();

    final boolean flip = pitch >= 90 && pitch <= 270;
    final Renderable sprite = this.getSprite(player, attackTime);

    final float width = 12;
    final float height = 24;

    GL11.glPushMatrix();

    GL11.glTranslated(x, y, 0);

    if (flip) {
      GL11.glScalef(-1, 1, 1);
    }

    GL11.glTranslatef(-width / 2, -height, 0);

    sprite.draw(0, 0);

    this.drawHeldItem(player, attackTime);

    GL11.glPopMatrix();
  }
Example #2
0
 private Renderable getSprite(EntityPlayer player, int attackTime) {
   if (attackTime > 0) {
     return this.attacking;
   }
   if (player.airTime > 0) {
     return this.jumping;
   }
   return player.getMovement() == EntityLiving.STANDING ? this.standing : this.walking;
 }