Search in sources :

Example 1 with SoundEffect

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

the class BiomeInfo method toString.

@Override
@Nonnull
public String toString() {
    final ResourceLocation rl = this.biome.getKey();
    final String registryName = rl == null ? (isFake() ? "FAKE" : "UNKNOWN") : rl.toString();
    final StringBuilder builder = new StringBuilder();
    builder.append("Biome [").append(getBiomeName()).append('/').append(registryName).append("] (").append(getBiomeId()).append("):");
    if (!isFake()) {
        builder.append("\n+ ").append('<');
        boolean comma = false;
        for (final BiomeDictionary.Type t : getBiomeTypes()) {
            if (comma)
                builder.append(',');
            else
                comma = true;
            builder.append(t.getName());
        }
        builder.append('>').append('\n');
        builder.append("+ temp: ").append(getTemperature()).append(" (").append(getTemperatureRating().getValue()).append(")");
        builder.append(" rain: ").append(getRainfall());
    }
    if (this.hasPrecipitation)
        builder.append(" PRECIPITATION");
    if (this.hasDust)
        builder.append(" DUST");
    if (this.hasAurora)
        builder.append(" AURORA");
    if (this.hasFog)
        builder.append(" FOG");
    if (this.dustColor != null)
        builder.append(" dustColor:").append(this.dustColor.toString());
    if (this.fogColor != null) {
        builder.append(" fogColor:").append(this.fogColor.toString());
        builder.append(" fogDensity:").append(this.fogDensity);
    }
    if (this.sounds.length > 0) {
        builder.append("\n+ sounds [\n");
        for (final SoundEffect sound : this.sounds) builder.append("+   ").append(sound.toString()).append('\n');
        builder.append("+ ]");
    }
    if (this.spotSounds.length > 0) {
        builder.append("\n+ spot sound chance:").append(this.spotSoundChance);
        builder.append("\n+ spot sounds [\n");
        for (final SoundEffect sound : this.spotSounds) builder.append("+   ").append(sound.toString()).append('\n');
        builder.append("+ ]");
    }
    if (this.comments.size() > 0) {
        builder.append("\n+ comments:\n");
        for (final String c : this.comments) builder.append("+   ").append(c).append('\n');
    }
    return builder.toString();
}
Also used : SoundEffect(org.blockartistry.DynSurround.client.sound.SoundEffect) Type(net.minecraftforge.common.BiomeDictionary.Type) ResourceLocation(net.minecraft.util.ResourceLocation) BiomeDictionary(net.minecraftforge.common.BiomeDictionary) Nonnull(javax.annotation.Nonnull)

Example 2 with SoundEffect

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

the class BlockProfile method toString.

@Override
@Nonnull
public String toString() {
    final StringBuilder builder = new StringBuilder();
    builder.append("Block [").append(this.info.toString()).append("]");
    if (this.sounds != NO_SOUNDS) {
        boolean commaFlag = false;
        builder.append(" chance:").append(this.chance);
        builder.append("; sounds [");
        for (final SoundEffect sound : this.sounds) {
            if (commaFlag)
                builder.append(",");
            else
                commaFlag = true;
            builder.append(sound.toString());
        }
        builder.append(']');
    } else {
        builder.append("NO SOUNDS");
    }
    if (this.stepSounds != NO_SOUNDS) {
        boolean commaFlag = false;
        builder.append(" chance:").append(this.stepChance);
        builder.append("; step sounds [");
        for (final SoundEffect sound : this.stepSounds) {
            if (commaFlag)
                builder.append(",");
            else
                commaFlag = true;
            builder.append(sound.toString());
        }
        builder.append(']');
    } else {
        builder.append("; NO STEP SOUNDS");
    }
    if (this.effects != this.alwaysOn) {
        boolean commaFlag = false;
        builder.append("; effects [");
        for (final BlockEffect effect : this.effects) {
            if (commaFlag)
                builder.append(",");
            else
                commaFlag = true;
            builder.append(effect.toString());
        }
        for (final BlockEffect effect : this.alwaysOn) {
            if (commaFlag)
                builder.append(",");
            else
                commaFlag = true;
            builder.append(effect.toString());
        }
        builder.append(']');
    } else {
        builder.append("; NO EFFECTS");
    }
    return builder.toString();
}
Also used : SoundEffect(org.blockartistry.DynSurround.client.sound.SoundEffect) BlockEffect(org.blockartistry.DynSurround.client.fx.BlockEffect) Nonnull(javax.annotation.Nonnull)

Example 3 with SoundEffect

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

the class BiomeSoundEffectsHandler method process.

@Override
public void process(@Nonnull final EntityPlayer player) {
    this.biomes.update();
    final TObjectFloatHashMap<SoundEffect> sounds = new TObjectFloatHashMap<>(Constants.DEFAULT_CAPACITY, Constants.DEFAULT_LOAD_FACTOR, -1F);
    if (doBiomeSounds())
        getBiomeSounds(sounds);
    final ObjectArray<SoundEffect> playerSounds = new ObjectArray<>();
    ClientRegistry.BIOME.PLAYER_INFO.findSoundMatches(playerSounds);
    if (ModOptions.sound.enableBattleMusic)
        ClientRegistry.BIOME.BATTLE_MUSIC_INFO.findSoundMatches(playerSounds);
    if (EnvironState.inVillage())
        ClientRegistry.BIOME.VILLAGE_INFO.findSoundMatches(playerSounds);
    playerSounds.forEach(fx -> sounds.put(fx, 1.0F));
    SoundEffectHandler.INSTANCE.queueAmbientSounds(sounds);
    if (doBiomeSounds()) {
        final BiomeInfo playerBiome = EnvironState.getPlayerBiome();
        final SoundEffect sound = playerBiome.getSpotSound(this.RANDOM);
        if (sound != null)
            SoundEffectHandler.INSTANCE.playSoundAtPlayer(player, sound);
    }
    final SoundEffect sound = ClientRegistry.BIOME.PLAYER_INFO.getSpotSound(this.RANDOM);
    if (sound != null)
        SoundEffectHandler.INSTANCE.playSoundAtPlayer(player, sound);
}
Also used : SoundEffect(org.blockartistry.DynSurround.client.sound.SoundEffect) TObjectFloatHashMap(gnu.trove.map.hash.TObjectFloatHashMap) BiomeInfo(org.blockartistry.DynSurround.registry.BiomeInfo) ObjectArray(org.blockartistry.lib.collections.ObjectArray)

Example 4 with SoundEffect

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

the class EntitySwingEffect method update.

@Override
public void update(@Nonnull final Entity subject) {
    final EntityLivingBase entity = (EntityLivingBase) subject;
    // Boats are strange - ignore them for now
    if (entity.getRidingEntity() instanceof EntityBoat)
        return;
    // Is the swing in motion
    if (entity.swingingHand != null && entity.swingProgressInt > this.swingProgress) {
        if (!this.isSwinging) {
            final ItemStack currentItem = entity.getHeldItem(entity.swingingHand);
            final SoundEffect soundEffect = ClientRegistry.ITEMS.getSwingSound(currentItem);
            if (soundEffect != null) {
                final RayTraceResult whatImHitting = RayTrace.trace(entity);
                if (whatImHitting == null || whatImHitting.typeOfHit != Type.BLOCK) {
                    final ITrackedSound snd = getState().createSound(soundEffect, entity);
                    getState().playSound(snd);
                }
            }
        }
        this.isSwinging = true;
        this.swingProgress = entity.swingProgressInt;
    } else {
        this.isSwinging = false;
        this.swingProgress = entity.swingProgressInt;
    }
}
Also used : SoundEffect(org.blockartistry.DynSurround.client.sound.SoundEffect) EntityBoat(net.minecraft.entity.item.EntityBoat) EntityLivingBase(net.minecraft.entity.EntityLivingBase) RayTraceResult(net.minecraft.util.math.RayTraceResult) ITrackedSound(org.blockartistry.lib.sound.ITrackedSound) ItemStack(net.minecraft.item.ItemStack)

Example 5 with SoundEffect

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

the class InspectionHUD method gatherBlockText.

private List<String> gatherBlockText(final ItemStack stack, final List<String> text, final IBlockState state, final BlockPos pos) {
    if (ItemStackUtil.isValidItemStack(stack)) {
        text.add(TextFormatting.RED + stack.getDisplayName());
        final String itemName = getItemName(stack);
        if (itemName != null) {
            text.add("ITEM: " + itemName);
            text.add(TextFormatting.DARK_AQUA + stack.getItem().getClass().getName());
        }
    }
    if (state != null) {
        this.block.set(state);
        text.add("BLOCK: " + this.block.toString());
        text.add(TextFormatting.DARK_AQUA + this.block.getBlock().getClass().getName());
        text.add("Material: " + MCHelper.getMaterialName(state.getMaterial()));
        final SoundType st = state.getBlock().getSoundType(state, EnvironState.getWorld(), pos, EnvironState.getPlayer());
        if (st != null) {
            text.add("Step Sound: " + st.getStepSound().getSoundName().toString());
        }
        if (ClientRegistry.FOOTSTEPS.hasFootprint(state))
            text.add("Footprints Generated");
        final BlockMap bm = ClientRegistry.FOOTSTEPS.getBlockMap();
        if (bm != null) {
            final List<String> data = new ArrayList<>();
            bm.collectData(EnvironState.getWorld(), state, pos, data);
            if (data.size() > 0) {
                text.add(TEXT_FOOTSTEP_ACOUSTICS);
                for (final String s : data) text.add(TextFormatting.GOLD + s);
            }
        }
        BlockEffect[] effects = ClientRegistry.BLOCK.getEffects(state);
        if (effects.length > 0) {
            text.add(TEXT_BLOCK_EFFECTS);
            for (final BlockEffect e : effects) {
                text.add(TextFormatting.GOLD + e.getEffectType().getName());
            }
        }
        effects = ClientRegistry.BLOCK.getAlwaysOnEffects(state);
        if (effects.length > 0) {
            text.add(TEXT_ALWAYS_ON_EFFECTS);
            for (final BlockEffect e : effects) {
                text.add(TextFormatting.GOLD + e.getEffectType().getName());
            }
        }
        SoundEffect[] sounds = ClientRegistry.BLOCK.getAllStepSounds(state);
        if (sounds.length > 0) {
            text.add(TEXT_STEP_SOUNDS);
            text.add(TextFormatting.DARK_GREEN + "Chance: 1 in " + ClientRegistry.BLOCK.getStepSoundChance(state));
            for (final SoundEffect s : sounds) text.add(TextFormatting.GOLD + s.toString());
        }
        sounds = ClientRegistry.BLOCK.getAllSounds(state);
        if (sounds.length > 0) {
            text.add(TEXT_BLOCK_SOUNDS);
            text.add(TextFormatting.DARK_GREEN + "Chance: 1 in " + ClientRegistry.BLOCK.getSoundChance(state));
            for (final SoundEffect s : sounds) text.add(TextFormatting.GOLD + s.toString());
        }
    }
    final List<String> oreNames = gatherOreNames(stack);
    if (oreNames.size() > 0) {
        text.add(TEXT_DICTIONARY_NAMES);
        for (final String ore : oreNames) text.add(TextFormatting.GOLD + ore);
    }
    return text;
}
Also used : SoundType(net.minecraft.block.SoundType) SoundEffect(org.blockartistry.DynSurround.client.sound.SoundEffect) BlockMap(org.blockartistry.DynSurround.client.footsteps.implem.BlockMap) BlockEffect(org.blockartistry.DynSurround.client.fx.BlockEffect) ArrayList(java.util.ArrayList)

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