mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-24 19:46:21 +01:00
More teleport changes. Thanks Zeerix!
This commit is contained in:
parent
5296f97cde
commit
b5d1619e75
@ -93,38 +93,32 @@ public class NetworkManager {
|
||||
|
||||
try {
|
||||
Object object;
|
||||
Packet packet;
|
||||
Packet packet = null; // CraftBukkit
|
||||
int i;
|
||||
int[] aint;
|
||||
|
||||
if (!this.n.isEmpty() && (this.f == 0 || System.currentTimeMillis() - ((Packet) this.n.get(0)).timestamp >= (long) this.f)) {
|
||||
object = this.g;
|
||||
synchronized (this.g) {
|
||||
// CraftBukkit start - thread safety and prioitizing packets in this.n (high prioirty queue) over those in this.o (low priority queue).
|
||||
object = this.g;
|
||||
synchronized (this.g) {
|
||||
long time = System.currentTimeMillis();
|
||||
if (!this.n.isEmpty() && (this.f == 0 || time - ((Packet) this.n.get(0)).timestamp >= (long) this.f)) {
|
||||
packet = (Packet) this.n.remove(0);
|
||||
this.x -= packet.a() + 1;
|
||||
}
|
||||
|
||||
Packet.a(packet, this.output);
|
||||
aint = e;
|
||||
i = packet.b();
|
||||
aint[i] += packet.a() + 1;
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (this.y-- <= 0 && !this.o.isEmpty() && (this.f == 0 || System.currentTimeMillis() - ((Packet) this.o.get(0)).timestamp >= (long) this.f)) {
|
||||
object = this.g;
|
||||
synchronized (this.g) {
|
||||
} else if (this.y-- <= 0 && !this.o.isEmpty() && (this.f == 0 || time - ((Packet) this.o.get(0)).timestamp >= (long) this.f)) {
|
||||
packet = (Packet) this.o.remove(0);
|
||||
this.x -= packet.a() + 1;
|
||||
this.y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (packet != null) {
|
||||
Packet.a(packet, this.output);
|
||||
aint = e;
|
||||
i = packet.b();
|
||||
aint[i] += packet.a() + 1;
|
||||
this.y = 0;
|
||||
flag = true;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
return flag;
|
||||
} catch (Exception exception) {
|
||||
|
@ -3,6 +3,11 @@ package net.minecraft.server;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// CraftBukkit start
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
// CraftBukkit end
|
||||
|
||||
public class PlayerManager {
|
||||
|
||||
public List a = new ArrayList();
|
||||
@ -134,14 +139,6 @@ public class PlayerManager {
|
||||
int i1 = i - k;
|
||||
int j1 = j - l;
|
||||
|
||||
// CraftBukkit start
|
||||
if (i1 > this.f || i1 < -this.f || j1 > this.f || j1 < -this.f) {
|
||||
this.removePlayer(entityplayer);
|
||||
this.addPlayer(entityplayer);
|
||||
return;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
if (i1 != 0 || j1 != 0) {
|
||||
for (int k1 = i - this.f; k1 <= i + this.f; ++k1) {
|
||||
for (int l1 = j - this.f; l1 <= j + this.f; ++l1) {
|
||||
@ -161,6 +158,19 @@ public class PlayerManager {
|
||||
|
||||
entityplayer.d = entityplayer.locX;
|
||||
entityplayer.e = entityplayer.locZ;
|
||||
|
||||
// CraftBukkit start - send nearest chunks first
|
||||
if (i1 > 1 || i1 < -1 || j1 > 1 || j1 < -1) {
|
||||
final int x = i;
|
||||
final int z = j;
|
||||
List<ChunkCoordIntPair> chunksToSend = entityplayer.f;
|
||||
Collections.sort(chunksToSend, new Comparator<ChunkCoordIntPair>() {
|
||||
public int compare(ChunkCoordIntPair a, ChunkCoordIntPair b) {
|
||||
return Math.max(Math.abs(a.x-x), Math.abs(a.z-z)) - Math.max(Math.abs(b.x-x), Math.abs(b.z-z));
|
||||
}
|
||||
});
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user