Search in sources :

Example 1 with SoundConfig

use of org.blockartistry.mod.DynSurround.data.config.SoundConfig in project BetterRain by OreCruncher.

the class BiomeRegistry method process.

private static void process(final BiomeConfig config) {
    for (final BiomeConfig.Entry entry : config.entries) {
        for (final Entry biomeEntry : registry.valueCollection()) {
            if (isBiomeMatch(entry, resolveName(biomeEntry.biome))) {
                if (entry.hasPrecipitation != null)
                    biomeEntry.hasPrecipitation = entry.hasPrecipitation.booleanValue();
                if (entry.hasAurora != null)
                    biomeEntry.hasAurora = entry.hasAurora.booleanValue();
                if (entry.hasDust != null)
                    biomeEntry.hasDust = entry.hasDust.booleanValue();
                if (entry.hasFog != null)
                    biomeEntry.hasFog = entry.hasFog.booleanValue();
                if (entry.fogDensity != null)
                    biomeEntry.fogDensity = entry.fogDensity.floatValue();
                if (entry.fogColor != null) {
                    final int[] rgb = MyUtils.splitToInts(entry.fogColor, ',');
                    if (rgb.length == 3)
                        biomeEntry.fogColor = new Color(rgb[0], rgb[1], rgb[2]);
                }
                if (entry.dustColor != null) {
                    final int[] rgb = MyUtils.splitToInts(entry.dustColor, ',');
                    if (rgb.length == 3)
                        biomeEntry.dustColor = new Color(rgb[0], rgb[1], rgb[2]);
                }
                if (entry.soundReset != null && entry.soundReset.booleanValue()) {
                    biomeEntry.sounds = new ArrayList<SoundEffect>();
                    biomeEntry.spotSounds = new ArrayList<SoundEffect>();
                }
                if (entry.spotSoundChance != null)
                    biomeEntry.spotSoundChance = entry.spotSoundChance.intValue();
                for (final SoundConfig sr : entry.sounds) {
                    if (SoundRegistry.isSoundBlocked(sr.sound))
                        continue;
                    final SoundEffect s = new SoundEffect(sr);
                    if (s.type == SoundType.SPOT)
                        biomeEntry.spotSounds.add(s);
                    else
                        biomeEntry.sounds.add(s);
                }
            }
        }
    }
}
Also used : SoundEffect(org.blockartistry.mod.DynSurround.client.sound.SoundEffect) Color(org.blockartistry.mod.DynSurround.util.Color) SoundConfig(org.blockartistry.mod.DynSurround.data.config.SoundConfig) BiomeConfig(org.blockartistry.mod.DynSurround.data.config.BiomeConfig)

Example 2 with SoundConfig

use of org.blockartistry.mod.DynSurround.data.config.SoundConfig in project BetterRain by OreCruncher.

the class BlockRegistry method process.

private static void process(final BlockConfig config) {
    for (final BlockConfig.Entry entry : config.entries) {
        if (entry.blocks.isEmpty())
            continue;
        for (final String blockName : entry.blocks) {
            final Block block = GameData.getBlockRegistry().getObject(new ResourceLocation(blockName));
            if (block == null || block == Blocks.air) {
                ModLog.warn("Unknown block [%s] in block config file", blockName);
                continue;
            }
            Entry blockData = registry.get(block);
            if (blockData == null) {
                blockData = new Entry(block);
                registry.put(block, blockData);
            }
            // Reset of a block clears all registry
            if (entry.soundReset != null && entry.soundReset.booleanValue())
                blockData.sounds.clear();
            if (entry.stepSoundReset != null && entry.stepSoundReset.booleanValue())
                blockData.stepSounds.clear();
            if (entry.effectReset != null && entry.effectReset.booleanValue())
                blockData.effects.clear();
            if (entry.chance != null)
                blockData.chance = entry.chance.intValue();
            if (entry.stepChance != null)
                blockData.stepChance = entry.stepChance.intValue();
            for (final SoundConfig sr : entry.sounds) {
                if (sr.sound != null && !SoundRegistry.isSoundBlocked(sr.sound)) {
                    final SoundEffect eff = new SoundEffect(sr);
                    if (eff.type == SoundType.STEP)
                        blockData.stepSounds.add(eff);
                    else
                        blockData.sounds.add(eff);
                }
            }
            for (final Effect e : entry.effects) {
                if (StringUtils.isEmpty(e.effect))
                    continue;
                BlockEffect blockEffect = null;
                final int chance = e.chance != null ? e.chance.intValue() : 100;
                if (StringUtils.equalsIgnoreCase("steam", e.effect))
                    blockEffect = new JetEffect.Steam(chance);
                else if (StringUtils.equalsIgnoreCase("fire", e.effect))
                    blockEffect = new JetEffect.Fire(chance);
                else if (StringUtils.equalsIgnoreCase("bubble", e.effect))
                    blockEffect = new JetEffect.Bubble(chance);
                else if (StringUtils.equalsIgnoreCase("dust", e.effect))
                    blockEffect = new JetEffect.Dust(chance);
                else if (StringUtils.equalsIgnoreCase("fountain", e.effect))
                    blockEffect = new JetEffect.Fountain(chance);
                else {
                    ModLog.warn("Unknown effect type in config: '%s'", e.effect);
                    continue;
                }
                blockData.effects.add(blockEffect);
            }
        }
    }
}
Also used : SoundEffect(org.blockartistry.mod.DynSurround.client.sound.SoundEffect) BlockEffect(org.blockartistry.mod.DynSurround.client.fx.BlockEffect) SoundConfig(org.blockartistry.mod.DynSurround.data.config.SoundConfig) ResourceLocation(net.minecraft.util.ResourceLocation) JetEffect(org.blockartistry.mod.DynSurround.client.fx.JetEffect) Block(net.minecraft.block.Block) BlockEffect(org.blockartistry.mod.DynSurround.client.fx.BlockEffect) JetEffect(org.blockartistry.mod.DynSurround.client.fx.JetEffect) SoundEffect(org.blockartistry.mod.DynSurround.client.sound.SoundEffect) Effect(org.blockartistry.mod.DynSurround.data.config.BlockConfig.Effect) BlockConfig(org.blockartistry.mod.DynSurround.data.config.BlockConfig)

Aggregations

SoundEffect (org.blockartistry.mod.DynSurround.client.sound.SoundEffect)2 SoundConfig (org.blockartistry.mod.DynSurround.data.config.SoundConfig)2 Block (net.minecraft.block.Block)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 BlockEffect (org.blockartistry.mod.DynSurround.client.fx.BlockEffect)1 JetEffect (org.blockartistry.mod.DynSurround.client.fx.JetEffect)1 BiomeConfig (org.blockartistry.mod.DynSurround.data.config.BiomeConfig)1 BlockConfig (org.blockartistry.mod.DynSurround.data.config.BlockConfig)1 Effect (org.blockartistry.mod.DynSurround.data.config.BlockConfig.Effect)1 Color (org.blockartistry.mod.DynSurround.util.Color)1