Package net.minecraft.profiler

Examples of net.minecraft.profiler.Profiler


    return new Vector3((float) renderEntity.posX - pos.x, (float) renderEntity.posY + renderEntity.getEyeHeight() - pos.y, (float) renderEntity.posZ - pos.z);
  }

  @SubscribeEvent
  public void onRenderWorldLast(RenderWorldLastEvent event) {
    Profiler profiler = Minecraft.getMinecraft().mcProfiler;
    profiler.startSection("botania-particles");
    ParticleRenderDispatcher.dispatch();
    profiler.startSection("lightning");

    float frame = event.partialTicks;
    Entity entity = Minecraft.getMinecraft().thePlayer;
    TextureManager render = Minecraft.getMinecraft().renderEngine;

    interpPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * frame;
    interpPosY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * frame;
    interpPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * frame;

    GL11.glTranslated(-interpPosX, -interpPosY, -interpPosZ);

    Tessellator tessellator = Tessellator.instance;

    GL11.glDepthMask(false);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    ParticleRenderDispatcher.lightningCount = 0;

    render.bindTexture(outsideResource);
    tessellator.startDrawingQuads();
    tessellator.setBrightness(0xF000F0);
    for(LightningBolt bolt : LightningBolt.boltlist)
      renderBolt(bolt, tessellator, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 0, false);
    tessellator.draw();

    render.bindTexture(insideResource);
    tessellator.startDrawingQuads();
    tessellator.setBrightness(0xF000F0);
    for(LightningBolt bolt : LightningBolt.boltlist)
      renderBolt(bolt, tessellator, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 1, true);
    tessellator.draw();

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDepthMask(true);

    GL11.glTranslated(interpPosX, interpPosY, interpPosZ);
    profiler.endSection();
    profiler.endSection();

  }
View Full Code Here


  private static final ResourceLocation manaBar = new ResourceLocation(LibResources.GUI_MANA_HUD);

  @SubscribeEvent
  public void onDrawScreen(RenderGameOverlayEvent.Post event) {
    Minecraft mc = Minecraft.getMinecraft();
    Profiler profiler = mc.mcProfiler;

    if(event.type == ElementType.ALL) {
      profiler.startSection("botania-hud");
      MovingObjectPosition pos = mc.objectMouseOver;
      if(pos != null) {
        Block block = mc.theWorld.getBlock(pos.blockX, pos.blockY, pos.blockZ);
        TileEntity tile = mc.theWorld.getTileEntity(pos.blockX, pos.blockY, pos.blockZ);
        ItemStack stack = mc.thePlayer.getCurrentEquippedItem();

        if(stack != null) {
          if(pos != null && stack.getItem() == ModItems.twigWand) {
            renderWandModeDisplay(event.resolution);

            if(block instanceof IWandHUD) {
              profiler.startSection("wandItem");
              ((IWandHUD) block).renderHUD(mc, event.resolution, mc.theWorld, pos.blockX, pos.blockY, pos.blockZ);
              profiler.endSection();
            }
          }
          else if(pos != null && stack.getItem() instanceof ILexicon)
            drawLexiconHUD(mc.thePlayer.getCurrentEquippedItem(), block, pos, event.resolution);
          else if(tile != null && tile instanceof TilePool)
            renderPoolRecipeHUD(event.resolution, (TilePool) tile, stack);
        }
      }

      profiler.startSection("manaBar");
      EntityPlayer player = Minecraft.getMinecraft().thePlayer;
      int totalMana = 0;
      int totalMaxMana = 0;
      boolean anyRequest = false;
      boolean creative = false;

      IInventory mainInv = player.inventory;
      IInventory baublesInv = PlayerHandler.getPlayerBaubles(player);

      int invSize = mainInv.getSizeInventory();
      int size = invSize;
      if(baublesInv != null)
        size += baublesInv.getSizeInventory();

      for(int i = 0; i < size; i++) {
        boolean useBaubles = i >= invSize;
        IInventory inv = useBaubles ? baublesInv : mainInv;
        ItemStack stack = inv.getStackInSlot(i - (useBaubles ? invSize : 0));

        if(stack != null) {
          Item item = stack.getItem();
          if(item instanceof IManaUsingItem)
            anyRequest = anyRequest || ((IManaUsingItem) item).usesMana(stack);

          if(item instanceof IManaItem) {
            if(!((IManaItem) item).isNoExport(stack)) {
              totalMana += ((IManaItem) item).getMana(stack);
              totalMaxMana += ((IManaItem) item).getMaxMana(stack);
            }
          }

          if(item instanceof ICreativeManaProvider && ((ICreativeManaProvider) item).isCreative(stack))
            creative = true;
        }
      }

      if(anyRequest)
        renderManaInvBar(event.resolution, creative, totalMana, totalMaxMana);

      profiler.endStartSection("bossBar");
      BossBarHandler.render(event.resolution);
      profiler.endSection();
      profiler.endSection();
    }
  }
View Full Code Here

    }
  }

  private void renderWandModeDisplay(ScaledResolution res) {
    Minecraft mc = Minecraft.getMinecraft();
    Profiler profiler = mc.mcProfiler;

    profiler.startSection("wandMode");
    int ticks = ReflectionHelper.getPrivateValue(GuiIngame.class, mc.ingameGUI, LibObfuscation.REMAINING_HIGHLIGHT_TICKS);
    ticks -= 15;
    if(ticks > 0) {
      int alpha = Math.min(255, (int) (ticks * 256.0F / 10.0F));
      int color = 0x00CC00 + (alpha << 24);
      String disp = StatCollector.translateToLocal(ItemTwigWand.getModeString(mc.thePlayer.getCurrentEquippedItem()));

      int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(disp) / 2;
      int y = res.getScaledHeight() - 70;

      GL11.glEnable(GL11.GL_BLEND);
      GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
      mc.fontRenderer.drawStringWithShadow(disp, x, y, color);
      GL11.glDisable(GL11.GL_BLEND);
    }
    profiler.endSection();
  }
View Full Code Here

    GL11.glDisable(GL11.GL_BLEND);
  }

  private void renderPoolRecipeHUD(ScaledResolution res, TilePool tile, ItemStack stack) {
    Minecraft mc = Minecraft.getMinecraft();
    Profiler profiler = mc.mcProfiler;

    profiler.startSection("poolRecipe");
    for(RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) {
      if(recipe.matches(stack)) {
        if((!recipe.isAlchemy() || tile.alchemy) && (!recipe.isConjuration() || tile.conjuration)) {
          int x = res.getScaledWidth() / 2 - 11;
          int y = res.getScaledHeight() / 2 + 10;

          int u = tile.getCurrentMana() >= recipe.getManaToConsume() ? 0 : 22;
          if(u == 0 && tile.getBlockMetadata() == 2 && recipe.getOutput().getItem() != Item.getItemFromBlock(ModBlocks.pool))
            u = 44;
          int v = mc.thePlayer.getCommandSenderName().equals("haighyorkie") && mc.thePlayer.isSneaking() ? 23 : 8;

          GL11.glEnable(GL11.GL_BLEND);
          GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

          mc.renderEngine.bindTexture(manaBar);
          RenderHelper.drawTexturedModalRect(x, y, 0, u, v, 22, 15);
          GL11.glColor4f(1F, 1F, 1F, 1F);

          net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
          RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x - 20, y);
          RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recipe.getOutput(), x + 26, y);
          RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, recipe.getOutput(), x + 26, y);
          net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();

          GL11.glDisable(GL11.GL_LIGHTING);
          GL11.glDisable(GL11.GL_BLEND);

          break;
        }
      }
    }
    profiler.endSection();
  }
View Full Code Here

    profiler.endSection();
  }

  private void drawLexiconHUD(ItemStack stack, Block block, MovingObjectPosition pos, ScaledResolution res) {
    Minecraft mc = Minecraft.getMinecraft();
    Profiler profiler = mc.mcProfiler;

    profiler.startSection("lexicon");
    FontRenderer font = mc.fontRenderer;
    boolean draw = false;
    String drawStr = "";

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    int sx = res.getScaledWidth() / 2 - 17;
    int sy = res.getScaledHeight() / 2 + 2;

    if(block instanceof ILexiconable) {
      LexiconEntry entry = ((ILexiconable) block).getEntry(mc.theWorld, pos.blockX, pos.blockY, pos.blockZ, mc.thePlayer, mc.thePlayer.getCurrentEquippedItem());
      if(entry != null) {
        if(!((ILexicon) stack.getItem()).isKnowledgeUnlocked(stack, entry.getKnowledgeType()))
          font = mc.standardGalacticFontRenderer;

        drawStr = StatCollector.translateToLocal(entry.getUnlocalizedName());
        draw = true;
      }
    }

    if(!draw && pos.entityHit == null) {
      profiler.startSection("wikiLookup");
      IWikiProvider provider = WikiHooks.getWikiFor(block);
      String url = provider.getWikiURL(mc.theWorld, pos);
      if(url != null && !url.isEmpty()) {
        String name = provider.getBlockName(mc.theWorld, pos);
        String wikiName = provider.getWikiName(mc.theWorld, pos);
        drawStr = name + " @ " + EnumChatFormatting.AQUA + wikiName;
        draw = true;
      }
      profiler.endSection();
    }

    if(draw) {
      if(!mc.thePlayer.isSneaking()) {
        drawStr = "?";
        font = mc.fontRenderer;
      }

      RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModItems.lexicon), sx, sy);
      GL11.glDisable(GL11.GL_LIGHTING);
      font.drawStringWithShadow(drawStr, sx + 10, sy + 8, 0xFFFFFFFF);
    }

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glColor4f(1F, 1F, 1F, 1F);
    profiler.endSection();
  }
View Full Code Here

  // already registered. /shrug
  public static void dispatch() {
    Tessellator tessellator = Tessellator.instance;

    boolean isLightingEnabled = GL11.glGetBoolean(GL11.GL_LIGHTING);
    Profiler profiler = Minecraft.getMinecraft().mcProfiler;

    GL11.glDepthMask(false);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
    if(isLightingEnabled)
      GL11.glDisable(GL11.GL_LIGHTING);

    profiler.startSection("sparkle");
    FXSparkle.dispatchQueuedRenders(tessellator);
    profiler.endStartSection("wisp");
    FXWisp.dispatchQueuedRenders(tessellator);
    profiler.endSection();

    if(isLightingEnabled)
      GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
    GL11.glDisable(GL11.GL_BLEND);
View Full Code Here

  }

  @Override
  public void onLivingUpdate() {
    final World worldObj = this.worldObj;
    final Profiler theProfiler = worldObj.theProfiler;
    final boolean isServer = !this.isClientWorld();
    if (this.jumpTicks > 0) {
      --this.jumpTicks;
    }

    if (this.newPosRotationIncrements > 0) {
      double var1 = this.posX + (this.newPosX - this.posX) / (double) this.newPosRotationIncrements;
      double var3 = this.posY + (this.newPosY - this.posY) / (double) this.newPosRotationIncrements;
      double var5 = this.posZ + (this.newPosZ - this.posZ) / (double) this.newPosRotationIncrements;
      double var7 = MathHelper.wrapAngleTo180_double(this.newRotationYaw - (double) this.rotationYaw);
      this.rotationYaw = (float) ((double) this.rotationYaw + var7 / (double) this.newPosRotationIncrements);
      this.rotationPitch = (float) ((double) this.rotationPitch + (this.newRotationPitch - (double) this.rotationPitch) / (double) this.newPosRotationIncrements);
      --this.newPosRotationIncrements;
      this.setPosition(var1, var3, var5);
      this.setRotation(this.rotationYaw, this.rotationPitch);
    } else if (isServer) {
      this.motionX *= 0.98D;
      this.motionY *= 0.98D;
      this.motionZ *= 0.98D;
    }

    if (Math.abs(this.motionX) < 0.005D) {
      this.motionX = 0.0D;
    }

    if (Math.abs(this.motionY) < 0.005D) {
      this.motionY = 0.0D;
    }

    if (Math.abs(this.motionZ) < 0.005D) {
      this.motionZ = 0.0D;
    }

    if (--collisionSkipCounter >= 0) {
      return;
    }

    theProfiler.startSection("ai");

    if (this.isMovementBlocked()) {
      this.isJumping = false;
      this.moveStrafing = 0.0F;
      this.moveForward = 0.0F;
      this.randomYawVelocity = 0.0F;
    } else if (this.isClientWorld()) {
      if (this.isAIEnabled()) {
        theProfiler.startSection("newAi");
        this.updateAITasks();
        theProfiler.endSection();
      } else {
        theProfiler.startSection("oldAi");
        this.updateEntityActionState();
        theProfiler.endSection();
        this.rotationYawHead = this.rotationYaw;
      }
    }

    theProfiler.endSection();
    theProfiler.startSection("jump");

    if (this.isJumping) {
      if (!this.isInWater() && !this.handleLavaMovement()) {
        if (this.onGround && this.jumpTicks == 0) {
          this.jump();
          this.jumpTicks = 10;
        }
      } else {
        this.motionY += 0.03999999910593033D;
      }
    } else {
      this.jumpTicks = 0;
    }

    theProfiler.endSection();
    theProfiler.startSection("travel");
    this.moveStrafing *= 0.98F;
    this.moveForward *= 0.98F;
    this.randomYawVelocity *= 0.9F;
    this.moveEntityWithHeading(this.moveStrafing, this.moveForward);
    theProfiler.endSection();
    theProfiler.startSection("push");

    if (!worldObj.isRemote) {
      this.collideWithNearbyEntities();
    }

    theProfiler.endSection();
  }
View Full Code Here

  @Declare
  public static int spawnMobsQuickly(WorldServer worldServer, boolean peaceful, boolean hostile, boolean animal) {
    if (worldServer.tickCount % clumping != 0) {
      return 0;
    }
    final Profiler profiler = worldServer.theProfiler;
    profiler.startSection("creatureTypes");
    float loadFactor = 1 - (float) (MinecraftServer.getTickTime() / MinecraftServer.getTargetTickTime());
    if (loadFactor < 0.2f || loadFactor > 1f) {
      loadFactor = 0.2f;
    }
    float entityMultiplier = worldServer.playerEntities.size() * TickThreading.instance.mobSpawningMultiplier * loadFactor;
    if (entityMultiplier == 0) {
      profiler.endSection();
      return 0;
    }
    boolean dayTime = worldServer.isDaytime();
    float mobMultiplier = entityMultiplier * (dayTime ? 1 : 2);
    Map<EnumCreatureType, Integer> requiredSpawns = (Map<EnumCreatureType, Integer>) new EnumMap(EnumCreatureType.class);
    for (EnumCreatureType creatureType : EnumCreatureType.values()) {
      int count = (int) ((creatureType.getPeacefulCreature() ? entityMultiplier : mobMultiplier) * creatureType.getMaxNumberOfCreature());
      if (!(creatureType.getPeacefulCreature() && !peaceful || creatureType.getAnimal() && !animal || !creatureType.getPeacefulCreature() && !hostile) && count > worldServer.countEntities(creatureType.getCreatureClass())) {
        requiredSpawns.put(creatureType, count);
      }
    }
    profiler.endSection();

    if (requiredSpawns.isEmpty()) {
      return 0;
    }

    profiler.startSection("spawnableChunks");
    int attemptedSpawnedMobs = 0;
    LongSet closeChunks = new LongSet();
    Collection<EntityPlayer> entityPlayers = worldServer.playerEntities;
    LongList spawnableChunks = new LongList(entityPlayers.size() * maxChunksPerPlayer);
    for (EntityPlayer entityPlayer : entityPlayers) {
      int pX = entityPlayer.chunkCoordX;
      int pZ = entityPlayer.chunkCoordZ;
      int x = pX - closeRange;
      int maxX = pX + closeRange;
      int startZ = pZ - closeRange;
      int maxZ = pZ + closeRange;
      for (; x <= maxX; x++) {
        for (int z = startZ; z <= maxZ; z++) {
          closeChunks.add(hash(x, z));
        }
      }
    }
    for (EntityPlayer entityPlayer : entityPlayers) {
      int pX = entityPlayer.chunkCoordX;
      int pZ = entityPlayer.chunkCoordZ;
      int x = pX - farRange;
      int maxX = pX + farRange;
      int startZ = pZ - farRange;
      int maxZ = pZ + farRange;
      for (; x <= maxX; x++) {
        for (int z = startZ; z <= maxZ; z++) {
          long hash = hash(x, z);
          if (!closeChunks.contains(hash)) {
            spawnableChunks.add(hash);
          }
        }
      }
    }
    profiler.endStartSection("spawnMobs");

    int size = spawnableChunks.size;
    if (size < 1) {
      return 0;
    }

    SpawnLoop:
    for (Map.Entry<EnumCreatureType, Integer> entry : requiredSpawns.entrySet()) {
      EnumCreatureType creatureType = entry.getKey();
      long hash = spawnableChunks.get(worldServer.rand.nextInt(size));
      int x = (int) (hash >> 32);
      int z = (int) hash;
      int sX = x * 16 + worldServer.rand.nextInt(16);
      int sZ = z * 16 + worldServer.rand.nextInt(16);
      boolean surface = creatureType.getPeacefulCreature() || (dayTime ? surfaceChance++ % 5 == 0 : surfaceChance++ % 5 != 0);
      int gap = gapChance++;
      int sY;
      if (creatureType == EnumCreatureType.waterCreature) {
        String biomeName = worldServer.getBiomeGenForCoords(sX, sZ).biomeName;
        if (!"Ocean".equals(biomeName) && !"River".equals(biomeName)) {
          continue;
        }
        sY = getPseudoRandomHeightValue(sX, sZ, worldServer, true, gap) - 2;
      } else {
        sY = getPseudoRandomHeightValue(sX, sZ, worldServer, surface, gap);
      }
      if (sY < 0) {
        continue;
      }
      if (worldServer.getBlockMaterial(sX, sY, sZ) == creatureType.getCreatureMaterial()) {
        EntityLivingData unusedEntityLivingData = null;
        for (int i = 0; i < ((clumping * 3) / 2); i++) {
          int ssX = sX + (worldServer.rand.nextInt(spawnVariance) - spawnVariance / 2);
          int ssZ = sZ + (worldServer.rand.nextInt(spawnVariance) - spawnVariance / 2);
          int ssY;

          if (creatureType == EnumCreatureType.waterCreature) {
            ssY = sY;
          } else if (creatureType == EnumCreatureType.ambient) {
            ssY = worldServer.rand.nextInt(63) + 1;
          } else {
            ssY = getPseudoRandomHeightValue(ssX, ssZ, worldServer, surface, gap);
            if (ssY == -1 ||
                !worldServer.getBlockMaterial(ssX, ssY - 1, ssZ).isOpaque() ||
                !Block.blocksList[worldServer.getBlockId(ssX, ssY - 1, ssZ)].canCreatureSpawn(creatureType, worldServer, ssX, ssY - 1, ssZ)) {
              continue;
            }
          }

          if (creatureType == EnumCreatureType.waterCreature || (!worldServer.getBlockMaterial(ssX, ssY - 1, ssZ).isLiquid())) {
            SpawnListEntry creatureClass = worldServer.spawnRandomCreature(creatureType, ssX, ssY, ssZ);
            if (creatureClass == null) {
              break;
            }

            EntityLiving spawnedEntity;
            try {
              spawnedEntity = (EntityLiving) creatureClass.entityClass.getConstructor(World.class).newInstance(worldServer);
              spawnedEntity.setLocationAndAngles((double) ssX, (double) ssY, (double) ssZ, worldServer.rand.nextFloat() * 360.0F, 0.0F);

              Event.Result canSpawn = ForgeEventFactory.canEntitySpawn(spawnedEntity, worldServer, ssX, ssY, ssZ);
              if (canSpawn == Event.Result.ALLOW || (canSpawn == Event.Result.DEFAULT && spawnedEntity.getCanSpawnHere())) {
                worldServer.spawnEntityInWorld(spawnedEntity);
                if (!ForgeEventFactory.doSpecialSpawn(spawnedEntity, worldServer, ssX, ssY, ssZ)) {
                  unusedEntityLivingData = spawnedEntity.onSpawnWithEgg(unusedEntityLivingData);
                }
              }
              attemptedSpawnedMobs++;
            } catch (Exception e) {
              Log.warning("Failed to spawn entity " + creatureClass, e);
              break SpawnLoop;
            }
          }
        }
      }
      if (attemptedSpawnedMobs >= 24) {
        break;
      }
    }
    profiler.endSection();
    return attemptedSpawnedMobs;
  }
View Full Code Here

  }

  @Override
  public void onLivingUpdate() {
    final World worldObj = this.worldObj;
    final Profiler theProfiler = worldObj.theProfiler;
    theProfiler.startSection("looting");

    if (!worldObj.isRemote && this.canPickUpLoot() && !this.dead && !this.isDead && this.getHealth() > 0 && worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")) {
      List<EntityItem> entityItemList = worldObj.getEntitiesWithinAABB(EntityItem.class, this.boundingBox.expand(1.0D, 0.0D, 1.0D));

      for (EntityItem entityItem : entityItemList) {

        if (!entityItem.isDead && entityItem.getEntityItem() != null) {
          ItemStack itemStack = entityItem.getEntityItem();

          // This isn't actually redundant, because patcher.
          //noinspection RedundantCast
          boolean isPlayer = (Object) this instanceof EntityPlayerMP;
          Item item = itemStack.getItem();
          if (item == null || (!(item instanceof ItemArmor) && (!isPlayer || entityItem.delayBeforeCanPickup > 8))) {
            continue;
          }

          int targetSlot = getArmorPosition(itemStack);

          if (targetSlot > -1) {
            boolean shouldEquip = true;
            ItemStack oldItem = this.getCurrentItemOrArmor(targetSlot);

            if (oldItem != null) {
              if (isPlayer) {
                continue;
              }
              if (targetSlot == 0) {
                if (item instanceof ItemSword && !(oldItem.getItem() instanceof ItemSword)) {
                  shouldEquip = true;
                } else if (item instanceof ItemSword && oldItem.getItem() instanceof ItemSword) {
                  ItemSword newSword = (ItemSword) item;
                  ItemSword oldSword = (ItemSword) oldItem.getItem();

                  if (newSword.func_82803_g() == oldSword.func_82803_g()) {
                    shouldEquip = itemStack.getItemDamage() > oldItem.getItemDamage() || itemStack.hasTagCompound() && !oldItem.hasTagCompound();
                  } else {
                    shouldEquip = newSword.func_82803_g() > oldSword.func_82803_g();
                  }
                } else {
                  shouldEquip = false;
                }
              } else if (item instanceof ItemArmor && !(oldItem.getItem() instanceof ItemArmor)) {
                shouldEquip = true;
              } else if (item instanceof ItemArmor && oldItem.getItem() instanceof ItemArmor) {
                ItemArmor newArmor = (ItemArmor) item;
                ItemArmor oldArmor = (ItemArmor) oldItem.getItem();

                if (newArmor.damageReduceAmount == oldArmor.damageReduceAmount) {
                  shouldEquip = itemStack.getItemDamage() > oldItem.getItemDamage() || itemStack.hasTagCompound() && !oldItem.hasTagCompound();
                } else {
                  shouldEquip = newArmor.damageReduceAmount > oldArmor.damageReduceAmount;
                }
              } else {
                shouldEquip = false;
              }
            }

            if (shouldEquip) {
              if (oldItem != null && this.rand.nextFloat() - 0.1F < this.equipmentDropChances[targetSlot]) {
                this.entityDropItem(oldItem, 0.0F);
              }

              this.setCurrentItemOrArmor(targetSlot, itemStack);
              this.equipmentDropChances[targetSlot] = 2.0F;
              this.persistenceRequired = true;
              this.onItemPickup(entityItem, 1);
              entityItem.setDead();
            }
          }
        }
      }
    }

    theProfiler.endSection();
  }
View Full Code Here

    return true;
  }

  @Override
  public void tick() {
    final Profiler profiler = this.theProfiler;
    final WorldInfo worldInfo = this.worldInfo;
    final int tickCount = ++this.tickCount;
    final boolean hasPlayers = !playerEntities.isEmpty();
    this.updateWeather();
    if (!forcedChunksInited) {
      ForgeChunkManager.loadForcedChunks(this);
    }
    updateEntityTick = 0;
    if (this.difficultySetting < 3 && this.getWorldInfo().isHardcoreModeEnabled()) {
      this.difficultySetting = 3;
    }

    if (tickCount % 120 == 0) {
      redstoneBurnoutMap.clear();
    }

    if (tickCount % 200 == 0) {
      this.provider.worldChunkMgr.cleanupCache();
    }

    if (hasPlayers && this.areAllPlayersAsleep()) {
      long var2 = worldInfo.getWorldTime();
      worldInfo.setWorldTime(var2 + 24000L - (var2 % 24000L));
      this.wakeAllPlayers();
    }

    profiler.startSection("mobSpawner");

    if (hasPlayers && (loadedEntityList.size() / TickThreading.instance.maxEntitiesPerPlayer) < playerEntities.size() && this.getGameRules().getGameRuleBooleanValue("doMobSpawning")) {
      if (TickThreading.instance.shouldFastSpawn(this)) {
        SpawnerAnimals.spawnMobsQuickly(this, spawnHostileMobs && (ticksPerMonsterSpawns != 0 && tickCount % ticksPerMonsterSpawns == 0L), spawnPeacefulMobs && (ticksPerAnimalSpawns != 0 && tickCount % ticksPerAnimalSpawns == 0L), worldInfo.getWorldTotalTime() % 400L == 0L);
      } else {
        animalSpawner.findChunksForSpawning(this, spawnHostileMobs && (ticksPerMonsterSpawns != 0 && tickCount % ticksPerMonsterSpawns == 0L), spawnPeacefulMobs && (ticksPerAnimalSpawns != 0 && tickCount % ticksPerAnimalSpawns == 0L), worldInfo.getWorldTotalTime() % 400L == 0L);
      }
    }

    profiler.endStartSection("chunkSource");
    theChunkProviderServer.unloadQueuedChunks();
    theChunkProviderServer.tick();
    this.skylightSubtracted = this.calculateSkylightSubtracted(1.0F);

    this.sendAndApplyBlockEvents();
    worldInfo.incrementTotalWorldTime(worldInfo.getWorldTotalTime() + 1L);
    worldInfo.setWorldTime(worldInfo.getWorldTime() + 1L);
    profiler.endStartSection("tickPending");
    this.tickUpdates(false);
    profiler.endStartSection("tickTiles");
    this.tickBlocksAndAmbiance();
    profiler.endStartSection("chunkMap");
    this.thePlayerManager.updatePlayerInstances();
    profiler.endStartSection("village");
    this.villageCollectionObj.tick();
    this.villageSiegeObj.tick();
    profiler.endStartSection("portalForcer");
    this.worldTeleporter.removeStalePortalLocations(this.getTotalWorldTime());
    for (Teleporter tele : customTeleporters) {
      tele.removeStalePortalLocations(getTotalWorldTime());
    }
    profiler.endSection();
    this.sendAndApplyBlockEvents();
  }
View Full Code Here

TOP

Related Classes of net.minecraft.profiler.Profiler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.