@Override public List<WorldInfo> getWorldInfoList() { List<WorldInfo> result = Lists.newArrayList(); for (NetData.WorldInfo pbWorldInfo : info.getWorldInfoList()) { WorldInfo worldInfo = new WorldInfo(); worldInfo.setTime(pbWorldInfo.getTime()); worldInfo.setTitle(pbWorldInfo.getTitle()); result.add(worldInfo); } return result; }
public WorldProviderCoreImpl(WorldInfo info, GeneratingChunkProvider chunkProvider, Block unloadedBlock, Context context) { this(info.getTitle(), info.getCustomTitle(), info.getSeed(), info.getTime(), info.getWorldGenerator(), chunkProvider, unloadedBlock, context); }
private String getWorldText(Future<ServerInfoMessage> info) { try { List<String> codedWorldInfo = new ArrayList<>(); ServerInfoMessage serverInfoMessage = info.get(); if (serverInfoMessage == null) { return FontColor.getColored(translationSystem.translate("${engine:menu#connection-failed}"), Color.RED); } for (WorldInfo wi : serverInfoMessage.getWorldInfoList()) { float timeInDays = wi.getTime() / (float) WorldTime.DAY_LENGTH; codedWorldInfo.add(String.format("%s (%.2f days)", wi.getTitle(), timeInDays)); } return Joiner.on('\n').join(codedWorldInfo); } catch (ExecutionException | InterruptedException e) { return FontColor.getColored(translationSystem.translate("${engine:menu#connection-failed}"), Color.RED); } }
@Override public WorldInfo getWorldInfo() { return new WorldInfo(title, customTitle, seed, worldTime.getMilliseconds(), worldGenerator); }
WorldInfo worldInfo = new WorldInfo(TerasologyConstants.MAIN_WORLD, targetWorldName, seed, (long) (WorldTime.DAY_LENGTH * WorldTime.NOON_OFFSET), uri); config.getUniverseConfig().setSpawnWorldTitle(worldInfo.getTitle()); config.getUniverseConfig().setUniverseSeed(universeWrapper.getSeed()); return gameManifest;
if (worldInfo.getSeed() == null || worldInfo.getSeed().isEmpty()) { FastRandom random = new FastRandom(); worldInfo.setSeed(random.nextString(16)); logger.info("World seed: \"{}\"", worldInfo.getSeed()); WorldGenerator worldGenerator; try { worldGenerator = WorldGeneratorManager.createGenerator(worldInfo.getWorldGenerator(), context); worldGenerator.setWorldSeed(worldInfo.getSeed()); context.put(WorldGenerator.class, worldGenerator); } catch (UnresolvedWorldGeneratorException e) { logger.error("Unable to load world generator {}. Available world generators: {}", worldInfo.getWorldGenerator(), worldGeneratorManager.getWorldGenerators()); context.get(GameEngine.class).changeState(new StateMainMenu("Failed to resolve world generator.")); return true; // We need to return true, otherwise the loading state will just call us again immediately
void updateDescription(final GameInfo gameInfo) { if (gameInfo == null) { worldGenerator.setText(""); moduleNames.setText(""); loadPreviewImages(null); return; } final String mainWorldGenerator = gameInfo.getManifest() .getWorldInfo(TerasologyConstants.MAIN_WORLD) .getWorldGenerator() .getObjectName() .toString(); final String commaSeparatedModules = gameInfo.getManifest() .getModules() .stream() .map(NameVersion::getName) .map(Name::toString) .sorted(String::compareToIgnoreCase) .collect(Collectors.joining(", ")); worldGenerator.setText(mainWorldGenerator); moduleNames.setText(commaSeparatedModules.length() > MODULES_LINE_LIMIT ? commaSeparatedModules.substring(0, MODULES_LINE_LIMIT) + "..." : commaSeparatedModules); loadPreviewImages(gameInfo); }
@Override public void draw(WorldInfo value, Canvas canvas) { canvas.drawText(value.getCustomTitle()); }
@Override protected void setupWorldProvider() { WorldProvider worldProvider = mock(WorldProvider.class); when(worldProvider.getWorldInfo()).thenReturn(new WorldInfo()); when(worldProvider.getTime()).thenReturn(WORLD_TIME); context.put(WorldProvider.class, worldProvider); }
public void addWorld(WorldInfo worldInfo) { this.worlds.put(worldInfo.getTitle(), worldInfo); }
private String getGeneralInfo(final GameInfo gameInfo) { return translationSystem.translate("${engine:menu#game-details-game-title} ") + gameInfo.getManifest().getTitle() + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-last-play}: ") + dateFormat.format(gameInfo.getTimestamp()) + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-game-duration} ") + DateTimeHelper .getDeltaBetweenTimestamps(new Date(0).getTime(), gameInfo.getManifest().getTime()) + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-game-seed} ") + gameInfo.getManifest().getSeed() + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-world-generator}: ") + '\t' + gameInfo.getManifest().getWorldInfo(TerasologyConstants.MAIN_WORLD).getWorldGenerator().getObjectName().toString(); }
@Override public Vector2i getPreferredSize(WorldInfo value, Canvas canvas) { String text = value.getCustomTitle(); return new Vector2i(canvas.getCurrentStyle().getFont().getWidth(text), canvas.getCurrentStyle().getFont().getLineHeight()); } });
private String getWorldDescription(final WorldInfo worldInfo) { return translationSystem.translate("${engine:menu#game-details-game-title} ") + worldInfo.getCustomTitle() + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-game-seed} ") + worldInfo.getSeed() + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-world-generator}: ") + worldInfo.getWorldGenerator().toString() + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-game-duration} ") + DateTimeHelper.getDeltaBetweenTimestamps(new Date(0).getTime(), worldInfo.getTime()); }
context.put(BiomeManager.class, mockBiomeManager); WorldProvider worldProvider = mock(WorldProvider.class); when(worldProvider.getWorldInfo()).thenReturn(new WorldInfo()); context.put(WorldProvider.class, worldProvider);
@Command(shortDescription = "Make new entity in a given pool", runOnServer = true) public String makeEntity(@CommandParam("The world in which the entity is formed") String worldName) { for (Map.Entry<WorldInfo, EngineEntityPool> entry : entityManager.getWorldPoolsMap().entrySet()) { if (entry.getKey().getTitle().equalsIgnoreCase(worldName)) { EntityRef entityRef = entry.getValue().create(); return "Entity created in " + entry.getKey().getTitle() + " world with id " + entityRef.getId(); } } return worldName + " does not exist"; }
i++; uri = world.getWorldGeneratorInfo().getUri(); worldInfo = new WorldInfo(TerasologyConstants.MAIN_WORLD + i, world.getWorldName().toString(), world.getWorldGenerator().getWorldSeed(), (long) (WorldTime.DAY_LENGTH * WorldTime.NOON_OFFSET), uri); gameManifest.addWorld(worldInfo);
@Command(shortDescription = "Get information about different worlds and " + "entities present in each pool", runOnServer = true) public String getUniverseInfo() { int worldCount = entityManager.getWorldPools().size(); StringBuilder message = new StringBuilder(); message.append("Number of worlds is " + worldCount + "\n"); Map<EngineEntityPool, Long> poolCounts = entityManager.getPoolCounts(); for (Map.Entry<WorldInfo, EngineEntityPool> entry : entityManager.getWorldPoolsMap().entrySet()) { message.append("Pool for " + entry.getKey().getTitle() + " has " + entry.getValue().getActiveEntityCount() + " entities \n"); } return message.toString(); }
WorldInfo worldInfo = new WorldInfo(TerasologyConstants.MAIN_WORLD, worldGenConfig.getWorldTitle(), gameManifest.getSeed(), (long) (WorldTime.DAY_LENGTH * WorldTime.NOON_OFFSET), worldGeneratorUri); gameManifest.addWorld(worldInfo);
@Command(shortDescription = "Moves the last created entity to another pool ", runOnServer = true) public String moveEntity(@CommandParam("The world in which the entity is formed") String worldName, @CommandParam("Id of the entity to be moved") int id) { for (Map.Entry<WorldInfo, EngineEntityPool> entry : entityManager.getWorldPoolsMap().entrySet()) { if (entry.getKey().getTitle().equalsIgnoreCase(worldName)) { if (entityManager.moveToPool(id, entry.getValue())) { return "Entity " + id + " moved to " + entry.getKey().getTitle() + "world"; } else { return "Entity" + id + "could not be moved"; } } } return worldName + " does not exist"; }