Skip to content

Commit

Permalink
Added minecraft sound names to Instrument enum
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed Jun 21, 2024
1 parent f681448 commit dd9ca06
Showing 1 changed file with 32 additions and 18 deletions.
50 changes: 32 additions & 18 deletions src/main/java/net/raphimc/noteblocklib/util/Instrument.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,33 @@

public enum Instrument {

HARP(0, 0, 0),
BASS(1, 4, 4),
BASS_DRUM(2, 1, 1),
SNARE(3, 2, 2),
HAT(4, 3, 3),
GUITAR(5, 7, 8),
FLUTE(6, 5, 6),
BELL(7, 6, 5),
CHIME(8, 8, 7),
XYLOPHONE(9, 9, 9),
IRON_XYLOPHONE(10, 10, 10),
COW_BELL(11, 11, 11),
DIDGERIDOO(12, 12, 12),
BIT(13, 13, 13),
BANJO(14, 14, 14),
PLING(15, 15, 15),
;
HARP(0, 0, 0, "block.note_block.harp"),
BASS(1, 4, 4, "block.note_block.bass"),
BASS_DRUM(2, 1, 1, "block.note_block.basedrum"),
SNARE(3, 2, 2, "block.note_block.snare"),
HAT(4, 3, 3, "block.note_block.hat"),
GUITAR(5, 7, 8, "block.note_block.guitar"),
FLUTE(6, 5, 6, "block.note_block.flute"),
BELL(7, 6, 5, "block.note_block.bell"),
CHIME(8, 8, 7, "block.note_block.chime"),
XYLOPHONE(9, 9, 9, "block.note_block.xylophone"),
IRON_XYLOPHONE(10, 10, 10, "block.note_block.iron_xylophone"),
COW_BELL(11, 11, 11, "block.note_block.cow_bell"),
DIDGERIDOO(12, 12, 12, "block.note_block.didgeridoo"),
BIT(13, 13, 13, "block.note_block.bit"),
BANJO(14, 14, 14, "block.note_block.banjo"),
PLING(15, 15, 15, "block.note_block.pling");

private final byte nbsId;
private final byte mcId;
private final byte mcbeId;
private final String mcSoundName;

Instrument(final int nbsId, final int mcId, final int mcbeId) {
Instrument(final int nbsId, final int mcId, final int mcbeId, final String mcSoundName) {
this.nbsId = (byte) nbsId;
this.mcId = (byte) mcId;
this.mcbeId = (byte) mcbeId;
this.mcSoundName = mcSoundName;
}

public byte nbsId() {
Expand All @@ -59,6 +60,10 @@ public byte mcbeId() {
return this.mcbeId;
}

public String mcSoundName() {
return this.mcSoundName;
}

public static Instrument fromNbsId(final byte nbsId) {
for (final Instrument instrument : Instrument.values()) {
if (instrument.nbsId == nbsId) {
Expand Down Expand Up @@ -86,4 +91,13 @@ public static Instrument fromMcbeId(final byte mcbeId) {
return null;
}

public static Instrument fromMcSoundName(final String mcSoundName) {
for (final Instrument instrument : Instrument.values()) {
if (instrument.mcSoundName.equals(mcSoundName)) {
return instrument;
}
}
return null;
}

}

0 comments on commit dd9ca06

Please sign in to comment.