diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2013-11-10 21:48:12 +0100 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2013-11-10 21:48:12 +0100 |
commit | 71abbb2f56c15634cca8615343d9699d0c50724d (patch) | |
tree | f56c254125256cc23f481b4ac18c843bd7470566 /source/Protocol/Protocol17x.cpp | |
parent | Removed cStringMap. (diff) | |
download | cuberite-71abbb2f56c15634cca8615343d9699d0c50724d.tar cuberite-71abbb2f56c15634cca8615343d9699d0c50724d.tar.gz cuberite-71abbb2f56c15634cca8615343d9699d0c50724d.tar.bz2 cuberite-71abbb2f56c15634cca8615343d9699d0c50724d.tar.lz cuberite-71abbb2f56c15634cca8615343d9699d0c50724d.tar.xz cuberite-71abbb2f56c15634cca8615343d9699d0c50724d.tar.zst cuberite-71abbb2f56c15634cca8615343d9699d0c50724d.zip |
Diffstat (limited to 'source/Protocol/Protocol17x.cpp')
-rw-r--r-- | source/Protocol/Protocol17x.cpp | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/source/Protocol/Protocol17x.cpp b/source/Protocol/Protocol17x.cpp index 9e230bafd..a962d238b 100644 --- a/source/Protocol/Protocol17x.cpp +++ b/source/Protocol/Protocol17x.cpp @@ -17,6 +17,7 @@ Implements the 1.7.x protocol classes: #include "../World.h" #include "../WorldStorage/FastNBT.h" #include "../StringCompression.h" +#include "../Entities/Minecart.h" #include "../Entities/FallingBlock.h" #include "../Entities/Pickup.h" #include "../Entities/Player.h" @@ -215,7 +216,7 @@ void cProtocol172::SendDestroyEntity(const cEntity & a_Entity) void cProtocol172::SendDisconnect(const AString & a_Reason) { cPacketizer Pkt(*this, 0x40); - Pkt.WriteString(a_Reason); + Pkt.WriteString(Printf("{\"text\":\"%s\"}", EscapeString(a_Reason).c_str())); } @@ -615,9 +616,7 @@ void cProtocol172::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_Src { cPacketizer Pkt(*this, 0x28); // Effect packet Pkt.WriteInt(a_EffectID); - Pkt.WriteInt(a_SrcX); - // TODO: Check if this is really an int - // wiki.vg says it's a byte, but that wouldn't cover the entire range needed (Y location * 8 = 0..2048) + Pkt.WriteByte(a_SrcX); Pkt.WriteInt(a_SrcY); Pkt.WriteInt(a_SrcZ); Pkt.WriteInt(a_Data); @@ -1666,12 +1665,43 @@ void cProtocol172::cPacketizer::WriteEntityMetadata(const cEntity & a_Entity) WriteItem(((const cPickup &)a_Entity).GetItem()); break; } + case cEntity::etMinecart: + { + WriteByte(0x51); + + // The following expression makes Minecarts shake more with less health or higher damage taken + // It gets half the maximum health, and takes it away from the current health minus the half health: + /* Health: 5 | 3 - (5 - 3) = 1 (shake power) + Health: 3 | 3 - (3 - 3) = 3 + Health: 1 | 3 - (1 - 3) = 5 + */ + WriteInt((((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * ((const cMinecart &)a_Entity).LastDamage()) * 4); + WriteByte(0x52); + WriteInt(1); // Shaking direction, doesn't seem to affect anything + WriteByte(0x73); + WriteFloat((float)(((const cMinecart &)a_Entity).LastDamage() + 10)); // Damage taken / shake effect multiplyer + + if (((cMinecart &)a_Entity).GetPayload() == cMinecart::mpFurnace) + { + WriteByte(0x10); + WriteByte(((const cMinecartWithFurnace &)a_Entity).IsFueled() ? 1 : 0); + } + break; + } + case cEntity::etProjectile: + { + if (((cProjectileEntity &)a_Entity).GetProjectileKind() == cProjectileEntity::pkArrow) + { + WriteByte(0x10); + WriteByte(((const cArrowEntity &)a_Entity).IsCritical() ? 1 : 0); + } + break; + } case cEntity::etMonster: { WriteMobMetadata((const cMonster &)a_Entity); break; } - // TODO: Other types } } |