/** * Set the initial values of a new world to create, from the values from an existing world. * * Called after construction when a user selects the "Recreate" button. */ public void recreateFromExistingWorld(WorldInfo original) { this.worldName = I18n.format("selectWorld.newWorld.copyOf", new Object[] {original.getWorldName()}); this.worldSeed = original.getSeed() + ""; this.selectedIndex = original.getTerrainType().getWorldTypeID(); this.chunkProviderSettingsJson = original.getGeneratorOptions(); this.generateStructuresEnabled = original.isMapFeaturesEnabled(); this.allowCheats = original.areCommandsAllowed(); if (original.isHardcoreModeEnabled()) { this.gameMode = "hardcore"; } else if (original.getGameType().isSurvivalOrAdventure()) { this.gameMode = "survival"; } else if (original.getGameType().isCreative()) { this.gameMode = "creative"; } }
public WorldServer(MinecraftServer server, ISaveHandler saveHandlerIn, WorldInfo info, int dimensionId, Profiler profilerIn) { super(saveHandlerIn, info, net.minecraftforge.common.DimensionManager.createProviderFor(dimensionId), profilerIn, false); this.mcServer = server; this.theEntityTracker = new EntityTracker(this); this.thePlayerManager = new PlayerChunkMap(this); // Guarantee the dimension ID was not reset by the provider int providerDim = this.provider.getDimension(); this.provider.registerWorld(this); this.provider.setDimension(providerDim); this.chunkProvider = this.createChunkProvider(); perWorldStorage = new MapStorage(new net.minecraftforge.common.WorldSpecificSaveHandler((WorldServer)this, saveHandlerIn)); this.worldTeleporter = new Teleporter(this); this.calculateInitialSkylight(); this.calculateInitialWeather(); this.getWorldBorder().setSize(server.getMaxWorldSize()); net.minecraftforge.common.DimensionManager.setWorld(dimensionId, this, mcServer); }
/** * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the * window resizes, the buttonList is cleared beforehand. */ public void initGui() { Keyboard.enableRepeatEvents(true); this.buttonList.clear(); GuiButton guibutton = this.addButton(new GuiButton(3, this.width / 2 - 100, this.height / 4 + 24 + 12, I18n.format("selectWorld.edit.resetIcon", new Object[0]))); this.buttonList.add(new GuiButton(4, this.width / 2 - 100, this.height / 4 + 48 + 12, I18n.format("selectWorld.edit.openFolder", new Object[0]))); this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, I18n.format("selectWorld.edit.save", new Object[0]))); this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("gui.cancel", new Object[0]))); guibutton.enabled = this.mc.getSaveLoader().getFile(this.worldId, "icon.png").isFile(); ISaveFormat isaveformat = this.mc.getSaveLoader(); WorldInfo worldinfo = isaveformat.getWorldInfo(this.worldId); String s = worldinfo.getWorldName(); this.nameEdit = new GuiTextField(2, this.fontRendererObj, this.width / 2 - 100, 60, 200, 20); this.nameEdit.setFocused(true); this.nameEdit.setText(s); }
public void func_146318_a(WorldInfo p_146318_1_) { this.field_146330_J = I18n.format("selectWorld.newWorld.copyOf", new Object[] {p_146318_1_.getWorldName()}); this.field_146329_I = p_146318_1_.getSeed() + ""; this.selectedIndex = p_146318_1_.getTerrainType().getWorldTypeID(); this.chunkProviderSettingsJson = p_146318_1_.getGeneratorOptions(); this.field_146341_s = p_146318_1_.isMapFeaturesEnabled(); this.allowCheats = p_146318_1_.areCommandsAllowed(); if (p_146318_1_.isHardcoreModeEnabled()) { this.gameMode = "hardcore"; } else if (p_146318_1_.getGameType().isSurvivalOrAdventure()) { this.gameMode = "survival"; } else if (p_146318_1_.getGameType().isCreative()) { this.gameMode = "creative"; } }
public WorldClient(NetHandlerPlayClient netHandler, WorldSettings settings, int dimension, EnumDifficulty difficulty, Profiler profilerIn) { super(new SaveHandlerMP(), new WorldInfo(settings, "MpServer"), net.minecraftforge.common.DimensionManager.createProviderFor(dimension), profilerIn, true); this.ambienceTicks = this.rand.nextInt(12000); this.viewableChunks = Sets.<ChunkPos>newHashSet(); this.connection = netHandler; this.getWorldInfo().setDifficulty(difficulty); this.provider.registerWorld(this); this.setSpawnPoint(new BlockPos(8, 64, 8)); //Forge: Moved below registerWorld to prevent NPE in our redirect. this.chunkProvider = this.createChunkProvider(); this.mapStorage = new SaveDataMemoryStorage(); this.calculateInitialSkylight(); this.calculateInitialWeather(); this.initCapabilities(); net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(this)); }
public static void setMissionWeather(MissionInit minit) { ServerSection ss = minit.getMission().getServerSection(); ServerInitialConditions sic = (ss != null) ? ss.getServerInitialConditions() : null; if (sic != null && sic.getWeather() != null && !sic.getWeather().equalsIgnoreCase("normal")) { int maxtime = 1000000 * 20; // Max allowed by Minecraft's own Weather Command. int cleartime = (sic.getWeather().equalsIgnoreCase("clear")) ? maxtime : 0; int raintime = (sic.getWeather().equalsIgnoreCase("rain")) ? maxtime : 0; int thundertime = (sic.getWeather().equalsIgnoreCase("thunder")) ? maxtime : 0; WorldServer worldserver = MinecraftServer.getServer().worldServers[0]; WorldInfo worldinfo = worldserver.getWorldInfo(); worldinfo.setCleanWeatherTime(cleartime); worldinfo.setRainTime(raintime); worldinfo.setThunderTime(thundertime); worldinfo.setRaining(raintime + thundertime > 0); worldinfo.setThundering(thundertime > 0); } }
public WorldClient(NetHandlerPlayClient netHandler, WorldSettings settings, int dimension, EnumDifficulty difficulty, Profiler profilerIn) { super(new SaveHandlerMP(), new WorldInfo(settings, "MpServer"), makeWorldProvider(dimension), profilerIn, true); this.ambienceTicks = this.rand.nextInt(12000); this.viewableChunks = Sets.<ChunkPos>newHashSet(); this.connection = netHandler; this.getWorldInfo().setDifficulty(difficulty); this.provider.registerWorld(this); this.setSpawnPoint(new BlockPos(8, 64, 8)); this.chunkProvider = this.createChunkProvider(); this.mapStorage = new SaveDataMemoryStorage(); this.calculateInitialSkylight(); this.calculateInitialWeather(); Reflector.call(this, Reflector.ForgeWorld_initCapabilities, new Object[0]); Reflector.postForgeBusEvent(Reflector.WorldEvent_Load_Constructor, new Object[] {this}); if (this.mc.playerController != null && this.mc.playerController.getClass() == PlayerControllerMP.class) { this.mc.playerController = new PlayerControllerOF(this.mc, netHandler); } }
/** * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the * window resizes, the buttonList is cleared beforehand. */ public void initGui() { Keyboard.enableRepeatEvents(true); this.buttonList.clear(); GuiButton guibutton = this.addButton(new GuiButton(3, this.width / 2 - 100, this.height / 4 + 24 + 12, I18n.format("selectWorld.edit.resetIcon", new Object[0]))); this.buttonList.add(new GuiButton(4, this.width / 2 - 100, this.height / 4 + 48 + 12, I18n.format("selectWorld.edit.openFolder", new Object[0]))); this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, I18n.format("selectWorld.edit.save", new Object[0]))); this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("gui.cancel", new Object[0]))); guibutton.enabled = this.mc.getSaveLoader().getFile(this.worldId, "icon.png").isFile(); ISaveFormat isaveformat = this.mc.getSaveLoader(); WorldInfo worldinfo = isaveformat.getWorldInfo(this.worldId); String s = worldinfo == null ? "" : worldinfo.getWorldName(); this.nameEdit = new GuiTextField(2, this.fontRendererObj, this.width / 2 - 100, 60, 200, 20); this.nameEdit.setFocused(true); this.nameEdit.setText(s); }
protected World(ISaveHandler saveHandlerIn, WorldInfo info, WorldProvider providerIn, Profiler profilerIn, boolean client) { this.ambientTickCountdown = this.rand.nextInt(12000); this.spawnHostileMobs = true; this.spawnPeacefulMobs = true; this.lightUpdateBlockList = new int[32768]; this.saveHandler = saveHandlerIn; this.theProfiler = profilerIn; this.worldInfo = info; this.provider = providerIn; this.isRemote = client; this.worldBorder = providerIn.getWorldBorder(); }
@SideOnly(Side.CLIENT) public List<WorldSummary> getSaveList() throws AnvilConverterException { if (this.savesDirectory != null && this.savesDirectory.exists() && this.savesDirectory.isDirectory()) { List<WorldSummary> list = Lists.<WorldSummary>newArrayList(); File[] afile = this.savesDirectory.listFiles(); for (File file1 : afile) { if (file1.isDirectory()) { String s = file1.getName(); WorldInfo worldinfo = this.getWorldInfo(s); if (worldinfo != null && (worldinfo.getSaveVersion() == 19132 || worldinfo.getSaveVersion() == 19133)) { boolean flag = worldinfo.getSaveVersion() != this.getSaveVersion(); String s1 = worldinfo.getWorldName(); if (StringUtils.isEmpty(s1)) { s1 = s; } long i = 0L; list.add(new WorldSummary(worldinfo, s, s1, 0L, flag)); } } } return list; } else { throw new AnvilConverterException("Unable to read or access folder where game worlds are saved!"); } }
@Override public NBTTagCompound getDataForWriting(SaveHandler handler, WorldInfo info) { NBTTagCompound forgeData = new NBTTagCompound(); NBTTagCompound dimData = DimensionManager.saveDimensionDataMap(); forgeData.setTag("DimensionData", dimData); FluidRegistry.writeDefaultFluidList(forgeData); return forgeData; }
public WorldServer(MinecraftServer server, ISaveHandler saveHandlerIn, WorldInfo info, int dimensionId, Profiler profilerIn) { super(saveHandlerIn, info, WorldProvider.getProviderForDimension(dimensionId), profilerIn, false); this.mcServer = server; this.theEntityTracker = new EntityTracker(this); this.thePlayerManager = new PlayerManager(this); this.provider.registerWorld(this); this.chunkProvider = this.createChunkProvider(); this.worldTeleporter = new Teleporter(this); this.calculateInitialSkylight(); this.calculateInitialWeather(); this.getWorldBorder().setSize(server.getMaxWorldSize()); }
public WorldClient(NetHandlerPlayClient p_i45063_1_, WorldSettings p_i45063_2_, int p_i45063_3_, EnumDifficulty p_i45063_4_, Profiler p_i45063_5_) { super(new SaveHandlerMP(), new WorldInfo(p_i45063_2_, "MpServer"), WorldProvider.getProviderForDimension(p_i45063_3_), p_i45063_5_, true); this.sendQueue = p_i45063_1_; this.getWorldInfo().setDifficulty(p_i45063_4_); this.setSpawnPoint(new BlockPos(8, 64, 8)); this.provider.registerWorld(this); this.chunkProvider = this.createChunkProvider(); this.mapStorage = new SaveDataMemoryStorage(); this.calculateInitialSkylight(); this.calculateInitialWeather(); }
/** * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the * window resizes, the buttonList is cleared beforehand. */ public void initGui() { Keyboard.enableRepeatEvents(true); this.buttonList.clear(); this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, I18n.format("selectWorld.renameButton", new Object[0]))); this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("gui.cancel", new Object[0]))); ISaveFormat isaveformat = this.mc.getSaveLoader(); WorldInfo worldinfo = isaveformat.getWorldInfo(this.saveName); String s = worldinfo.getWorldName(); this.field_146583_f = new GuiTextField(2, this.fontRendererObj, this.width / 2 - 100, 60, 200, 20); this.field_146583_f.setFocused(true); this.field_146583_f.setText(s); }
/** * Adds Demo buttons on Main Menu for players who are playing Demo. */ private void addDemoButtons(int p_73972_1_, int p_73972_2_) { this.buttonList.add(new GuiButton(11, this.width / 2 - 100, p_73972_1_, I18n.format("menu.playdemo", new Object[0]))); this.buttonList.add(this.buttonResetDemo = new GuiButton(12, this.width / 2 - 100, p_73972_1_ + p_73972_2_ * 1, I18n.format("menu.resetdemo", new Object[0]))); ISaveFormat isaveformat = this.mc.getSaveLoader(); WorldInfo worldinfo = isaveformat.getWorldInfo("Demo_World"); if (worldinfo == null) { this.buttonResetDemo.enabled = false; } }
/** * Adds Demo buttons on Main Menu for players who are playing Demo. */ private void addDemoButtons(int p_73972_1_, int p_73972_2_) { this.buttonList.add(new GuiButton(11, this.width / 2 - 100, p_73972_1_, I18n.format("menu.playdemo", new Object[0]))); this.buttonResetDemo = this.addButton(new GuiButton(12, this.width / 2 - 100, p_73972_1_ + p_73972_2_ * 1, I18n.format("menu.resetdemo", new Object[0]))); ISaveFormat isaveformat = this.mc.getSaveLoader(); WorldInfo worldinfo = isaveformat.getWorldInfo("Demo_World"); if (worldinfo == null) { this.buttonResetDemo.enabled = false; } }
public void recreateWorld() { this.client.displayGuiScreen(new GuiScreenWorking()); GuiCreateWorld guicreateworld = new GuiCreateWorld(this.worldSelScreen); ISaveHandler isavehandler = this.client.getSaveLoader().getSaveLoader(this.worldSummary.getFileName(), false); WorldInfo worldinfo = isavehandler.loadWorldInfo(); isavehandler.flush(); guicreateworld.recreateFromExistingWorld(worldinfo); this.client.displayGuiScreen(guicreateworld); }
public List<SaveFormatComparator> getSaveList() throws AnvilConverterException { if (this.savesDirectory != null && this.savesDirectory.exists() && this.savesDirectory.isDirectory()) { List<SaveFormatComparator> list = Lists.<SaveFormatComparator>newArrayList(); File[] afile = this.savesDirectory.listFiles(); for (File file1 : afile) { if (file1.isDirectory()) { String s = file1.getName(); WorldInfo worldinfo = this.getWorldInfo(s); if (worldinfo != null && (worldinfo.getSaveVersion() == 19132 || worldinfo.getSaveVersion() == 19133)) { boolean flag = worldinfo.getSaveVersion() != this.getSaveVersion(); String s1 = worldinfo.getWorldName(); if (StringUtils.isEmpty(s1)) { s1 = s; } long i = 0L; list.add(new SaveFormatComparator(s, s1, worldinfo.getLastTimePlayed(), i, worldinfo.getGameType(), flag, worldinfo.isHardcoreModeEnabled(), worldinfo.areCommandsAllowed())); } } } return list; } else { throw new AnvilConverterException("Unable to read or access folder where game worlds are saved!"); } }
public WorldClient(NetHandlerPlayClient p_i45063_1_, WorldSettings p_i45063_2_, int p_i45063_3_, EnumDifficulty p_i45063_4_, Profiler p_i45063_5_) { super(new SaveHandlerMP(), new WorldInfo(p_i45063_2_, "MpServer"), WorldProvider.getProviderForDimension(p_i45063_3_), p_i45063_5_, true); this.sendQueue = p_i45063_1_; this.getWorldInfo().setDifficulty(p_i45063_4_); this.provider.registerWorld(this); this.setSpawnPoint(new BlockPos(8, 64, 8)); this.chunkProvider = this.createChunkProvider(); this.mapStorage = new SaveDataMemoryStorage(); this.calculateInitialSkylight(); this.calculateInitialWeather(); }
public void addServerStatsToSnooper(Snooper playerSnooper) { playerSnooper.addClientStat("whitelist_enabled", Boolean.valueOf(false)); playerSnooper.addClientStat("whitelist_count", Integer.valueOf(0)); if (this.playerList != null) { playerSnooper.addClientStat("players_current", Integer.valueOf(this.getCurrentPlayerCount())); playerSnooper.addClientStat("players_max", Integer.valueOf(this.getMaxPlayers())); playerSnooper.addClientStat("players_seen", Integer.valueOf(this.playerList.getAvailablePlayerDat().length)); } playerSnooper.addClientStat("uses_auth", Boolean.valueOf(this.onlineMode)); playerSnooper.addClientStat("gui_state", this.getGuiEnabled() ? "enabled" : "disabled"); playerSnooper.addClientStat("run_time", Long.valueOf((getCurrentTimeMillis() - playerSnooper.getMinecraftStartTimeMillis()) / 60L * 1000L)); playerSnooper.addClientStat("avg_tick_ms", Integer.valueOf((int)(MathHelper.average(this.tickTimeArray) * 1.0E-6D))); int i = 0; if (this.worldServers != null) { for (WorldServer worldserver : this.worldServers) { if (worldserver != null) { WorldInfo worldinfo = worldserver.getWorldInfo(); playerSnooper.addClientStat("world[" + i + "][dimension]", Integer.valueOf(worldserver.provider.getDimensionType().getId())); playerSnooper.addClientStat("world[" + i + "][mode]", worldinfo.getGameType()); playerSnooper.addClientStat("world[" + i + "][difficulty]", worldserver.getDifficulty()); playerSnooper.addClientStat("world[" + i + "][hardcore]", Boolean.valueOf(worldinfo.isHardcoreModeEnabled())); playerSnooper.addClientStat("world[" + i + "][generator_name]", worldinfo.getTerrainType().getWorldTypeName()); playerSnooper.addClientStat("world[" + i + "][generator_version]", Integer.valueOf(worldinfo.getTerrainType().getGeneratorVersion())); playerSnooper.addClientStat("world[" + i + "][height]", Integer.valueOf(this.buildLimit)); playerSnooper.addClientStat("world[" + i + "][chunks_loaded]", Integer.valueOf(worldserver.getChunkProvider().getLoadedChunkCount())); ++i; } } } playerSnooper.addClientStat("worlds", Integer.valueOf(i)); }
@Override public WorldInfo getWorldInfo() { if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) { return m_proxyWorld.getWorldInfo(); } else if (m_realWorld != null) { return m_realWorld.getWorldInfo(); } else { return super.getWorldInfo(); } }
public WorldServer(MinecraftServer server, ISaveHandler saveHandlerIn, WorldInfo info, int dimensionId, Profiler profilerIn) { super(saveHandlerIn, info, DimensionType.getById(dimensionId).createDimension(), profilerIn, false); this.mcServer = server; this.theEntityTracker = new EntityTracker(this); this.thePlayerManager = new PlayerChunkMap(this); this.provider.registerWorld(this); this.chunkProvider = this.createChunkProvider(); this.worldTeleporter = new Teleporter(this); this.calculateInitialSkylight(); this.calculateInitialWeather(); this.getWorldBorder().setSize(server.getMaxWorldSize()); }
protected World(ISaveHandler saveHandlerIn, WorldInfo info, WorldProvider providerIn, Profiler profilerIn, boolean client) { this.eventListeners = Lists.newArrayList(new IWorldEventListener[] {this.pathListener}); this.theCalendar = Calendar.getInstance(); this.worldScoreboard = new Scoreboard(); this.spawnHostileMobs = true; this.spawnPeacefulMobs = true; this.lightUpdateBlockList = new int[32768]; this.saveHandler = saveHandlerIn; this.theProfiler = profilerIn; this.worldInfo = info; this.provider = providerIn; this.isRemote = client; this.worldBorder = providerIn.createWorldBorder(); }
public void recreateWorld() { this.client.displayGuiScreen(new GuiScreenWorking()); GuiCreateWorld guicreateworld = new GuiCreateWorld(this.worldSelScreen); ISaveHandler isavehandler = this.client.getSaveLoader().getSaveLoader(this.worldSummary.getFileName(), false); WorldInfo worldinfo = isavehandler.loadWorldInfo(); isavehandler.flush(); if (worldinfo != null) { guicreateworld.recreateFromExistingWorld(worldinfo); this.client.displayGuiScreen(guicreateworld); } }
/** * Adds Demo buttons on Main Menu for players who are playing Demo. */ private void addDemoButtons(int p_73972_1_, int p_73972_2_) { this.buttonList .add(new GuiButton(11, this.width / 2 - 100, p_73972_1_, I18n.format("menu.playdemo", new Object[0]))); this.buttonResetDemo = this.addButton(new GuiButton(12, this.width / 2 - 100, p_73972_1_ + p_73972_2_ * 1, I18n.format("menu.resetdemo", new Object[0]))); ISaveFormat isaveformat = this.mc.getSaveLoader(); WorldInfo worldinfo = isaveformat.getWorldInfo("Demo_World"); if (worldinfo == null) { this.buttonResetDemo.enabled = false; } }
@Inject(method = "<init>", at = @At("RETURN")) public void onConstruct(MinecraftServer server, ISaveHandler saveHandlerIn, WorldInfo info, int dimensionId, Profiler profilerIn, CallbackInfo callbackInfo) { this.dimensionId = dimensionId; BlockChain chain = new BlockChain(worldInfo.getWorldName() + "," + dimensionId); chain.load(); BlockCraft.instance.blockChains.put(worldInfo.getWorldName() + "," + dimensionId, chain); }