11package com .xxmicloxx .NoteBlockAPI .songplayer ;
22
33import org .bukkit .Bukkit ;
4+ import org .bukkit .Location ;
45import org .bukkit .Material ;
56import org .bukkit .block .Block ;
67import 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