Paper/src/main/java/net/minecraft/server/Packet20NamedEntitySpawn.java

79 Zeilen
2.3 KiB
Java

package net.minecraft.server;
2013-07-01 13:03:00 +02:00
import java.io.DataInput;
import java.io.DataOutput;
2012-07-29 09:33:13 +02:00
import java.util.List;
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;
2012-07-29 09:33:13 +02:00
private DataWatcher i;
private List j;
public Packet20NamedEntitySpawn() {}
public Packet20NamedEntitySpawn(EntityHuman entityhuman) {
this.a = entityhuman.id;
2013-03-25 05:22:32 +01:00
// 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
2013-07-01 13:03:00 +02:00
this.b = entityhuman.getName();
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;
2012-07-29 09:33:13 +02:00
this.i = entityhuman.getDataWatcher();
}
2013-07-01 13:03:00 +02:00
public void a(DataInput datainput) throws IOException { // CraftBukkit
this.a = datainput.readInt();
this.b = a(datainput, 16);
this.c = datainput.readInt();
this.d = datainput.readInt();
this.e = datainput.readInt();
this.f = datainput.readByte();
this.g = datainput.readByte();
this.h = datainput.readShort();
this.j = DataWatcher.a(datainput);
}
2013-07-01 13:03:00 +02:00
public void a(DataOutput dataoutput) throws IOException { // CraftBukkit
dataoutput.writeInt(this.a);
a(this.b, dataoutput);
dataoutput.writeInt(this.c);
dataoutput.writeInt(this.d);
dataoutput.writeInt(this.e);
dataoutput.writeByte(this.f);
dataoutput.writeByte(this.g);
dataoutput.writeShort(this.h);
this.i.a(dataoutput);
}
2012-12-20 05:03:52 +01:00
public void handle(Connection connection) {
connection.a(this);
}
public int a() {
return 28;
}
}