mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-07-14 10:49:33 +00:00
chore: format Minecraft.World
This commit is contained in:
@@ -4,165 +4,141 @@
|
||||
#include "PacketListener.h"
|
||||
#include "MoveEntityPacket.h"
|
||||
|
||||
MoveEntityPacket::MoveEntityPacket()
|
||||
{
|
||||
hasRot = false;
|
||||
MoveEntityPacket::MoveEntityPacket() {
|
||||
hasRot = false;
|
||||
|
||||
id = -1;
|
||||
xa = 0;
|
||||
ya = 0;
|
||||
za = 0;
|
||||
yRot = 0;
|
||||
xRot = 0;
|
||||
id = -1;
|
||||
xa = 0;
|
||||
ya = 0;
|
||||
za = 0;
|
||||
yRot = 0;
|
||||
xRot = 0;
|
||||
}
|
||||
|
||||
MoveEntityPacket::MoveEntityPacket(int id)
|
||||
{
|
||||
this->id = id;
|
||||
hasRot = false;
|
||||
MoveEntityPacket::MoveEntityPacket(int id) {
|
||||
this->id = id;
|
||||
hasRot = false;
|
||||
|
||||
xa = 0;
|
||||
ya = 0;
|
||||
za = 0;
|
||||
yRot = 0;
|
||||
xRot = 0;
|
||||
xa = 0;
|
||||
ya = 0;
|
||||
za = 0;
|
||||
yRot = 0;
|
||||
xRot = 0;
|
||||
}
|
||||
|
||||
void MoveEntityPacket::read(DataInputStream *dis) //throws IOException
|
||||
void MoveEntityPacket::read(DataInputStream* dis) // throws IOException
|
||||
{
|
||||
id = dis->readShort();
|
||||
id = dis->readShort();
|
||||
}
|
||||
|
||||
void MoveEntityPacket::write(DataOutputStream *dos) //throws IOException
|
||||
void MoveEntityPacket::write(DataOutputStream* dos) // throws IOException
|
||||
{
|
||||
if( (id < 0 ) || (id >= 2048 ) )
|
||||
{
|
||||
// We shouln't be tracking an entity that doesn't have a short type of id
|
||||
__debugbreak();
|
||||
}
|
||||
dos->writeShort((short)id);
|
||||
if ((id < 0) || (id >= 2048)) {
|
||||
// We shouln't be tracking an entity that doesn't have a short type of
|
||||
// id
|
||||
__debugbreak();
|
||||
}
|
||||
dos->writeShort((short)id);
|
||||
}
|
||||
|
||||
void MoveEntityPacket::handle(PacketListener *listener)
|
||||
{
|
||||
listener->handleMoveEntity(shared_from_this());
|
||||
void MoveEntityPacket::handle(PacketListener* listener) {
|
||||
listener->handleMoveEntity(shared_from_this());
|
||||
}
|
||||
|
||||
int MoveEntityPacket::getEstimatedSize()
|
||||
{
|
||||
return 2;
|
||||
int MoveEntityPacket::getEstimatedSize() { return 2; }
|
||||
|
||||
bool MoveEntityPacket::canBeInvalidated() { return true; }
|
||||
|
||||
bool MoveEntityPacket::isInvalidatedBy(std::shared_ptr<Packet> packet) {
|
||||
std::shared_ptr<MoveEntityPacket> target =
|
||||
std::dynamic_pointer_cast<MoveEntityPacket>(packet);
|
||||
return target != NULL && target->id == id;
|
||||
}
|
||||
|
||||
bool MoveEntityPacket::canBeInvalidated()
|
||||
{
|
||||
return true;
|
||||
MoveEntityPacket::PosRot::PosRot() { hasRot = true; }
|
||||
|
||||
MoveEntityPacket::PosRot::PosRot(int id, char xa, char ya, char za, char yRot,
|
||||
char xRot)
|
||||
: MoveEntityPacket(id) {
|
||||
this->xa = xa;
|
||||
this->ya = ya;
|
||||
this->za = za;
|
||||
this->yRot = yRot;
|
||||
this->xRot = xRot;
|
||||
hasRot = true;
|
||||
}
|
||||
|
||||
bool MoveEntityPacket::isInvalidatedBy(std::shared_ptr<Packet> packet)
|
||||
void MoveEntityPacket::PosRot::read(DataInputStream* dis) // throws IOException
|
||||
{
|
||||
std::shared_ptr<MoveEntityPacket> target = std::dynamic_pointer_cast<MoveEntityPacket>(packet);
|
||||
return target != NULL && target->id == id;
|
||||
MoveEntityPacket::read(dis);
|
||||
xa = (int)dis->readByte();
|
||||
ya = (int)dis->readByte();
|
||||
za = (int)dis->readByte();
|
||||
yRot = (int)dis->readByte();
|
||||
xRot = (int)dis->readByte();
|
||||
}
|
||||
|
||||
MoveEntityPacket::PosRot::PosRot()
|
||||
void MoveEntityPacket::PosRot::write(
|
||||
DataOutputStream* dos) // throws IOException
|
||||
{
|
||||
hasRot = true;
|
||||
MoveEntityPacket::write(dos);
|
||||
dos->writeByte((uint8_t)xa);
|
||||
dos->writeByte((uint8_t)ya);
|
||||
dos->writeByte((uint8_t)za);
|
||||
dos->writeByte((uint8_t)yRot);
|
||||
dos->writeByte((uint8_t)xRot);
|
||||
}
|
||||
|
||||
MoveEntityPacket::PosRot::PosRot(int id, char xa, char ya, char za, char yRot, char xRot) : MoveEntityPacket( id )
|
||||
{
|
||||
this->xa = xa;
|
||||
this->ya = ya;
|
||||
this->za = za;
|
||||
this->yRot = yRot;
|
||||
this->xRot = xRot;
|
||||
hasRot = true;
|
||||
int MoveEntityPacket::PosRot::getEstimatedSize() { return 2 + 5; }
|
||||
|
||||
MoveEntityPacket::Pos::Pos() {}
|
||||
|
||||
MoveEntityPacket::Pos::Pos(int id, char xa, char ya, char za)
|
||||
: MoveEntityPacket(id) {
|
||||
this->xa = xa;
|
||||
this->ya = ya;
|
||||
this->za = za;
|
||||
}
|
||||
|
||||
void MoveEntityPacket::PosRot::read(DataInputStream *dis) //throws IOException
|
||||
void MoveEntityPacket::Pos::read(DataInputStream* dis) // throws IOException
|
||||
{
|
||||
MoveEntityPacket::read(dis);
|
||||
xa = (int)dis->readByte();
|
||||
ya = (int)dis->readByte();
|
||||
za = (int)dis->readByte();
|
||||
yRot = (int)dis->readByte();
|
||||
xRot = (int)dis->readByte();
|
||||
MoveEntityPacket::read(dis);
|
||||
xa = (int)dis->readByte();
|
||||
ya = (int)dis->readByte();
|
||||
za = (int)dis->readByte();
|
||||
}
|
||||
|
||||
void MoveEntityPacket::PosRot::write(DataOutputStream *dos) //throws IOException
|
||||
void MoveEntityPacket::Pos::write(DataOutputStream* dos) // throws IOException
|
||||
{
|
||||
MoveEntityPacket::write(dos);
|
||||
dos->writeByte((uint8_t)xa);
|
||||
dos->writeByte((uint8_t)ya);
|
||||
dos->writeByte((uint8_t)za);
|
||||
dos->writeByte((uint8_t)yRot);
|
||||
dos->writeByte((uint8_t)xRot);
|
||||
MoveEntityPacket::write(dos);
|
||||
dos->writeByte((uint8_t)xa);
|
||||
dos->writeByte((uint8_t)ya);
|
||||
dos->writeByte((uint8_t)za);
|
||||
}
|
||||
|
||||
int MoveEntityPacket::PosRot::getEstimatedSize()
|
||||
{
|
||||
return 2+5;
|
||||
int MoveEntityPacket::Pos::getEstimatedSize() { return 2 + 3; }
|
||||
|
||||
MoveEntityPacket::Rot::Rot() { hasRot = true; }
|
||||
|
||||
MoveEntityPacket::Rot::Rot(int id, char yRot, char xRot)
|
||||
: MoveEntityPacket(id) {
|
||||
this->yRot = yRot;
|
||||
this->xRot = xRot;
|
||||
hasRot = true;
|
||||
}
|
||||
|
||||
MoveEntityPacket::Pos::Pos()
|
||||
void MoveEntityPacket::Rot::read(DataInputStream* dis) // throws IOException
|
||||
{
|
||||
MoveEntityPacket::read(dis);
|
||||
yRot = (int)dis->readByte();
|
||||
xRot = (int)dis->readByte();
|
||||
}
|
||||
|
||||
MoveEntityPacket::Pos::Pos(int id, char xa, char ya, char za) : MoveEntityPacket(id)
|
||||
void MoveEntityPacket::Rot::write(DataOutputStream* dos) // throws IOException
|
||||
{
|
||||
this->xa = xa;
|
||||
this->ya = ya;
|
||||
this->za = za;
|
||||
MoveEntityPacket::write(dos);
|
||||
dos->writeByte((uint8_t)yRot);
|
||||
dos->writeByte((uint8_t)xRot);
|
||||
}
|
||||
|
||||
void MoveEntityPacket::Pos::read(DataInputStream *dis) //throws IOException
|
||||
{
|
||||
MoveEntityPacket::read(dis);
|
||||
xa = (int)dis->readByte();
|
||||
ya = (int)dis->readByte();
|
||||
za = (int)dis->readByte();
|
||||
}
|
||||
|
||||
void MoveEntityPacket::Pos::write(DataOutputStream *dos) //throws IOException
|
||||
{
|
||||
MoveEntityPacket::write(dos);
|
||||
dos->writeByte((uint8_t)xa);
|
||||
dos->writeByte((uint8_t)ya);
|
||||
dos->writeByte((uint8_t)za);
|
||||
}
|
||||
|
||||
int MoveEntityPacket::Pos::getEstimatedSize()
|
||||
{
|
||||
return 2+3;
|
||||
}
|
||||
|
||||
MoveEntityPacket::Rot::Rot()
|
||||
{
|
||||
hasRot = true;
|
||||
}
|
||||
|
||||
MoveEntityPacket::Rot::Rot(int id, char yRot, char xRot) : MoveEntityPacket(id)
|
||||
{
|
||||
this->yRot = yRot;
|
||||
this->xRot = xRot;
|
||||
hasRot = true;
|
||||
}
|
||||
|
||||
void MoveEntityPacket::Rot::read(DataInputStream *dis) //throws IOException
|
||||
{
|
||||
MoveEntityPacket::read(dis);
|
||||
yRot = (int)dis->readByte();
|
||||
xRot = (int)dis->readByte();
|
||||
}
|
||||
|
||||
void MoveEntityPacket::Rot::write(DataOutputStream *dos) //throws IOException
|
||||
{
|
||||
MoveEntityPacket::write(dos);
|
||||
dos->writeByte((uint8_t)yRot);
|
||||
dos->writeByte((uint8_t)xRot);
|
||||
}
|
||||
|
||||
int MoveEntityPacket::Rot::getEstimatedSize()
|
||||
{
|
||||
return 2+2;
|
||||
}
|
||||
int MoveEntityPacket::Rot::getEstimatedSize() { return 2 + 2; }
|
||||
|
||||
Reference in New Issue
Block a user