Search in sources :

Example 6 with IAcoustic

use of org.blockartistry.DynSurround.client.footsteps.interfaces.IAcoustic 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)

Example 7 with IAcoustic

use of org.blockartistry.DynSurround.client.footsteps.interfaces.IAcoustic in project DynamicSurroundings by OreCruncher.

the class AcousticsJsonReader method parseSelector.

private void parseSelector(final EventSelectorAcoustics selector, final JsonObject acousticsDefinition) throws JsonParseException {
    for (final EventType i : EventType.values()) {
        final String eventName = i.jsonName();
        if (acousticsDefinition.has(eventName)) {
            final JsonElement unsolved = acousticsDefinition.get(eventName);
            final IAcoustic acoustic = solveAcoustic(unsolved);
            selector.setAcousticPair(i, acoustic);
        }
    }
}
Also used : EventType(org.blockartistry.DynSurround.client.footsteps.interfaces.EventType) IAcoustic(org.blockartistry.DynSurround.client.footsteps.interfaces.IAcoustic) JsonElement(com.google.gson.JsonElement)

Example 8 with IAcoustic

use of org.blockartistry.DynSurround.client.footsteps.interfaces.IAcoustic in project DynamicSurroundings by OreCruncher.

the class ArmorAccents method provide.

@Override
@Nonnull
public ObjectArray<IAcoustic> provide(@Nonnull final EntityLivingBase entity, @Nullable final BlockPos pos, @Nonnull final ObjectArray<IAcoustic> in) {
    final ArmorClass armor;
    final ArmorClass foot;
    if (EnvironState.isPlayer(entity)) {
        armor = EnvironState.getPlayerArmorClass();
        foot = EnvironState.getPlayerFootArmorClass();
    } else {
        armor = ArmorClass.effectiveArmorClass(entity);
        foot = ArmorClass.footArmorClass(entity);
    }
    final IAcoustic armorAddon = ClientRegistry.FOOTSTEPS.getArmorAcoustic(armor);
    IAcoustic footAddon = ClientRegistry.FOOTSTEPS.getFootArmorAcoustic(foot);
    if (armorAddon != null || footAddon != null) {
        // Eliminate duplicates
        if (armorAddon == footAddon)
            footAddon = null;
        in.add(armorAddon);
        in.add(footAddon);
    }
    return in;
}
Also used : IAcoustic(org.blockartistry.DynSurround.client.footsteps.interfaces.IAcoustic) ArmorClass(org.blockartistry.DynSurround.registry.ArmorClass) Nonnull(javax.annotation.Nonnull)

Aggregations

IAcoustic (org.blockartistry.DynSurround.client.footsteps.interfaces.IAcoustic)8 Nonnull (javax.annotation.Nonnull)3 Nullable (javax.annotation.Nullable)3 IBlockState (net.minecraft.block.state.IBlockState)3 JsonElement (com.google.gson.JsonElement)2 SoundType (net.minecraft.block.SoundType)2 BlockPos (net.minecraft.util.math.BlockPos)2 JsonArray (com.google.gson.JsonArray)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)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