Search in sources :

Example 1 with TeleportHelperCategory

use of org.spongepowered.common.applaunch.config.common.TeleportHelperCategory 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());
    }
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) NonNull(org.checkerframework.checker.nullness.qual.NonNull) StateContainer(org.spongepowered.api.state.StateContainer) Collectors(java.util.stream.Collectors) BlockState(org.spongepowered.api.block.BlockState) TeleportHelperFilter(org.spongepowered.api.world.teleport.TeleportHelperFilter) Objects(java.util.Objects) Registry(net.minecraft.core.Registry) List(java.util.List) Locale(java.util.Locale) BlockType(org.spongepowered.api.block.BlockType) SpongeConfigs(org.spongepowered.common.applaunch.config.core.SpongeConfigs) ResourceKey(org.spongepowered.api.ResourceKey) TeleportHelperCategory(org.spongepowered.common.applaunch.config.common.TeleportHelperCategory) Nullable(org.checkerframework.checker.nullness.qual.Nullable) TeleportHelperCategory(org.spongepowered.common.applaunch.config.common.TeleportHelperCategory) BlockType(org.spongepowered.api.block.BlockType) ResourceLocation(net.minecraft.resources.ResourceLocation) Objects(java.util.Objects)

Aggregations

List (java.util.List)1 Locale (java.util.Locale)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 Registry (net.minecraft.core.Registry)1 ResourceLocation (net.minecraft.resources.ResourceLocation)1 NonNull (org.checkerframework.checker.nullness.qual.NonNull)1 Nullable (org.checkerframework.checker.nullness.qual.Nullable)1 ResourceKey (org.spongepowered.api.ResourceKey)1 BlockState (org.spongepowered.api.block.BlockState)1 BlockType (org.spongepowered.api.block.BlockType)1 StateContainer (org.spongepowered.api.state.StateContainer)1 TeleportHelperFilter (org.spongepowered.api.world.teleport.TeleportHelperFilter)1 TeleportHelperCategory (org.spongepowered.common.applaunch.config.common.TeleportHelperCategory)1 SpongeConfigs (org.spongepowered.common.applaunch.config.core.SpongeConfigs)1