/** * Updates the time and weather for the given player to those of the given world */ public void updateTimeAndWeatherForPlayer(EntityPlayerMP playerIn, WorldServer worldIn) { WorldBorder worldborder = this.mcServer.worldServers[0].getWorldBorder(); playerIn.connection.sendPacket(new SPacketWorldBorder(worldborder, SPacketWorldBorder.Action.INITIALIZE)); playerIn.connection.sendPacket(new SPacketTimeUpdate(worldIn.getTotalWorldTime(), worldIn.getWorldTime(), worldIn.getGameRules().getBoolean("doDaylightCycle"))); BlockPos blockpos = worldIn.getSpawnPoint(); playerIn.connection.sendPacket(new SPacketSpawnPosition(blockpos)); if (worldIn.isRaining()) { playerIn.connection.sendPacket(new SPacketChangeGameState(1, 0.0F)); playerIn.connection.sendPacket(new SPacketChangeGameState(7, worldIn.getRainStrength(1.0F))); playerIn.connection.sendPacket(new SPacketChangeGameState(8, worldIn.getThunderStrength(1.0F))); } }
/** * Callback for when the command is executed */ public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { BlockPos blockpos; if (args.length == 0) { blockpos = getCommandSenderAsPlayer(sender).getPosition(); } else { if (args.length != 3 || sender.getEntityWorld() == null) { throw new WrongUsageException("commands.setworldspawn.usage", new Object[0]); } blockpos = parseBlockPos(sender, args, 0, true); } sender.getEntityWorld().setSpawnPoint(blockpos); server.getPlayerList().sendPacketToAllPlayers(new SPacketSpawnPosition(blockpos)); notifyCommandListener(sender, this, "commands.setworldspawn.success", new Object[] {Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())}); }
private static void transferPlayerToDimension(PlayerList playerList, net.minecraft.entity.player.EntityPlayerMP player, int dimension, Teleporter teleporter) { int i = player.dimension; WorldServer worldserver = playerList.getServerInstance().getWorld(player.dimension); player.dimension = dimension; WorldServer worldserver1 = playerList.getServerInstance().getWorld(player.dimension); player.connection.sendPacket(new SPacketRespawn(player.dimension, worldserver1.getDifficulty(), worldserver1.getWorldInfo().getTerrainType(), player.interactionManager.getGameType())); //MoreCommands Bug fix: client world has wrong spawn position, because WorldClient is recreated after receiving S07PacketRespawn //with default spawn coordinates 8, 64, 8. This causes e.g. the compass to point to a wrong direction. A possible solution is sending a S05PacketSpawnPosition. //Fixes https://bugs.mojang.com/browse/MC-679 player.connection.sendPacket(new SPacketSpawnPosition(new BlockPos(worldserver1.getWorldInfo().getSpawnX(), worldserver1.getWorldInfo().getSpawnY(), worldserver1.getWorldInfo().getSpawnZ()))); playerList.updatePermissionLevel(player); worldserver.removeEntityDangerously(player); player.isDead = false; playerList.transferEntityToWorld(player, i, worldserver, worldserver1, teleporter); playerList.preparePlayer(player, worldserver); player.connection.setPlayerLocation(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch); player.interactionManager.setWorld(worldserver1); player.connection.sendPacket(new SPacketPlayerAbilities(player.capabilities)); playerList.updateTimeAndWeatherForPlayer(player, worldserver1); playerList.syncPlayerInventory(player); for (PotionEffect potioneffect : player.getActivePotionEffects()) { player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potioneffect)); } net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, i, dimension); }
public void handleSpawnPosition(SPacketSpawnPosition packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); this.gameController.player.setSpawnPoint(packetIn.getSpawnPos(), true); this.gameController.world.getWorldInfo().setSpawn(packetIn.getSpawnPos()); }
public void handleSpawnPosition(SPacketSpawnPosition packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); this.gameController.thePlayer.setSpawnPoint(packetIn.getSpawnPos(), true); this.gameController.theWorld.getWorldInfo().setSpawn(packetIn.getSpawnPos()); }
void handleSpawnPosition(SPacketSpawnPosition packetIn);