File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
src/main/java/cn/nukkit/entity/item Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -143,15 +143,20 @@ public boolean onUpdate(int currentTick) {
143
143
}
144
144
145
145
if (this .closestPlayer == null || this .closestPlayer .distanceSquared (this ) > 64.0D ) {
146
+ this .closestPlayer = null ;
147
+ double closestDistance = 0.0D ;
146
148
for (Player p : this .getViewers ().values ()) {
147
- if (!p .isSpectator () && p .distance (this ) <= 8 ) {
148
- this .closestPlayer = p ;
149
- break ;
149
+ if (!p .isSpectator () && p .spawned && p .isAlive ()) {
150
+ double d = p .distanceSquared (this );
151
+ if (d <= 64.0D && (this .closestPlayer == null || d < closestDistance )) {
152
+ this .closestPlayer = p ;
153
+ closestDistance = d ;
154
+ }
150
155
}
151
156
}
152
157
}
153
158
154
- if (this .closestPlayer != null && this .closestPlayer .isSpectator ()) {
159
+ if (this .closestPlayer != null && ( this .closestPlayer .isSpectator () || ! this . closestPlayer . spawned || ! this . closestPlayer . isAlive () )) {
155
160
this .closestPlayer = null ;
156
161
}
157
162
You can’t perform that action at this time.
0 commit comments