@Override
  public PacketPlayerModeUpdate onMessage(PacketPlayerModeUpdate packet, MessageContext ctx) {
    ModPlayer playerExtension =
        (ModPlayer) Game.minecraft().thePlayer.getExtendedProperties(ModPlayer.IDENTIFIER);
    playerExtension.setPlayerMode(PlayerMode.get(packet.mode));

    return null;
  }
  @Override
  public void renderFirstPerson(ItemStack item, Object... data) {
    super.renderFirstPerson(item, data);

    EntityPlayer playerToRender = (EntityPlayer) data[1];
    OpenGL.translate(1.75F, 1.45F, 0.1F);
    OpenGL.rotate(180.0F, 1.0F, 0.0F, 0.0F);
    OpenGL.rotate(-45.0F, 0.0F, 0.0F, 1.0F);
    OpenGL.rotate(-100.0F, 0.0F, 1.0F, 0.0F);

    if (playerToRender == Game.minecraft().renderViewEntity
        && Game.minecraft().gameSettings.thirdPersonView == 0
        && (!(Game.minecraft().currentScreen instanceof GuiInventory)
                && !(Game.minecraft().currentScreen instanceof GuiContainerCreative)
            || RenderManager.instance.playerViewY != 180.0F)) {;
    }

    OpenGL.scale(1.6F, 1.6F, 1.6F);
    this.getModelTexMap().getTexture().bind();
    this.getModel().render();
  }
  @SubscribeEvent
  public void renderTick(RenderGameOverlayEvent.Pre event) {
    if (Game.minecraft().thePlayer != null
        && event.type == RenderGameOverlayEvent.ElementType.HOTBAR) {
      helmSlot = Game.minecraft().thePlayer.inventory.armorItemInSlot(3);
      chestplateSlot = Game.minecraft().thePlayer.inventory.armorItemInSlot(2);
      leggingsSlot = Game.minecraft().thePlayer.inventory.armorItemInSlot(1);
      bootsSlot = Game.minecraft().thePlayer.inventory.armorItemInSlot(0);

      if (Game.minecraft().thePlayer.getHeldItem() != null
          && Game.minecraft().thePlayer.getHeldItem().getItem() instanceof ItemFirearm) {
        ItemFirearm itemFireArm = (ItemFirearm) Game.minecraft().thePlayer.getHeldItem().getItem();
        String displayStatus =
            " " + itemFireArm.getAmmoCount() + "/" + itemFireArm.getMaxAmmoCount();
        int barWidth = 0;

        if (!Game.minecraft().thePlayer.capabilities.isCreativeMode && isWearingArmor()) {
          barWidth = 90;
          Draw.drawProgressBar(
              displayStatus,
              itemFireArm.getMaxAmmoCount(),
              itemFireArm.getAmmoCount(),
              (Screen.scaledDisplayResolution().getScaledWidth() / 2),
              Screen.scaledDisplayResolution().getScaledHeight() - 48,
              barWidth,
              1,
              0,
              0xFFFF0000,
              false);
          Draw.drawItemIcon(
              itemFireArm.getAmmoType(),
              (Screen.scaledDisplayResolution().getScaledWidth() / 2)
                  + barWidth / 2
                  - Draw.getStringRenderWidth(displayStatus)
                  - 2,
              Screen.scaledDisplayResolution().getScaledHeight() - 53,
              16,
              16);
        } else if (!Game.minecraft().thePlayer.capabilities.isCreativeMode && !isWearingArmor()) {
          barWidth = 182;
          Draw.drawProgressBar(
              displayStatus,
              itemFireArm.getMaxAmmoCount(),
              itemFireArm.getAmmoCount(),
              (Screen.scaledDisplayResolution().getScaledWidth() / 2) - (182 / 2),
              Screen.scaledDisplayResolution().getScaledHeight() - 48,
              barWidth,
              1,
              0,
              0xFF00DDFF,
              false);
          Draw.drawItemIcon(
              itemFireArm.getAmmoType(),
              (Screen.scaledDisplayResolution().getScaledWidth() / 2)
                  - (barWidth / 2)
                  + barWidth / 2
                  - Draw.getStringRenderWidth(displayStatus)
                  - 2,
              Screen.scaledDisplayResolution().getScaledHeight() - 53,
              16,
              16);
        } else {
          barWidth = 182;
          displayStatus = "\u221e";
          Draw.drawProgressBar(
              "",
              1,
              1,
              (Screen.scaledDisplayResolution().getScaledWidth() / 2) - (barWidth / 2),
              Screen.scaledDisplayResolution().getScaledHeight() - 35,
              barWidth,
              1,
              0,
              0xFF00DDFF,
              false);
          Draw.drawItemIcon(
              itemFireArm.getAmmoType(),
              (Screen.scaledDisplayResolution().getScaledWidth() / 2)
                  - (barWidth / 2)
                  + barWidth / 2
                  - Draw.getStringRenderWidth(displayStatus),
              Screen.scaledDisplayResolution().getScaledHeight() - 40,
              16,
              16);
        }
      }
    }
  }