use of org.blockartistry.DynSurround.data.xface.SoundConfig 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);
}
}
}
}
}
use of org.blockartistry.DynSurround.data.xface.SoundConfig in project DynamicSurroundings by OreCruncher.
the class BiomeInfo method update.
// Internal to the package
void update(@Nonnull final BiomeConfig entry) {
addComment(entry.comment);
if (entry.hasPrecipitation != null)
setHasPrecipitation(entry.hasPrecipitation.booleanValue());
if (entry.hasAurora != null)
setHasAurora(entry.hasAurora.booleanValue());
if (entry.hasDust != null)
setHasDust(entry.hasDust.booleanValue());
if (entry.hasFog != null)
setHasFog(entry.hasFog.booleanValue());
if (entry.fogDensity != null)
setFogDensity(entry.fogDensity.floatValue());
if (entry.fogColor != null) {
final int[] rgb = MyUtils.splitToInts(entry.fogColor, ',');
if (rgb.length == 3)
setFogColor(new Color(rgb[0], rgb[1], rgb[2]));
}
if (entry.dustColor != null) {
final int[] rgb = MyUtils.splitToInts(entry.dustColor, ',');
if (rgb.length == 3)
setDustColor(new Color(rgb[0], rgb[1], rgb[2]));
}
if (entry.soundReset != null && entry.soundReset.booleanValue()) {
addComment("> Sound Reset");
resetSounds();
}
if (entry.spotSoundChance != null)
setSpotSoundChance(entry.spotSoundChance.intValue());
for (final SoundConfig sr : entry.sounds) {
if (ClientRegistry.SOUND.isSoundBlocked(sr.sound))
continue;
final SoundEffect.Builder b = new SoundEffect.Builder(sr);
final SoundEffect s = b.build();
if (s.getSoundType() == SoundType.SPOT)
addSpotSound(s);
else
addSound(s);
}
}
Aggregations