當前位置: 首頁>>代碼示例>>Java>>正文


Java SoundCategories類代碼示例

本文整理匯總了Java中org.spongepowered.api.effect.sound.SoundCategories的典型用法代碼示例。如果您正苦於以下問題:Java SoundCategories類的具體用法?Java SoundCategories怎麽用?Java SoundCategories使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SoundCategories類屬於org.spongepowered.api.effect.sound包,在下文中一共展示了SoundCategories類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: playNote

import org.spongepowered.api.effect.sound.SoundCategories; //導入依賴的package包/類
@Override
public void playNote() {
    final Location<World> location = getLocation();
    final Location<World> downLocation = location.add(0, -1, 0);
    // Get the instrument type based on the underlying block
    final InstrumentType instrumentType = downLocation.getProperty(InstrumentProperty.class)
            .map(InstrumentProperty::getValue).orElse(InstrumentTypes.HARP);
    final NotePitch notePitch = get(Keys.NOTE_PITCH).get();
    // Trigger the note play effect
    ((LanternWorld) location.getExtent()).addBlockAction(location.getBlockPosition(),
            getBlock().getType(), new NoteAction(instrumentType, notePitch));
    // Calculate the pitch value based on the note pitch
    double pitch = (double) ((LanternNotePitch) notePitch).getInternalId();
    pitch = Math.pow(2.0, (pitch - 12.0) / 12.0);
    location.getExtent().playSound(instrumentType.getSound(), SoundCategories.BLOCK,
            location.getPosition().add(0.5, 0.5, 0.5), 3.0, pitch);
}
 
開發者ID:LanternPowered,項目名稱:LanternServer,代碼行數:18,代碼來源:LanternNote.java

示例2: onChat

import org.spongepowered.api.effect.sound.SoundCategories; //導入依賴的package包/類
@Listener
public void onChat(MessageChannelEvent.Chat event) {
    String message = event.getRawMessage().toPlain();
    for (Player p : Sponge.getServer().getOnlinePlayers()) {
        if (message.contains(p.getName())) {
            ModuleConfig config = Modules.POKE.get().getConfig().get();
            CommentedConfigurationNode node = config.get();
            String soundname = node.getNode("sound", "sound").getString();
            String categoryname = node.getNode("sound", "category").getString();
            Double volume = node.getNode("sound", "volume").getDouble();
            Double pitch = node.getNode("sound", "pitch").getDouble();
            Double minVolume = node.getNode("sound", "minVolume").getDouble();
            SoundType type = Sponge.getRegistry().getType(CatalogTypes.SOUND_TYPE, soundname.toUpperCase()).get();
            //TODO wait for CatalogTypes.SOUND_CATEGORY to be added
            SoundCategory category;
            try {
                category = Sponge.getRegistry().getType(CatalogTypes.SOUND_CATEGORY, categoryname.toUpperCase()).get();
            } catch (Error ex) {
                category = SoundCategories.PLAYER;
            }
            p.playSound(type, category, p.getLocation().getPosition(), volume, pitch, minVolume);
        }
    }
}
 
開發者ID:Bammerbom,項目名稱:UltimateCore,代碼行數:25,代碼來源:PokeListener.java

示例3: pulse

import org.spongepowered.api.effect.sound.SoundCategories; //導入依賴的package包/類
@Override
public void pulse(int deltaTicks) {
    super.pulse(deltaTicks);

    this.ticksToLive -= deltaTicks;
    if (this.ticksToLive > 0) {
        return;
    }
    if (this.remove) {
        try (CauseStack.Frame frame = CauseStack.current().pushCauseFrame()) {
            // Add this entity to the cause of removal
            frame.pushCause(this);
            // Remove the entity
            remove();
        }
    } else {
        // Remove the entity the next pulse
        this.remove = true;

        // Play the sound effects
        final Vector3d position = getPosition();
        getWorld().playSound(SoundTypes.ENTITY_LIGHTNING_THUNDER, SoundCategories.WEATHER, position,
                10000.0, 0.8 + getRandom().nextDouble() * 0.2);
        getWorld().playSound(SoundTypes.ENTITY_LIGHTNING_IMPACT, SoundCategories.WEATHER, position,
                2.0, 0.5 + getRandom().nextDouble() * 0.2);

        // TODO: Damage entities?
        // TODO: Create fire
    }
}
 
開發者ID:LanternPowered,項目名稱:LanternServer,代碼行數:31,代碼來源:LanternLightning.java

示例4: SoundCategoryRegistryModule

import org.spongepowered.api.effect.sound.SoundCategories; //導入依賴的package包/類
public SoundCategoryRegistryModule() {
    super(SoundCategories.class);
}
 
開發者ID:LanternPowered,項目名稱:LanternServer,代碼行數:4,代碼來源:SoundCategoryRegistryModule.java

示例5: playOpenSound

import org.spongepowered.api.effect.sound.SoundCategories; //導入依賴的package包/類
@Override
protected void playOpenSound(Location<World> location) {
    location.getExtent().playSound(SoundTypes.BLOCK_ENDERCHEST_OPEN, SoundCategories.BLOCK,
            location.getPosition().add(0.5, 0.5, 0.5), 0.5, this.random.nextDouble() * 0.1 + 0.9);
}
 
開發者ID:LanternPowered,項目名稱:LanternServer,代碼行數:6,代碼來源:LanternEnderChest.java

示例6: playCloseSound

import org.spongepowered.api.effect.sound.SoundCategories; //導入依賴的package包/類
@Override
protected void playCloseSound(Location<World> location) {
    location.getExtent().playSound(SoundTypes.BLOCK_ENDERCHEST_CLOSE, SoundCategories.BLOCK,
            location.getPosition().add(0.5, 0.5, 0.5), 0.5, this.random.nextDouble() * 0.1 + 0.9);
}
 
開發者ID:LanternPowered,項目名稱:LanternServer,代碼行數:6,代碼來源:LanternEnderChest.java

示例7: playOpenSound

import org.spongepowered.api.effect.sound.SoundCategories; //導入依賴的package包/類
@Override
protected void playOpenSound(Location<World> location) {
    location.getExtent().playSound(SoundTypes.BLOCK_CHEST_OPEN, SoundCategories.BLOCK,
            location.getPosition().add(0.5, 0.5, 0.5), 0.5, this.random.nextDouble() * 0.1 + 0.9);
}
 
開發者ID:LanternPowered,項目名稱:LanternServer,代碼行數:6,代碼來源:LanternChest.java

示例8: playCloseSound

import org.spongepowered.api.effect.sound.SoundCategories; //導入依賴的package包/類
@Override
protected void playCloseSound(Location<World> location) {
    location.getExtent().playSound(SoundTypes.BLOCK_CHEST_CLOSE, SoundCategories.BLOCK,
            location.getPosition().add(0.5, 0.5, 0.5), 0.5, this.random.nextDouble() * 0.1 + 0.9);
}
 
開發者ID:LanternPowered,項目名稱:LanternServer,代碼行數:6,代碼來源:LanternChest.java

示例9: playOpenSound

import org.spongepowered.api.effect.sound.SoundCategories; //導入依賴的package包/類
@Override
protected void playOpenSound(Location<World> location) {
    location.getExtent().playSound(SoundTypes.BLOCK_SHULKER_BOX_OPEN, SoundCategories.BLOCK,
            location.getPosition().add(0.5, 0.5, 0.5), 0.5, this.random.nextDouble() * 0.1 + 0.9);
}
 
開發者ID:LanternPowered,項目名稱:LanternServer,代碼行數:6,代碼來源:LanternShulkerBox.java

示例10: playCloseSound

import org.spongepowered.api.effect.sound.SoundCategories; //導入依賴的package包/類
@Override
protected void playCloseSound(Location<World> location) {
    location.getExtent().playSound(SoundTypes.BLOCK_SHULKER_BOX_CLOSE, SoundCategories.BLOCK,
            location.getPosition().add(0.5, 0.5, 0.5), 0.5, this.random.nextDouble() * 0.1 + 0.9);
}
 
開發者ID:LanternPowered,項目名稱:LanternServer,代碼行數:6,代碼來源:LanternShulkerBox.java


注:本文中的org.spongepowered.api.effect.sound.SoundCategories類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。