/** Updates the time and weather for the given player to those of the given world */
  public void updateTimeAndWeatherForPlayer(
      EntityPlayerMP par1EntityPlayerMP, WorldServer par2WorldServer) {
    par1EntityPlayerMP.playerNetServerHandler.sendPacketToPlayer(
        new Packet4UpdateTime(par2WorldServer.getTotalWorldTime(), par2WorldServer.getWorldTime()));

    if (par2WorldServer.isRaining()) {
      par1EntityPlayerMP.playerNetServerHandler.sendPacketToPlayer(new Packet70GameEvent(1, 0));
    }
  }
  /** Updates the time and weather for the given player to those of the given world */
  public void updateTimeAndWeatherForPlayer(EntityPlayerMP playerIn, WorldServer worldIn) {
    WorldBorder var3 = this.mcServer.worldServers[0].getWorldBorder();
    playerIn.playerNetServerHandler.sendPacket(
        new S44PacketWorldBorder(var3, S44PacketWorldBorder.Action.INITIALIZE));
    playerIn.playerNetServerHandler.sendPacket(
        new S03PacketTimeUpdate(
            worldIn.getTotalWorldTime(),
            worldIn.getWorldTime(),
            worldIn.getGameRules().getGameRuleBooleanValue("doDaylightCycle")));

    if (worldIn.isRaining()) {
      playerIn.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(1, 0.0F));
      playerIn.playerNetServerHandler.sendPacket(
          new S2BPacketChangeGameState(7, worldIn.getRainStrength(1.0F)));
      playerIn.playerNetServerHandler.sendPacket(
          new S2BPacketChangeGameState(8, worldIn.getWeightedThunderStrength(1.0F)));
    }
  }
Esempio n. 3
0
  public void updateTimeLightAndEntities() {
    this.theProfiler.startSection("jobs");
    Queue var1 = this.futureTaskQueue;

    synchronized (this.futureTaskQueue) {
      while (!this.futureTaskQueue.isEmpty()) {
        try {
          ((FutureTask) this.futureTaskQueue.poll()).run();
        } catch (Throwable var9) {
          logger.fatal(var9);
        }
      }
    }

    this.theProfiler.endStartSection("levels");
    int var11;

    for (var11 = 0; var11 < this.worldServers.length; ++var11) {
      long var2 = System.nanoTime();

      if (var11 == 0 || this.getAllowNether()) {
        WorldServer var4 = this.worldServers[var11];
        this.theProfiler.startSection(var4.getWorldInfo().getWorldName());

        if (this.tickCounter % 20 == 0) {
          this.theProfiler.startSection("timeSync");
          this.serverConfigManager.sendPacketToAllPlayersInDimension(
              new S03PacketTimeUpdate(
                  var4.getTotalWorldTime(),
                  var4.getWorldTime(),
                  var4.getGameRules().getGameRuleBooleanValue("doDaylightCycle")),
              var4.provider.getDimensionId());
          this.theProfiler.endSection();
        }

        this.theProfiler.startSection("tick");
        CrashReport var6;

        try {
          var4.tick();
        } catch (Throwable var8) {
          var6 = CrashReport.makeCrashReport(var8, "Exception ticking world");
          var4.addWorldInfoToCrashReport(var6);
          throw new ReportedException(var6);
        }

        try {
          var4.updateEntities();
        } catch (Throwable var7) {
          var6 = CrashReport.makeCrashReport(var7, "Exception ticking world entities");
          var4.addWorldInfoToCrashReport(var6);
          throw new ReportedException(var6);
        }

        this.theProfiler.endSection();
        this.theProfiler.startSection("tracker");
        var4.getEntityTracker().updateTrackedEntities();
        this.theProfiler.endSection();
        this.theProfiler.endSection();
      }

      this.timeOfLastDimensionTick[var11][this.tickCounter % 100] = System.nanoTime() - var2;
    }

    this.theProfiler.endStartSection("connection");
    this.getNetworkSystem().networkTick();
    this.theProfiler.endStartSection("players");
    this.serverConfigManager.onTick();
    this.theProfiler.endStartSection("tickables");

    for (var11 = 0; var11 < this.playersOnline.size(); ++var11) {
      ((IUpdatePlayerListBox) this.playersOnline.get(var11)).update();
    }

    this.theProfiler.endSection();
  }
  public void initializeConnectionToPlayer(
      INetworkManager par1INetworkManager, EntityPlayerMP par2EntityPlayerMP) {
    this.readPlayerDataFromFile(par2EntityPlayerMP);
    par2EntityPlayerMP.setWorld(
        this.mcServer.worldServerForDimension(par2EntityPlayerMP.dimension));
    par2EntityPlayerMP.theItemInWorldManager.setWorld((WorldServer) par2EntityPlayerMP.worldObj);
    String var3 = "local";

    if (par1INetworkManager.getSocketAddress() != null) {
      var3 = par1INetworkManager.getSocketAddress().toString();
    }

    logger.info(
        par2EntityPlayerMP.username
            + "["
            + var3
            + "] logged in with entity id "
            + par2EntityPlayerMP.entityId
            + " at ("
            + par2EntityPlayerMP.posX
            + ", "
            + par2EntityPlayerMP.posY
            + ", "
            + par2EntityPlayerMP.posZ
            + ")");
    WorldServer var4 = this.mcServer.worldServerForDimension(par2EntityPlayerMP.dimension);
    ChunkCoordinates var5 = var4.getSpawnPoint();
    this.func_72381_a(par2EntityPlayerMP, (EntityPlayerMP) null, var4);
    NetServerHandler var6 =
        new NetServerHandler(this.mcServer, par1INetworkManager, par2EntityPlayerMP);
    var6.sendPacketToPlayer(
        new Packet1Login(
            par2EntityPlayerMP.entityId,
            var4.getWorldInfo().getTerrainType(),
            par2EntityPlayerMP.theItemInWorldManager.getGameType(),
            var4.getWorldInfo().isHardcoreModeEnabled(),
            var4.provider.dimensionId,
            var4.difficultySetting,
            var4.getHeight(),
            this.getMaxPlayers()));
    var6.sendPacketToPlayer(new Packet6SpawnPosition(var5.posX, var5.posY, var5.posZ));
    var6.sendPacketToPlayer(new Packet202PlayerAbilities(par2EntityPlayerMP.capabilities));
    var6.sendPacketToPlayer(new Packet16BlockItemSwitch(par2EntityPlayerMP.inventory.currentItem));
    this.updateTimeAndWeatherForPlayer(par2EntityPlayerMP, var4);
    this.sendPacketToAllPlayers(
        new Packet3Chat("\u00a7e" + par2EntityPlayerMP.username + " joined the game."));
    this.playerLoggedIn(par2EntityPlayerMP);
    var6.setPlayerLocation(
        par2EntityPlayerMP.posX,
        par2EntityPlayerMP.posY,
        par2EntityPlayerMP.posZ,
        par2EntityPlayerMP.rotationYaw,
        par2EntityPlayerMP.rotationPitch);
    this.mcServer.getNetworkThread().addPlayer(var6);
    var6.sendPacketToPlayer(new Packet4UpdateTime(var4.getTotalWorldTime(), var4.getWorldTime()));

    if (this.mcServer.getTexturePack().length() > 0) {
      par2EntityPlayerMP.requestTexturePackLoad(
          this.mcServer.getTexturePack(), this.mcServer.textureSize());
    }

    Iterator var7 = par2EntityPlayerMP.getActivePotionEffects().iterator();

    while (var7.hasNext()) {
      PotionEffect var8 = (PotionEffect) var7.next();
      var6.sendPacketToPlayer(new Packet41EntityEffect(par2EntityPlayerMP.entityId, var8));
    }

    par2EntityPlayerMP.addSelfToInternalCraftingInventory();
  }
Esempio n. 5
0
  public void updateTimeLightAndEntities() {
    this.theProfiler.startSection("levels");
    int i;

    Integer[] ids = DimensionManager.getIDs(this.tickCounter % 200 == 0);
    for (int x = 0; x < ids.length; x++) {
      int id = ids[x];
      long j = System.nanoTime();

      if (id == 0 || this.getAllowNether()) {
        WorldServer worldserver = DimensionManager.getWorld(id);
        this.theProfiler.startSection(worldserver.getWorldInfo().getWorldName());
        this.theProfiler.startSection("pools");
        worldserver.getWorldVec3Pool().clear();
        this.theProfiler.endSection();

        if (this.tickCounter % 20 == 0) {
          this.theProfiler.startSection("timeSync");
          this.serverConfigManager.sendPacketToAllPlayersInDimension(
              new Packet4UpdateTime(worldserver.getTotalWorldTime(), worldserver.getWorldTime()),
              worldserver.provider.dimensionId);
          this.theProfiler.endSection();
        }

        this.theProfiler.startSection("tick");
        FMLCommonHandler.instance().onPreWorldTick(worldserver);
        CrashReport crashreport;

        try {
          worldserver.tick();
        } catch (Throwable throwable) {
          crashreport = CrashReport.makeCrashReport(throwable, "Exception ticking world");
          worldserver.addWorldInfoToCrashReport(crashreport);
          throw new ReportedException(crashreport);
        }

        try {
          worldserver.updateEntities();
        } catch (Throwable throwable1) {
          crashreport = CrashReport.makeCrashReport(throwable1, "Exception ticking world entities");
          worldserver.addWorldInfoToCrashReport(crashreport);
          throw new ReportedException(crashreport);
        }

        FMLCommonHandler.instance().onPostWorldTick(worldserver);
        this.theProfiler.endSection();
        this.theProfiler.startSection("tracker");
        worldserver.getEntityTracker().updateTrackedEntities();
        this.theProfiler.endSection();
        this.theProfiler.endSection();
      }

      worldTickTimes.get(id)[this.tickCounter % 100] = System.nanoTime() - j;
    }

    this.theProfiler.endStartSection("dim_unloading");
    DimensionManager.unloadWorlds(worldTickTimes);
    this.theProfiler.endStartSection("connection");
    this.getNetworkThread().networkTick();
    this.theProfiler.endStartSection("players");
    this.serverConfigManager.sendPlayerInfoToAllPlayers();
    this.theProfiler.endStartSection("tickables");

    for (i = 0; i < this.tickables.size(); ++i) {
      ((IUpdatePlayerListBox) this.tickables.get(i)).update();
    }

    this.theProfiler.endSection();
  }