本文整理汇总了Java中org.spongepowered.api.data.type.NotePitch类的典型用法代码示例。如果您正苦于以下问题:Java NotePitch类的具体用法?Java NotePitch怎么用?Java NotePitch使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NotePitch类属于org.spongepowered.api.data.type包,在下文中一共展示了NotePitch类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerDefaults
import org.spongepowered.api.data.type.NotePitch; //导入依赖的package包/类
@Override
public void registerDefaults() {
registerOption("block_state", BlockState.class);
registerOption("color", Color.class);
registerOption("direction", Direction.class);
registerOption("firework_effects", List.class,
value -> value.isEmpty() ? new IllegalArgumentException("The firework effects list may not be empty") : null);
registerOption("quantity", Integer.class,
value -> value < 1 ? new IllegalArgumentException("Quantity must be at least 1") : null);
registerOption("item_stack_snapshot", ItemStackSnapshot.class);
registerOption("note", NotePitch.class);
registerOption("offset", Vector3d.class);
registerOption("potion_effect_type", PotionEffectType.class);
registerOption("scale", Double.class,
value -> value < 0 ? new IllegalArgumentException("Scale may not be negative") : null);
registerOption("velocity", Vector3d.class);
registerOption("slow_horizontal_velocity", Boolean.class);
}
示例2: playNote
import org.spongepowered.api.data.type.NotePitch; //导入依赖的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);
}
示例3: of
import org.spongepowered.api.data.type.NotePitch; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public static NotePitch of(Note note) {
if (note == null) {
return null;
}
return NOTES.get(note.getId());
}
示例4: cycleNext
import org.spongepowered.api.data.type.NotePitch; //导入依赖的package包/类
@Override
public NotePitch cycleNext() {
return this.next;
}
示例5: setNext
import org.spongepowered.api.data.type.NotePitch; //导入依赖的package包/类
public void setNext(NotePitch next) {
if (this.next != null) {
throw new IllegalStateException("The next pitch value can only be set once!");
}
this.next = next;
}
示例6: nextNote
import org.spongepowered.api.data.type.NotePitch; //导入依赖的package包/类
/**
* Cycles the current {@link NotePitch} to the next one.
*/
public void nextNote() {
final NotePitch notePitch = get(Keys.NOTE_PITCH).get();
offer(Keys.NOTE_PITCH, notePitch.cycleNext());
}
示例7: NoteAction
import org.spongepowered.api.data.type.NotePitch; //导入依赖的package包/类
public NoteAction(InstrumentType instrumentType, NotePitch notePitch) {
this.instrumentType = instrumentType;
this.notePitch = notePitch;
}