Beispiel #1
0
 public void respawn(boolean flag, int i) {
   if (!theWorld.multiplayerWorld && !theWorld.worldProvider.canRespawnHere()) {
     usePortal();
   }
   ChunkCoordinates chunkcoordinates = null;
   ChunkCoordinates chunkcoordinates1 = null;
   boolean flag1 = true;
   if (thePlayer != null && !flag) {
     chunkcoordinates = thePlayer.getPlayerSpawnCoordinate();
     if (chunkcoordinates != null) {
       chunkcoordinates1 = EntityPlayer.func_25060_a(theWorld, chunkcoordinates);
       if (chunkcoordinates1 == null) {
         thePlayer.addChatMessage("tile.bed.notValid");
       }
     }
   }
   if (chunkcoordinates1 == null) {
     chunkcoordinates1 = theWorld.getSpawnPoint();
     flag1 = false;
   }
   net.minecraft.src.IChunkProvider ichunkprovider = theWorld.getIChunkProvider();
   if (ichunkprovider instanceof ChunkProviderLoadOrGenerate) {
     ChunkProviderLoadOrGenerate chunkproviderloadorgenerate =
         (ChunkProviderLoadOrGenerate) ichunkprovider;
     chunkproviderloadorgenerate.setCurrentChunkOver(
         chunkcoordinates1.x >> 4, chunkcoordinates1.z >> 4);
   }
   theWorld.setSpawnLocation();
   theWorld.updateEntityList();
   int j = 0;
   if (thePlayer != null) {
     j = thePlayer.entityId;
     theWorld.setEntityDead(thePlayer);
   }
   renderViewEntity = null;
   thePlayer = (EntityPlayerSP) playerController.createPlayer(theWorld);
   thePlayer.dimension = i;
   renderViewEntity = thePlayer;
   thePlayer.preparePlayerToSpawn();
   if (flag1) {
     thePlayer.setPlayerSpawnCoordinate(chunkcoordinates);
     thePlayer.setLocationAndAngles(
         (float) chunkcoordinates1.x + 0.5F,
         (float) chunkcoordinates1.y + 0.1F,
         (float) chunkcoordinates1.z + 0.5F,
         0.0F,
         0.0F);
   }
   playerController.flipPlayer(thePlayer);
   theWorld.spawnPlayerWithLoadedChunks(thePlayer);
   thePlayer.movementInput = new MovementInputFromOptions(gameSettings);
   thePlayer.entityId = j;
   thePlayer.func_6420_o();
   playerController.func_6473_b(thePlayer);
   func_6255_d("Respawning");
   if (currentScreen instanceof GuiGameOver) {
     displayGuiScreen(null);
   }
 }
Beispiel #2
0
 public void changeWorld(World world, String s, EntityPlayer entityplayer) {
   statFileWriter.func_27175_b();
   statFileWriter.syncStats();
   renderViewEntity = null;
   loadingScreen.printText(s);
   loadingScreen.displayLoadingString("");
   sndManager.playStreaming(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
   if (theWorld != null) {
     theWorld.saveWorldIndirectly(loadingScreen);
   }
   theWorld = world;
   if (world != null) {
     playerController.func_717_a(world);
     if (!isMultiplayerWorld()) {
       if (entityplayer == null) {
         thePlayer = (EntityPlayerSP) world.func_4085_a(net.minecraft.src.EntityPlayerSP.class);
       }
     } else if (thePlayer != null) {
       thePlayer.preparePlayerToSpawn();
       if (world != null) {
         world.entityJoinedWorld(thePlayer);
       }
     }
     if (!world.multiplayerWorld) {
       func_6255_d(s);
     }
     if (thePlayer == null) {
       thePlayer = (EntityPlayerSP) playerController.createPlayer(world);
       thePlayer.preparePlayerToSpawn();
       playerController.flipPlayer(thePlayer);
     }
     thePlayer.movementInput = new MovementInputFromOptions(gameSettings);
     if (renderGlobal != null) {
       renderGlobal.changeWorld(world);
     }
     if (effectRenderer != null) {
       effectRenderer.clearEffects(world);
     }
     playerController.func_6473_b(thePlayer);
     if (entityplayer != null) {
       world.emptyMethod1();
     }
     net.minecraft.src.IChunkProvider ichunkprovider = world.getIChunkProvider();
     if (ichunkprovider instanceof ChunkProviderLoadOrGenerate) {
       ChunkProviderLoadOrGenerate chunkproviderloadorgenerate =
           (ChunkProviderLoadOrGenerate) ichunkprovider;
       int i = MathHelper.floor_float((int) thePlayer.posX) >> 4;
       int j = MathHelper.floor_float((int) thePlayer.posZ) >> 4;
       chunkproviderloadorgenerate.setCurrentChunkOver(i, j);
     }
     world.spawnPlayerWithLoadedChunks(thePlayer);
     if (world.isNewWorld) {
       world.saveWorldIndirectly(loadingScreen);
     }
     renderViewEntity = thePlayer;
   } else {
     thePlayer = null;
   }
   System.gc();
   systemTime = 0L;
 }