summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-07-17 22:23:08 +0200
committermadmaxoft <github@xoft.cz>2014-07-17 22:23:08 +0200
commit7a9f9ab744e88267299b347ac6c9171acfe3afaa (patch)
tree7cc853f2e143ec42948e5b44f207d286cc9db039 /src
parentInitial version of a script to check basic style. (diff)
parentMerge pull request #1204 from Howaner/Blocks (diff)
downloadcuberite-7a9f9ab744e88267299b347ac6c9171acfe3afaa.tar
cuberite-7a9f9ab744e88267299b347ac6c9171acfe3afaa.tar.gz
cuberite-7a9f9ab744e88267299b347ac6c9171acfe3afaa.tar.bz2
cuberite-7a9f9ab744e88267299b347ac6c9171acfe3afaa.tar.lz
cuberite-7a9f9ab744e88267299b347ac6c9171acfe3afaa.tar.xz
cuberite-7a9f9ab744e88267299b347ac6c9171acfe3afaa.tar.zst
cuberite-7a9f9ab744e88267299b347ac6c9171acfe3afaa.zip
Diffstat (limited to 'src')
-rw-r--r--src/Blocks/BlockSapling.h2
-rw-r--r--src/ChunkMap.cpp4
-rw-r--r--src/Entities/Entity.cpp31
3 files changed, 12 insertions, 25 deletions
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));
}
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index de2016015..9f280f1c5 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1737,7 +1737,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;
}
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 0a85537bf..bb584cb9e 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);