summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2013-10-11 01:41:54 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2013-10-11 01:41:54 +0200
commitd7b2c534fd2e272c328b176432c922fd11a7cd85 (patch)
tree8431feefc1a28a05c18eb01c06a22550b7f34d77 /source
parentSecond round of fixes (diff)
downloadcuberite-d7b2c534fd2e272c328b176432c922fd11a7cd85.tar
cuberite-d7b2c534fd2e272c328b176432c922fd11a7cd85.tar.gz
cuberite-d7b2c534fd2e272c328b176432c922fd11a7cd85.tar.bz2
cuberite-d7b2c534fd2e272c328b176432c922fd11a7cd85.tar.lz
cuberite-d7b2c534fd2e272c328b176432c922fd11a7cd85.tar.xz
cuberite-d7b2c534fd2e272c328b176432c922fd11a7cd85.tar.zst
cuberite-d7b2c534fd2e272c328b176432c922fd11a7cd85.zip
Diffstat (limited to 'source')
-rw-r--r--source/Mobs/Bat.h3
-rw-r--r--source/Mobs/Cavespider.cpp3
-rw-r--r--source/Mobs/Enderman.cpp3
-rw-r--r--source/Mobs/Ocelot.h3
-rw-r--r--source/Mobs/Silverfish.h3
-rw-r--r--source/Protocol/Protocol125.cpp157
-rw-r--r--source/Protocol/Protocol125.h10
-rw-r--r--source/Protocol/Protocol132.cpp6
8 files changed, 106 insertions, 82 deletions
diff --git a/source/Mobs/Bat.h b/source/Mobs/Bat.h
index 7aaec361b..0b50e06cd 100644
--- a/source/Mobs/Bat.h
+++ b/source/Mobs/Bat.h
@@ -14,8 +14,7 @@ class cBat :
public:
cBat(void) :
- // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
- super("Bat", 65, "mob.bat.hurt", "mob.bat.death", 0.7, 0.7)
+ super("Bat", 65, "mob.bat.hurt", "mob.bat.death", 0.5, 0.9)
{
}
diff --git a/source/Mobs/Cavespider.cpp b/source/Mobs/Cavespider.cpp
index 569aadcc4..2d50b391a 100644
--- a/source/Mobs/Cavespider.cpp
+++ b/source/Mobs/Cavespider.cpp
@@ -9,8 +9,7 @@
cCavespider::cCavespider(void) :
- // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
- super("Cavespider", 59, "mob.spider.say", "mob.spider.death", 0.9, 0.6)
+ super("Cavespider", 59, "mob.spider.say", "mob.spider.death", 0.7, 0.5)
{
}
diff --git a/source/Mobs/Enderman.cpp b/source/Mobs/Enderman.cpp
index 04c1a60e1..c0ea3d6aa 100644
--- a/source/Mobs/Enderman.cpp
+++ b/source/Mobs/Enderman.cpp
@@ -8,8 +8,7 @@
cEnderman::cEnderman(void) :
- // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
- super("Enderman", 58, "mob.endermen.hit", "mob.endermen.death", 0.5, 2.5),
+ super("Enderman", 58, "mob.endermen.hit", "mob.endermen.death", 0.5, 2.9),
m_bIsScreaming(false),
CarriedBlock(E_BLOCK_AIR),
CarriedMeta(0)
diff --git a/source/Mobs/Ocelot.h b/source/Mobs/Ocelot.h
index 98ea224e2..6d24c5672 100644
--- a/source/Mobs/Ocelot.h
+++ b/source/Mobs/Ocelot.h
@@ -14,8 +14,7 @@ class cOcelot :
public:
cOcelot(void) :
- // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
- super("Ocelot", 98, "mob.cat.hitt", "mob.cat.hitt", 0.9, 0.5)
+ super("Ocelot", 98, "mob.cat.hitt", "mob.cat.hitt", 0.6, 0.8)
{
}
diff --git a/source/Mobs/Silverfish.h b/source/Mobs/Silverfish.h
index 7d675a9c0..d632ac169 100644
--- a/source/Mobs/Silverfish.h
+++ b/source/Mobs/Silverfish.h
@@ -14,8 +14,7 @@ class cSilverfish :
public:
cSilverfish(void) :
- // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
- super("Silverfish", 60, "mob.silverfish.hit", "mob.silverfish.kill", 0.9, 0.3)
+ super("Silverfish", 60, "mob.silverfish.hit", "mob.silverfish.kill", 0.3, 0.7)
{
}
diff --git a/source/Protocol/Protocol125.cpp b/source/Protocol/Protocol125.cpp
index 0f5f3a616..96a4e57ff 100644
--- a/source/Protocol/Protocol125.cpp
+++ b/source/Protocol/Protocol125.cpp
@@ -363,7 +363,16 @@ void cProtocol125::SendEntityMetadata(const cEntity & a_Entity)
WriteByte(PACKET_METADATA);
WriteInt (a_Entity.GetUniqueID());
- WriteMetadata(a_Entity);
+ WriteCommonMetadata(a_Entity);
+ if (a_Entity.IsMob())
+ {
+ WriteMobMetadata(((const cMonster &)a_Entity));
+ }
+ else
+ {
+ WriteEntityMetadata(a_Entity);
+ }
+ WriteByte(0x7f);
Flush();
}
@@ -730,7 +739,11 @@ void cProtocol125::SendSpawnMob(const cMonster & a_Mob)
WriteByte (0);
WriteByte (0);
WriteByte (0);
- WriteMetadata(a_Mob);
+
+ WriteCommonMetadata(a_Mob);
+ WriteMobMetadata(a_Mob);
+ WriteByte(0x7f);
+
Flush();
}
@@ -1633,10 +1646,8 @@ int cProtocol125::ParseItem(cItem & a_Item)
-void cProtocol125::WriteMetadata(const cEntity & a_Entity)
+void cProtocol125::WriteCommonMetadata(const cEntity & a_Entity)
{
- // Common Metadata
-
Byte CommonMetadata = 0;
if (a_Entity.IsOnFire())
@@ -1666,78 +1677,91 @@ void cProtocol125::WriteMetadata(const cEntity & a_Entity)
WriteByte(0x0);
WriteByte(CommonMetadata);
+}
+
+
- // Common Metadata End
- // Specific Entity Metadata
+
+void cProtocol125::WriteEntityMetadata(const cEntity & a_Entity)
+{
if (a_Entity.IsMinecart())
{
WriteByte(0x51);
// No idea how Mojang makes their carts shakey shakey, so here is a complicated one-liner expression that does something similar
- WriteInt( (((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * ((cMinecart &)a_Entity).LastDamage()) * 4 );
+ 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)(((cMinecart &)a_Entity).LastDamage() + 10)); // Damage taken / shake effect multiplyer
+ WriteFloat((float)(((const cMinecart &)a_Entity).LastDamage() + 10)); // Damage taken / shake effect multiplyer
+
+ if (a_Entity.IsA("cMinecartWithFurnace"))
+ {
+ WriteByte(0x10);
+ WriteByte(((const cMinecartWithFurnace &)a_Entity).IsFueled() ? 1 : 0); // Fueled?
+ }
}
- else if (a_Entity.IsA("cCreeper"))
+}
+
+
+
+
+
+void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
+{
+ if (a_Mob.GetMobType() == E_META_SPAWN_EGG_CREEPER)
{
WriteByte(0x10);
- WriteByte(((cCreeper &)a_Entity).IsBlowing() ? 1 : -1); // Blowing up?
+ WriteByte(((const cCreeper &)a_Mob).IsBlowing() ? 1 : -1); // Blowing up?
WriteByte(0x11);
- WriteByte(((cCreeper &)a_Entity).IsCharged() ? 1 : 0); // Lightning-charged?
- }
- else if (a_Entity.IsA("cMinecartWithFurnace"))
- {
- WriteByte(0x10);
- WriteByte(((const cMinecartWithFurnace &)a_Entity).IsFueled() ? 1 : 0); // Fueled?
+ WriteByte(((const cCreeper &)a_Mob).IsCharged() ? 1 : 0); // Lightning-charged?
}
- else if (a_Entity.IsA("cBat"))
+ else if (a_Mob.GetMobType() == E_META_SPAWN_EGG_BAT)
{
WriteByte(0x10);
- WriteByte(((const cBat &)a_Entity).IsHanging() ? 1 : 0); // Upside down?
+ WriteByte(((const cBat &)a_Mob).IsHanging() ? 1 : 0); // Upside down?
}
- else if (a_Entity.IsA("cPig"))
+ else if (a_Mob.GetMobType() == E_META_SPAWN_EGG_PIG)
{
WriteByte(0x10);
- WriteByte(((const cPig &)a_Entity).IsSaddled() ? 1 : 0); // Saddled?
+ WriteByte(((const cPig &)a_Mob).IsSaddled() ? 1 : 0); // Saddled?
}
- else if (a_Entity.IsA("cVillager"))
+ else if (a_Mob.GetMobType() == E_META_SPAWN_EGG_VILLAGER)
{
WriteByte(0x50);
- WriteInt(((const cVillager &)a_Entity).GetVilType()); // What sort of TESTIFICATE?
+ WriteInt(((const cVillager &)a_Mob).GetVilType()); // What sort of TESTIFICATE?
}
- else if (a_Entity.IsA("cZombie"))
+ else if (a_Mob.GetMobType() == E_META_SPAWN_EGG_ZOMBIE)
{
WriteByte(0xC);
- WriteByte(((const cZombie &)a_Entity).IsBaby() ? 1 : 0); // Babby zombie?
+ WriteByte(((const cZombie &)a_Mob).IsBaby() ? 1 : 0); // Babby zombie?
WriteByte(0xD);
- WriteByte(((const cZombie &)a_Entity).IsVillagerZombie() ? 1 : 0); // Converted zombie?
+ WriteByte(((const cZombie &)a_Mob).IsVillagerZombie() ? 1 : 0); // Converted zombie?
WriteByte(0xE);
- WriteByte(((const cZombie &)a_Entity).IsConverting() ? 1 : 0); // Converted-but-converting-back zombllager?
+ WriteByte(((const cZombie &)a_Mob).IsConverting() ? 1 : 0); // Converted-but-converting-back zombllager?
}
- else if (a_Entity.IsA("cGhast"))
+ else if (a_Mob.GetMobType() == E_META_SPAWN_EGG_GHAST)
{
WriteByte(0x10);
- WriteByte(((const cGhast &)a_Entity).IsCharging()); // About to eject un flamé-bol? :P
+ WriteByte(((const cGhast &)a_Mob).IsCharging()); // About to eject un flamé-bol? :P
}
- else if (a_Entity.IsA("cArrowEntity"))
+ else if (a_Mob.GetMobType() == E_META_SPAWN_EGG_ARROW)
{
WriteByte(0x10);
- WriteByte(((const cArrowEntity &)a_Entity).IsCritical() ? 1 : 0); // Critical hitting arrow?
+ WriteByte(((const cArrowEntity &)a_Mob).IsCritical() ? 1 : 0); // Critical hitting arrow?
}
- else if (a_Entity.IsA("cWolf"))
+ else if (a_Mob.GetMobType() == E_META_SPAWN_EGG_WOLF)
{
Byte WolfStatus = 0;
- if (((const cWolf &)a_Entity).IsSitting())
+ if (((const cWolf &)a_Mob).IsSitting())
{
WolfStatus |= 0x1;
}
- if (((const cWolf &)a_Entity).IsAngry())
+ if (((const cWolf &)a_Mob).IsAngry())
{
WolfStatus |= 0x2;
}
- if (((const cWolf &)a_Entity).IsTame())
+ if (((const cWolf &)a_Mob).IsTame())
{
WolfStatus |= 0x4;
}
@@ -1745,84 +1769,84 @@ void cProtocol125::WriteMetadata(const cEntity & a_Entity)
WriteByte(WolfStatus);
WriteByte(0x72);
- WriteFloat((float)(a_Entity.GetHealth())); // Tail health-o-meter (only shown when tamed, by the way)
+ WriteFloat((float)(a_Mob.GetHealth())); // Tail health-o-meter (only shown when tamed, by the way)
WriteByte(0x13);
- WriteByte(((const cWolf &)a_Entity).IsBegging() ? 1 : 0); // Ultra cute mode?
+ WriteByte(((const cWolf &)a_Mob).IsBegging() ? 1 : 0); // Ultra cute mode?
}
- else if (a_Entity.IsA("cSheep"))
+ else if (a_Mob.GetMobType() == E_META_SPAWN_EGG_SHEEP)
{
// [1](1111)
// [] = Is sheared? () = Color, from 0 to 15
WriteByte(0x10);
Byte SheepMetadata = 0;
- SheepMetadata = ((const cSheep &)a_Entity).GetFurColor(); // Fur colour
+ SheepMetadata = ((const cSheep &)a_Mob).GetFurColor(); // Fur colour
- if (((const cSheep &)a_Entity).IsSheared()) // Is sheared?
+ if (((const cSheep &)a_Mob).IsSheared()) // Is sheared?
{
SheepMetadata |= 0x16;
}
WriteByte(SheepMetadata);
}
- else if (a_Entity.IsA("cEnderman"))
+ else if (a_Mob.GetMobType() == E_META_SPAWN_EGG_ENDERMAN)
{
WriteByte(0x10);
- WriteByte((Byte)(((cEnderman &)a_Entity).GetCarriedBlock())); // Block that he stole from your house
+ WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedBlock())); // Block that he stole from your house
WriteByte(0x11);
- WriteByte((Byte)(((cEnderman &)a_Entity).GetCarriedMeta())); // Meta of block that he stole from your house
+ WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedMeta())); // Meta of block that he stole from your house
WriteByte(0x12);
- WriteByte(((cEnderman &)a_Entity).IsScreaming() ? 1 : 0); // Screaming at your face?
+ WriteByte(((const cEnderman &)a_Mob).IsScreaming() ? 1 : 0); // Screaming at your face?
}
- else if (a_Entity.IsA("cSkeleton"))
+ else if (a_Mob.GetMobType() == E_META_SPAWN_EGG_SKELETON)
{
WriteByte(0xD);
- WriteByte(((const cSkeleton &)a_Entity).IsWither() ? 1 : 0); // It's a skeleton, but it's not
+ WriteByte(((const cSkeleton &)a_Mob).IsWither() ? 1 : 0); // It's a skeleton, but it's not
}
- else if (a_Entity.IsA("cWitch"))
+ else if (a_Mob.GetMobType() == E_META_SPAWN_EGG_WITCH)
{
WriteByte(0x15);
- WriteByte(((cWitch &)a_Entity).IsAngry() ? 1 : 0); // Aggravated? Doesn't seem to do anything
+ WriteByte(((const cWitch &)a_Mob).IsAngry() ? 1 : 0); // Aggravated? Doesn't seem to do anything
}
- else if ((a_Entity.IsA("cSlime")) || (a_Entity.IsA("cMagmaCube")))
+ else if ((a_Mob.GetMobType() == E_META_SPAWN_EGG_SLIME) || (a_Mob.GetMobType() == E_META_SPAWN_EGG_MAGMA_CUBE))
{
WriteByte(0x10);
- if (a_Entity.IsA("cSlime"))
+ if (a_Mob.GetMobType() == E_META_SPAWN_EGG_SLIME)
{
- WriteByte(((const cSlime &)a_Entity).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME
+ WriteByte(((const cSlime &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME
}
else
{
- WriteByte(((const cMagmaCube &)a_Entity).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME
+ WriteByte(((const cMagmaCube &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME
}
}
- else if (a_Entity.IsA("cHorse"))
+ else if (a_Mob.GetMobType() == E_META_SPAWN_EGG_HORSE)
{
int Flags = 0;
- if (((const cHorse &)a_Entity).IsTame())
+ if (((const cHorse &)a_Mob).IsTame())
{
Flags |= 0x2;
}
- if (((const cHorse &)a_Entity).IsSaddled())
+ if (((const cHorse &)a_Mob).IsSaddled())
{
Flags |= 0x4;
}
- if (((const cHorse &)a_Entity).IsChested())
+ if (((const cHorse &)a_Mob).IsChested())
{
Flags |= 0x8;
}
- if (((const cHorse &)a_Entity).IsBaby())
+ if (((const cHorse &)a_Mob).IsBaby())
{
Flags |= 0x10; // IsBred flag, according to wiki.vg - don't think it does anything in multiplayer
}
- if (((const cHorse &)a_Entity).IsEating())
+ if (((const cHorse &)a_Mob).IsEating())
{
Flags |= 0x20;
}
- if (((const cHorse &)a_Entity).IsRearing())
+ if (((const cHorse &)a_Mob).IsRearing())
{
Flags |= 0x40;
}
- if (((const cHorse &)a_Entity).IsMthOpen())
+ if (((const cHorse &)a_Mob).IsMthOpen())
{
Flags |= 0x80;
}
@@ -1830,22 +1854,17 @@ void cProtocol125::WriteMetadata(const cEntity & a_Entity)
WriteInt(Flags);
WriteByte(0x13);
- WriteByte(((const cHorse &)a_Entity).GetHType()); // Type of horse (donkey, chestnut, etc.)
+ WriteByte(((const cHorse &)a_Mob).GetHType()); // Type of horse (donkey, chestnut, etc.)
WriteByte(0x54);
int Appearance = 0;
- Appearance = ((const cHorse &)a_Entity).GetHColor(); // Mask FF
- Appearance |= ((const cHorse &)a_Entity).GetHStyle() * 256; // Mask FF00, so multiply by 256
+ Appearance = ((const cHorse &)a_Mob).GetHColor(); // Mask FF
+ Appearance |= ((const cHorse &)a_Mob).GetHStyle() * 256; // Mask FF00, so multiply by 256
WriteInt(Appearance);
WriteByte(0x56);
- WriteInt(((const cHorse &)a_Entity).GetHArmour()); // Horshey armour
+ WriteInt(((const cHorse &)a_Mob).GetHArmour()); // Horshey armour
}
-
- // End Specific Metadata
- // End Metadata Packet
-
- WriteByte(0x7f);
}
diff --git a/source/Protocol/Protocol125.h b/source/Protocol/Protocol125.h
index 7b493881b..ae198780c 100644
--- a/source/Protocol/Protocol125.h
+++ b/source/Protocol/Protocol125.h
@@ -142,8 +142,14 @@ protected:
/// Parses one item, "slot" as the protocol wiki calls it, from m_ReceivedData; returns the usual ParsePacket() codes
virtual int ParseItem(cItem & a_Item);
- /// Writes the entity metadata
- void WriteMetadata(const cEntity & a_Entity);
+ /// Writes the COMMON entity metadata
+ void WriteCommonMetadata(const cEntity & a_Entity);
+
+ /// Writes normal entity metadata
+ void WriteEntityMetadata(const cEntity & a_Entity);
+
+ /// Writes mobile entity metadata
+ void WriteMobMetadata(const cMonster & a_Mob);
} ;
diff --git a/source/Protocol/Protocol132.cpp b/source/Protocol/Protocol132.cpp
index 63b838b70..53159a3b3 100644
--- a/source/Protocol/Protocol132.cpp
+++ b/source/Protocol/Protocol132.cpp
@@ -416,7 +416,11 @@ void cProtocol132::SendSpawnMob(const cMonster & a_Mob)
WriteShort ((short)(a_Mob.GetSpeedX() * 400));
WriteShort ((short)(a_Mob.GetSpeedY() * 400));
WriteShort ((short)(a_Mob.GetSpeedZ() * 400));
- WriteMetadata(a_Mob);
+
+ WriteCommonMetadata(a_Mob);
+ WriteMobMetadata(a_Mob);
+ WriteByte(0x7f);
+
Flush();
}