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();
}
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));
}
Aggregations