Search in sources :

Example 6 with SoundEffect

use of org.blockartistry.DynSurround.client.sound.SoundEffect 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);
                }
            }
        }
    }
}
Also used : SoundEffect(org.blockartistry.DynSurround.client.sound.SoundEffect) BlockEffect(org.blockartistry.DynSurround.client.fx.BlockEffect) SoundConfig(org.blockartistry.DynSurround.data.xface.SoundConfig) BlockEffectType(org.blockartistry.DynSurround.client.fx.BlockEffectType) EffectConfig(org.blockartistry.DynSurround.data.xface.EffectConfig)

Example 7 with SoundEffect

use of org.blockartistry.DynSurround.client.sound.SoundEffect in project DynamicSurroundings by OreCruncher.

the class ItemRegistry method initComplete.

@Override
public void initComplete() {
    // Iterate through the list of registered Items to see
    // if we know about them, or can infer based on class
    // matching.
    final Iterator<Item> iterator = Item.REGISTRY.iterator();
    while (iterator.hasNext()) {
        final Item item = iterator.next();
        if (!this.items.containsKey(item)) {
            if (doesBelong(this.swordItems, item)) {
                this.items.put(item, ItemType.SWORD);
            } else if (doesBelong(this.axeItems, item)) {
                this.items.put(item, ItemType.AXE);
            } else if (doesBelong(this.toolItems, item)) {
                this.items.put(item, ItemType.TOOL);
            } else if (doesBelong(this.shieldItems, item)) {
                this.items.put(item, ItemType.SHIELD);
            } else if (doesBelong(this.bowItems, item)) {
                this.items.put(item, ItemType.BOW);
            } else if (doesBelong(this.crystalItems, item)) {
                this.items.put(item, ItemType.ARMOR);
                this.armorMap.put(item, ArmorClass.CRYSTAL);
            } else if (doesBelong(this.heavyItems, item)) {
                this.items.put(item, ItemType.ARMOR);
                this.armorMap.put(item, ArmorClass.HEAVY);
            } else if (doesBelong(this.mediumItems, item)) {
                this.items.put(item, ItemType.ARMOR);
                this.armorMap.put(item, ArmorClass.MEDIUM);
            } else if (doesBelong(this.lightItems, item)) {
                this.items.put(item, ItemType.ARMOR);
                this.armorMap.put(item, ArmorClass.LIGHT);
            } else if (item instanceof ItemFood) {
                this.items.put(item, ItemType.FOOD);
            }
        }
        // Process sounds for Items that we are concerned with
        final ItemType t = this.items.get(item);
        if (t != null) {
            SoundEffect se = this.getSwingSound(item, t);
            if (se != null)
                this.swings.put(item, se);
            se = this.getUseSound(item, t);
            if (se != null)
                this.uses.put(item, se);
            se = this.getEquipSound(item, t);
            if (se != null)
                this.equips.put(item, se);
        }
    }
    // Free up resources that are no longer needed
    this.swordItems = null;
    this.axeItems = null;
    this.bowItems = null;
    this.toolItems = null;
    this.shieldItems = null;
    this.crystalItems = null;
    this.heavyItems = null;
    this.mediumItems = null;
    this.lightItems = null;
}
Also used : SoundEffect(org.blockartistry.DynSurround.client.sound.SoundEffect) Item(net.minecraft.item.Item) ItemFood(net.minecraft.item.ItemFood)

Example 8 with SoundEffect

use of org.blockartistry.DynSurround.client.sound.SoundEffect in project DynamicSurroundings by OreCruncher.

the class EntityBowSoundEffect method update.

@Override
public void update(@Nonnull final Entity subject) {
    final EntityLivingBase entity = (EntityLivingBase) subject;
    final ItemStack currentStack = entity.getActiveItemStack();
    if (ItemStackUtil.isValidItemStack(currentStack)) {
        if (this.lastActiveStack == null || !ItemStack.areItemStacksEqual(currentStack, this.lastActiveStack)) {
            if (ClientRegistry.ITEMS.isBow(currentStack) || ClientRegistry.ITEMS.isShield(currentStack)) {
                final SoundEffect soundEffect = ClientRegistry.ITEMS.getUseSound(currentStack);
                if (soundEffect != null) {
                    final ITrackedSound fx = getState().createSound(soundEffect, entity);
                    getState().playSound(fx);
                }
            }
            this.lastActiveStack = currentStack;
        }
    } else {
        this.lastActiveStack = null;
    }
}
Also used : SoundEffect(org.blockartistry.DynSurround.client.sound.SoundEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ITrackedSound(org.blockartistry.lib.sound.ITrackedSound) ItemStack(net.minecraft.item.ItemStack)

Example 9 with SoundEffect

use of org.blockartistry.DynSurround.client.sound.SoundEffect in project DynamicSurroundings by OreCruncher.

the class RandomBlockEffectScanner method blockScan.

@Override
public void blockScan(@Nonnull final IBlockState state, @Nonnull final BlockPos pos, @Nonnull final Random rand) {
    final IBlockAccessEx provider = this.locus.getWorld();
    final BlockEffect[] effects = this.profile.getEffects();
    for (int i = 0; i < effects.length; i++) {
        final BlockEffect be = effects[i];
        if (be.canTrigger(provider, state, pos, rand))
            be.doEffect(provider, state, pos, rand);
    }
    final SoundEffect sound = this.profile.getSoundToPlay(rand);
    if (sound != null)
        sound.doEffect(provider, state, pos, rand);
}
Also used : SoundEffect(org.blockartistry.DynSurround.client.sound.SoundEffect) BlockEffect(org.blockartistry.DynSurround.client.fx.BlockEffect) IBlockAccessEx(org.blockartistry.lib.chunk.IBlockAccessEx)

Example 10 with SoundEffect

use of org.blockartistry.DynSurround.client.sound.SoundEffect 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);
    }
}
Also used : SoundEffect(org.blockartistry.DynSurround.client.sound.SoundEffect) Color(org.blockartistry.lib.Color) SoundConfig(org.blockartistry.DynSurround.data.xface.SoundConfig)

Aggregations

SoundEffect (org.blockartistry.DynSurround.client.sound.SoundEffect)10 BlockEffect (org.blockartistry.DynSurround.client.fx.BlockEffect)4 Nonnull (javax.annotation.Nonnull)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 ItemStack (net.minecraft.item.ItemStack)2 SoundConfig (org.blockartistry.DynSurround.data.xface.SoundConfig)2 ITrackedSound (org.blockartistry.lib.sound.ITrackedSound)2 TObjectFloatHashMap (gnu.trove.map.hash.TObjectFloatHashMap)1 ArrayList (java.util.ArrayList)1 SoundType (net.minecraft.block.SoundType)1 EntityBoat (net.minecraft.entity.item.EntityBoat)1 Item (net.minecraft.item.Item)1 ItemFood (net.minecraft.item.ItemFood)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 BiomeDictionary (net.minecraftforge.common.BiomeDictionary)1 Type (net.minecraftforge.common.BiomeDictionary.Type)1 BlockMap (org.blockartistry.DynSurround.client.footsteps.implem.BlockMap)1 BlockEffectType (org.blockartistry.DynSurround.client.fx.BlockEffectType)1 EffectConfig (org.blockartistry.DynSurround.data.xface.EffectConfig)1