@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();
  }
 @Override
 public void renderInWorld(ItemStack item, Object... data) {
   super.renderInWorld(item, data);
   OpenGL.pushMatrix();
   {
     OpenGL.rotate(
         (this.mc.theWorld.getWorldTime() + Game.partialTicks() % 360) * 10, 0.0F, 1.0F, 0.0F);
     OpenGL.disable(GL11.GL_CULL_FACE);
     this.getModelTexMap().getTexture().bind();
     this.getModel().render();
   }
   OpenGL.popMatrix();
 }
  @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);
        }
      }
    }
  }
Exemplo n.º 5
0
  @Override
  protected void render(IRenderObject renderObject, float boxTranslation) {
    if (renderObject != null && renderObject.getObject() instanceof EntityAethon) {
      RenderObject o = (RenderObject) renderObject;
      EntityAethon aethon = (EntityAethon) o.getEntity();

      boolean isFlying = aethon.isFlying();
      float swingProgress = o.swingProgress;
      float swingProgressPrev = o.swingProgressPrev;
      float wingDistMulti = 5F;
      float wingSpeed = isFlying ? 1.75F : 20F;
      float neckSpeed = isFlying ? 8F : 18F;
      float tailSpeed = isFlying ? 4F : 18F;
      long ticks = aethon.ticksExisted;

      if (isFlying) {
        this.rThigh.rotateAngleX = (float) Math.toRadians(-44F);
        this.lThigh.rotateAngleX = (float) Math.toRadians(-44F);
        this.rArm.rotateAngleX = (float) Math.toRadians(-18F);
        this.lArm.rotateAngleX = (float) Math.toRadians(-18F);

        this.neck1.rotateAngleX =
            (float) Math.toRadians((Math.sin((ticks + Game.partialTicks()) / (neckSpeed)) * 3F));
        this.neck2.rotateAngleX =
            (float) Math.toRadians((Math.sin((ticks + Game.partialTicks()) / (neckSpeed)) * 3F));
        this.neck3.rotateAngleX =
            (float) Math.toRadians((Math.sin((ticks + Game.partialTicks()) / (neckSpeed)) * 3F));
        this.neck4.rotateAngleX =
            (float) Math.toRadians((Math.sin((ticks + Game.partialTicks()) / (neckSpeed)) * 3F));

        this.tail1.rotateAngleX =
            (float)
                Math.toRadians(-82F + (Math.sin((ticks + Game.partialTicks()) / (tailSpeed)) * 3F));
        this.tail2.rotateAngleX =
            (float)
                Math.toRadians(-12F + (Math.sin((ticks + Game.partialTicks()) / (tailSpeed)) * 3F));
        this.tail3.rotateAngleX =
            (float)
                Math.toRadians(0F + (Math.sin((ticks + Game.partialTicks()) / (tailSpeed)) * 3F));
        this.tail4.rotateAngleX =
            (float)
                Math.toRadians(0F + (Math.sin((ticks + Game.partialTicks()) / (tailSpeed)) * 3F));
        this.tail5.rotateAngleX =
            (float)
                Math.toRadians(0F + (Math.sin((ticks + Game.partialTicks()) / (tailSpeed)) * 3F));

        this.lWingArm.rotateAngleY =
            (float)
                Math.toRadians(
                    (40F
                        + (Math.sin((ticks + Game.partialTicks()) / (wingSpeed)) * 3F)
                            * wingDistMulti));
        this.lWingArm.rotateAngleZ =
            (float)
                Math.toRadians(
                    (40F
                        + (Math.sin((ticks + Game.partialTicks()) / (wingSpeed)) * 2F)
                            * wingDistMulti));
        this.lWingArm.rotateAngleZ =
            (float)
                Math.toRadians(
                    (40F
                        + (Math.sin((ticks + Game.partialTicks()) / (wingSpeed)) * 10F)
                            * wingDistMulti));
        this.lWingArm2.rotateAngleX =
            (float)
                Math.toRadians(
                    (100F
                        + (Math.sin((ticks + Game.partialTicks()) / (wingSpeed)) * 6F)
                            * wingDistMulti));
        this.lWingArm2.rotateAngleY =
            (float)
                -Math.toRadians(
                    (30F
                        + (Math.cos((ticks + Game.partialTicks()) / (wingSpeed)) * 4F)
                            * wingDistMulti));
        this.lWingArm2.rotateAngleZ =
            (float)
                Math.toRadians(
                    (40F
                        + (Math.sin((ticks + Game.partialTicks()) / (wingSpeed)) * 4F)
                            * wingDistMulti));

        this.rWingArm.rotateAngleY =
            (float)
                -Math.toRadians(
                    (40F
                        + (Math.sin((ticks + Game.partialTicks()) / (wingSpeed)) * 3F)
                            * wingDistMulti));
        this.rWingArm.rotateAngleZ =
            (float)
                -Math.toRadians(
                    (40F
                        + (Math.sin((ticks + Game.partialTicks()) / (wingSpeed)) * 2F)
                            * wingDistMulti));
        this.rWingArm.rotateAngleZ =
            (float)
                -Math.toRadians(
                    (40F
                        + (Math.sin((ticks + Game.partialTicks()) / (wingSpeed)) * 10F)
                            * wingDistMulti));
        this.rWingArm2.rotateAngleX =
            (float)
                Math.toRadians(
                    (100F
                        + (Math.sin((ticks + Game.partialTicks()) / (wingSpeed)) * 6F)
                            * wingDistMulti));
        this.rWingArm2.rotateAngleY =
            (float)
                Math.toRadians(
                    (30F
                        + (Math.cos((ticks + Game.partialTicks()) / (wingSpeed)) * 4F)
                            * wingDistMulti));
        this.rWingArm2.rotateAngleZ =
            (float)
                -Math.toRadians(
                    (40F
                        + (Math.sin((ticks + Game.partialTicks()) / (wingSpeed)) * 4F)
                            * wingDistMulti));
      } else {
        this.rThigh.rotateAngleX =
            (float)
                (Math.toRadians(-44F)
                    + MathHelper.cos(swingProgress * 0.3662F) * 0.9F * swingProgressPrev);
        this.lThigh.rotateAngleX =
            (float)
                (Math.toRadians(-44F)
                    + MathHelper.sin(swingProgress * 0.3662F) * 0.9F * swingProgressPrev);
        this.rArm.rotateAngleX =
            (float)
                (Math.toRadians(-18F)
                    + MathHelper.cos(swingProgress * 0.3662F) * 0.6F * swingProgressPrev
                    + 0.6665191F);
        this.lArm.rotateAngleX =
            (float)
                (Math.toRadians(-18F)
                    + MathHelper.sin(swingProgress * 0.3662F) * 0.6F * swingProgressPrev
                    + 0.6665191F);

        this.neck1.rotateAngleX =
            (float) Math.toRadians((Math.sin((ticks + Game.partialTicks()) / (neckSpeed)) * 3F));
        this.neck2.rotateAngleX =
            (float)
                Math.toRadians(16F + (Math.sin((ticks + Game.partialTicks()) / (neckSpeed)) * 3F));
        this.neck3.rotateAngleX =
            (float)
                Math.toRadians(16F + (Math.sin((ticks + Game.partialTicks()) / (neckSpeed)) * 3F));
        this.neck4.rotateAngleX =
            (float)
                Math.toRadians(19F + (Math.sin((ticks + Game.partialTicks()) / (neckSpeed)) * 3F));

        this.tail1.rotateAngleX =
            (float)
                Math.toRadians(-72F + (Math.sin((ticks + Game.partialTicks()) / (tailSpeed)) * 3F));
        this.tail2.rotateAngleX =
            (float)
                Math.toRadians(16F + (Math.sin((ticks + Game.partialTicks()) / (tailSpeed)) * 3F));
        this.tail3.rotateAngleX =
            (float)
                Math.toRadians(16F + (Math.sin((ticks + Game.partialTicks()) / (tailSpeed)) * 3F));
        this.tail4.rotateAngleX =
            (float)
                Math.toRadians(19F + (Math.sin((ticks + Game.partialTicks()) / (tailSpeed)) * 3F));
        this.tail5.rotateAngleX =
            (float)
                Math.toRadians(19F + (Math.sin((ticks + Game.partialTicks()) / (tailSpeed)) * 3F));

        this.lWingArm.rotateAngleX = (float) Math.toRadians(-41.74F);
        this.lWingArm.rotateAngleY = (float) Math.toRadians(0F);
        this.lWingArm.rotateAngleZ = (float) Math.toRadians(23.48F);
        this.lWingArm2.rotateAngleX = (float) Math.toRadians(23.48F);
        this.lWingArm2.rotateAngleY = (float) Math.toRadians(10.29F);
        this.lWingArm2.rotateAngleZ = (float) Math.toRadians(-12.86F);

        this.rWingArm.rotateAngleX = (float) Math.toRadians(-41.74F);
        this.rWingArm.rotateAngleY = (float) Math.toRadians(0F);
        this.rWingArm.rotateAngleZ = (float) Math.toRadians(-23.48F);
        this.rWingArm2.rotateAngleX = (float) Math.toRadians(23.48F);
        this.rWingArm2.rotateAngleY = (float) Math.toRadians(-10.29F);
        this.rWingArm2.rotateAngleZ = (float) Math.toRadians(12.86F);
      }

      OpenGL.pushMatrix();
      {
        if (isFlying) {
          OpenGL.rotate(75F, 1, 0, 0);
        }

        this.rWingArm.render(boxTranslation);
        this.rArm.render(boxTranslation);
        this.lWingArm.render(boxTranslation);
        this.lArm.render(boxTranslation);
        this.chest.render(boxTranslation);
      }
      OpenGL.popMatrix();
    } else {
      this.rWingArm.render(boxTranslation);
      this.rArm.render(boxTranslation);
      this.lWingArm.render(boxTranslation);
      this.lArm.render(boxTranslation);
      this.chest.render(boxTranslation);
    }
  }