summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorTravis Watkins <amaranth@ubuntu.com>2012-01-17 16:26:20 -0600
committerEvilSeph <evilseph@gmail.com>2012-01-23 23:32:21 -0500
commitcf521b5a5ca399e807f05f7ba3fd12bc3e160875 (patch)
tree3bafe455b336f820e84bc1c8b46cd1ad60ae2066 /src/main/java
parent97ce5c447993b2a7f5cc32764b091ccf55365f0c (diff)
downloadcraftbukkit-cf521b5a5ca399e807f05f7ba3fd12bc3e160875.tar
craftbukkit-cf521b5a5ca399e807f05f7ba3fd12bc3e160875.tar.gz
craftbukkit-cf521b5a5ca399e807f05f7ba3fd12bc3e160875.tar.lz
craftbukkit-cf521b5a5ca399e807f05f7ba3fd12bc3e160875.tar.xz
craftbukkit-cf521b5a5ca399e807f05f7ba3fd12bc3e160875.zip
Only truncate player name when sending spawn packet.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/net/minecraft/server/EntityTrackerEntry.java5
-rw-r--r--src/main/java/net/minecraft/server/Packet20NamedEntitySpawn.java71
2 files changed, 71 insertions, 5 deletions
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
index 0a2a76dd..caef4df7 100644
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
@@ -248,11 +248,6 @@ public class EntityTrackerEntry {
entityitem.locZ = (double) packet21pickupspawn.d / 32.0D;
return packet21pickupspawn;
} else if (this.tracker instanceof EntityPlayer) {
- // CraftBukkit start - limit name length to 16 characters
- if (((EntityHuman) this.tracker).name.length() > 16) {
- ((EntityHuman) this.tracker).name = ((EntityHuman) this.tracker).name.substring(0, 16);
- }
- // CraftBukkit end
return new Packet20NamedEntitySpawn((EntityHuman) this.tracker);
} else {
if (this.tracker instanceof EntityMinecart) {
diff --git a/src/main/java/net/minecraft/server/Packet20NamedEntitySpawn.java b/src/main/java/net/minecraft/server/Packet20NamedEntitySpawn.java
new file mode 100644
index 00000000..0b6780ff
--- /dev/null
+++ b/src/main/java/net/minecraft/server/Packet20NamedEntitySpawn.java
@@ -0,0 +1,71 @@
+package net.minecraft.server;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException; // CraftBukkit
+
+public class Packet20NamedEntitySpawn extends Packet {
+
+ public int a;
+ public String b;
+ public int c;
+ public int d;
+ public int e;
+ public byte f;
+ public byte g;
+ public int h;
+
+ public Packet20NamedEntitySpawn() {}
+
+ public Packet20NamedEntitySpawn(EntityHuman entityhuman) {
+ this.a = entityhuman.id;
+
+ // CraftBukkit start - limit name length to 16 characters
+ if (entityhuman.name.length() > 16) {
+ this.b = entityhuman.name.substring(0, 16);
+ }
+ else {
+ this.b = entityhuman.name;
+ }
+ // CraftBukkit end
+
+ this.c = MathHelper.floor(entityhuman.locX * 32.0D);
+ this.d = MathHelper.floor(entityhuman.locY * 32.0D);
+ this.e = MathHelper.floor(entityhuman.locZ * 32.0D);
+ this.f = (byte) ((int) (entityhuman.yaw * 256.0F / 360.0F));
+ this.g = (byte) ((int) (entityhuman.pitch * 256.0F / 360.0F));
+ ItemStack itemstack = entityhuman.inventory.getItemInHand();
+
+ this.h = itemstack == null ? 0 : itemstack.id;
+ }
+
+ public void a(DataInputStream datainputstream) throws IOException { // CraftBukkit
+ this.a = datainputstream.readInt();
+ this.b = a(datainputstream, 16);
+ this.c = datainputstream.readInt();
+ this.d = datainputstream.readInt();
+ this.e = datainputstream.readInt();
+ this.f = datainputstream.readByte();
+ this.g = datainputstream.readByte();
+ this.h = datainputstream.readShort();
+ }
+
+ public void a(DataOutputStream dataoutputstream) throws IOException { // CraftBukkit
+ dataoutputstream.writeInt(this.a);
+ a(this.b, dataoutputstream);
+ dataoutputstream.writeInt(this.c);
+ dataoutputstream.writeInt(this.d);
+ dataoutputstream.writeInt(this.e);
+ dataoutputstream.writeByte(this.f);
+ dataoutputstream.writeByte(this.g);
+ dataoutputstream.writeShort(this.h);
+ }
+
+ public void handle(NetHandler nethandler) {
+ nethandler.a(this);
+ }
+
+ public int a() {
+ return 28;
+ }
+}