예제 #1
0
        public virtual void DoLogin(net.minecraft.src.Packet1Login packet1login)
        {
            net.minecraft.src.EntityPlayerMP entityplayermp = mcServer.serverConfigurationManager.Login(this, packet1login.username);
            if (entityplayermp != null)
            {
                mcServer.serverConfigurationManager.ReadPlayerDataFromFile(entityplayermp);
                entityplayermp.SetWorldHandler(mcServer.GetWorldServer(entityplayermp.dimension));

                //TODO: Cleanup all java.lang.StringBuilder instances
                //logger.Info((new java.lang.StringBuilder()).Append(GetUserAndIPString()).Append(" logged in with entity id ").Append(entityplayermp.entityId).Append(" at (").Append(entityplayermp.posX).Append(", ").Append(entityplayermp.posY).Append(", ").Append(entityplayermp.posZ).Append(")").ToString());
                logger.Info($"{GetUserAndIPString()} logged in with entity id {entityplayermp.entityId} at ({entityplayermp.posX}, {entityplayermp.posY}, {entityplayermp.posZ})");

                net.minecraft.src.WorldServer      worldserver      = mcServer.GetWorldServer(entityplayermp.dimension);
                net.minecraft.src.ChunkCoordinates chunkcoordinates = worldserver.GetSpawnPoint();
                net.minecraft.src.NetServerHandler netserverhandler = new net.minecraft.src.NetServerHandler(mcServer, netManager, entityplayermp);

                netserverhandler.SendPacket(new net.minecraft.src.Packet1Login(string.Empty, entityplayermp.entityId, worldserver.GetSeed(), unchecked ((byte)worldserver.worldProvider.worldType)));
                netserverhandler.SendPacket(new net.minecraft.src.Packet6SpawnPosition(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ));

                mcServer.serverConfigurationManager.Func_28170_a(entityplayermp, worldserver);

                //TODO: Defer login message to hook
                //mcServer.configManager.SendPacketToAllPlayers(new net.minecraft.src.Packet3Chat((new java.lang.StringBuilder()).Append("\xf7e").Append(entityplayermp.username).Append(" joined the game.").ToString()));
                mcServer.serverConfigurationManager.SendPacketToAllPlayers(new net.minecraft.src.Packet3Chat($"§e{entityplayermp.username} joined the game."));
                mcServer.serverConfigurationManager.PlayerLoggedIn(entityplayermp);

                netserverhandler.TeleportTo(entityplayermp.posX, entityplayermp.posY, entityplayermp.posZ, entityplayermp.rotationYaw, entityplayermp.rotationPitch);
                mcServer.networkServer.AddPlayer(netserverhandler);

                netserverhandler.SendPacket(new net.minecraft.src.Packet4UpdateTime(worldserver.GetWorldTime()));

                entityplayermp.Func_20057_k();
            }
            finishedProcessing = true;
        }
 public virtual net.minecraft.src.EntityPlayerMP RecreatePlayerEntity(net.minecraft.src.EntityPlayerMP
                                                                      entityplayermp, int i)
 {
     mcServer.GetEntityTracker(entityplayermp.dimension).RemoveTrackedPlayerSymmetric(
         entityplayermp);
     mcServer.GetEntityTracker(entityplayermp.dimension).UntrackEntity(entityplayermp);
     GetPlayerManager(entityplayermp.dimension).RemovePlayer(entityplayermp);
     playerEntities.Remove(entityplayermp);
     mcServer.GetWorldServer(entityplayermp.dimension).RemovePlayer(entityplayermp);
     net.minecraft.src.ChunkCoordinates chunkcoordinates = entityplayermp.GetSpawnChunk
                                                               ();
     entityplayermp.dimension = i;
     net.minecraft.src.EntityPlayerMP entityplayermp1 = new net.minecraft.src.EntityPlayerMP
                                                            (mcServer, mcServer.GetWorldServer(entityplayermp.dimension), entityplayermp.username
                                                            , new net.minecraft.src.ItemInWorldManager(mcServer.GetWorldServer(entityplayermp
                                                                                                                               .dimension)));
     entityplayermp1.entityId         = entityplayermp.entityId;
     entityplayermp1.netServerHandler = entityplayermp.netServerHandler;
     net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(entityplayermp
                                                                         .dimension);
     if (chunkcoordinates != null)
     {
         net.minecraft.src.ChunkCoordinates chunkcoordinates1 = net.minecraft.src.EntityPlayer
                                                                .Func_25051_a(mcServer.GetWorldServer(entityplayermp.dimension), chunkcoordinates
                                                                              );
         if (chunkcoordinates1 != null)
         {
             entityplayermp1.SetLocationAndAngles((float)chunkcoordinates1.posX + 0.5F, (float
                                                                                         )chunkcoordinates1.posY + 0.1F, (float)chunkcoordinates1.posZ + 0.5F, 0.0F, 0.0F
                                                  );
             entityplayermp1.SetSpawnChunk(chunkcoordinates);
         }
         else
         {
             entityplayermp1.netServerHandler.SendPacket(new net.minecraft.src.Packet70Bed
                                                             (0));
         }
     }
     worldserver.chunkProviderServer.LoadChunk((int)entityplayermp1.posX >> 4, (int)entityplayermp1
                                               .posZ >> 4);
     for (; worldserver.GetCollidingBoundingBoxes(entityplayermp1, entityplayermp1.boundingBox
                                                  ).Count != 0; entityplayermp1.SetPosition(entityplayermp1.posX, entityplayermp1.
                                                                                            posY + 1.0D, entityplayermp1.posZ))
     {
     }
     entityplayermp1.netServerHandler.SendPacket(new net.minecraft.src.Packet9Respawn
                                                     (unchecked ((byte)entityplayermp1.dimension)));
     entityplayermp1.netServerHandler.TeleportTo(entityplayermp1.posX, entityplayermp1
                                                 .posY, entityplayermp1.posZ, entityplayermp1.rotationYaw, entityplayermp1.rotationPitch
                                                 );
     Func_28170_a(entityplayermp1, worldserver);
     GetPlayerManager(entityplayermp1.dimension).AddPlayer(entityplayermp1);
     worldserver.AddEntity(entityplayermp1);
     playerEntities.Add(entityplayermp1);
     entityplayermp1.Func_20057_k();
     entityplayermp1.Func_22068_s();
     return(entityplayermp1);
 }