-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathMusicInstrument.java
More file actions
130 lines (109 loc) · 4.67 KB
/
MusicInstrument.java
File metadata and controls
130 lines (109 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package org.bukkit;
import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryBuilderFactory;
import io.papermc.paper.registry.RegistryKey;
import io.papermc.paper.registry.data.InlinedRegistryBuilderProvider;
import io.papermc.paper.registry.data.InstrumentRegistryEntry;
import java.util.Collection;
import java.util.function.Consumer;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.key.KeyPattern;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@NullMarked
public abstract class MusicInstrument implements Keyed, net.kyori.adventure.translation.Translatable {
/**
* Creates an inlined music instrument.
*
* @param value a consumer for the builder factory
* @return the created music instrument
*/
@ApiStatus.Experimental
public static MusicInstrument create(final Consumer<RegistryBuilderFactory<MusicInstrument, ? extends InstrumentRegistryEntry.Builder>> value) {
return InlinedRegistryBuilderProvider.instance().createInstrument(value);
}
// Start generate - MusicInstrument
public static final MusicInstrument ADMIRE_GOAT_HORN = getInstrument("admire_goat_horn");
public static final MusicInstrument CALL_GOAT_HORN = getInstrument("call_goat_horn");
public static final MusicInstrument DREAM_GOAT_HORN = getInstrument("dream_goat_horn");
public static final MusicInstrument FEEL_GOAT_HORN = getInstrument("feel_goat_horn");
public static final MusicInstrument PONDER_GOAT_HORN = getInstrument("ponder_goat_horn");
public static final MusicInstrument SEEK_GOAT_HORN = getInstrument("seek_goat_horn");
public static final MusicInstrument SING_GOAT_HORN = getInstrument("sing_goat_horn");
public static final MusicInstrument YEARN_GOAT_HORN = getInstrument("yearn_goat_horn");
// End generate - MusicInstrument
private static MusicInstrument getInstrument(final @KeyPattern.Value String key) {
return RegistryAccess.registryAccess().getRegistry(RegistryKey.INSTRUMENT).getOrThrow(Key.key(Key.MINECRAFT_NAMESPACE, key));
}
/**
* Returns a {@link MusicInstrument} by a {@link NamespacedKey}.
*
* @param namespacedKey the key
* @return the event or null
* @deprecated use {@link Registry#get(NamespacedKey)} instead
*/
@Nullable
@Deprecated(since = "1.20.1")
public static MusicInstrument getByKey(final NamespacedKey namespacedKey) {
return RegistryAccess.registryAccess().getRegistry(RegistryKey.INSTRUMENT).get(namespacedKey);
}
/**
* Returns all known music instruments.
*
* @return the music instruments
* @deprecated use {@link Registry#iterator()}
*/
@Deprecated(since = "1.20.1")
public static Collection<MusicInstrument> values() {
return RegistryAccess.registryAccess().getRegistry(RegistryKey.INSTRUMENT).stream().toList();
}
/**
* Gets the use duration of this music instrument.
*
* @return the duration expressed in seconds
*/
public abstract float getDuration();
/**
* Gets the range of the sound.
*
* @return the range of the sound
*/
public abstract float getRange();
/**
* Gets the description of this instrument as displayed to the client.
*
* @return the description component
*/
public abstract Component description();
/**
* Gets the sound for this instrument.
*
* @return the sound
*/
public abstract Sound getSound();
/**
* @deprecated use {@link Registry#getKey(Keyed)}, {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)},
* and {@link io.papermc.paper.registry.RegistryKey#INSTRUMENT}. MusicInstruments can exist without a key.
*/
@Deprecated(forRemoval = true, since = "1.20.5")
@Override
public abstract NamespacedKey getKey();
/**
* @deprecated use {@link Registry#getKey(Keyed)}, {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)},
* and {@link io.papermc.paper.registry.RegistryKey#INSTRUMENT}. MusicInstruments can exist without a key.
*/
@Deprecated(forRemoval = true, since = "1.20.5")
@Override
public net.kyori.adventure.key.@org.jetbrains.annotations.NotNull Key key() {
return Keyed.super.key();
}
/**
* @deprecated this method assumes that the instrument description
* always be a translatable component which is not guaranteed.
*/
@Override
@Deprecated(forRemoval = true)
public abstract String translationKey();
}