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);
 }
        public virtual void PlayerLoggedIn(net.minecraft.src.EntityPlayerMP entityplayermp)
        {
            playerEntities.Add(entityplayermp);
            SharpBukkitPlayers[entityplayermp.username.ToLower()] = new SharpBukkitPlayer(entityplayermp); //SHARP

            net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(entityplayermp
                                                                                .dimension);
            worldserver.chunkProviderServer.LoadChunk((int)entityplayermp.posX >> 4, (int)entityplayermp
                                                      .posZ >> 4);
            for (; worldserver.GetCollidingBoundingBoxes(entityplayermp, entityplayermp.boundingBox
                                                         ).Count != 0; entityplayermp.SetPosition(entityplayermp.posX, entityplayermp.posY
                                                                                                  + 1.0D, entityplayermp.posZ))
            {
            }
            worldserver.AddEntity(entityplayermp);
            GetPlayerManager(entityplayermp.dimension).AddPlayer(entityplayermp);
        }
Exemplo n.º 3
0
 public override void HandleFlying(net.minecraft.src.Packet10Flying packet10flying
                                   )
 {
     net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(playerEntity
                                                                         .dimension);
     field_22003_h = true;
     if (!hasMoved)
     {
         double d = packet10flying.yPosition - lastPosY;
         if (packet10flying.xPosition == lastPosX && d * d < 0.01D && packet10flying.zPosition
             == lastPosZ)
         {
             hasMoved = true;
         }
     }
     if (hasMoved)
     {
         if (playerEntity.ridingEntity != null)
         {
             float f  = playerEntity.rotationYaw;
             float f1 = playerEntity.rotationPitch;
             playerEntity.ridingEntity.UpdateRiderPosition();
             double d2 = playerEntity.posX;
             double d4 = playerEntity.posY;
             double d6 = playerEntity.posZ;
             double d8 = 0.0D;
             double d9 = 0.0D;
             if (packet10flying.rotating)
             {
                 f  = packet10flying.yaw;
                 f1 = packet10flying.pitch;
             }
             if (packet10flying.moving && packet10flying.yPosition == -999D && packet10flying.
                 stance == -999D)
             {
                 d8 = packet10flying.xPosition;
                 d9 = packet10flying.zPosition;
             }
             playerEntity.onGround = packet10flying.onGround;
             playerEntity.OnUpdateEntity(true);
             playerEntity.MoveEntity(d8, 0.0D, d9);
             playerEntity.SetPositionAndRotation(d2, d4, d6, f, f1);
             playerEntity.motionX = d8;
             playerEntity.motionZ = d9;
             if (playerEntity.ridingEntity != null)
             {
                 worldserver.Func_12017_b(playerEntity.ridingEntity, true);
             }
             if (playerEntity.ridingEntity != null)
             {
                 playerEntity.ridingEntity.UpdateRiderPosition();
             }
             mcServer.serverConfigurationManager.Func_613_b(playerEntity);
             lastPosX = playerEntity.posX;
             lastPosY = playerEntity.posY;
             lastPosZ = playerEntity.posZ;
             worldserver.UpdateEntity(playerEntity);
             return;
         }
         if (playerEntity.IsSleeping())
         {
             playerEntity.OnUpdateEntity(true);
             playerEntity.SetPositionAndRotation(lastPosX, lastPosY, lastPosZ, playerEntity.rotationYaw
                                                 , playerEntity.rotationPitch);
             worldserver.UpdateEntity(playerEntity);
             return;
         }
         double d1 = playerEntity.posY;
         lastPosX = playerEntity.posX;
         lastPosY = playerEntity.posY;
         lastPosZ = playerEntity.posZ;
         double d3 = playerEntity.posX;
         double d5 = playerEntity.posY;
         double d7 = playerEntity.posZ;
         float  f2 = playerEntity.rotationYaw;
         float  f3 = playerEntity.rotationPitch;
         if (packet10flying.moving && packet10flying.yPosition == -999D && packet10flying.
             stance == -999D)
         {
             packet10flying.moving = false;
         }
         if (packet10flying.moving)
         {
             d3 = packet10flying.xPosition;
             d5 = packet10flying.yPosition;
             d7 = packet10flying.zPosition;
             double d10 = packet10flying.stance - packet10flying.yPosition;
             if (!playerEntity.IsSleeping() && (d10 > 1.6499999999999999D || d10 < 0.10000000000000001D
                                                ))
             {
                 KickPlayer("Illegal stance");
                 logger.Warning((new java.lang.StringBuilder()).Append(playerEntity.username).Append
                                    (" had an illegal stance: ").Append(d10).ToString());
                 return;
             }
             if (System.Math.Abs(packet10flying.xPosition) > 32000000D || System.Math.Abs(packet10flying
                                                                                          .zPosition) > 32000000D)
             {
                 KickPlayer("Illegal position");
                 return;
             }
         }
         if (packet10flying.rotating)
         {
             f2 = packet10flying.yaw;
             f3 = packet10flying.pitch;
         }
         playerEntity.OnUpdateEntity(true);
         playerEntity.ySize = 0.0F;
         playerEntity.SetPositionAndRotation(lastPosX, lastPosY, lastPosZ, f2, f3);
         if (!hasMoved)
         {
             return;
         }
         double d11 = d3 - playerEntity.posX;
         double d12 = d5 - playerEntity.posY;
         double d13 = d7 - playerEntity.posZ;
         double d14 = d11 * d11 + d12 * d12 + d13 * d13;
         if (d14 > 100D)
         {
             logger.Warning((new java.lang.StringBuilder()).Append(playerEntity.username).Append
                                (" moved too quickly!").ToString());
             KickPlayer("You moved too quickly :( (Hacking?)");
             return;
         }
         float f4   = 0.0625F;
         bool  flag = worldserver.GetCollidingBoundingBoxes(playerEntity, playerEntity.boundingBox
                                                            .Copy().GetInsetBoundingBox(f4, f4, f4)).Count == 0;
         playerEntity.MoveEntity(d11, d12, d13);
         d11 = d3 - playerEntity.posX;
         d12 = d5 - playerEntity.posY;
         if (d12 > -0.5D || d12 < 0.5D)
         {
             d12 = 0.0D;
         }
         d13 = d7 - playerEntity.posZ;
         d14 = d11 * d11 + d12 * d12 + d13 * d13;
         bool flag1 = false;
         if (d14 > 0.0625D && !playerEntity.IsSleeping())
         {
             flag1 = true;
             logger.Warning((new java.lang.StringBuilder()).Append(playerEntity.username).Append
                                (" moved wrongly!").ToString());
             System.Console.Out.WriteLine((new java.lang.StringBuilder()).Append("Got position "
                                                                                 ).Append(d3).Append(", ").Append(d5).Append(", ").Append(d7).ToString());
             System.Console.Out.WriteLine((new java.lang.StringBuilder()).Append("Expected ").
                                          Append(playerEntity.posX).Append(", ").Append(playerEntity.posY).Append(", ").Append
                                              (playerEntity.posZ).ToString());
         }
         playerEntity.SetPositionAndRotation(d3, d5, d7, f2, f3);
         bool flag2 = worldserver.GetCollidingBoundingBoxes(playerEntity, playerEntity.boundingBox
                                                            .Copy().GetInsetBoundingBox(f4, f4, f4)).Count == 0;
         if (flag && (flag1 || !flag2) && !playerEntity.IsSleeping())
         {
             TeleportTo(lastPosX, lastPosY, lastPosZ, f2, f3);
             return;
         }
         net.minecraft.src.AxisAlignedBB axisalignedbb = playerEntity.boundingBox.Copy().Expand
                                                             (f4, f4, f4).AddCoord(0.0D, -0.55000000000000004D, 0.0D);
         if (!mcServer.allowFlight && !worldserver.Func_27069_b(axisalignedbb))
         {
             if (d12 >= -0.03125D)
             {
                 playerInAirTime++;
                 if (playerInAirTime > 80)
                 {
                     logger.Warning((new java.lang.StringBuilder()).Append(playerEntity.username).Append
                                        (" was kicked for floating too long!").ToString());
                     KickPlayer("Flying is not enabled on this server");
                     return;
                 }
             }
         }
         else
         {
             playerInAirTime = 0;
         }
         playerEntity.onGround = packet10flying.onGround;
         mcServer.serverConfigurationManager.Func_613_b(playerEntity);
         playerEntity.HandleFalling(playerEntity.posY - d1, packet10flying.onGround);
     }
 }