From db36f1a9fad7a79d489c36abd6140e7b48f7d413 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 17 Jul 2014 13:54:28 +0100 Subject: Fixed crash with entities in unloaded chunks * Fixes #1190 --- src/ChunkMap.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index b9bb39aa8..e2cf50314 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1736,7 +1736,9 @@ void cChunkMap::RemoveEntity(cEntity * a_Entity) { cCSLock Lock(m_CSLayers); cChunkPtr Chunk = GetChunkNoGen(a_Entity->GetChunkX(), ZERO_CHUNK_Y, a_Entity->GetChunkZ()); - if ((Chunk == NULL) || !Chunk->IsValid()) + + // Even if a chunk is not valid, it may still contain entities such as players; make sure to remove them (#1190) + if (Chunk == NULL) { return; } -- cgit v1.2.3 From 3dd9649665e88e27298d93fd3c08b76ac5b0befa Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 17 Jul 2014 14:32:52 +0100 Subject: Fixed mob knockback * Fixes #901 --- src/Entities/Entity.cpp | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index c6dc1fca3..4a6de25b7 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -334,36 +334,21 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs { - int KnockbackLevel = 0; - if (a_TDI.Attacker->GetEquippedWeapon().m_ItemType == E_ITEM_BOW) + int KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback); // More common enchantment + if (KnockbackLevel < 1) { + // We support punch on swords and vice versa! :) KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchPunch); } - else - { - KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback); - } - Vector3d additionalSpeed(0, 0, 0); + Vector3d AdditionalSpeed(0, 0, 0); switch (KnockbackLevel) { - case 1: - { - additionalSpeed.Set(5, .3, 5); - break; - } - case 2: - { - additionalSpeed.Set(8, .3, 8); - break; - } - default: - { - additionalSpeed.Set(2, .3, 2); - break; - } + case 1: AdditionalSpeed.Set(5, 0.3, 5); break; + case 2: AdditionalSpeed.Set(8, 0.3, 8); break; + default: break; } - AddSpeed(a_TDI.Knockback * additionalSpeed); + AddSpeed(a_TDI.Knockback + AdditionalSpeed); } m_World->BroadcastEntityStatus(*this, esGenericHurt); -- cgit v1.2.3 From 68cc9c6f91bbbadedf3641099e0aa17352e4dde8 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 17 Jul 2014 21:35:34 +0200 Subject: Fix sapling drop. --- src/Blocks/BlockSapling.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Blocks/BlockSapling.h b/src/Blocks/BlockSapling.h index 3d925029a..3f443b734 100644 --- a/src/Blocks/BlockSapling.h +++ b/src/Blocks/BlockSapling.h @@ -21,7 +21,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { // Only the first 2 bits contain the display information, the others are for growing - a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 3)); + a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 0x7)); } -- cgit v1.2.3