mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-05 10:20:53 +01:00
Added internal MC support for multiple worlds
This commit is contained in:
parent
9e7991ab52
commit
2be5181b0c
@ -158,8 +158,11 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
|||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
this.f.remove(chunkcoordintpair);
|
this.f.remove(chunkcoordintpair);
|
||||||
this.a.b((Packet) (new Packet51MapChunk(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, 16, 128, 16, this.b.e)));
|
|
||||||
List list = this.b.e.d(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, chunkcoordintpair.a * 16 + 16, 128, chunkcoordintpair.b * 16 + 16);
|
// Craftbukkit start
|
||||||
|
this.a.b((Packet) (new Packet51MapChunk(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, 16, 128, 16, this.world)));
|
||||||
|
List list = ((WorldServer)world).d(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, chunkcoordintpair.a * 16 + 16, 128, chunkcoordintpair.b * 16 + 16);
|
||||||
|
// Craftbukkit end
|
||||||
|
|
||||||
for (int j = 0; j < list.size(); ++j) {
|
for (int j = 0; j < list.size(); ++j) {
|
||||||
this.a((TileEntity) list.get(j));
|
this.a((TileEntity) list.get(j));
|
||||||
|
152
src/main/java/net/minecraft/server/EntityTracker.java
Normal file
152
src/main/java/net/minecraft/server/EntityTracker.java
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
package net.minecraft.server;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class EntityTracker {
|
||||||
|
|
||||||
|
private Set a = new HashSet();
|
||||||
|
private EntityList b = new EntityList();
|
||||||
|
private MinecraftServer c;
|
||||||
|
private int d;
|
||||||
|
|
||||||
|
public EntityTracker(MinecraftServer minecraftserver) {
|
||||||
|
this.c = minecraftserver;
|
||||||
|
this.d = minecraftserver.f.a();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(Entity entity) {
|
||||||
|
if (entity instanceof EntityPlayer) {
|
||||||
|
this.a(entity, 512, 2);
|
||||||
|
EntityPlayer entityplayer = (EntityPlayer) entity;
|
||||||
|
Iterator iterator = this.a.iterator();
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next();
|
||||||
|
|
||||||
|
if (entitytrackerentry.a != entityplayer) {
|
||||||
|
entitytrackerentry.b(entityplayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (entity instanceof EntityFish) {
|
||||||
|
this.a(entity, 64, 5, true);
|
||||||
|
} else if (entity instanceof EntityArrow) {
|
||||||
|
this.a(entity, 64, 5, true);
|
||||||
|
} else if (entity instanceof EntitySnowball) {
|
||||||
|
this.a(entity, 64, 5, true);
|
||||||
|
} else if (entity instanceof EntityEgg) {
|
||||||
|
this.a(entity, 64, 5, true);
|
||||||
|
} else if (entity instanceof EntityItem) {
|
||||||
|
this.a(entity, 64, 20, true);
|
||||||
|
} else if (entity instanceof EntityMinecart) {
|
||||||
|
this.a(entity, 160, 5, true);
|
||||||
|
} else if (entity instanceof EntityBoat) {
|
||||||
|
this.a(entity, 160, 5, true);
|
||||||
|
} else if (entity instanceof EntitySquid) {
|
||||||
|
this.a(entity, 160, 3, true);
|
||||||
|
} else if (entity instanceof IAnimal) {
|
||||||
|
this.a(entity, 160, 3);
|
||||||
|
} else if (entity instanceof EntityTNTPrimed) {
|
||||||
|
this.a(entity, 160, 10, true);
|
||||||
|
} else if (entity instanceof EntityFallingSand) {
|
||||||
|
this.a(entity, 160, 20, true);
|
||||||
|
} else if (entity instanceof EntityPainting) {
|
||||||
|
this.a(entity, 160, Integer.MAX_VALUE, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(Entity entity, int i, int j) {
|
||||||
|
this.a(entity, i, j, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(Entity entity, int i, int j, boolean flag) {
|
||||||
|
if (i > this.d) {
|
||||||
|
i = this.d;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.b.b(entity.id)) {
|
||||||
|
throw new IllegalStateException("Entity is already tracked!");
|
||||||
|
} else {
|
||||||
|
EntityTrackerEntry entitytrackerentry = new EntityTrackerEntry(entity, i, j, flag);
|
||||||
|
|
||||||
|
this.a.add(entitytrackerentry);
|
||||||
|
this.b.a(entity.id, entitytrackerentry);
|
||||||
|
entitytrackerentry.b(entity.world.d); // Craftbukkit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void b(Entity entity) {
|
||||||
|
if (entity instanceof EntityPlayer) {
|
||||||
|
EntityPlayer entityplayer = (EntityPlayer) entity;
|
||||||
|
Iterator iterator = this.a.iterator();
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next();
|
||||||
|
|
||||||
|
entitytrackerentry.a(entityplayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityTrackerEntry entitytrackerentry1 = (EntityTrackerEntry) this.b.d(entity.id);
|
||||||
|
|
||||||
|
if (entitytrackerentry1 != null) {
|
||||||
|
this.a.remove(entitytrackerentry1);
|
||||||
|
entitytrackerentry1.a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a() {
|
||||||
|
ArrayList arraylist = new ArrayList();
|
||||||
|
Iterator iterator = this.a.iterator();
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next();
|
||||||
|
|
||||||
|
entitytrackerentry.a(entitytrackerentry.a.world.d); // Craftbukkit
|
||||||
|
if (entitytrackerentry.m && entitytrackerentry.a instanceof EntityPlayer) {
|
||||||
|
arraylist.add((EntityPlayer) entitytrackerentry.a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < arraylist.size(); ++i) {
|
||||||
|
EntityPlayer entityplayer = (EntityPlayer) arraylist.get(i);
|
||||||
|
Iterator iterator1 = this.a.iterator();
|
||||||
|
|
||||||
|
while (iterator1.hasNext()) {
|
||||||
|
EntityTrackerEntry entitytrackerentry1 = (EntityTrackerEntry) iterator1.next();
|
||||||
|
|
||||||
|
if (entitytrackerentry1.a != entityplayer) {
|
||||||
|
entitytrackerentry1.b(entityplayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(Entity entity, Packet packet) {
|
||||||
|
EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) this.b.a(entity.id);
|
||||||
|
|
||||||
|
if (entitytrackerentry != null) {
|
||||||
|
entitytrackerentry.a(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void b(Entity entity, Packet packet) {
|
||||||
|
EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) this.b.a(entity.id);
|
||||||
|
|
||||||
|
if (entitytrackerentry != null) {
|
||||||
|
entitytrackerentry.b(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(EntityPlayer entityplayer) {
|
||||||
|
Iterator iterator = this.a.iterator();
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next();
|
||||||
|
|
||||||
|
entitytrackerentry.c(entityplayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -26,7 +26,7 @@ public class MinecraftServer implements ICommandListener, Runnable {
|
|||||||
public static HashMap b = new HashMap();
|
public static HashMap b = new HashMap();
|
||||||
public NetworkListenThread c;
|
public NetworkListenThread c;
|
||||||
public PropertyManager d;
|
public PropertyManager d;
|
||||||
public WorldServer e;
|
//public WorldServer e;
|
||||||
public ServerConfigurationManager f;
|
public ServerConfigurationManager f;
|
||||||
private boolean o = true;
|
private boolean o = true;
|
||||||
public boolean g = false;
|
public boolean g = false;
|
||||||
@ -39,6 +39,7 @@ public class MinecraftServer implements ICommandListener, Runnable {
|
|||||||
public boolean l;
|
public boolean l;
|
||||||
public boolean m;
|
public boolean m;
|
||||||
public boolean n;
|
public boolean n;
|
||||||
|
public List<WorldServer> worlds = new ArrayList<WorldServer>();
|
||||||
|
|
||||||
// Craftbukkit start - adds argument OptionSet
|
// Craftbukkit start - adds argument OptionSet
|
||||||
public MinecraftServer(OptionSet options) {
|
public MinecraftServer(OptionSet options) {
|
||||||
@ -109,11 +110,16 @@ public class MinecraftServer implements ICommandListener, Runnable {
|
|||||||
|
|
||||||
private void c(String s) {
|
private void c(String s) {
|
||||||
a.info("Preparing start region");
|
a.info("Preparing start region");
|
||||||
this.e = new WorldServer(this, new File("."), s, this.d.a("hellworld", false) ? -1 : 0);
|
|
||||||
this.e.a(new WorldManager(this));
|
// Craftbukkit start
|
||||||
this.e.k = this.d.a("spawn-monsters", true) ? 1 : 0;
|
WorldServer world = new WorldServer(this, new File("."), s, this.d.a("hellworld", false) ? -1 : 0);
|
||||||
this.e.a(this.d.a("spawn-monsters", true), this.m);
|
world.a(new WorldManager(this, world));
|
||||||
this.f.a(this.e);
|
world.k = this.d.a("spawn-monsters", true) ? 1 : 0;
|
||||||
|
world.a(this.d.a("spawn-monsters", true), this.m);
|
||||||
|
this.f.a(world);
|
||||||
|
worlds.add(world);
|
||||||
|
// Craftbukkit end
|
||||||
|
|
||||||
short short1 = 196;
|
short short1 = 196;
|
||||||
long i = System.currentTimeMillis();
|
long i = System.currentTimeMillis();
|
||||||
|
|
||||||
@ -133,11 +139,15 @@ public class MinecraftServer implements ICommandListener, Runnable {
|
|||||||
i = l;
|
i = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.e.A.d(this.e.spawnX + j >> 4, this.e.spawnZ + k >> 4);
|
// Craftbukkit start
|
||||||
|
for (WorldServer worldserver : worlds) {
|
||||||
|
world.A.d(world.spawnX + j >> 4, world.spawnZ + k >> 4);
|
||||||
|
|
||||||
while (this.e.d() && this.o) {
|
while (world.d() && this.o) {
|
||||||
;
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// Craftbukkit end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +169,12 @@ public class MinecraftServer implements ICommandListener, Runnable {
|
|||||||
|
|
||||||
private void f() {
|
private void f() {
|
||||||
a.info("Saving chunks");
|
a.info("Saving chunks");
|
||||||
this.e.a(true, (IProgressUpdate) null);
|
|
||||||
|
// Craftbukkit start
|
||||||
|
for (WorldServer world : worlds) {
|
||||||
|
world.a(true, (IProgressUpdate) null);
|
||||||
|
}
|
||||||
|
// Craftbukkit end
|
||||||
}
|
}
|
||||||
|
|
||||||
private void g() {
|
private void g() {
|
||||||
@ -173,7 +188,7 @@ public class MinecraftServer implements ICommandListener, Runnable {
|
|||||||
this.f.d();
|
this.f.d();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.e != null) {
|
if (this.worlds.size() > 0) { // Craftbukkit
|
||||||
this.f();
|
this.f();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,21 +285,31 @@ public class MinecraftServer implements ICommandListener, Runnable {
|
|||||||
AxisAlignedBB.a();
|
AxisAlignedBB.a();
|
||||||
Vec3D.a();
|
Vec3D.a();
|
||||||
++this.h;
|
++this.h;
|
||||||
|
|
||||||
|
// Craftbukkit start
|
||||||
if (this.h % 20 == 0) {
|
if (this.h % 20 == 0) {
|
||||||
this.f.a((Packet) (new Packet4UpdateTime(this.e.e)));
|
for (int i = 0; i < this.f.b.size(); ++i) {
|
||||||
|
EntityPlayer entityplayer = (EntityPlayer) this.f.b.get(i);
|
||||||
|
entityplayer.a.b((Packet) (new Packet4UpdateTime(entityplayer.world.e)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (WorldServer world : worlds) {
|
||||||
|
world.f();
|
||||||
|
|
||||||
this.e.f();
|
while (world.d()) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
// CraftBukkit start
|
;
|
||||||
((CraftScheduler) server.getScheduler()).mainThreadHeartbeat(this.h);
|
((CraftScheduler) server.getScheduler()).mainThreadHeartbeat(this.h);
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
while (this.e.d()) {
|
while (this.e.d()) {
|
||||||
;
|
;
|
||||||
|
world.c();
|
||||||
}
|
}
|
||||||
|
// Craftbukkit end
|
||||||
|
|
||||||
this.e.c();
|
|
||||||
this.c.a();
|
this.c.a();
|
||||||
this.f.b();
|
this.f.b();
|
||||||
this.k.a();
|
this.k.a();
|
||||||
@ -325,17 +350,32 @@ public class MinecraftServer implements ICommandListener, Runnable {
|
|||||||
this.o = false;
|
this.o = false;
|
||||||
} else if (s.toLowerCase().startsWith("save-all")) {
|
} else if (s.toLowerCase().startsWith("save-all")) {
|
||||||
this.a(s1, "Forcing save..");
|
this.a(s1, "Forcing save..");
|
||||||
this.e.a(true, (IProgressUpdate) null);
|
|
||||||
// Craftbukkit start -- save player data on save-all.
|
// Craftbukkit start
|
||||||
|
for (WorldServer world : worlds) {
|
||||||
|
world.a(true, (IProgressUpdate) null);
|
||||||
|
}
|
||||||
|
|
||||||
this.f.d();
|
this.f.d();
|
||||||
// Craftbukkit end
|
// Craftbukkit end
|
||||||
|
|
||||||
this.a(s1, "Save complete.");
|
this.a(s1, "Save complete.");
|
||||||
} else if (s.toLowerCase().startsWith("save-off")) {
|
} else if (s.toLowerCase().startsWith("save-off")) {
|
||||||
this.a(s1, "Disabling level saving..");
|
this.a(s1, "Disabling level saving..");
|
||||||
this.e.C = true;
|
|
||||||
|
// Craftbukkit start
|
||||||
|
for (WorldServer world : worlds) {
|
||||||
|
world.C = true;
|
||||||
|
}
|
||||||
|
// Craftbukkit end
|
||||||
} else if (s.toLowerCase().startsWith("save-on")) {
|
} else if (s.toLowerCase().startsWith("save-on")) {
|
||||||
this.a(s1, "Enabling level saving..");
|
this.a(s1, "Enabling level saving..");
|
||||||
this.e.C = false;
|
|
||||||
|
// Craftbukkit start
|
||||||
|
for (WorldServer world : worlds) {
|
||||||
|
world.C = false;
|
||||||
|
}
|
||||||
|
// Craftbukkit end
|
||||||
} else {
|
} else {
|
||||||
String s2;
|
String s2;
|
||||||
|
|
||||||
|
118
src/main/java/net/minecraft/server/NetLoginHandler.java
Normal file
118
src/main/java/net/minecraft/server/NetLoginHandler.java
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
package net.minecraft.server;
|
||||||
|
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class NetLoginHandler extends NetHandler {
|
||||||
|
|
||||||
|
public static Logger a = Logger.getLogger("Minecraft");
|
||||||
|
private static Random d = new Random();
|
||||||
|
public NetworkManager b;
|
||||||
|
public boolean c = false;
|
||||||
|
private MinecraftServer e;
|
||||||
|
private int f = 0;
|
||||||
|
private String g = null;
|
||||||
|
private Packet1Login h = null;
|
||||||
|
private String i = "";
|
||||||
|
|
||||||
|
public NetLoginHandler(MinecraftServer minecraftserver, Socket socket, String s) {
|
||||||
|
this.e = minecraftserver;
|
||||||
|
this.b = new NetworkManager(socket, s, this);
|
||||||
|
this.b.d = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a() {
|
||||||
|
if (this.h != null) {
|
||||||
|
this.b(this.h);
|
||||||
|
this.h = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.f++ == 600) {
|
||||||
|
this.a("Took too long to log in");
|
||||||
|
} else {
|
||||||
|
this.b.a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(String s) {
|
||||||
|
try {
|
||||||
|
a.info("Disconnecting " + this.b() + ": " + s);
|
||||||
|
this.b.a((Packet) (new Packet255KickDisconnect(s)));
|
||||||
|
this.b.c();
|
||||||
|
this.c = true;
|
||||||
|
} catch (Exception exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(Packet2Handshake packet2handshake) {
|
||||||
|
if (this.e.l) {
|
||||||
|
this.i = Long.toHexString(d.nextLong());
|
||||||
|
this.b.a((Packet) (new Packet2Handshake(this.i)));
|
||||||
|
} else {
|
||||||
|
this.b.a((Packet) (new Packet2Handshake("-")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(Packet1Login packet1login) {
|
||||||
|
this.g = packet1login.b;
|
||||||
|
if (packet1login.a != 8) {
|
||||||
|
if (packet1login.a > 8) {
|
||||||
|
this.a("Outdated server!");
|
||||||
|
} else {
|
||||||
|
this.a("Outdated client!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!this.e.l) {
|
||||||
|
this.b(packet1login);
|
||||||
|
} else {
|
||||||
|
(new ThreadLoginVerifier(this, packet1login)).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void b(Packet1Login packet1login) {
|
||||||
|
EntityPlayer entityplayer = this.e.f.a(this, packet1login.b, packet1login.c);
|
||||||
|
|
||||||
|
if (entityplayer != null) {
|
||||||
|
a.info(this.b() + " logged in with entity id " + entityplayer.id);
|
||||||
|
NetServerHandler netserverhandler = new NetServerHandler(this.e, this.b, entityplayer);
|
||||||
|
|
||||||
|
// Craftbukkit start
|
||||||
|
netserverhandler.b((Packet) (new Packet1Login("", "", entityplayer.id, entityplayer.world.u, (byte) entityplayer.world.q.g)));
|
||||||
|
netserverhandler.b((Packet) (new Packet6SpawnPosition(entityplayer.world.spawnX, entityplayer.world.spawnY, entityplayer.world.spawnZ)));
|
||||||
|
this.e.f.a((Packet) (new Packet3Chat("§e" + entityplayer.name + " joined the game.")));
|
||||||
|
this.e.f.a(entityplayer);
|
||||||
|
netserverhandler.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch);
|
||||||
|
this.e.c.a(netserverhandler);
|
||||||
|
netserverhandler.b((Packet) (new Packet4UpdateTime(entityplayer.world.e)));
|
||||||
|
// Craftbukkit end
|
||||||
|
|
||||||
|
entityplayer.l();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.c = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(String s, Object[] aobject) {
|
||||||
|
a.info(this.b() + " lost connection");
|
||||||
|
this.c = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(Packet packet) {
|
||||||
|
this.a("Protocol error");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String b() {
|
||||||
|
return this.g != null ? this.g + " [" + this.b.b().toString() + "]" : this.b.b().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
static String a(NetLoginHandler netloginhandler) {
|
||||||
|
return netloginhandler.i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Packet1Login a(NetLoginHandler netloginhandler, Packet1Login packet1login) {
|
||||||
|
return netloginhandler.h = packet1login;
|
||||||
|
}
|
||||||
|
}
|
@ -156,7 +156,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
this.e.motX = d5;
|
this.e.motX = d5;
|
||||||
this.e.motZ = d4;
|
this.e.motZ = d4;
|
||||||
if (this.e.vehicle != null) {
|
if (this.e.vehicle != null) {
|
||||||
this.d.e.b(this.e.vehicle, true);
|
((WorldServer)this.e.world).b(this.e.vehicle, true); // Craftbukkit
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.e.vehicle != null) {
|
if (this.e.vehicle != null) {
|
||||||
@ -167,7 +167,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
this.g = this.e.locX;
|
this.g = this.e.locX;
|
||||||
this.h = this.e.locY;
|
this.h = this.e.locY;
|
||||||
this.i = this.e.locZ;
|
this.i = this.e.locZ;
|
||||||
this.d.e.f(this.e);
|
this.e.world.f(this.e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
double d6 = d2 - this.e.locY;
|
double d6 = d2 - this.e.locY;
|
||||||
double d7 = d3 - this.e.locZ;
|
double d7 = d3 - this.e.locZ;
|
||||||
float f4 = 0.0625F;
|
float f4 = 0.0625F;
|
||||||
boolean flag = this.d.e.a(this.e, this.e.boundingBox.b().e((double) f4, (double) f4, (double) f4)).size() == 0;
|
boolean flag = this.e.world.a(this.e, this.e.boundingBox.b().e((double) f4, (double) f4, (double) f4)).size() == 0; // Craftbukkit
|
||||||
|
|
||||||
this.e.c(d4, d6, d7);
|
this.e.c(d4, d6, d7);
|
||||||
d4 = d1 - this.e.locX;
|
d4 = d1 - this.e.locX;
|
||||||
@ -231,7 +231,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.e.b(d1, d2, d3, f2, f3);
|
this.e.b(d1, d2, d3, f2, f3);
|
||||||
boolean flag2 = this.d.e.a(this.e, this.e.boundingBox.b().e((double) f4, (double) f4, (double) f4)).size() == 0;
|
boolean flag2 = this.e.world.a(this.e, this.e.boundingBox.b().e((double) f4, (double) f4, (double) f4)).size() == 0; // Craftbukkit
|
||||||
|
|
||||||
if (flag && (flag1 || !flag2)) {
|
if (flag && (flag1 || !flag2)) {
|
||||||
this.a(this.g, this.h, this.i, f2, f3);
|
this.a(this.g, this.h, this.i, f2, f3);
|
||||||
@ -274,7 +274,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
if (packet14blockdig.e == 4) {
|
if (packet14blockdig.e == 4) {
|
||||||
this.e.O();
|
this.e.O();
|
||||||
} else {
|
} else {
|
||||||
boolean flag = this.d.e.B = this.d.f.g(this.e.name);
|
boolean flag = ((WorldServer)this.e.world).B = this.d.f.g(this.e.name); // Craftbukkit
|
||||||
boolean flag1 = false;
|
boolean flag1 = false;
|
||||||
|
|
||||||
if (packet14blockdig.e == 0) {
|
if (packet14blockdig.e == 0) {
|
||||||
@ -306,8 +306,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int l = packet14blockdig.d;
|
int l = packet14blockdig.d;
|
||||||
int i1 = (int) MathHelper.e((float) (i - this.d.e.spawnX));
|
int i1 = (int) MathHelper.e((float) (i - this.e.world.spawnX)); // Craftbukkit
|
||||||
int j1 = (int) MathHelper.e((float) (k - this.d.e.spawnZ));
|
int j1 = (int) MathHelper.e((float) (k - this.e.world.spawnZ)); // Craftbukkit
|
||||||
|
|
||||||
if (i1 > j1) {
|
if (i1 > j1) {
|
||||||
j1 = i1;
|
j1 = i1;
|
||||||
@ -378,7 +378,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
double d8 = d5 * d5 + d6 * d6 + d7 * d7;
|
double d8 = d5 * d5 + d6 * d6 + d7 * d7;
|
||||||
|
|
||||||
if (d8 < 256.0D) {
|
if (d8 < 256.0D) {
|
||||||
this.e.a.b((Packet) (new Packet53BlockChange(i, j, k, this.d.e)));
|
this.e.a.b((Packet) (new Packet53BlockChange(i, j, k, this.e.world))); // Craftbukkit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,13 +388,13 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
lastZ = k;
|
lastZ = k;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
this.d.e.B = false;
|
((WorldServer)this.e.world).B = false; // Craftbukkit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void a(Packet15Place packet15place) {
|
public void a(Packet15Place packet15place) {
|
||||||
ItemStack itemstack = this.e.inventory.e();
|
ItemStack itemstack = this.e.inventory.e();
|
||||||
boolean flag = this.d.e.B = this.d.f.g(this.e.name);
|
boolean flag = ((WorldServer)this.e.world).B = this.d.f.g(this.e.name); // Craftbukkit
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
CraftBlock blockClicked = null;
|
CraftBlock blockClicked = null;
|
||||||
@ -411,7 +411,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
lastMaterial = 0;
|
lastMaterial = 0;
|
||||||
} else {
|
} else {
|
||||||
// CraftBukkit RIGHTCLICK or BLOCK_PLACE .. or nothing
|
// CraftBukkit RIGHTCLICK or BLOCK_PLACE .. or nothing
|
||||||
blockClicked = (CraftBlock) d.e.getWorld().getBlockAt(packet15place.a, packet15place.b, packet15place.c);
|
blockClicked = (CraftBlock) ((WorldServer)e.world).getWorld().getBlockAt(packet15place.a, packet15place.b, packet15place.c);
|
||||||
lastRightClicked = blockClicked;
|
lastRightClicked = blockClicked;
|
||||||
lastMaterial = (packet15place.e == null) ? 0 : packet15place.e.id;
|
lastMaterial = (packet15place.e == null) ? 0 : packet15place.e.id;
|
||||||
}
|
}
|
||||||
@ -454,7 +454,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
int itemstackAmount = itemstack.count;
|
int itemstackAmount = itemstack.count;
|
||||||
this.e.c.a(this.e, this.d.e, itemstack);
|
this.e.c.a(this.e, this.e.world, itemstack);
|
||||||
|
|
||||||
// CraftBukkit notch decrements the counter by 1 in the above method with food,
|
// CraftBukkit notch decrements the counter by 1 in the above method with food,
|
||||||
// snowballs and so forth, but he does it in a place that doesnt cause the
|
// snowballs and so forth, but he does it in a place that doesnt cause the
|
||||||
@ -467,8 +467,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
int j = packet15place.b;
|
int j = packet15place.b;
|
||||||
int k = packet15place.c;
|
int k = packet15place.c;
|
||||||
int l = packet15place.d;
|
int l = packet15place.d;
|
||||||
int i1 = (int) MathHelper.e((float) (i - this.d.e.spawnX));
|
int i1 = (int) MathHelper.e((float) (i - this.e.world.spawnX)); // Craftbukkit
|
||||||
int j1 = (int) MathHelper.e((float) (k - this.d.e.spawnZ));
|
int j1 = (int) MathHelper.e((float) (k - this.e.world.spawnZ)); // Craftbukkit
|
||||||
|
|
||||||
if (i1 > j1) {
|
if (i1 > j1) {
|
||||||
j1 = i1;
|
j1 = i1;
|
||||||
@ -480,10 +480,10 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
BlockRightClickEvent event = new BlockRightClickEvent(Type.BLOCK_RIGHTCLICKED, blockClicked, blockFace, craftItem, player);
|
BlockRightClickEvent event = new BlockRightClickEvent(Type.BLOCK_RIGHTCLICKED, blockClicked, blockFace, craftItem, player);
|
||||||
server.getPluginManager().callEvent(event);
|
server.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
this.e.c.a(this.e, this.d.e, itemstack, i, j, k, l);
|
this.e.c.a(this.e, this.e.world, itemstack, i, j, k, l);
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
this.e.a.b((Packet) (new Packet53BlockChange(i, j, k, this.d.e)));
|
this.e.a.b((Packet) (new Packet53BlockChange(i, j, k, this.e.world)));
|
||||||
if (l == 0) {
|
if (l == 0) {
|
||||||
--j;
|
--j;
|
||||||
}
|
}
|
||||||
@ -508,7 +508,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.e.a.b((Packet) (new Packet53BlockChange(i, j, k, this.d.e)));
|
this.e.a.b((Packet) (new Packet53BlockChange(i, j, k, this.e.world)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemstack != null && itemstack.count == 0) {
|
if (itemstack != null && itemstack.count == 0) {
|
||||||
@ -527,7 +527,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
this.b((Packet) (new Packet103SetSlot(this.e.activeContainer.f, slot.c, this.e.inventory.e())));
|
this.b((Packet) (new Packet103SetSlot(this.e.activeContainer.f, slot.c, this.e.inventory.e())));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.d.e.B = false;
|
((WorldServer)this.e.world).B = false; // Craftbukkit
|
||||||
}
|
}
|
||||||
|
|
||||||
public void a(String s, Object[] aobject) {
|
public void a(String s, Object[] aobject) {
|
||||||
@ -676,7 +676,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void a(Packet7UseEntity packet7useentity) {
|
public void a(Packet7UseEntity packet7useentity) {
|
||||||
Entity entity = this.d.e.a(packet7useentity.b);
|
Entity entity = ((WorldServer)this.e.world).a(packet7useentity.b); // Craftbukkit
|
||||||
|
|
||||||
if (entity != null && this.e.i(entity)) {
|
if (entity != null && this.e.i(entity)) {
|
||||||
if (packet7useentity.c == 0) {
|
if (packet7useentity.c == 0) {
|
||||||
@ -736,8 +736,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void a(Packet130UpdateSign packet130updatesign) {
|
public void a(Packet130UpdateSign packet130updatesign) {
|
||||||
if (this.d.e.f(packet130updatesign.a, packet130updatesign.b, packet130updatesign.c)) {
|
if (this.e.world.f(packet130updatesign.a, packet130updatesign.b, packet130updatesign.c)) { // Craftbukkit
|
||||||
TileEntity tileentity = this.d.e.getTileEntity(packet130updatesign.a, packet130updatesign.b, packet130updatesign.c);
|
TileEntity tileentity = this.e.world.getTileEntity(packet130updatesign.a, packet130updatesign.b, packet130updatesign.c); // Craftbukkit
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
@ -772,7 +772,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tileentitysign.d();
|
tileentitysign.d();
|
||||||
this.d.e.g(i, k, j);
|
this.e.world.g(i, k, j); // Craftbukkit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
190
src/main/java/net/minecraft/server/PlayerInstance.java
Normal file
190
src/main/java/net/minecraft/server/PlayerInstance.java
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
package net.minecraft.server;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
class PlayerInstance {
|
||||||
|
|
||||||
|
private List b;
|
||||||
|
private int c;
|
||||||
|
private int d;
|
||||||
|
private ChunkCoordIntPair e;
|
||||||
|
private short[] f;
|
||||||
|
private int g;
|
||||||
|
private int h;
|
||||||
|
private int i;
|
||||||
|
private int j;
|
||||||
|
private int k;
|
||||||
|
private int l;
|
||||||
|
private int m;
|
||||||
|
private WorldServer world; // Craftbukkit
|
||||||
|
|
||||||
|
final PlayerManager a;
|
||||||
|
|
||||||
|
// Craftbukkit - this method signature is changed.
|
||||||
|
public PlayerInstance(PlayerManager playermanager, int i, int j, WorldServer world) {
|
||||||
|
this.a = playermanager;
|
||||||
|
this.b = new ArrayList();
|
||||||
|
this.f = new short[10];
|
||||||
|
this.g = 0;
|
||||||
|
this.c = i;
|
||||||
|
this.d = j;
|
||||||
|
this.e = new ChunkCoordIntPair(i, j);
|
||||||
|
|
||||||
|
// Craftbukkit start
|
||||||
|
this.world = world;
|
||||||
|
world.A.d(i, j);
|
||||||
|
// Craftbukkit end
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(EntityPlayer entityplayer) {
|
||||||
|
if (this.b.contains(entityplayer)) {
|
||||||
|
throw new IllegalStateException("Failed to add player. " + entityplayer + " already is in chunk " + this.c + ", " + this.d);
|
||||||
|
} else {
|
||||||
|
entityplayer.ak.add(this.e);
|
||||||
|
entityplayer.a.b((Packet) (new Packet50PreChunk(this.e.a, this.e.b, true)));
|
||||||
|
this.b.add(entityplayer);
|
||||||
|
entityplayer.f.add(this.e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void b(EntityPlayer entityplayer) {
|
||||||
|
if (!this.b.contains(entityplayer)) {
|
||||||
|
(new IllegalStateException("Failed to remove player. " + entityplayer + " isn\'t in chunk " + this.c + ", " + this.d)).printStackTrace();
|
||||||
|
} else {
|
||||||
|
this.b.remove(entityplayer);
|
||||||
|
if (this.b.size() == 0) {
|
||||||
|
long i = (long) this.c + 2147483647L | (long) this.d + 2147483647L << 32;
|
||||||
|
|
||||||
|
PlayerManager.b(this.a).b(i);
|
||||||
|
if (this.g > 0) {
|
||||||
|
PlayerManager.c(this.a).remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
((WorldServer)entityplayer.world).A.c(this.c, this.d); // Craftbukkit
|
||||||
|
}
|
||||||
|
|
||||||
|
entityplayer.f.remove(this.e);
|
||||||
|
if (entityplayer.ak.contains(this.e)) {
|
||||||
|
entityplayer.a.b((Packet) (new Packet50PreChunk(this.c, this.d, false)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(int i, int j, int k) {
|
||||||
|
if (this.g == 0) {
|
||||||
|
PlayerManager.c(this.a).add(this);
|
||||||
|
this.h = this.i = i;
|
||||||
|
this.j = this.k = j;
|
||||||
|
this.l = this.m = k;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.h > i) {
|
||||||
|
this.h = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.i < i) {
|
||||||
|
this.i = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.j > j) {
|
||||||
|
this.j = j;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.k < j) {
|
||||||
|
this.k = j;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.l > k) {
|
||||||
|
this.l = k;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.m < k) {
|
||||||
|
this.m = k;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.g < 10) {
|
||||||
|
short short1 = (short) (i << 12 | k << 8 | j);
|
||||||
|
|
||||||
|
for (int l = 0; l < this.g; ++l) {
|
||||||
|
if (this.f[l] == short1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.f[this.g++] = short1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(Packet packet) {
|
||||||
|
for (int i = 0; i < this.b.size(); ++i) {
|
||||||
|
EntityPlayer entityplayer = (EntityPlayer) this.b.get(i);
|
||||||
|
|
||||||
|
if (entityplayer.ak.contains(this.e)) {
|
||||||
|
entityplayer.a.b(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a() {
|
||||||
|
if (this.g != 0) {
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
int k;
|
||||||
|
|
||||||
|
if (this.g == 1) {
|
||||||
|
i = this.c * 16 + this.h;
|
||||||
|
j = this.j;
|
||||||
|
k = this.d * 16 + this.l;
|
||||||
|
this.a((Packet) (new Packet53BlockChange(i, j, k, world))); // Craftbukkit
|
||||||
|
if (Block.p[world.getTypeId(i, j, k)]) { // Craftbukkit
|
||||||
|
this.a(world.getTileEntity(i, j, k)); // Craftbukkit
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int l;
|
||||||
|
|
||||||
|
if (this.g == 10) {
|
||||||
|
this.j = this.j / 2 * 2;
|
||||||
|
this.k = (this.k / 2 + 1) * 2;
|
||||||
|
i = this.h + this.c * 16;
|
||||||
|
j = this.j;
|
||||||
|
k = this.l + this.d * 16;
|
||||||
|
l = this.i - this.h + 1;
|
||||||
|
int i1 = this.k - this.j + 2;
|
||||||
|
int j1 = this.m - this.l + 1;
|
||||||
|
|
||||||
|
this.a((Packet) (new Packet51MapChunk(i, j, k, l, i1, j1, world))); // Craftbukkit
|
||||||
|
List list = world.d(i, j, k, i + l, j + i1, k + j1); // Craftbukkit
|
||||||
|
|
||||||
|
for (int k1 = 0; k1 < list.size(); ++k1) {
|
||||||
|
this.a((TileEntity) list.get(k1));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.a((Packet) (new Packet52MultiBlockChange(this.c, this.d, this.f, this.g, world))); // Craftbukkit
|
||||||
|
|
||||||
|
for (i = 0; i < this.g; ++i) {
|
||||||
|
j = this.c * 16 + (this.g >> 12 & 15);
|
||||||
|
k = this.g & 255;
|
||||||
|
l = this.d * 16 + (this.g >> 8 & 15);
|
||||||
|
if (Block.p[world.getTypeId(j, k, l)]) { // Craftbukkit
|
||||||
|
System.out.println("Sending!");
|
||||||
|
this.a(world.getTileEntity(j, k, l)); // Craftbukkit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.g = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void a(TileEntity tileentity) {
|
||||||
|
if (tileentity != null) {
|
||||||
|
Packet packet = tileentity.g();
|
||||||
|
|
||||||
|
if (packet != null) {
|
||||||
|
this.a(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,22 +22,24 @@ public class PlayerManager {
|
|||||||
this.c.clear();
|
this.c.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayerInstance a(int i, int j, boolean flag) {
|
// Craftbukkit - method signature changed!
|
||||||
|
private PlayerInstance a(int i, int j, boolean flag, WorldServer world) {
|
||||||
long k = (long) i + 2147483647L | (long) j + 2147483647L << 32;
|
long k = (long) i + 2147483647L | (long) j + 2147483647L << 32;
|
||||||
PlayerInstance playerinstance = (PlayerInstance) this.b.a(k);
|
PlayerInstance playerinstance = (PlayerInstance) this.b.a(k);
|
||||||
|
|
||||||
if (playerinstance == null && flag) {
|
if (playerinstance == null && flag) {
|
||||||
playerinstance = new PlayerInstance(this, i, j);
|
playerinstance = new PlayerInstance(this, i, j, world);
|
||||||
this.b.a(k, playerinstance);
|
this.b.a(k, playerinstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
return playerinstance;
|
return playerinstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void a(int i, int j, int k) {
|
// Craftbukkit - method signature changed!
|
||||||
|
public void a(int i, int j, int k, WorldServer world) {
|
||||||
int l = i >> 4;
|
int l = i >> 4;
|
||||||
int i1 = k >> 4;
|
int i1 = k >> 4;
|
||||||
PlayerInstance playerinstance = this.a(l, i1, false);
|
PlayerInstance playerinstance = this.a(l, i1, false, world);
|
||||||
|
|
||||||
if (playerinstance != null) {
|
if (playerinstance != null) {
|
||||||
playerinstance.a(i & 15, j, k & 15);
|
playerinstance.a(i & 15, j, k & 15);
|
||||||
@ -67,7 +69,7 @@ public class PlayerManager {
|
|||||||
int dz = 0;
|
int dz = 0;
|
||||||
|
|
||||||
// Origin
|
// Origin
|
||||||
this.a(i, j, true).a(entityplayer);
|
this.a(i, j, true, ((WorldServer)entityplayer.world)).a(entityplayer);
|
||||||
|
|
||||||
// All but the last leg
|
// All but the last leg
|
||||||
for (int legSize = 1; legSize <= size * 2; legSize++) {
|
for (int legSize = 1; legSize <= size * 2; legSize++) {
|
||||||
@ -77,7 +79,7 @@ public class PlayerManager {
|
|||||||
for (int k = 0; k < legSize; k++ ) {
|
for (int k = 0; k < legSize; k++ ) {
|
||||||
dx += dir[0];
|
dx += dir[0];
|
||||||
dz += dir[1];
|
dz += dir[1];
|
||||||
this.a(i + dx, j + dz, true).a(entityplayer);
|
this.a(i + dx, j + dz, true, ((WorldServer)entityplayer.world)).a(entityplayer); // Craftbukkit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,7 +89,7 @@ public class PlayerManager {
|
|||||||
for (int k = 0; k < size * 2; k++) {
|
for (int k = 0; k < size * 2; k++) {
|
||||||
dx += direction[facing][0];
|
dx += direction[facing][0];
|
||||||
dz += direction[facing][1];
|
dz += direction[facing][1];
|
||||||
this.a(i + dx, j + dz, true).a(entityplayer);
|
this.a(i + dx, j + dz, true, ((WorldServer)entityplayer.world)).a(entityplayer);
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
@ -100,7 +102,7 @@ public class PlayerManager {
|
|||||||
|
|
||||||
for (int k = i - 10; k <= i + 10; ++k) {
|
for (int k = i - 10; k <= i + 10; ++k) {
|
||||||
for (int l = j - 10; l <= j + 10; ++l) {
|
for (int l = j - 10; l <= j + 10; ++l) {
|
||||||
PlayerInstance playerinstance = this.a(k, l, false);
|
PlayerInstance playerinstance = this.a(k, l, false, ((WorldServer)entityplayer.world));
|
||||||
|
|
||||||
if (playerinstance != null) {
|
if (playerinstance != null) {
|
||||||
playerinstance.b(entityplayer);
|
playerinstance.b(entityplayer);
|
||||||
@ -135,11 +137,11 @@ public class PlayerManager {
|
|||||||
for (int k1 = i - 10; k1 <= i + 10; ++k1) {
|
for (int k1 = i - 10; k1 <= i + 10; ++k1) {
|
||||||
for (int l1 = j - 10; l1 <= j + 10; ++l1) {
|
for (int l1 = j - 10; l1 <= j + 10; ++l1) {
|
||||||
if (!this.a(k1, l1, k, l)) {
|
if (!this.a(k1, l1, k, l)) {
|
||||||
this.a(k1, l1, true).a(entityplayer);
|
this.a(k1, l1, true, ((WorldServer)entityplayer.world)).a(entityplayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.a(k1 - i1, l1 - j1, i, j)) {
|
if (!this.a(k1 - i1, l1 - j1, i, j)) {
|
||||||
PlayerInstance playerinstance = this.a(k1 - i1, l1 - j1, false);
|
PlayerInstance playerinstance = this.a(k1 - i1, l1 - j1, false, ((WorldServer)entityplayer.world));
|
||||||
|
|
||||||
if (playerinstance != null) {
|
if (playerinstance != null) {
|
||||||
playerinstance.b(entityplayer);
|
playerinstance.b(entityplayer);
|
||||||
|
@ -75,17 +75,20 @@ public class ServerConfigurationManager {
|
|||||||
public void a(EntityPlayer entityplayer) {
|
public void a(EntityPlayer entityplayer) {
|
||||||
this.b.add(entityplayer);
|
this.b.add(entityplayer);
|
||||||
this.l.b(entityplayer);
|
this.l.b(entityplayer);
|
||||||
this.c.e.A.d((int) entityplayer.locX >> 4, (int) entityplayer.locZ >> 4);
|
|
||||||
|
|
||||||
while (this.c.e.a(entityplayer, entityplayer.boundingBox).size() != 0) {
|
// Craftbukkit start
|
||||||
|
((WorldServer)entityplayer.world).A.d((int) entityplayer.locX >> 4, (int) entityplayer.locZ >> 4);
|
||||||
|
|
||||||
|
while (entityplayer.world.a(entityplayer, entityplayer.boundingBox).size() != 0) {
|
||||||
entityplayer.a(entityplayer.locX, entityplayer.locY + 1.0D, entityplayer.locZ);
|
entityplayer.a(entityplayer.locX, entityplayer.locY + 1.0D, entityplayer.locZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.c.e.a(entityplayer);
|
entityplayer.world.a(entityplayer);
|
||||||
this.d.a(entityplayer);
|
|
||||||
|
|
||||||
// CraftBukkit
|
|
||||||
server.getPluginManager().callEvent(new PlayerEvent(PlayerEvent.Type.PLAYER_JOIN, server.getPlayer(entityplayer)));
|
server.getPluginManager().callEvent(new PlayerEvent(PlayerEvent.Type.PLAYER_JOIN, server.getPlayer(entityplayer)));
|
||||||
|
// Craftbukkit end
|
||||||
|
|
||||||
|
this.d.a(entityplayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void b(EntityPlayer entityplayer) {
|
public void b(EntityPlayer entityplayer) {
|
||||||
@ -94,7 +97,7 @@ public class ServerConfigurationManager {
|
|||||||
|
|
||||||
public void c(EntityPlayer entityplayer) {
|
public void c(EntityPlayer entityplayer) {
|
||||||
this.l.a(entityplayer);
|
this.l.a(entityplayer);
|
||||||
this.c.e.d(entityplayer);
|
entityplayer.world.d(entityplayer); // Craftbukkit
|
||||||
this.b.remove(entityplayer);
|
this.b.remove(entityplayer);
|
||||||
this.d.b(entityplayer);
|
this.d.b(entityplayer);
|
||||||
|
|
||||||
@ -107,8 +110,8 @@ public class ServerConfigurationManager {
|
|||||||
// CraftBukkit start - note: this entire method needs to be changed
|
// CraftBukkit start - note: this entire method needs to be changed
|
||||||
// Instead of kicking then returning, we need to store the kick reason
|
// Instead of kicking then returning, we need to store the kick reason
|
||||||
// in the event, check with plugins to see if it's ok, and THEN kick
|
// in the event, check with plugins to see if it's ok, and THEN kick
|
||||||
// depending on the outcome.
|
// depending on the outcome. Also change any reference to this.e.c to entity.world
|
||||||
EntityPlayer entity = new EntityPlayer(c, (World) c.e, s, new ItemInWorldManager((World) c.e));
|
EntityPlayer entity = new EntityPlayer(c, c.worlds.get(0), s, new ItemInWorldManager(c.worlds.get(0)));
|
||||||
Player player = (entity == null) ? null : (Player) entity.getBukkitEntity();
|
Player player = (entity == null) ? null : (Player) entity.getBukkitEntity();
|
||||||
PlayerLoginEvent event = new PlayerLoginEvent(Type.PLAYER_LOGIN, player);
|
PlayerLoginEvent event = new PlayerLoginEvent(Type.PLAYER_LOGIN, player);
|
||||||
|
|
||||||
@ -139,23 +142,24 @@ public class ServerConfigurationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new EntityPlayer(this.c, this.c.e, s, new ItemInWorldManager(this.c.e));
|
return new EntityPlayer(this.c, entity.world, s, new ItemInWorldManager(entity.world));
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityPlayer d(EntityPlayer entityplayer) {
|
public EntityPlayer d(EntityPlayer entityplayer) {
|
||||||
|
// Craftbukkit start - every reference to this.c.e should be entityplayer.world
|
||||||
this.c.k.a(entityplayer);
|
this.c.k.a(entityplayer);
|
||||||
this.c.k.b(entityplayer);
|
this.c.k.b(entityplayer);
|
||||||
this.d.b(entityplayer);
|
this.d.b(entityplayer);
|
||||||
this.b.remove(entityplayer);
|
this.b.remove(entityplayer);
|
||||||
this.c.e.e(entityplayer);
|
entityplayer.world.e(entityplayer);
|
||||||
EntityPlayer entityplayer1 = new EntityPlayer(this.c, this.c.e, entityplayer.name, new ItemInWorldManager(this.c.e));
|
EntityPlayer entityplayer1 = new EntityPlayer(this.c, entityplayer.world, entityplayer.name, new ItemInWorldManager(entityplayer.world));
|
||||||
|
|
||||||
entityplayer1.id = entityplayer.id;
|
entityplayer1.id = entityplayer.id;
|
||||||
entityplayer1.a = entityplayer.a;
|
entityplayer1.a = entityplayer.a;
|
||||||
this.c.e.A.d((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4);
|
((WorldServer)entityplayer.world).A.d((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4);
|
||||||
|
|
||||||
while (this.c.e.a(entityplayer1, entityplayer1.boundingBox).size() != 0) {
|
while (entityplayer.world.a(entityplayer1, entityplayer1.boundingBox).size() != 0) {
|
||||||
entityplayer1.a(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ);
|
entityplayer1.a(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,18 +178,20 @@ public class ServerConfigurationManager {
|
|||||||
entityplayer1.a.b((Packet) (new Packet9Respawn()));
|
entityplayer1.a.b((Packet) (new Packet9Respawn()));
|
||||||
entityplayer1.a.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch);
|
entityplayer1.a.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch);
|
||||||
this.d.a(entityplayer1);
|
this.d.a(entityplayer1);
|
||||||
this.c.e.a(entityplayer1);
|
entityplayer.world.a(entityplayer1);
|
||||||
this.b.add(entityplayer1);
|
this.b.add(entityplayer1);
|
||||||
entityplayer1.l();
|
entityplayer1.l();
|
||||||
return entityplayer1;
|
return entityplayer1;
|
||||||
|
// Craftbukkit end
|
||||||
}
|
}
|
||||||
|
|
||||||
public void b() {
|
public void b() {
|
||||||
this.d.a();
|
this.d.a();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void a(int i, int j, int k) {
|
// Craftbukkit - changed signature
|
||||||
this.d.a(i, j, k);
|
public void a(int i, int j, int k, WorldServer world) {
|
||||||
|
this.d.a(i, j, k, world); // Craftbukkit
|
||||||
}
|
}
|
||||||
|
|
||||||
public void a(Packet packet) {
|
public void a(Packet packet) {
|
||||||
|
39
src/main/java/net/minecraft/server/WorldManager.java
Normal file
39
src/main/java/net/minecraft/server/WorldManager.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package net.minecraft.server;
|
||||||
|
|
||||||
|
public class WorldManager implements IWorldAccess {
|
||||||
|
|
||||||
|
private MinecraftServer a;
|
||||||
|
public WorldServer world; // Craftbukkit
|
||||||
|
|
||||||
|
// Craftbukkit - changed signature
|
||||||
|
public WorldManager(MinecraftServer minecraftserver, WorldServer world) {
|
||||||
|
this.a = minecraftserver;
|
||||||
|
this.world = world;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(String s, double d0, double d1, double d2, double d3, double d4, double d5) {}
|
||||||
|
|
||||||
|
public void a(Entity entity) {
|
||||||
|
this.a.k.a(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void b(Entity entity) {
|
||||||
|
this.a.k.b(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(String s, double d0, double d1, double d2, float f, float f1) {}
|
||||||
|
|
||||||
|
public void a(int i, int j, int k, int l, int i1, int j1) {}
|
||||||
|
|
||||||
|
public void a() {}
|
||||||
|
|
||||||
|
public void a(int i, int j, int k) {
|
||||||
|
this.a.f.a(i, j, k, world); // Craftbukkit
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(String s, int i, int j, int k) {}
|
||||||
|
|
||||||
|
public void a(int i, int j, int k, TileEntity tileentity) {
|
||||||
|
this.a.f.a(i, j, k, tileentity);
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,7 @@ import net.minecraft.server.EntityPlayer;
|
|||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.PropertyManager;
|
import net.minecraft.server.PropertyManager;
|
||||||
import net.minecraft.server.ServerConfigurationManager;
|
import net.minecraft.server.ServerConfigurationManager;
|
||||||
|
import net.minecraft.server.WorldServer;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
@ -148,8 +149,13 @@ public final class CraftServer implements Server {
|
|||||||
return pluginManager;
|
return pluginManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
public BukkitScheduler getScheduler() {
|
public BukkitScheduler getScheduler() {
|
||||||
return scheduler;
|
return scheduler;
|
||||||
|
=======
|
||||||
|
public World[] getWorlds() {
|
||||||
|
return console.worlds.toArray(new World[0]);
|
||||||
|
>>>>>>> f045828... Added internal MC support for multiple worlds
|
||||||
}
|
}
|
||||||
|
|
||||||
public World[] getWorlds() {
|
public World[] getWorlds() {
|
||||||
@ -170,14 +176,16 @@ public final class CraftServer implements Server {
|
|||||||
console.d = config;
|
console.d = config;
|
||||||
|
|
||||||
boolean animals = config.a("spawn-monsters", console.m);
|
boolean animals = config.a("spawn-monsters", console.m);
|
||||||
boolean monsters = config.a("spawn-monsters", console.e.k > 0);
|
boolean monsters = config.a("spawn-monsters", console.worlds.get(0).k > 0);
|
||||||
|
|
||||||
console.l = config.a("online-mode", console.l);
|
console.l = config.a("online-mode", console.l);
|
||||||
console.m = config.a("spawn-animals", console.m);
|
console.m = config.a("spawn-animals", console.m);
|
||||||
console.n = config.a("pvp", console.n);
|
console.n = config.a("pvp", console.n);
|
||||||
|
|
||||||
console.e.k = monsters ? 1 : 0;
|
for (WorldServer world : console.worlds) {
|
||||||
console.e.a(monsters, animals);
|
world.k = monsters ? 1 : 0;
|
||||||
|
world.a(monsters, animals);
|
||||||
|
}
|
||||||
|
|
||||||
pluginManager.clearPlugins();
|
pluginManager.clearPlugins();
|
||||||
commandMap.clearCommands();
|
commandMap.clearCommands();
|
||||||
|
Loading…
Reference in New Issue
Block a user