2025-03-11 00:23:54 +01:00
|
|
|
package game.packet;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import game.entity.Entity;
|
|
|
|
import game.network.NetHandlerPlayClient;
|
|
|
|
import game.network.Packet;
|
|
|
|
import game.network.PacketBuffer;
|
|
|
|
import game.world.World;
|
|
|
|
|
|
|
|
public class S14PacketEntity implements Packet<NetHandlerPlayClient>
|
|
|
|
{
|
|
|
|
protected int entityId;
|
|
|
|
protected byte posX;
|
|
|
|
protected byte posY;
|
|
|
|
protected byte posZ;
|
|
|
|
protected byte yaw;
|
|
|
|
protected byte pitch;
|
|
|
|
protected boolean onGround;
|
2025-03-20 00:29:25 +01:00
|
|
|
protected boolean rotation;
|
2025-03-11 00:23:54 +01:00
|
|
|
|
|
|
|
public S14PacketEntity()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public S14PacketEntity(int entityIdIn)
|
|
|
|
{
|
|
|
|
this.entityId = entityIdIn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reads the raw packet data from the data stream.
|
|
|
|
*/
|
|
|
|
public void readPacketData(PacketBuffer buf) throws IOException
|
|
|
|
{
|
|
|
|
this.entityId = buf.readVarIntFromBuffer();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Writes the raw packet data to the data stream.
|
|
|
|
*/
|
|
|
|
public void writePacketData(PacketBuffer buf) throws IOException
|
|
|
|
{
|
|
|
|
buf.writeVarIntToBuffer(this.entityId);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Passes this Packet on to the NetHandler for processing.
|
|
|
|
*/
|
|
|
|
public void processPacket(NetHandlerPlayClient handler)
|
|
|
|
{
|
|
|
|
handler.handleEntityMovement(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString()
|
|
|
|
{
|
|
|
|
return "Entity_" + super.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Entity getEntity(World worldIn)
|
|
|
|
{
|
|
|
|
return worldIn.getEntityByID(this.entityId);
|
|
|
|
}
|
|
|
|
|
2025-03-20 00:29:25 +01:00
|
|
|
public byte getPosX()
|
2025-03-11 00:23:54 +01:00
|
|
|
{
|
|
|
|
return this.posX;
|
|
|
|
}
|
|
|
|
|
2025-03-20 00:29:25 +01:00
|
|
|
public byte getPosY()
|
2025-03-11 00:23:54 +01:00
|
|
|
{
|
|
|
|
return this.posY;
|
|
|
|
}
|
|
|
|
|
2025-03-20 00:29:25 +01:00
|
|
|
public byte getPosZ()
|
2025-03-11 00:23:54 +01:00
|
|
|
{
|
|
|
|
return this.posZ;
|
|
|
|
}
|
|
|
|
|
2025-03-20 00:29:25 +01:00
|
|
|
public byte getYaw()
|
2025-03-11 00:23:54 +01:00
|
|
|
{
|
|
|
|
return this.yaw;
|
|
|
|
}
|
|
|
|
|
2025-03-20 00:29:25 +01:00
|
|
|
public byte getPitch()
|
2025-03-11 00:23:54 +01:00
|
|
|
{
|
|
|
|
return this.pitch;
|
|
|
|
}
|
|
|
|
|
2025-03-20 00:29:25 +01:00
|
|
|
public boolean hasRotations()
|
2025-03-11 00:23:54 +01:00
|
|
|
{
|
2025-03-20 00:29:25 +01:00
|
|
|
return this.rotation;
|
2025-03-11 00:23:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean getOnGround()
|
|
|
|
{
|
|
|
|
return this.onGround;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class S15PacketEntityRelMove extends S14PacketEntity
|
|
|
|
{
|
|
|
|
public S15PacketEntityRelMove()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public S15PacketEntityRelMove(int entityIdIn, byte x, byte y, byte z, boolean onGroundIn)
|
|
|
|
{
|
|
|
|
super(entityIdIn);
|
|
|
|
this.posX = x;
|
|
|
|
this.posY = y;
|
|
|
|
this.posZ = z;
|
|
|
|
this.onGround = onGroundIn;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void readPacketData(PacketBuffer buf) throws IOException
|
|
|
|
{
|
|
|
|
super.readPacketData(buf);
|
|
|
|
this.posX = buf.readByte();
|
|
|
|
this.posY = buf.readByte();
|
|
|
|
this.posZ = buf.readByte();
|
|
|
|
this.onGround = buf.readBoolean();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void writePacketData(PacketBuffer buf) throws IOException
|
|
|
|
{
|
|
|
|
super.writePacketData(buf);
|
|
|
|
buf.writeByte(this.posX);
|
|
|
|
buf.writeByte(this.posY);
|
|
|
|
buf.writeByte(this.posZ);
|
|
|
|
buf.writeBoolean(this.onGround);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class S16PacketEntityLook extends S14PacketEntity
|
|
|
|
{
|
|
|
|
public S16PacketEntityLook()
|
|
|
|
{
|
2025-03-20 00:29:25 +01:00
|
|
|
this.rotation = true;
|
2025-03-11 00:23:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public S16PacketEntityLook(int entityIdIn, byte yawIn, byte pitchIn, boolean onGroundIn)
|
|
|
|
{
|
|
|
|
super(entityIdIn);
|
|
|
|
this.yaw = yawIn;
|
|
|
|
this.pitch = pitchIn;
|
2025-03-20 00:29:25 +01:00
|
|
|
this.rotation = true;
|
2025-03-11 00:23:54 +01:00
|
|
|
this.onGround = onGroundIn;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void readPacketData(PacketBuffer buf) throws IOException
|
|
|
|
{
|
|
|
|
super.readPacketData(buf);
|
|
|
|
this.yaw = buf.readByte();
|
|
|
|
this.pitch = buf.readByte();
|
|
|
|
this.onGround = buf.readBoolean();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void writePacketData(PacketBuffer buf) throws IOException
|
|
|
|
{
|
|
|
|
super.writePacketData(buf);
|
|
|
|
buf.writeByte(this.yaw);
|
|
|
|
buf.writeByte(this.pitch);
|
|
|
|
buf.writeBoolean(this.onGround);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class S17PacketEntityLookMove extends S14PacketEntity
|
|
|
|
{
|
|
|
|
public S17PacketEntityLookMove()
|
|
|
|
{
|
2025-03-20 00:29:25 +01:00
|
|
|
this.rotation = true;
|
2025-03-11 00:23:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public S17PacketEntityLookMove(int p_i45973_1_, byte p_i45973_2_, byte p_i45973_3_, byte p_i45973_4_, byte p_i45973_5_, byte p_i45973_6_, boolean p_i45973_7_)
|
|
|
|
{
|
|
|
|
super(p_i45973_1_);
|
|
|
|
this.posX = p_i45973_2_;
|
|
|
|
this.posY = p_i45973_3_;
|
|
|
|
this.posZ = p_i45973_4_;
|
|
|
|
this.yaw = p_i45973_5_;
|
|
|
|
this.pitch = p_i45973_6_;
|
|
|
|
this.onGround = p_i45973_7_;
|
2025-03-20 00:29:25 +01:00
|
|
|
this.rotation = true;
|
2025-03-11 00:23:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void readPacketData(PacketBuffer buf) throws IOException
|
|
|
|
{
|
|
|
|
super.readPacketData(buf);
|
|
|
|
this.posX = buf.readByte();
|
|
|
|
this.posY = buf.readByte();
|
|
|
|
this.posZ = buf.readByte();
|
|
|
|
this.yaw = buf.readByte();
|
|
|
|
this.pitch = buf.readByte();
|
|
|
|
this.onGround = buf.readBoolean();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void writePacketData(PacketBuffer buf) throws IOException
|
|
|
|
{
|
|
|
|
super.writePacketData(buf);
|
|
|
|
buf.writeByte(this.posX);
|
|
|
|
buf.writeByte(this.posY);
|
|
|
|
buf.writeByte(this.posZ);
|
|
|
|
buf.writeByte(this.yaw);
|
|
|
|
buf.writeByte(this.pitch);
|
|
|
|
buf.writeBoolean(this.onGround);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|