mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-25 07:15:10 +00:00
chore: format Minecraft.World
This commit is contained in:
@@ -5,132 +5,114 @@
|
||||
#include "PacketListener.h"
|
||||
#include "ExplodePacket.h"
|
||||
|
||||
|
||||
|
||||
ExplodePacket::ExplodePacket()
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
r = 0.0f;
|
||||
m_bKnockbackOnly = false;
|
||||
knockbackX = 0.0f;
|
||||
knockbackY = 0.0f;
|
||||
knockbackZ = 0.0f;
|
||||
ExplodePacket::ExplodePacket() {
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
r = 0.0f;
|
||||
m_bKnockbackOnly = false;
|
||||
knockbackX = 0.0f;
|
||||
knockbackY = 0.0f;
|
||||
knockbackZ = 0.0f;
|
||||
}
|
||||
|
||||
ExplodePacket::ExplodePacket(double x, double y, double z, float r, std::unordered_set<TilePos, TilePosKeyHash, TilePosKeyEq> *toBlow, Vec3 *knockback, bool knockBackOnly)
|
||||
{
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->z = z;
|
||||
this->r = r;
|
||||
m_bKnockbackOnly = knockBackOnly;
|
||||
ExplodePacket::ExplodePacket(
|
||||
double x, double y, double z, float r,
|
||||
std::unordered_set<TilePos, TilePosKeyHash, TilePosKeyEq>* toBlow,
|
||||
Vec3* knockback, bool knockBackOnly) {
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->z = z;
|
||||
this->r = r;
|
||||
m_bKnockbackOnly = knockBackOnly;
|
||||
|
||||
if(toBlow != NULL)
|
||||
{
|
||||
this->toBlow.assign(toBlow->begin(),toBlow->end());
|
||||
//for( AUTO_VAR(it, toBlow->begin()); it != toBlow->end(); it++ )
|
||||
//{
|
||||
// this->toBlow.push_back(*it);
|
||||
//}
|
||||
}
|
||||
if (toBlow != NULL) {
|
||||
this->toBlow.assign(toBlow->begin(), toBlow->end());
|
||||
// for( AUTO_VAR(it, toBlow->begin()); it != toBlow->end(); it++ )
|
||||
//{
|
||||
// this->toBlow.push_back(*it);
|
||||
// }
|
||||
}
|
||||
|
||||
if (knockback != NULL)
|
||||
{
|
||||
knockbackX = (float) knockback->x;
|
||||
knockbackY = (float) knockback->y;
|
||||
knockbackZ = (float) knockback->z;
|
||||
}
|
||||
if (knockback != NULL) {
|
||||
knockbackX = (float)knockback->x;
|
||||
knockbackY = (float)knockback->y;
|
||||
knockbackZ = (float)knockback->z;
|
||||
}
|
||||
}
|
||||
|
||||
void ExplodePacket::read(DataInputStream *dis) //throws IOException
|
||||
void ExplodePacket::read(DataInputStream* dis) // throws IOException
|
||||
{
|
||||
m_bKnockbackOnly = dis->readBoolean();
|
||||
m_bKnockbackOnly = dis->readBoolean();
|
||||
|
||||
if(!m_bKnockbackOnly)
|
||||
{
|
||||
x = dis->readDouble();
|
||||
y = dis->readDouble();
|
||||
z = dis->readDouble();
|
||||
r = dis->readFloat();
|
||||
int count = dis->readInt();
|
||||
if (!m_bKnockbackOnly) {
|
||||
x = dis->readDouble();
|
||||
y = dis->readDouble();
|
||||
z = dis->readDouble();
|
||||
r = dis->readFloat();
|
||||
int count = dis->readInt();
|
||||
|
||||
int xp = (int)x;
|
||||
int yp = (int)y;
|
||||
int zp = (int)z;
|
||||
for (int i=0; i<count; i++)
|
||||
{
|
||||
int xx = ((signed char)dis->readByte())+xp;
|
||||
int yy = ((signed char)dis->readByte())+yp;
|
||||
int zz = ((signed char)dis->readByte())+zp;
|
||||
toBlow.push_back( TilePos(xx, yy, zz) );
|
||||
}
|
||||
}
|
||||
int xp = (int)x;
|
||||
int yp = (int)y;
|
||||
int zp = (int)z;
|
||||
for (int i = 0; i < count; i++) {
|
||||
int xx = ((signed char)dis->readByte()) + xp;
|
||||
int yy = ((signed char)dis->readByte()) + yp;
|
||||
int zz = ((signed char)dis->readByte()) + zp;
|
||||
toBlow.push_back(TilePos(xx, yy, zz));
|
||||
}
|
||||
}
|
||||
|
||||
knockbackX = dis->readFloat();
|
||||
knockbackY = dis->readFloat();
|
||||
knockbackZ = dis->readFloat();
|
||||
knockbackX = dis->readFloat();
|
||||
knockbackY = dis->readFloat();
|
||||
knockbackZ = dis->readFloat();
|
||||
}
|
||||
|
||||
void ExplodePacket::write(DataOutputStream *dos) //throws IOException
|
||||
void ExplodePacket::write(DataOutputStream* dos) // throws IOException
|
||||
{
|
||||
dos->writeBoolean(m_bKnockbackOnly);
|
||||
dos->writeBoolean(m_bKnockbackOnly);
|
||||
|
||||
if(!m_bKnockbackOnly)
|
||||
{
|
||||
dos->writeDouble(x);
|
||||
dos->writeDouble(y);
|
||||
dos->writeDouble(z);
|
||||
dos->writeFloat(r);
|
||||
dos->writeInt((int)toBlow.size());
|
||||
if (!m_bKnockbackOnly) {
|
||||
dos->writeDouble(x);
|
||||
dos->writeDouble(y);
|
||||
dos->writeDouble(z);
|
||||
dos->writeFloat(r);
|
||||
dos->writeInt((int)toBlow.size());
|
||||
|
||||
int xp = (int)x;
|
||||
int yp = (int)y;
|
||||
int zp = (int)z;
|
||||
int xp = (int)x;
|
||||
int yp = (int)y;
|
||||
int zp = (int)z;
|
||||
|
||||
//(Myset::const_iterator it = c1.begin();
|
||||
//it != c1.end(); ++it)
|
||||
|
||||
for( AUTO_VAR(it, toBlow.begin()); it != toBlow.end(); it++ )
|
||||
{
|
||||
TilePos tp = *it;
|
||||
//(Myset::const_iterator it = c1.begin();
|
||||
// it != c1.end(); ++it)
|
||||
|
||||
int xx = tp.x-xp;
|
||||
int yy = tp.y-yp;
|
||||
int zz = tp.z-zp;
|
||||
dos->writeByte((uint8_t)xx);
|
||||
dos->writeByte((uint8_t)yy);
|
||||
dos->writeByte((uint8_t)zz);
|
||||
}
|
||||
}
|
||||
for (AUTO_VAR(it, toBlow.begin()); it != toBlow.end(); it++) {
|
||||
TilePos tp = *it;
|
||||
|
||||
dos->writeFloat(knockbackX);
|
||||
dos->writeFloat(knockbackY);
|
||||
dos->writeFloat(knockbackZ);
|
||||
int xx = tp.x - xp;
|
||||
int yy = tp.y - yp;
|
||||
int zz = tp.z - zp;
|
||||
dos->writeByte((uint8_t)xx);
|
||||
dos->writeByte((uint8_t)yy);
|
||||
dos->writeByte((uint8_t)zz);
|
||||
}
|
||||
}
|
||||
|
||||
dos->writeFloat(knockbackX);
|
||||
dos->writeFloat(knockbackY);
|
||||
dos->writeFloat(knockbackZ);
|
||||
}
|
||||
|
||||
void ExplodePacket::handle(PacketListener *listener)
|
||||
{
|
||||
listener->handleExplosion(shared_from_this());
|
||||
void ExplodePacket::handle(PacketListener* listener) {
|
||||
listener->handleExplosion(shared_from_this());
|
||||
}
|
||||
|
||||
int ExplodePacket::getEstimatedSize()
|
||||
{
|
||||
return 8*3+4+4+(int)toBlow.size()*3+12;
|
||||
int ExplodePacket::getEstimatedSize() {
|
||||
return 8 * 3 + 4 + 4 + (int)toBlow.size() * 3 + 12;
|
||||
}
|
||||
|
||||
float ExplodePacket::getKnockbackX()
|
||||
{
|
||||
return knockbackX;
|
||||
}
|
||||
float ExplodePacket::getKnockbackX() { return knockbackX; }
|
||||
|
||||
float ExplodePacket::getKnockbackY()
|
||||
{
|
||||
return knockbackY;
|
||||
}
|
||||
float ExplodePacket::getKnockbackY() { return knockbackY; }
|
||||
|
||||
float ExplodePacket::getKnockbackZ()
|
||||
{
|
||||
return knockbackZ;
|
||||
}
|
||||
float ExplodePacket::getKnockbackZ() { return knockbackZ; }
|
||||
|
||||
Reference in New Issue
Block a user