use of org.blockartistry.mod.DynSurround.client.sound.SoundEffect in project BetterRain by OreCruncher.
the class BlockEffectHandler method process.
@Override
public void process(final World world, final EntityPlayer player) {
if (Minecraft.getMinecraft().isGamePaused())
return;
final BlockPos playerPos = new BlockPos(player);
final String conditions = EnvironState.getConditions();
final int RANGE = ModOptions.specialEffectRange;
final int CHECK_COUNT = (int) (Math.pow(RANGE * 2 - 1, 3) * RATIO);
for (int i = 0; i < CHECK_COUNT; i++) {
final BlockPos pos = playerPos.add(random.nextInt(RANGE) - random.nextInt(RANGE), random.nextInt(RANGE) - random.nextInt(RANGE), random.nextInt(RANGE) - random.nextInt(RANGE));
final Block block = MCHelper.getBlock(world, pos);
if (block != Blocks.air) {
final List<BlockEffect> chain = BlockRegistry.getEffects(block);
if (chain != null) {
for (final BlockEffect effect : chain) if (effect.trigger(block, world, pos, random))
effect.doEffect(block, world, pos, random);
}
final SoundEffect sound = BlockRegistry.getSound(block, random, conditions);
if (sound != null)
sound.doEffect(block, world, pos, random);
}
}
if (EnvironState.isPlayerOnGround() && EnvironState.isPlayerMoving()) {
final BlockPos pos = playerPos.down(1);
final Block block = MCHelper.getBlock(world, pos);
if (block != Blocks.air && !block.getMaterial().isLiquid()) {
final SoundEffect sound = BlockRegistry.getStepSound(block, random, conditions);
if (sound != null)
sound.doEffect(block, world, pos, random);
}
}
}
use of org.blockartistry.mod.DynSurround.client.sound.SoundEffect 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);
}
}
}
}
}
use of org.blockartistry.mod.DynSurround.client.sound.SoundEffect in project BetterRain by OreCruncher.
the class BiomeRegistry method getSpotSound.
public static SoundEffect getSpotSound(final BiomeGenBase biome, final String conditions, final Random random) {
final Entry e = get(biome);
if (e == null || e.spotSounds.isEmpty() || random.nextInt(e.spotSoundChance) != 0)
return null;
int totalWeight = 0;
final List<SoundEffect> candidates = new ArrayList<SoundEffect>();
for (final SoundEffect s : e.spotSounds) if (s.matches(conditions)) {
candidates.add(s);
totalWeight += s.weight;
}
if (totalWeight <= 0)
return null;
if (candidates.size() == 1)
return candidates.get(0);
int targetWeight = random.nextInt(totalWeight);
int i = 0;
for (i = candidates.size(); (targetWeight -= candidates.get(i - 1).weight) >= 0; i--) ;
return candidates.get(i - 1);
}
use of org.blockartistry.mod.DynSurround.client.sound.SoundEffect 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);
}
}
}
}
use of org.blockartistry.mod.DynSurround.client.sound.SoundEffect in project BetterRain by OreCruncher.
the class EnvironStateHandler method onItemUse.
@SubscribeEvent
public void onItemUse(final AttackEntityEvent event) {
if (SWORD == null || event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if (event.entityPlayer.worldObj.isRemote && EnvironState.isPlayer(event.entityPlayer)) {
final ItemStack currentItem = event.entityPlayer.getCurrentEquippedItem();
if (currentItem != null) {
SoundEffect sound = null;
final Item item = currentItem.getItem();
if (item instanceof ItemSword)
sound = SWORD;
else if (item instanceof ItemAxe)
sound = AXE;
if (sound != null)
SoundManager.playSoundAtPlayer(EnvironState.getPlayer(), sound);
}
}
}
Aggregations