Ejemplo n.º 1
0
 public void dropPlayerItemWithRandomChoice(ItemStack itemstack, boolean flag) {
   if (itemstack == null) {
     return;
   }
   EntityItem entityitem =
       new EntityItem(
           worldObj,
           posX,
           (posY - 0.30000001192092896D) + (double) getEyeHeight(),
           posZ,
           itemstack);
   entityitem.delayBeforeCanPickup = 40;
   float f = 0.1F;
   if (flag) {
     float f2 = rand.nextFloat() * 0.5F;
     float f4 = rand.nextFloat() * 3.141593F * 2.0F;
     entityitem.motionX = -MathHelper.sin(f4) * f2;
     entityitem.motionZ = MathHelper.cos(f4) * f2;
     entityitem.motionY = 0.20000000298023224D;
   } else {
     float f1 = 0.3F;
     entityitem.motionX =
         -MathHelper.sin((rotationYaw / 180F) * 3.141593F)
             * MathHelper.cos((rotationPitch / 180F) * 3.141593F)
             * f1;
     entityitem.motionZ =
         MathHelper.cos((rotationYaw / 180F) * 3.141593F)
             * MathHelper.cos((rotationPitch / 180F) * 3.141593F)
             * f1;
     entityitem.motionY = -MathHelper.sin((rotationPitch / 180F) * 3.141593F) * f1 + 0.1F;
     f1 = 0.02F;
     float f3 = rand.nextFloat() * 3.141593F * 2.0F;
     f1 *= rand.nextFloat();
     entityitem.motionX += Math.cos(f3) * (double) f1;
     entityitem.motionY += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
     entityitem.motionZ += Math.sin(f3) * (double) f1;
   }
   joinEntityItemWithWorld(entityitem);
   addStat(StatList.dropStat, 1);
 }
Ejemplo n.º 2
0
 public void onDeath(DamageSource damagesource) {
   super.onDeath(damagesource);
   setSize(0.2F, 0.2F);
   setPosition(posX, posY, posZ);
   motionY = 0.10000000149011612D;
   if (username.equals("Notch")) {
     dropPlayerItemWithRandomChoice(new ItemStack(Item.appleRed, 1), true);
   }
   inventory.dropAllItems();
   if (damagesource != null) {
     motionX = -MathHelper.cos(((attackedAtYaw + rotationYaw) * 3.141593F) / 180F) * 0.1F;
     motionZ = -MathHelper.sin(((attackedAtYaw + rotationYaw) * 3.141593F) / 180F) * 0.1F;
   } else {
     motionX = motionZ = 0.0D;
   }
   yOffset = 0.1F;
   addStat(StatList.deathsStat, 1);
 }
Ejemplo n.º 3
0
 public void attackTargetEntityWithCurrentItem(Entity entity) {
   int i = inventory.getDamageVsEntity(entity);
   if (isPotionActive(Potion.damageBoost)) {
     i += 3 << getActivePotionEffect(Potion.damageBoost).getAmplifier();
   }
   if (isPotionActive(Potion.weakness)) {
     i -= 2 << getActivePotionEffect(Potion.weakness).getAmplifier();
   }
   int j = 0;
   int k = 0;
   if (entity instanceof EntityLiving) {
     k = EnchantmentHelper.getEnchantmentModifierLiving(inventory, (EntityLiving) entity);
     j += EnchantmentHelper.getKnockbackModifier(inventory, (EntityLiving) entity);
   }
   if (isSprinting()) {
     j++;
   }
   if (i > 0 || k > 0) {
     boolean flag =
         fallDistance > 0.0F
             && !onGround
             && !isOnLadder()
             && !isInWater()
             && !isPotionActive(Potion.blindness)
             && ridingEntity == null
             && (entity instanceof EntityLiving);
     if (flag) {
       i += rand.nextInt(i / 2 + 2);
     }
     i += k;
     boolean flag1 = entity.attackEntityFrom(DamageSource.causePlayerDamage(this), i);
     if (flag1) {
       if (j > 0) {
         entity.addVelocity(
             -MathHelper.sin((rotationYaw * 3.141593F) / 180F) * (float) j * 0.5F,
             0.10000000000000001D,
             MathHelper.cos((rotationYaw * 3.141593F) / 180F) * (float) j * 0.5F);
         motionX *= 0.59999999999999998D;
         motionZ *= 0.59999999999999998D;
         setSprinting(false);
       }
       if (flag) {
         onCriticalHit(entity);
       }
       if (k > 0) {
         func_40183_c(entity);
       }
       if (i >= 18) {
         triggerAchievement(AchievementList.overkill);
       }
     }
     ItemStack itemstack = getCurrentEquippedItem();
     if (itemstack != null && (entity instanceof EntityLiving)) {
       itemstack.hitEntity((EntityLiving) entity, this);
       if (itemstack.stackSize <= 0) {
         itemstack.onItemDestroyedByUse(this);
         destroyCurrentEquippedItem();
       }
     }
     if (entity instanceof EntityLiving) {
       if (entity.isEntityAlive()) {
         alertWolves((EntityLiving) entity, true);
       }
       addStat(StatList.damageDealtStat, i);
       int l = EnchantmentHelper.getFireAspectModifier(inventory, (EntityLiving) entity);
       if (l > 0) {
         entity.setFire(l * 4);
       }
     }
     addExhaustion(0.3F);
   }
 }
Ejemplo n.º 4
0
  /** Draws the screen and all the components in it. */
  public void drawScreen(int par1, int par2, float par3) {
    if (panorama) {
      renderSkybox(par1, par2, par3);
    } else {
      drawDefaultBackground();
    }
    Tessellator tessellator = Tessellator.instance;
    if (oldlogo) {
      drawLogo(par3);
    }
    char c = 274;
    int i = width / 2 - c / 2;
    byte byte0 = 30;
    if (panorama) {
      drawGradientRect(0, 0, width, height, 0x80ffffff, 0xffffff);
      drawGradientRect(0, 0, width, height, 0, 0x80000000);
    }
    if (!oldlogo) {
      mc.func_110434_K().func_110577_a(field_110352_y);
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

      if ((double) updateCounter < 0.0001D) {
        drawTexturedModalRect(i + 0, byte0 + 0, 0, 0, 99, 44);
        drawTexturedModalRect(i + 99, byte0 + 0, 129, 0, 27, 44);
        drawTexturedModalRect(i + 99 + 26, byte0 + 0, 126, 0, 3, 44);
        drawTexturedModalRect(i + 99 + 26 + 3, byte0 + 0, 99, 0, 26, 44);
        drawTexturedModalRect(i + 155, byte0 + 0, 0, 45, 155, 44);
      } else {
        drawTexturedModalRect(i + 0, byte0 + 0, 0, 0, 155, 44);
        drawTexturedModalRect(i + 155, byte0 + 0, 0, 45, 155, 44);
      }
    }

    tessellator.setColorOpaque_I(0xffffff);
    GL11.glPushMatrix();
    GL11.glTranslatef(width / 2 + 90, 70F, 0.0F);
    GL11.glRotatef(-20F, 0.0F, 0.0F, 1.0F);
    float f =
        1.8F
            - MathHelper.abs(
                MathHelper.sin(
                        ((float) (Minecraft.getSystemTime() % 1000L) / 1000F)
                            * (float) Math.PI
                            * 2.0F)
                    * 0.1F);
    f = (f * 100F) / (float) (fontRenderer.getStringWidth(splashText) + 32);
    GL11.glScalef(f, f, f);
    drawCenteredString(fontRenderer, splashText, 0, -8, 0xffff00);
    GL11.glPopMatrix();
    String s = version.contains(":") ? version.split(":", 2)[1] : version;
    if (s.equals("OFF")) {
      s = "Minecraft " + (new CallableMinecraftVersion(null)).minecraftVersion();
    }

    if (mc.isDemo()) {
      s = (new StringBuilder()).append(s).append(" Demo").toString();
    }

    if (panorama) {
      drawString(fontRenderer, s, 2, height - 10, 0xffffff);
    } else {
      drawString(fontRenderer, s, 2, 2, 0x505050);
    }
    String s1 = "Copyright Mojang AB. Do not distribute!";
    drawString(
        fontRenderer, s1, width - fontRenderer.getStringWidth(s1) - 2, height - 10, 0xffffff);

    if (field_92025_p != null && field_92025_p.length() > 0) {
      drawRect(
          field_92022_t - 2, field_92021_u - 2, field_92020_v + 2, field_92019_w - 1, 0x55200000);
      drawString(fontRenderer, field_92025_p, field_92022_t, field_92021_u, 0xffffff);
      drawString(
          fontRenderer,
          field_96138_a,
          (width - field_92024_r) / 2,
          ((GuiButton) buttonList.get(0)).yPosition - 12,
          0xffffff);
    }

    super.drawScreen(par1, par2, par3);
  }
Ejemplo n.º 5
0
  /** Draws the main menu panorama */
  private void drawPanorama(int par1, int par2, float par3) {
    Tessellator tessellator = Tessellator.instance;
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    Project.gluPerspective(120F, 1.0F, 0.05F, 10F);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDepthMask(false);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    int i = 8;

    for (int j = 0; j < i * i; j++) {
      GL11.glPushMatrix();
      float f = ((float) (j % i) / (float) i - 0.5F) / 64F;
      float f1 = ((float) (j / i) / (float) i - 0.5F) / 64F;
      float f2 = 0.0F;
      GL11.glTranslatef(f, f1, f2);
      GL11.glRotatef(
          MathHelper.sin(((float) panoramaTimer + par3) / 400F) * 25F + 20F, 1.0F, 0.0F, 0.0F);
      GL11.glRotatef(-((float) panoramaTimer + par3) * 0.1F, 0.0F, 1.0F, 0.0F);

      for (int k = 0; k < 6; k++) {
        GL11.glPushMatrix();

        if (k == 1) {
          GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
        }

        if (k == 2) {
          GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);
        }

        if (k == 3) {
          GL11.glRotatef(-90F, 0.0F, 1.0F, 0.0F);
        }

        if (k == 4) {
          GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F);
        }

        if (k == 5) {
          GL11.glRotatef(-90F, 1.0F, 0.0F, 0.0F);
        }

        mc.func_110434_K().func_110577_a(titlePanoramaPaths[k]);
        tessellator.startDrawingQuads();
        tessellator.setColorRGBA_I(0xffffff, 255 / (j + 1));
        float f3 = 0.0F;
        tessellator.addVertexWithUV(-1D, -1D, 1.0D, 0.0F + f3, 0.0F + f3);
        tessellator.addVertexWithUV(1.0D, -1D, 1.0D, 1.0F - f3, 0.0F + f3);
        tessellator.addVertexWithUV(1.0D, 1.0D, 1.0D, 1.0F - f3, 1.0F - f3);
        tessellator.addVertexWithUV(-1D, 1.0D, 1.0D, 0.0F + f3, 1.0F - f3);
        tessellator.draw();
        GL11.glPopMatrix();
      }

      GL11.glPopMatrix();
      GL11.glColorMask(true, true, true, false);
    }

    tessellator.setTranslation(0.0D, 0.0D, 0.0D);
    GL11.glColorMask(true, true, true, true);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
  }