Search in sources :

Example 1 with AcousticsManager

use of org.blockartistry.DynSurround.client.footsteps.implem.AcousticsManager in project DynamicSurroundings by OreCruncher.

the class FootstepsRegistry method init.

@Override
public void init() {
    this.acousticsManager = new AcousticsManager();
    this.primitiveMap = new PrimitiveMap(this.acousticsManager);
    this.blockMap = new BlockMap(this.acousticsManager);
    this.FOOTPRINT_MATERIAL = new IdentityHashSet<>();
    this.FOOTPRINT_STATES = new IdentityHashSet<>();
    this.ARMOR_SOUND = new EnumMap<>(ArmorClass.class);
    this.ARMOR_SOUND_FOOT = new EnumMap<>(ArmorClass.class);
    this.variators = new HashMap<>();
    // Initialize the known materials that leave footprints
    this.FOOTPRINT_MATERIAL.add(Material.CLAY);
    this.FOOTPRINT_MATERIAL.add(Material.GRASS);
    this.FOOTPRINT_MATERIAL.add(Material.GROUND);
    this.FOOTPRINT_MATERIAL.add(Material.ICE);
    this.FOOTPRINT_MATERIAL.add(Material.PACKED_ICE);
    this.FOOTPRINT_MATERIAL.add(Material.SAND);
    this.FOOTPRINT_MATERIAL.add(Material.CRAFTED_SNOW);
    this.FOOTPRINT_MATERIAL.add(Material.SNOW);
    // It's a hack - needs refactor
    AcousticsManager.SWIM = null;
    AcousticsManager.JUMP = null;
    AcousticsManager.SPLASH = null;
    final List<Pack> repo = ResourcePacks.findResourcePacks();
    reloadAcoustics(repo);
    reloadPrimitiveMap(repo);
    seedMap();
}
Also used : AcousticsManager(org.blockartistry.DynSurround.client.footsteps.implem.AcousticsManager) BlockMap(org.blockartistry.DynSurround.client.footsteps.implem.BlockMap) PrimitiveMap(org.blockartistry.DynSurround.client.footsteps.implem.PrimitiveMap) Pack(org.blockartistry.DynSurround.packs.ResourcePacks.Pack)

Example 2 with AcousticsManager

use of org.blockartistry.DynSurround.client.footsteps.implem.AcousticsManager in project DynamicSurroundings by OreCruncher.

the class FootstepsRegistry method initComplete.

@Override
public void initComplete() {
    AcousticsManager.SWIM = this.acousticsManager.compileAcoustics("_SWIM");
    AcousticsManager.JUMP = this.acousticsManager.compileAcoustics("_JUMP");
    AcousticsManager.SPLASH = new IAcoustic[] { new RainSplashAcoustic(this.acousticsManager.compileAcoustics("waterfine")) };
    final AcousticsManager am = this.acousticsManager;
    this.ARMOR_SOUND.put(ArmorClass.NONE, am.getAcoustic("NOT_EMITTER"));
    this.ARMOR_SOUND.put(ArmorClass.LIGHT, am.getAcoustic("armor_light"));
    this.ARMOR_SOUND.put(ArmorClass.MEDIUM, am.getAcoustic("armor_medium"));
    this.ARMOR_SOUND.put(ArmorClass.CRYSTAL, am.getAcoustic("armor_crystal"));
    this.ARMOR_SOUND.put(ArmorClass.HEAVY, am.getAcoustic("armor_heavy"));
    this.ARMOR_SOUND_FOOT.put(ArmorClass.NONE, am.getAcoustic("NOT_EMITTER"));
    this.ARMOR_SOUND_FOOT.put(ArmorClass.LIGHT, am.getAcoustic("armor_light"));
    this.ARMOR_SOUND_FOOT.put(ArmorClass.MEDIUM, am.getAcoustic("medium_foot"));
    this.ARMOR_SOUND_FOOT.put(ArmorClass.CRYSTAL, am.getAcoustic("crystal_foot"));
    this.ARMOR_SOUND_FOOT.put(ArmorClass.HEAVY, am.getAcoustic("heavy_foot"));
    this.childVariator = getVariator("child");
    this.playerVariator = getVariator(ModOptions.sound.firstPersonFootstepCadence ? "playerSlow" : "player");
    this.playerQuadrupedVariator = getVariator(ModOptions.sound.firstPersonFootstepCadence ? "quadrupedSlow" : "quadruped");
    // Generate a list of IBlockState objects for all blocks registered
    // with Forge.
    final Set<IBlockState> blockStates = StreamSupport.stream(ForgeRegistries.BLOCKS.spliterator(), false).map(block -> block.getBlockState().getValidStates()).flatMap(l -> l.stream()).collect(Collectors.toSet());
    // Scan the block list looking for any block states that do not have sounds
    // definitions supplied by configuration files or by primitives. This scan
    // has the side effect of priming the caches.
    final Set<IBlockState> missingAcoustics = blockStates.stream().filter(bs -> !FootstepsRegistry.this.getBlockMap().hasAcoustics(bs)).collect(Collectors.toSet());
    if (ModOptions.logging.enableDebugLogging) {
        if (missingAcoustics.size() > 0) {
            DSurround.log().info("          >>>> MISSING ACOUSTIC ENTRIES <<<< ");
            DSurround.log().info("Sounds for these states will default to their step sound");
            DSurround.log().info("========================================================");
            missingAcoustics.stream().map(IBlockState::toString).sorted().forEach(DSurround.log()::info);
        }
    }
    // Identify any IBlockStates that could have footprints associated and
    // register them if necessary.
    blockStates.stream().filter(bs -> bs.getMaterial().blocksMovement() && !this.FOOTPRINT_MATERIAL.contains(bs.getMaterial()) && !this.FOOTPRINT_STATES.contains(bs)).filter(bs -> {
        final SoundType sound = MCHelper.getSoundType(bs);
        if (sound != null) {
            final SoundEvent event = sound.getStepSound();
            if (event != null) {
                final ResourceLocation resource = event.getSoundName();
                if (resource != null) {
                    final String soundName = resource.toString();
                    return FOOTPRINT_SOUND_PROFILE.contains(soundName);
                }
            }
        }
        return false;
    }).forEach(bs -> this.FOOTPRINT_STATES.add(bs));
}
Also used : AcousticsManager(org.blockartistry.DynSurround.client.footsteps.implem.AcousticsManager) Arrays(java.util.Arrays) Generator(org.blockartistry.DynSurround.client.footsteps.system.Generator) ModConfigurationFile(org.blockartistry.DynSurround.data.xface.ModConfigurationFile) Item(net.minecraft.item.Item) GeneratorQP(org.blockartistry.DynSurround.client.footsteps.system.GeneratorQP) Scanner(java.util.Scanner) DSurround(org.blockartistry.DynSurround.DSurround) BlockReed(net.minecraft.block.BlockReed) Block(net.minecraft.block.Block) MCHelper(org.blockartistry.lib.MCHelper) Side(net.minecraftforge.fml.relauncher.Side) OreDictionary(net.minecraftforge.oredict.OreDictionary) Locale(java.util.Locale) Map(java.util.Map) ItemStackUtil(org.blockartistry.lib.ItemStackUtil) IdentityHashSet(org.blockartistry.lib.collections.IdentityHashSet) AcousticsManager(org.blockartistry.DynSurround.client.footsteps.implem.AcousticsManager) BlockOre(net.minecraft.block.BlockOre) Pack(org.blockartistry.DynSurround.packs.ResourcePacks.Pack) BlockMushroom(net.minecraft.block.BlockMushroom) EnumMap(java.util.EnumMap) BlockIce(net.minecraft.block.BlockIce) PrimitiveMap(org.blockartistry.DynSurround.client.footsteps.implem.PrimitiveMap) Set(java.util.Set) IAcoustic(org.blockartistry.DynSurround.client.footsteps.interfaces.IAcoustic) Collectors(java.util.stream.Collectors) ConfigProperty(org.blockartistry.DynSurround.client.footsteps.util.ConfigProperty) BlockLeaves(net.minecraft.block.BlockLeaves) List(java.util.List) ModOptions(org.blockartistry.DynSurround.ModOptions) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Entry(java.util.Map.Entry) BlockFence(net.minecraft.block.BlockFence) ItemBlockSpecial(net.minecraft.item.ItemBlockSpecial) BlockCrops(net.minecraft.block.BlockCrops) Blocks(net.minecraft.init.Blocks) BlockFlower(net.minecraft.block.BlockFlower) RainSplashAcoustic(org.blockartistry.DynSurround.client.footsteps.implem.RainSplashAcoustic) HashMap(java.util.HashMap) BlockSapling(net.minecraft.block.BlockSapling) ItemStack(net.minecraft.item.ItemStack) BlockPlanks(net.minecraft.block.BlockPlanks) StreamSupport(java.util.stream.StreamSupport) ClientRegistry(org.blockartistry.DynSurround.client.ClientRegistry) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) SoundType(net.minecraft.block.SoundType) Iterator(java.util.Iterator) ResourcePacks(org.blockartistry.DynSurround.packs.ResourcePacks) IOException(java.io.IOException) VariatorConfig(org.blockartistry.DynSurround.data.xface.VariatorConfig) BlockDoor(net.minecraft.block.BlockDoor) AcousticProfile(org.blockartistry.DynSurround.client.footsteps.implem.AcousticProfile) AcousticsJsonReader(org.blockartistry.DynSurround.client.footsteps.parsers.AcousticsJsonReader) IBlockState(net.minecraft.block.state.IBlockState) Material(net.minecraft.block.material.Material) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ForgeRegistries(net.minecraftforge.fml.common.registry.ForgeRegistries) ResourceLocation(net.minecraft.util.ResourceLocation) ItemBlock(net.minecraft.item.ItemBlock) BlockLog(net.minecraft.block.BlockLog) ForgeEntry(org.blockartistry.DynSurround.data.xface.ModConfigurationFile.ForgeEntry) InputStream(java.io.InputStream) BlockMap(org.blockartistry.DynSurround.client.footsteps.implem.BlockMap) SoundEvent(net.minecraft.util.SoundEvent) SoundType(net.minecraft.block.SoundType) SoundEvent(net.minecraft.util.SoundEvent) IBlockState(net.minecraft.block.state.IBlockState) RainSplashAcoustic(org.blockartistry.DynSurround.client.footsteps.implem.RainSplashAcoustic) ResourceLocation(net.minecraft.util.ResourceLocation)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Arrays (java.util.Arrays)1 EnumMap (java.util.EnumMap)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Scanner (java.util.Scanner)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 StreamSupport (java.util.stream.StreamSupport)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 Block (net.minecraft.block.Block)1 BlockCrops (net.minecraft.block.BlockCrops)1 BlockDoor (net.minecraft.block.BlockDoor)1 BlockFence (net.minecraft.block.BlockFence)1