本文整理匯總了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);
}
示例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);
}
}
}
示例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
}
}
示例4: SoundCategoryRegistryModule
import org.spongepowered.api.effect.sound.SoundCategories; //導入依賴的package包/類
public SoundCategoryRegistryModule() {
super(SoundCategories.class);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}