Search in sources :

Example 1 with BlockEffect

use of org.blockartistry.mod.DynSurround.client.fx.BlockEffect 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

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 SoundEffect (org.blockartistry.mod.DynSurround.client.sound.SoundEffect)1 BlockConfig (org.blockartistry.mod.DynSurround.data.config.BlockConfig)1 Effect (org.blockartistry.mod.DynSurround.data.config.BlockConfig.Effect)1 SoundConfig (org.blockartistry.mod.DynSurround.data.config.SoundConfig)1