use of net.minecraft.resources.ResourceLocation in project SpongeCommon by SpongePowered.
the class SpongeBiomeProviderFactory method layered.
@Override
public <T extends LayeredBiomeConfig> ConfigurableBiomeProvider<T> layered(final T config) {
final WritableRegistry<net.minecraft.world.level.biome.Biome> biomeRegistry = BootstrapProperties.registries.registryOrThrow(Registry.BIOME_REGISTRY);
final OverworldBiomeSource layeredBiomeProvider = new OverworldBiomeSource(config.seed(), config.largeBiomes(), false, biomeRegistry);
final List<net.minecraft.world.level.biome.Biome> biomes = new ArrayList<>();
for (final RegistryReference<Biome> biome : config.biomes()) {
biomes.add(biomeRegistry.get((ResourceLocation) (Object) biome.location()));
}
((BiomeSourceAccessor) layeredBiomeProvider).accessor$possibleBiomes(biomes);
return (ConfigurableBiomeProvider<T>) layeredBiomeProvider;
}
use of net.minecraft.resources.ResourceLocation in project SpongeCommon by SpongePowered.
the class DimensionTypeMixin_API method context.
@Override
public Context context() {
if (this.api$context == null) {
final ResourceLocation key = SpongeCommon.server().registryAccess().dimensionTypes().getKey((DimensionType) (Object) this);
this.api$context = new Context(Context.DIMENSION_KEY, key.getPath());
}
return this.api$context;
}
use of net.minecraft.resources.ResourceLocation in project SpongeCommon by SpongePowered.
the class RegistryBackedTrackableBridge method bridge$refreshTrackerStates.
default void bridge$refreshTrackerStates() {
final ResourceLocation key = this.bridge$trackerRegistryBacking().getKey((T) (Object) this);
final String namespace = key.getNamespace();
final String path = key.getPath();
final NamespacedCategory namespacedCategory = this.bridge$trackerCategory().namespacedOrCreate(namespace);
final NamespacedCategory.ValueCategory valueCategory = namespacedCategory.valueOrCreate(path);
if (!namespacedCategory.enabled()) {
this.bridge$setAllowsBlockBulkCaptures(false);
this.bridge$setAllowsBlockEventCreation(false);
this.bridge$setAllowsEntityBulkCaptures(false);
this.bridge$setAllowsEntityEventCreation(false);
valueCategory.setAllowBlockEvents(false);
valueCategory.setAllowEntityEvents(false);
valueCategory.setCaptureBlocksInBulk(false);
valueCategory.setCaptureEntitiesInBulk(false);
} else {
this.bridge$setAllowsBlockEventCreation(valueCategory.allowsBlockEvents());
this.bridge$setAllowsEntityEventCreation(valueCategory.allowsEntityEvents());
this.bridge$setAllowsBlockBulkCaptures(valueCategory.capturesBlocksInBulk());
this.bridge$setAllowsEntityBulkCaptures(valueCategory.capturesEntitiesInBulk());
}
if (namespacedCategory.enabled() && this.bridge$trackerCategory().autoPopulate()) {
this.bridge$saveTrackerConfig();
}
}
use of net.minecraft.resources.ResourceLocation in project SpongeCommon by SpongePowered.
the class SpongeWorldManager method templateKeys.
@Override
public List<ResourceKey> templateKeys() {
final List<ResourceKey> templateKeys = new ArrayList<>();
// Treat Vanilla ones as template keys
templateKeys.add(WorldTypes.OVERWORLD.location());
templateKeys.add(WorldTypes.THE_NETHER.location());
templateKeys.add(WorldTypes.THE_END.location());
try (final Stream<Path> pluginDirectories = Files.walk(this.getDimensionDataPackDirectory(), 1)) {
pluginDirectories.filter(Files::isDirectory).forEach(pluginDirectory -> {
final Path dimensionPath = pluginDirectory.resolve("dimension");
if (Files.isDirectory(dimensionPath)) {
try (final Stream<Path> pluginTemplates = Files.walk(dimensionPath, 1)) {
pluginTemplates.filter(template -> template.toString().endsWith(".json")).forEach(template -> templateKeys.add((ResourceKey) (Object) new ResourceLocation(pluginDirectory.getFileName().toString(), FilenameUtils.removeExtension(template.getFileName().toString()))));
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
});
} catch (final IOException e) {
throw new RuntimeException(e);
}
return templateKeys;
}
use of net.minecraft.resources.ResourceLocation in project SpongeCommon by SpongePowered.
the class ConfigTeleportHelperFilter method updateCacheIfNecessary.
private static void updateCacheIfNecessary() {
if (ConfigTeleportHelperFilter.floorBlockTypes == null) {
final TeleportHelperCategory teleportHelperCat = SpongeConfigs.getCommon().get().teleportHelper;
ConfigTeleportHelperFilter.floorBlockTypes = teleportHelperCat.unsafeFloorBlocks.stream().map(x -> ResourceKey.resolve(x.toLowerCase(Locale.ENGLISH))).map(x -> (BlockType) Registry.BLOCK.get((ResourceLocation) (Object) x)).filter(Objects::nonNull).collect(Collectors.toList());
ConfigTeleportHelperFilter.floorBlockStates = teleportHelperCat.unsafeFloorBlocks.stream().map(x -> ResourceKey.resolve(x.toLowerCase(Locale.ENGLISH))).map(x -> Registry.BLOCK.getOptional((ResourceLocation) (Object) x).map(b -> (BlockType) b).map(StateContainer::defaultState).orElse(null)).filter(Objects::nonNull).collect(Collectors.toList());
ConfigTeleportHelperFilter.bodyBlockTypes = teleportHelperCat.unsafeBlockBlocks.stream().map(x -> ResourceKey.resolve(x.toLowerCase(Locale.ENGLISH))).map(x -> (BlockType) Registry.BLOCK.get((ResourceLocation) (Object) x)).filter(Objects::nonNull).collect(Collectors.toList());
ConfigTeleportHelperFilter.bodyBlockStates = teleportHelperCat.unsafeBlockBlocks.stream().map(x -> ResourceKey.resolve(x.toLowerCase(Locale.ENGLISH))).map(x -> Registry.BLOCK.getOptional((ResourceLocation) (Object) x).map(b -> (BlockType) b).map(StateContainer::defaultState).orElse(null)).filter(Objects::nonNull).collect(Collectors.toList());
}
}
Aggregations