Skip to content

Commit 195a5bf

Browse files
committed
NoteBlockSongPlayer location changed to center of the block #19
1 parent c6377a6 commit 195a5bf

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.xxmicloxx</groupId>
77
<artifactId>NoteBlockAPI</artifactId>
8-
<version>1.2.4-SNAPSHOT</version>
8+
<version>1.2.4</version>
99
<name>NoteBlockAPI</name>
1010

1111
<properties>

src/main/java/com/xxmicloxx/NoteBlockAPI/songplayer/NoteBlockSongPlayer.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.xxmicloxx.NoteBlockAPI.songplayer;
22

33
import org.bukkit.Bukkit;
4+
import org.bukkit.Location;
45
import org.bukkit.Material;
56
import org.bukkit.block.Block;
67
import org.bukkit.entity.Player;
@@ -87,13 +88,15 @@ public void playTick(Player player, int tick) {
8788
return;
8889
}
8990
byte playerVolume = NoteBlockAPI.getPlayerVolume(player);
90-
91+
Location loc = noteBlock.getLocation();
92+
loc = new Location(loc.getWorld(), loc.getX() + 0.5f, loc.getY() - 0.5f, loc.getZ() + 0.5f);
93+
9194
for (Layer layer : song.getLayerHashMap().values()) {
9295
Note note = layer.getNote(tick);
9396
if (note == null) {
9497
continue;
9598
}
96-
player.playNote(noteBlock.getLocation(), InstrumentUtils.getBukkitInstrument(note.getInstrument()),
99+
player.playNote(loc, InstrumentUtils.getBukkitInstrument(note.getInstrument()),
97100
new org.bukkit.Note(note.getKey() - 33));
98101

99102
float volume = ((layer.getVolume() * (int) this.volume * (int) playerVolume) / 1000000F)
@@ -105,14 +108,14 @@ public void playTick(Player player, int tick) {
105108
[note.getInstrument() - InstrumentUtils.getCustomInstrumentFirstIndex()];
106109

107110
if (instrument.getSound() != null) {
108-
CompatibilityUtils.playSound(player, noteBlock.getLocation(),
111+
CompatibilityUtils.playSound(player, loc,
109112
instrument.getSound(), this.soundCategory, volume, pitch, false);
110113
} else {
111-
CompatibilityUtils.playSound(player, noteBlock.getLocation(),
114+
CompatibilityUtils.playSound(player, loc,
112115
instrument.getSoundFileName(), this.soundCategory, volume, pitch, false);
113116
}
114117
} else {
115-
CompatibilityUtils.playSound(player, noteBlock.getLocation(),
118+
CompatibilityUtils.playSound(player, loc,
116119
InstrumentUtils.getInstrument(note.getInstrument()), this.soundCategory, volume, pitch, false);
117120
}
118121

@@ -137,7 +140,9 @@ public void playTick(Player player, int tick) {
137140
*/
138141
@Override
139142
public boolean isInRange(Player player) {
140-
if (player.getLocation().distance(noteBlock.getLocation()) > getDistance()) {
143+
Location loc = noteBlock.getLocation();
144+
loc = new Location(loc.getWorld(), loc.getX() + 0.5f, loc.getY() - 0.5f, loc.getZ() + 0.5f);
145+
if (player.getLocation().distance(loc) > getDistance()) {
141146
return false;
142147
} else {
143148
return true;

0 commit comments

Comments
 (0)