3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-20 05:20:07 +01:00

Made teleporting between worlds 'smoother'. Thanks Raphfrk!

Dieser Commit ist enthalten in:
EvilSeph 2011-05-04 22:16:26 -04:00
Ursprung ef7e3689b3
Commit 54e2254904
2 geänderte Dateien mit 17 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -37,8 +37,11 @@ class PlayerInstance {
if (this.b.contains(entityplayer)) { if (this.b.contains(entityplayer)) {
throw new IllegalStateException("Failed to add player. " + entityplayer + " already is in chunk " + this.chunkX + ", " + this.chunkZ); throw new IllegalStateException("Failed to add player. " + entityplayer + " already is in chunk " + this.chunkX + ", " + this.chunkZ);
} else { } else {
entityplayer.g.add(this.e); // CraftBukkit start
entityplayer.netServerHandler.sendPacket(new Packet50PreChunk(this.e.x, this.e.z, true)); if (entityplayer.g.add(this.e)) {
entityplayer.netServerHandler.sendPacket(new Packet50PreChunk(this.e.x, this.e.z, true));
}
// CraftBukkit end
this.b.add(entityplayer); this.b.add(entityplayer);
entityplayer.f.add(this.e); entityplayer.f.add(this.e);
} }
@ -63,7 +66,7 @@ class PlayerInstance {
} }
entityplayer.f.remove(this.e); entityplayer.f.remove(this.e);
if (entityplayer.g.contains(this.e)) { if (entityplayer.g.remove(this.e)) { // CraftBukkit - contains -> remove
entityplayer.netServerHandler.sendPacket(new Packet50PreChunk(this.chunkX, this.chunkZ, false)); entityplayer.netServerHandler.sendPacket(new Packet50PreChunk(this.chunkX, this.chunkZ, false));
} }
} }

Datei anzeigen

@ -12,6 +12,7 @@ import net.minecraft.server.Packet54PlayNoteBlock;
import net.minecraft.server.Packet6SpawnPosition; import net.minecraft.server.Packet6SpawnPosition;
import net.minecraft.server.ServerConfigurationManager; import net.minecraft.server.ServerConfigurationManager;
import net.minecraft.server.WorldServer; import net.minecraft.server.WorldServer;
import net.minecraft.server.ChunkCoordIntPair;
import org.bukkit.Achievement; import org.bukkit.Achievement;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -194,6 +195,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (teleportSuccess) { if (teleportSuccess) {
manager.server.tracker.trackPlayer(entity); manager.server.tracker.trackPlayer(entity);
manager.server.tracker.untrackEntity(entity); manager.server.tracker.untrackEntity(entity);
int cx = (int) location.getBlockX() >> 4;
int cz = (int) location.getBlockZ() >> 4;
for (int x = -10 ; x <= 10 ; x++ ) {
for (int z = -10 ; z <= 10 ; z++ ) {
ChunkCoordIntPair chunkPosition = new ChunkCoordIntPair(cx + x, cz + z);
if (entity.g.remove(chunkPosition)) {
newEntity.g.add(chunkPosition);
}
}
}
oldWorld.manager.removePlayer(entity); oldWorld.manager.removePlayer(entity);
manager.players.remove(entity); manager.players.remove(entity);
oldWorld.removeEntity(entity); oldWorld.removeEntity(entity);