mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 13:07:06 +01:00
Fixed a bunch of multiworld issues (entity tracking etc)
This commit is contained in:
parent
036f49ddbf
commit
1784e42d5f
5 changed files with 37 additions and 17 deletions
|
@ -51,7 +51,7 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
|||
|
||||
// CraftBukkit start
|
||||
public int spawnProtection;
|
||||
public List<WorldServer> worlds = new ArrayList<WorldServer>(); // TODO - REPLACE ABOVE
|
||||
public List<WorldServer> worlds = new ArrayList<WorldServer>();
|
||||
public CraftServer server;
|
||||
public OptionSet options;
|
||||
public ColouredConsoleSender console;
|
||||
|
@ -461,7 +461,15 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
|||
}
|
||||
|
||||
public WorldServer a(int i) {
|
||||
return i == -1 ? this.worlds.get(1) : this.worlds.get(0); // Craftbukkit
|
||||
// Craftbukkit start
|
||||
for (WorldServer world : worlds) {
|
||||
if (world.dimension == i) {
|
||||
return world;
|
||||
}
|
||||
}
|
||||
|
||||
return worlds.get(0);
|
||||
// Craftbukkit end
|
||||
}
|
||||
|
||||
public EntityTracker b(int i) {
|
||||
|
|
|
@ -29,7 +29,7 @@ public class ServerConfigurationManager {
|
|||
public static Logger a = Logger.getLogger("Minecraft");
|
||||
public List players = new ArrayList();
|
||||
public MinecraftServer server; // CraftBukkit - private -> public
|
||||
private PlayerManager[] d = new PlayerManager[2];
|
||||
// private PlayerManager[] d = new PlayerManager[2]; // Craftbukkit - removed
|
||||
public int maxPlayers; // CraftBukkit - private -> public
|
||||
private Set banByName = new HashSet();
|
||||
private Set banByIP = new HashSet();
|
||||
|
@ -58,8 +58,7 @@ public class ServerConfigurationManager {
|
|||
this.m = minecraftserver.a("white-list.txt");
|
||||
int i = minecraftserver.propertyManager.getInt("view-distance", 10);
|
||||
|
||||
this.d[0] = new PlayerManager(minecraftserver, 0, i);
|
||||
this.d[1] = new PlayerManager(minecraftserver, -1, i);
|
||||
// Craftbukkit - removed playermanagers
|
||||
this.maxPlayers = minecraftserver.propertyManager.getInt("max-players", 20);
|
||||
this.o = minecraftserver.propertyManager.getBoolean("white-list", false);
|
||||
this.g();
|
||||
|
@ -78,8 +77,7 @@ public class ServerConfigurationManager {
|
|||
}
|
||||
|
||||
public void a(EntityPlayer entityplayer) {
|
||||
this.d[0].removePlayer(entityplayer);
|
||||
this.d[1].removePlayer(entityplayer);
|
||||
// Craftbukkit - removed playermanagers
|
||||
this.a(entityplayer.dimension).addPlayer(entityplayer);
|
||||
WorldServer worldserver = this.server.a(entityplayer.dimension);
|
||||
|
||||
|
@ -87,11 +85,17 @@ public class ServerConfigurationManager {
|
|||
}
|
||||
|
||||
public int a() {
|
||||
return this.d[0].c();
|
||||
// Craftbukkit start
|
||||
if (this.server.worlds.size() == 0) {
|
||||
return this.server.propertyManager.getInt("view-distance", 10) * 16 - 16;
|
||||
} else {
|
||||
return this.server.worlds.get(0).manager.c();
|
||||
}
|
||||
// Craftbukkit end
|
||||
}
|
||||
|
||||
private PlayerManager a(int i) {
|
||||
return i == -1 ? this.d[1] : this.d[0];
|
||||
return server.a(i).manager; // Craftbukkit
|
||||
}
|
||||
|
||||
public void b(EntityPlayer entityplayer) {
|
||||
|
@ -241,7 +245,7 @@ public class ServerConfigurationManager {
|
|||
entityplayer1.setPosition(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ);
|
||||
}
|
||||
|
||||
entityplayer1.netServerHandler.sendPacket(new Packet9Respawn((byte) entityplayer1.dimension));
|
||||
entityplayer1.netServerHandler.sendPacket(new Packet9Respawn((byte) ((WorldServer)entityplayer1.world).getWorld().getEnvironment().getId()));
|
||||
entityplayer1.netServerHandler.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch);
|
||||
this.a(entityplayer1, worldserver);
|
||||
this.a(entityplayer1.dimension).addPlayer(entityplayer1);
|
||||
|
@ -266,7 +270,8 @@ public class ServerConfigurationManager {
|
|||
entityplayer.dimension = b0;
|
||||
WorldServer worldserver1 = this.server.a(entityplayer.dimension);
|
||||
|
||||
entityplayer.netServerHandler.sendPacket(new Packet9Respawn((byte) entityplayer.dimension));
|
||||
// Craftbukkit
|
||||
entityplayer.netServerHandler.sendPacket(new Packet9Respawn((byte) ((WorldServer)entityplayer.world).getWorld().getEnvironment().getId()));
|
||||
worldserver.removeEntity(entityplayer);
|
||||
entityplayer.dead = false;
|
||||
double d0 = entityplayer.locX;
|
||||
|
@ -306,9 +311,11 @@ public class ServerConfigurationManager {
|
|||
}
|
||||
|
||||
public void b() {
|
||||
for (int i = 0; i < this.d.length; ++i) {
|
||||
this.d[i].flush();
|
||||
// Craftbukkit start
|
||||
for (int i = 0; i < this.server.worlds.size(); ++i) {
|
||||
this.server.worlds.get(i).manager.flush();
|
||||
}
|
||||
// Craftbukkit end
|
||||
}
|
||||
|
||||
public void flagDirty(int i, int j, int k, int l) {
|
||||
|
|
|
@ -27,12 +27,14 @@ public class WorldServer extends World implements BlockChangeDelegate {
|
|||
this.cserver = minecraftserver.server;
|
||||
this.world = new CraftWorld(this);
|
||||
this.pvpMode = minecraftserver.pvpMode;
|
||||
this.manager = new PlayerManager(minecraftserver, dimension, minecraftserver.propertyManager.getInt("view-distance", 10));
|
||||
}
|
||||
|
||||
public final int dimension;
|
||||
private final CraftWorld world;
|
||||
private final CraftServer cserver;
|
||||
public EntityTracker tracker;
|
||||
public PlayerManager manager;
|
||||
|
||||
public CraftWorld getWorld() {
|
||||
return world;
|
||||
|
|
|
@ -287,7 +287,7 @@ public final class CraftServer implements Server {
|
|||
}
|
||||
|
||||
// See if the server can process this command
|
||||
return console.consoleCommandHandler.handle(new ServerCommand(commandLine, new ServerCommandListener(sender)));
|
||||
return console.consoleCommandHandler.handle(new ServerCommand(commandLine, (ICommandListener)new ServerCommandListener(sender)));
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
|
@ -366,10 +366,11 @@ public final class CraftServer implements Server {
|
|||
converter.convert(name, new ConvertProgressUpdater(console));
|
||||
}
|
||||
|
||||
WorldServer internal = new WorldServer(console, new ServerNBTManager(new File("."), name, true), name, environment.getId(), seed);
|
||||
int dimension = environment.getId() + 200 + console.worlds.size();
|
||||
WorldServer internal = new WorldServer(console, new ServerNBTManager(new File("."), name, true), name, dimension, seed);
|
||||
internal.z = console.worlds.get(0).z;
|
||||
|
||||
internal.tracker = new EntityTracker(console, environment.getId());
|
||||
internal.tracker = new EntityTracker(console, dimension);
|
||||
internal.addIWorldAccess((IWorldAccess)new WorldManager(console, internal));
|
||||
internal.spawnMonsters = 1;
|
||||
internal.setSpawnFlags(true, true);
|
||||
|
|
|
@ -173,11 +173,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
|
||||
if (oldWorld != newWorld) {
|
||||
entity.dimension = newWorld.dimension;
|
||||
entity.netServerHandler.sendPacket(new Packet9Respawn((byte) entity.dimension));
|
||||
entity.netServerHandler.sendPacket(new Packet9Respawn((byte) location.getWorld().getEnvironment().getId()));
|
||||
oldWorld.removeEntity(entity);
|
||||
entity.dead = false;
|
||||
|
||||
entity.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
if (entity.Q()) {
|
||||
oldWorld.entityJoinedWorld(entity, false);
|
||||
newWorld.addEntity(entity);
|
||||
entity.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
newWorld.entityJoinedWorld(entity, false);
|
||||
|
|
Loading…
Reference in a new issue