Beispiel #1
0
 private void modifyWorld(WorldServer worldServer) {
   ChunkProviderServer cubeCache = cc.getServerChunkCacheAndInitWorld(worldServer);
   worldServer.theChunkProviderServer = cubeCache;
   WorldAccess.setChunkProvider(worldServer, cubeCache);
   WorldServerAccess.setPlayerManager(worldServer, cc.getPlayerManager(worldServer));
   worldServer.getGameRules().setOrCreateGameRule("doMobSpawning", String.valueOf(false));
 }
  /** 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)));
    }
  }
Beispiel #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(NetworkManager netManager, EntityPlayerMP playerIn) {
    GameProfile var3 = playerIn.getGameProfile();
    PlayerProfileCache var4 = this.mcServer.getPlayerProfileCache();
    GameProfile var5 = var4.func_152652_a(var3.getId());
    String var6 = var5 == null ? var3.getName() : var5.getName();
    var4.func_152649_a(var3);
    NBTTagCompound var7 = this.readPlayerDataFromFile(playerIn);
    playerIn.setWorld(this.mcServer.worldServerForDimension(playerIn.dimension));
    playerIn.theItemInWorldManager.setWorld((WorldServer) playerIn.worldObj);
    String var8 = "local";

    if (netManager.getRemoteAddress() != null) {
      var8 = netManager.getRemoteAddress().toString();
    }

    logger.info(
        playerIn.getName()
            + "["
            + var8
            + "] logged in with entity id "
            + playerIn.getEntityId()
            + " at ("
            + playerIn.posX
            + ", "
            + playerIn.posY
            + ", "
            + playerIn.posZ
            + ")");
    WorldServer var9 = this.mcServer.worldServerForDimension(playerIn.dimension);
    WorldInfo var10 = var9.getWorldInfo();
    BlockPos var11 = var9.getSpawnPoint();
    this.func_72381_a(playerIn, (EntityPlayerMP) null, var9);
    NetHandlerPlayServer var12 = new NetHandlerPlayServer(this.mcServer, netManager, playerIn);
    var12.sendPacket(
        new S01PacketJoinGame(
            playerIn.getEntityId(),
            playerIn.theItemInWorldManager.getGameType(),
            var10.isHardcoreModeEnabled(),
            var9.provider.getDimensionId(),
            var9.getDifficulty(),
            this.getMaxPlayers(),
            var10.getTerrainType(),
            var9.getGameRules().getGameRuleBooleanValue("reducedDebugInfo")));
    var12.sendPacket(
        new S3FPacketCustomPayload(
            "MC|Brand",
            (new PacketBuffer(Unpooled.buffer()))
                .writeString(this.getServerInstance().getServerModName())));
    var12.sendPacket(
        new S41PacketServerDifficulty(var10.getDifficulty(), var10.isDifficultyLocked()));
    var12.sendPacket(new S05PacketSpawnPosition(var11));
    var12.sendPacket(new S39PacketPlayerAbilities(playerIn.capabilities));
    var12.sendPacket(new S09PacketHeldItemChange(playerIn.inventory.currentItem));
    playerIn.getStatFile().func_150877_d();
    playerIn.getStatFile().func_150884_b(playerIn);
    this.func_96456_a((ServerScoreboard) var9.getScoreboard(), playerIn);
    this.mcServer.refreshStatusNextTick();
    ChatComponentTranslation var13;

    if (!playerIn.getName().equalsIgnoreCase(var6)) {
      var13 =
          new ChatComponentTranslation(
              "multiplayer.player.joined.renamed", new Object[] {playerIn.getDisplayName(), var6});
    } else {
      var13 =
          new ChatComponentTranslation(
              "multiplayer.player.joined", new Object[] {playerIn.getDisplayName()});
    }

    var13.getChatStyle().setColor(EnumChatFormatting.YELLOW);
    this.sendChatMsg(var13);
    this.playerLoggedIn(playerIn);
    var12.setPlayerLocation(
        playerIn.posX, playerIn.posY, playerIn.posZ, playerIn.rotationYaw, playerIn.rotationPitch);
    this.updateTimeAndWeatherForPlayer(playerIn, var9);

    if (this.mcServer.getResourcePackUrl().length() > 0) {
      playerIn.func_175397_a(
          this.mcServer.getResourcePackUrl(), this.mcServer.getResourcePackHash());
    }

    Iterator var14 = playerIn.getActivePotionEffects().iterator();

    while (var14.hasNext()) {
      PotionEffect var15 = (PotionEffect) var14.next();
      var12.sendPacket(new S1DPacketEntityEffect(playerIn.getEntityId(), var15));
    }

    playerIn.addSelfToInternalCraftingInventory();

    if (var7 != null && var7.hasKey("Riding", 10)) {
      Entity var16 = EntityList.createEntityFromNBT(var7.getCompoundTag("Riding"), var9);

      if (var16 != null) {
        var16.forceSpawn = true;
        var9.spawnEntityInWorld(var16);
        playerIn.mountEntity(var16);
        var16.forceSpawn = false;
      }
    }
  }