use of org.blockartistry.mod.DynSurround.data.config.BlockConfig 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);
}
}
}
}
Aggregations