use of org.blockartistry.DynSurround.client.fx.BlockEffectType in project DynamicSurroundings by OreCruncher.
the class BlockRegistry method register.
public void register(@Nonnull final BlockConfig entry) {
if (entry.blocks.isEmpty())
return;
final SoundRegistry soundRegistry = ClientRegistry.SOUND;
for (final String blockName : entry.blocks) {
final BlockInfo blockInfo = BlockInfo.create(blockName);
if (blockInfo == null) {
DSurround.log().warn("Unknown block [%s] in block config file", blockName);
continue;
}
final BlockProfile blockData = getOrCreateProfile(blockInfo);
if (blockData == null) {
DSurround.log().warn("Unknown block [%s] in block config file", blockName);
continue;
}
// Reset of a block clears all registry
if (entry.soundReset != null && entry.soundReset.booleanValue())
blockData.clearSounds();
if (entry.stepSoundReset != null && entry.stepSoundReset.booleanValue())
blockData.clearStepSounds();
if (entry.effectReset != null && entry.effectReset.booleanValue())
blockData.clearEffects();
if (entry.chance != null)
blockData.setChance(entry.chance.intValue());
if (entry.stepChance != null)
blockData.setStepChance(entry.stepChance.intValue());
for (final SoundConfig sr : entry.sounds) {
if (sr.sound != null && !soundRegistry.isSoundBlocked(sr.sound)) {
final SoundEffect.Builder b = new SoundEffect.Builder(sr);
if (sr.soundCategory == null)
b.setSoundCategory(SoundCategory.BLOCKS);
final SoundEffect eff = b.build();
if (eff.getSoundType() == SoundType.STEP)
blockData.addStepSound(eff);
else
blockData.addSound(eff);
}
}
for (final EffectConfig e : entry.effects) {
if (StringUtils.isEmpty(e.effect))
continue;
final BlockEffectType type = BlockEffectType.get(e.effect);
if (type == BlockEffectType.UNKNOWN) {
DSurround.log().warn("Unknown block effect type in configuration: [%s]", e.effect);
} else if (type.isEnabled()) {
final int chance = e.chance != null ? e.chance.intValue() : 100;
final BlockEffect blockEffect = type.getInstance(chance);
if (blockEffect != null) {
if (e.conditions != null)
blockEffect.setConditions(e.conditions);
blockData.addEffect(blockEffect);
}
}
}
}
}
Aggregations