use of org.terasology.gestalt.naming.Name in project Terasology by MovingBlocks.
the class UniverseSetupScreen method findIndex.
/**
* Looks for the index of a selected world from the given list.
* @param worldsList the list to search
* @param worldName the name of the world to find
* @return the found index value or -1 if not found
*/
private int findIndex(List<WorldSetupWrapper> worldsList, String worldName) {
for (int i = 0; i < worldsList.size(); i++) {
WorldSetupWrapper currentWorldFromList = worldsList.get(i);
Name customName = currentWorldFromList.getWorldName();
if (customName.toString().equals(worldName)) {
return i;
}
}
return -1;
}
use of org.terasology.gestalt.naming.Name in project Terasology by MovingBlocks.
the class NewGameScreen method getGameplayModules.
private List<Module> getGameplayModules() {
List<Module> gameplayModules = Lists.newArrayList();
for (Name moduleId : moduleManager.getRegistry().getModuleIds()) {
Module latestVersion = moduleManager.getRegistry().getLatestModuleVersion(moduleId);
if (StandardModuleExtension.isGameplayModule(latestVersion)) {
gameplayModules.add(latestVersion);
}
}
gameplayModules.sort(Comparator.comparing(o -> o.getMetadata().getDisplayName().value()));
return gameplayModules;
}
use of org.terasology.gestalt.naming.Name in project Terasology by MovingBlocks.
the class SelectionScreen method updateDescription.
void updateDescription(final GameInfo gameInfo) {
if (gameInfo == null) {
worldGenerator.setText("");
moduleNames.setText("");
loadPreviewImages(null);
return;
}
final WorldGeneratorInfo wgi = worldGeneratorManager.getWorldGeneratorInfo(gameInfo.getManifest().getWorldInfo(TerasologyConstants.MAIN_WORLD).getWorldGenerator());
String mainWorldGenerator = "ERROR: world generator ";
if (wgi != null) {
mainWorldGenerator = wgi.getDisplayName();
} else {
mainWorldGenerator = mainWorldGenerator + gameInfo.getManifest().getWorldInfo(TerasologyConstants.MAIN_WORLD).getWorldGenerator().toString() + " not found";
}
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);
}
use of org.terasology.gestalt.naming.Name in project Terasology by MovingBlocks.
the class ReflectionUtil method getSimpleUriFor.
/**
* Returns the {@link SimpleUri} for a type belonging to the {@link ModuleEnvironment}.
* If the type does not belong to the module environment, null is returned.
*/
public static SimpleUri getSimpleUriFor(Type type, ModuleEnvironment environment) {
Class<?> clazz = getRawType(type);
if (clazz.getClassLoader() == null) {
// Loaded with the bootstrap class loader, definitely not part of a module
return null;
}
Name moduleProviding = environment.getModuleProviding(clazz);
if (moduleProviding == null) {
return null;
}
return new SimpleUri(moduleProviding, clazz.getSimpleName());
}
use of org.terasology.gestalt.naming.Name in project Terasology by MovingBlocks.
the class CeilingSupportingHorizontalFamily method populateBlockMaps.
/**
* Populates the map with all 8 rotations of the block that are possible.
* <p>
* These are all four 90 degree rotations about the Y-axis (YAW) for each case where the TOP side is
* - facing upwards
* - facing downwards
*
* @param blockBuilder The block builder to use to produce blocks
* @param shape The shape the block should be made in
* @param definition The definition for the family
* @param uri The base URI for the block
*/
private void populateBlockMaps(BlockBuilderHelper blockBuilder, BlockShape shape, BlockFamilyDefinition definition, BlockUri uri) {
for (Rotation rotation : Rotation.horizontalRotations()) {
Side horizontalSide = rotation.rotate(Side.FRONT);
ExtendedSide extendedSideTop = ExtendedSide.getExtendedSideFor(Side.TOP, horizontalSide);
blocks.put(extendedSideTop, transformBlock(blockBuilder, shape, definition, new BlockUri(uri, new Name(extendedSideTop.name())), rotation, extendedSideTop));
ExtendedSide extendedSideBottom = ExtendedSide.getExtendedSideFor(Side.BOTTOM, horizontalSide);
Yaw yaw = Rotation.horizontalRotations().get((rotation.getYaw().getIndex() + 2) % 4).getYaw();
blocks.put(extendedSideBottom, transformBlock(blockBuilder, shape, definition, new BlockUri(uri, new Name(extendedSideBottom.name())), Rotation.rotate(yaw, Pitch.CLOCKWISE_180, Roll.NONE), extendedSideBottom));
}
}
Aggregations