Search in sources :

Example 1 with BlockEffect

use of org.blockartistry.DynSurround.client.fx.BlockEffect 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 2 with BlockEffect

use of org.blockartistry.DynSurround.client.fx.BlockEffect 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)

Example 3 with BlockEffect

use of org.blockartistry.DynSurround.client.fx.BlockEffect 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 4 with BlockEffect

use of org.blockartistry.DynSurround.client.fx.BlockEffect in project DynamicSurroundings by OreCruncher.

the class AlwaysOnBlockEffectScanner 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.getAlwaysOnEffects();
    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);
    }
}
Also used : BlockEffect(org.blockartistry.DynSurround.client.fx.BlockEffect) IBlockAccessEx(org.blockartistry.lib.chunk.IBlockAccessEx)

Example 5 with BlockEffect

use of org.blockartistry.DynSurround.client.fx.BlockEffect 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)

Aggregations

BlockEffect (org.blockartistry.DynSurround.client.fx.BlockEffect)5 SoundEffect (org.blockartistry.DynSurround.client.sound.SoundEffect)4 IBlockAccessEx (org.blockartistry.lib.chunk.IBlockAccessEx)2 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1 SoundType (net.minecraft.block.SoundType)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 SoundConfig (org.blockartistry.DynSurround.data.xface.SoundConfig)1