Skip to content

Commit 4f8f1fe

Browse files
committed
Changed Note equality check to not include group id
1 parent 5be284d commit 4f8f1fe

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/main/java/net/raphimc/noteblocklib/format/minecraft/ShiftedMinecraftInstrument.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public int getOctavesShift() {
5252

5353
@Override
5454
public ShiftedMinecraftInstrument copy() {
55-
return new ShiftedMinecraftInstrument(this.instrument, this.octavesShift);
55+
return this;
5656
}
5757

5858
@Override

src/main/java/net/raphimc/noteblocklib/model/note/Note.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public Note() {
4040

4141
/**
4242
* @return The group ID of the note. Groups are used in events to determine which notes are affected by an event. -1 means that the note is not in any group.
43+
* @implNote Not checked for in equals and hashCode, as it is only used for events and does not affect the sound of the note.
4344
*/
4445
public int getGroupId() {
4546
return this.groupId;
@@ -48,6 +49,7 @@ public int getGroupId() {
4849
/**
4950
* @param groupId The group ID of the note. Groups are used in events to determine which notes are affected by an event. -1 means that the note is not in any group.
5051
* @return this
52+
* @implNote Not checked for in equals and hashCode, as it is only used for events and does not affect the sound of the note.
5153
*/
5254
public Note setGroupId(final int groupId) {
5355
this.groupId = groupId;
@@ -219,12 +221,12 @@ public Note copy() {
219221
public boolean equals(final Object o) {
220222
if (o == null || getClass() != o.getClass()) return false;
221223
final Note note = (Note) o;
222-
return groupId == note.groupId && Float.compare(midiKey, note.midiKey) == 0 && Float.compare(volume, note.volume) == 0 && Float.compare(panning, note.panning) == 0 && Objects.equals(instrument, note.instrument);
224+
return Float.compare(midiKey, note.midiKey) == 0 && Float.compare(volume, note.volume) == 0 && Float.compare(panning, note.panning) == 0 && Objects.equals(instrument, note.instrument);
223225
}
224226

225227
@Override
226228
public int hashCode() {
227-
return Objects.hash(groupId, instrument, midiKey, volume, panning);
229+
return Objects.hash(instrument, midiKey, volume, panning);
228230
}
229231

230232
}

src/main/java/net/raphimc/noteblocklib/util/SongUtil.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,13 @@
2222
import net.raphimc.noteblocklib.model.note.Note;
2323
import net.raphimc.noteblocklib.model.song.Song;
2424

25-
import java.text.DecimalFormat;
2625
import java.util.Collections;
2726
import java.util.EnumSet;
2827
import java.util.IdentityHashMap;
2928
import java.util.Set;
3029

3130
public class SongUtil {
3231

33-
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##");
34-
3532
/**
3633
* @param song The song
3734
* @return True if the song contains notes which are outside the vanilla Minecraft octave range.

0 commit comments

Comments
 (0)