summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/minecraft')
-rw-r--r--src/main/java/net/minecraft/server/EntityPlayer.java7
-rw-r--r--src/main/java/net/minecraft/server/EntityTracker.java152
-rw-r--r--src/main/java/net/minecraft/server/MinecraftServer.java80
-rw-r--r--src/main/java/net/minecraft/server/NetLoginHandler.java118
-rw-r--r--src/main/java/net/minecraft/server/NetServerHandler.java44
-rw-r--r--src/main/java/net/minecraft/server/PlayerInstance.java190
-rw-r--r--src/main/java/net/minecraft/server/PlayerManager.java22
-rw-r--r--src/main/java/net/minecraft/server/ServerConfigurationManager.java38
-rw-r--r--src/main/java/net/minecraft/server/WorldManager.java39
9 files changed, 620 insertions, 70 deletions
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index ae2d84f6..d347de4b 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -158,8 +158,11 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
if (flag) {
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) {
this.a((TileEntity) list.get(j));
diff --git a/src/main/java/net/minecraft/server/EntityTracker.java b/src/main/java/net/minecraft/server/EntityTracker.java
new file mode 100644
index 00000000..8cfbf30c
--- /dev/null
+++ b/src/main/java/net/minecraft/server/EntityTracker.java
@@ -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);
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 887a68dd..716f3a73 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -26,7 +26,7 @@ public class MinecraftServer implements ICommandListener, Runnable {
public static HashMap b = new HashMap();
public NetworkListenThread c;
public PropertyManager d;
- public WorldServer e;
+ //public WorldServer e;
public ServerConfigurationManager f;
private boolean o = true;
public boolean g = false;
@@ -39,6 +39,7 @@ public class MinecraftServer implements ICommandListener, Runnable {
public boolean l;
public boolean m;
public boolean n;
+ public List<WorldServer> worlds = new ArrayList<WorldServer>();
// Craftbukkit start - adds argument OptionSet
public MinecraftServer(OptionSet options) {
@@ -109,11 +110,16 @@ public class MinecraftServer implements ICommandListener, Runnable {
private void c(String s) {
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));
- this.e.k = this.d.a("spawn-monsters", true) ? 1 : 0;
- this.e.a(this.d.a("spawn-monsters", true), this.m);
- this.f.a(this.e);
+
+ // Craftbukkit start
+ WorldServer world = new WorldServer(this, new File("."), s, this.d.a("hellworld", false) ? -1 : 0);
+ world.a(new WorldManager(this, world));
+ 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;
long i = System.currentTimeMillis();
@@ -133,11 +139,15 @@ public class MinecraftServer implements ICommandListener, Runnable {
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() {
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() {
@@ -173,7 +188,7 @@ public class MinecraftServer implements ICommandListener, Runnable {
this.f.d();
}
- if (this.e != null) {
+ if (this.worlds.size() > 0) { // Craftbukkit
this.f();
}
}
@@ -270,21 +285,31 @@ public class MinecraftServer implements ICommandListener, Runnable {
AxisAlignedBB.a();
Vec3D.a();
++this.h;
+
+ // Craftbukkit start
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);
- // CraftBukkit end
while (this.e.d()) {
;
+ world.c();
}
+ // Craftbukkit end
- this.e.c();
this.c.a();
this.f.b();
this.k.a();
@@ -325,17 +350,32 @@ public class MinecraftServer implements ICommandListener, Runnable {
this.o = false;
} else if (s.toLowerCase().startsWith("save-all")) {
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();
// Craftbukkit end
+
this.a(s1, "Save complete.");
} else if (s.toLowerCase().startsWith("save-off")) {
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")) {
this.a(s1, "Enabling level saving..");
- this.e.C = false;
+
+ // Craftbukkit start
+ for (WorldServer world : worlds) {
+ world.C = false;
+ }
+ // Craftbukkit end
} else {
String s2;
diff --git a/src/main/java/net/minecraft/server/NetLoginHandler.java b/src/main/java/net/minecraft/server/NetLoginHandler.java
new file mode 100644
index 00000000..6347e389
--- /dev/null
+++ b/src/main/java/net/minecraft/server/NetLoginHandler.java
@@ -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;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java
index af94bad0..33dfd642 100644
--- a/src/main/java/net/minecraft/server/NetServerHandler.java
+++ b/src/main/java/net/minecraft/server/NetServerHandler.java
@@ -156,7 +156,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
this.e.motX = d5;
this.e.motZ = d4;
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) {
@@ -167,7 +167,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
this.g = this.e.locX;
this.h = this.e.locY;
this.i = this.e.locZ;
- this.d.e.f(this.e);
+ this.e.world.f(this.e);
return;
}
@@ -210,7 +210,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
double d6 = d2 - this.e.locY;
double d7 = d3 - this.e.locZ;
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);
d4 = d1 - this.e.locX;
@@ -231,7 +231,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
}
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)) {
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) {
this.e.O();
} 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;
if (packet14blockdig.e == 0) {
@@ -306,8 +306,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
}
int l = packet14blockdig.d;
- int i1 = (int) MathHelper.e((float) (i - this.d.e.spawnX));
- int j1 = (int) MathHelper.e((float) (k - this.d.e.spawnZ));
+ int i1 = (int) MathHelper.e((float) (i - this.e.world.spawnX)); // Craftbukkit
+ int j1 = (int) MathHelper.e((float) (k - this.e.world.spawnZ)); // Craftbukkit
if (i1 > j1) {
j1 = i1;
@@ -378,7 +378,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
double d8 = d5 * d5 + d6 * d6 + d7 * d7;
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;
// CraftBukkit end
- this.d.e.B = false;
+ ((WorldServer)this.e.world).B = false; // Craftbukkit
}
}
public void a(Packet15Place packet15place) {
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
CraftBlock blockClicked = null;
@@ -411,7 +411,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
lastMaterial = 0;
} else {
// 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;
lastMaterial = (packet15place.e == null) ? 0 : packet15place.e.id;
}
@@ -454,7 +454,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
if (!event.isCancelled()) {
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,
// 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 k = packet15place.c;
int l = packet15place.d;
- int i1 = (int) MathHelper.e((float) (i - this.d.e.spawnX));
- int j1 = (int) MathHelper.e((float) (k - this.d.e.spawnZ));
+ int i1 = (int) MathHelper.e((float) (i - this.e.world.spawnX)); // Craftbukkit
+ int j1 = (int) MathHelper.e((float) (k - this.e.world.spawnZ)); // Craftbukkit
if (i1 > j1) {
j1 = i1;
@@ -480,10 +480,10 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
BlockRightClickEvent event = new BlockRightClickEvent(Type.BLOCK_RIGHTCLICKED, blockClicked, blockFace, craftItem, player);
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
- 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) {
--j;
}
@@ -508,7 +508,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
++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) {
@@ -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.d.e.B = false;
+ ((WorldServer)this.e.world).B = false; // Craftbukkit
}
public void a(String s, Object[] aobject) {
@@ -676,7 +676,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
}
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 (packet7useentity.c == 0) {
@@ -736,8 +736,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
}
public void a(Packet130UpdateSign packet130updatesign) {
- if (this.d.e.f(packet130updatesign.a, packet130updatesign.b, packet130updatesign.c)) {
- TileEntity tileentity = this.d.e.getTileEntity(packet130updatesign.a, packet130updatesign.b, packet130updatesign.c);
+ if (this.e.world.f(packet130updatesign.a, packet130updatesign.b, packet130updatesign.c)) { // Craftbukkit
+ TileEntity tileentity = this.e.world.getTileEntity(packet130updatesign.a, packet130updatesign.b, packet130updatesign.c); // Craftbukkit
int i;
int j;
@@ -772,7 +772,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
}
tileentitysign.d();
- this.d.e.g(i, k, j);
+ this.e.world.g(i, k, j); // Craftbukkit
}
}
}
diff --git a/src/main/java/net/minecraft/server/PlayerInstance.java b/src/main/java/net/minecraft/server/PlayerInstance.java
new file mode 100644
index 00000000..23443e03
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PlayerInstance.java
@@ -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);
+ }
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/PlayerManager.java b/src/main/java/net/minecraft/server/PlayerManager.java
index f2ace21e..3837635b 100644
--- a/src/main/java/net/minecraft/server/PlayerManager.java
+++ b/src/main/java/net/minecraft/server/PlayerManager.java
@@ -22,22 +22,24 @@ public class PlayerManager {
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;
PlayerInstance playerinstance = (PlayerInstance) this.b.a(k);
if (playerinstance == null && flag) {
- playerinstance = new PlayerInstance(this, i, j);
+ playerinstance = new PlayerInstance(this, i, j, world);
this.b.a(k, 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 i1 = k >> 4;
- PlayerInstance playerinstance = this.a(l, i1, false);
+ PlayerInstance playerinstance = this.a(l, i1, false, world);
if (playerinstance != null) {
playerinstance.a(i & 15, j, k & 15);
@@ -67,7 +69,7 @@ public class PlayerManager {
int dz = 0;
// Origin
- this.a(i, j, true).a(entityplayer);
+ this.a(i, j, true, ((WorldServer)entityplayer.world)).a(entityplayer);
// All but the last leg
for (int legSize = 1; legSize <= size * 2; legSize++) {
@@ -77,7 +79,7 @@ public class PlayerManager {
for (int k = 0; k < legSize; k++ ) {
dx += dir[0];
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++) {
dx += direction[facing][0];
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
@@ -100,7 +102,7 @@ public class PlayerManager {
for (int k = i - 10; k <= i + 10; ++k) {
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) {
playerinstance.b(entityplayer);
@@ -135,11 +137,11 @@ public class PlayerManager {
for (int k1 = i - 10; k1 <= i + 10; ++k1) {
for (int l1 = j - 10; l1 <= j + 10; ++l1) {
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)) {
- PlayerInstance playerinstance = this.a(k1 - i1, l1 - j1, false);
+ PlayerInstance playerinstance = this.a(k1 - i1, l1 - j1, false, ((WorldServer)entityplayer.world));
if (playerinstance != null) {
playerinstance.b(entityplayer);
diff --git a/src/main/java/net/minecraft/server/ServerConfigurationManager.java b/src/main/java/net/minecraft/server/ServerConfigurationManager.java
index a8ef81a2..8a44578e 100644
--- a/src/main/java/net/minecraft/server/ServerConfigurationManager.java
+++ b/src/main/java/net/minecraft/server/ServerConfigurationManager.java
@@ -75,17 +75,20 @@ public class ServerConfigurationManager {
public void a(EntityPlayer entityplayer) {
this.b.add(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);
}
- this.c.e.a(entityplayer);
- this.d.a(entityplayer);
+ entityplayer.world.a(entityplayer);
- // CraftBukkit
server.getPluginManager().callEvent(new PlayerEvent(PlayerEvent.Type.PLAYER_JOIN, server.getPlayer(entityplayer)));
+ // Craftbukkit end
+
+ this.d.a(entityplayer);
}
public void b(EntityPlayer entityplayer) {
@@ -94,7 +97,7 @@ public class ServerConfigurationManager {
public void c(EntityPlayer entityplayer) {
this.l.a(entityplayer);
- this.c.e.d(entityplayer);
+ entityplayer.world.d(entityplayer); // Craftbukkit
this.b.remove(entityplayer);
this.d.b(entityplayer);
@@ -107,8 +110,8 @@ public class ServerConfigurationManager {
// CraftBukkit start - note: this entire method needs to be changed
// 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
- // depending on the outcome.
- EntityPlayer entity = new EntityPlayer(c, (World) c.e, s, new ItemInWorldManager((World) c.e));
+ // depending on the outcome. Also change any reference to this.e.c to entity.world
+ EntityPlayer entity = new EntityPlayer(c, c.worlds.get(0), s, new ItemInWorldManager(c.worlds.get(0)));
Player player = (entity == null) ? null : (Player) entity.getBukkitEntity();
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
}
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.b(entityplayer);
this.d.b(entityplayer);
this.b.remove(entityplayer);
- this.c.e.e(entityplayer);
- EntityPlayer entityplayer1 = new EntityPlayer(this.c, this.c.e, entityplayer.name, new ItemInWorldManager(this.c.e));
+ entityplayer.world.e(entityplayer);
+ EntityPlayer entityplayer1 = new EntityPlayer(this.c, entityplayer.world, entityplayer.name, new ItemInWorldManager(entityplayer.world));
entityplayer1.id = entityplayer.id;
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);
}
@@ -174,18 +178,20 @@ public class ServerConfigurationManager {
entityplayer1.a.b((Packet) (new Packet9Respawn()));
entityplayer1.a.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch);
this.d.a(entityplayer1);
- this.c.e.a(entityplayer1);
+ entityplayer.world.a(entityplayer1);
this.b.add(entityplayer1);
entityplayer1.l();
return entityplayer1;
+ // Craftbukkit end
}
public void b() {
this.d.a();
}
- public void a(int i, int j, int k) {
- this.d.a(i, j, k);
+ // Craftbukkit - changed signature
+ public void a(int i, int j, int k, WorldServer world) {
+ this.d.a(i, j, k, world); // Craftbukkit
}
public void a(Packet packet) {
diff --git a/src/main/java/net/minecraft/server/WorldManager.java b/src/main/java/net/minecraft/server/WorldManager.java
new file mode 100644
index 00000000..c12c5369
--- /dev/null
+++ b/src/main/java/net/minecraft/server/WorldManager.java
@@ -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);
+ }
+}