summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Blocks/BlockHandler.cpp32
-rw-r--r--src/Blocks/BlockIce.h24
-rw-r--r--src/Entities/ArrowEntity.cpp22
-rw-r--r--src/Entities/ArrowEntity.h1
-rw-r--r--src/Entities/Entity.cpp25
-rw-r--r--src/Entities/Player.cpp20
6 files changed, 101 insertions, 23 deletions
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index 52f7dd608..3c85a31e0 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -424,19 +424,43 @@ void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterfac
cItems Pickups;
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- if (a_CanDrop)
+ // Thanks to daniel0916
+ cPlayer * Player = (cPlayer *)a_Digger;
+ cEnchantments Enchantments = Player->GetInventory().GetEquippedItem().m_Enchantments;
+ if (Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0)
{
- if (!a_DropVerbatim)
+ BLOCKTYPE Type = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+ if (Type == E_BLOCK_CAKE || Type == E_BLOCK_CARROTS || Type == E_BLOCK_COCOA_POD || Type == E_BLOCK_DOUBLE_STONE_SLAB ||
+ Type == E_BLOCK_DOUBLE_WOODEN_SLAB || Type == E_BLOCK_FIRE || Type == E_BLOCK_FARMLAND || Type == E_BLOCK_MELON_STEM ||
+ Type == E_BLOCK_MOB_SPAWNER || Type == E_BLOCK_NETHER_WART || Type == E_BLOCK_POTATOES || Type == E_BLOCK_PUMPKIN_STEM ||
+ Type == E_BLOCK_SNOW || Type == E_BLOCK_SUGARCANE || Type == E_BLOCK_TALL_GRASS || Type == E_BLOCK_CROPS
+ )
{
+ // Silktouch can't be used for this blocks
ConvertToPickups(Pickups, Meta);
}
else
{
- // TODO: Add a proper overridable function for this
Pickups.Add(m_BlockType, 1, Meta);
}
}
-
+ else
+ {
+ if (a_CanDrop)
+ {
+ if (!a_DropVerbatim)
+ {
+ ConvertToPickups(Pickups, Meta);
+ }
+ else
+ {
+ // TODO: Add a proper overridable function for this
+ Pickups.Add(m_BlockType, 1, Meta);
+ }
+ }
+
+ }
+
// Allow plugins to modify the pickups:
a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups);
diff --git a/src/Blocks/BlockIce.h b/src/Blocks/BlockIce.h
index c38630fe3..cfe1d179f 100644
--- a/src/Blocks/BlockIce.h
+++ b/src/Blocks/BlockIce.h
@@ -30,18 +30,18 @@ public:
{
return;
}
-
- BLOCKTYPE BlockBelow = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ);
- if (!cBlockInfo::FullyOccupiesVoxel(BlockBelow) && !IsBlockLiquid(BlockBelow))
+
+ cEnchantments Enchantments = a_Player->GetInventory().GetEquippedItem().m_Enchantments;
+ if (Enchantments.GetLevel(cEnchantments::enchSilkTouch) == 0)
{
- return;
+ BLOCKTYPE BlockBelow = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ);
+ if (!cBlockInfo::FullyOccupiesVoxel(BlockBelow) && !IsBlockLiquid(BlockBelow))
+ {
+ return;
+ }
+
+ a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_WATER, 0);
+ // This is called later than the real destroying of this ice block
}
-
- a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_WATER, 0);
- // This is called later than the real destroying of this ice block
}
-} ;
-
-
-
-
+} ; \ No newline at end of file
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index c4fd378fb..e71f30a66 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -109,18 +109,32 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
Damage += m_World->GetTickRandomNumber(Damage / 2 + 2);
}
- LOGD("Arrow hit an entity");
int PowerLevel = m_Creator->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchPower);
if (PowerLevel > 0)
{
- LOGD("Arrow hit an entity 2");
int ExtraDamage = 0.25 * (PowerLevel + 1);
Damage += ceil(ExtraDamage);
}
- a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1);
+
+ int KnockbackAmount = 1;
+ int PunchLevel = m_Creator->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchPunch);
+ if (PunchLevel > 0)
+ {
+ Vector3f LookVector = m_Creator->GetLookVector();
+ Vector3f FinalSpeed = Vector3f(0, 0, 0);
+ switch (PunchLevel)
+ {
+ case 1: FinalSpeed = LookVector * Vector3d(5, 0.3, 5);
+ case 2: FinalSpeed = LookVector * Vector3d(8, 0.3, 8);
+ default: break;
+ }
+ a_EntityHit.SetSpeed(FinalSpeed);
+ }
+
+ a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, KnockbackAmount);
- if (m_TicksLeftBurning > 0)
+ if ((m_TicksLeftBurning > 0 && !a_EntityHit.IsSubmerged() && !a_EntityHit.IsSwimming()))
{
a_EntityHit.StartBurning(100);
}
diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h
index 2ea6e9fde..553bcb6e7 100644
--- a/src/Entities/ArrowEntity.h
+++ b/src/Entities/ArrowEntity.h
@@ -91,6 +91,7 @@ protected:
/// If true, the arrow is in the process of being collected - don't go to anyone else
bool m_bIsCollected;
+ // Stores the creator from that arrow
cEntity * m_Creator;
/// Stores the block position that arrow is lodged into, sets m_IsInGround to false if it becomes air
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 398f7703b..05bad3a78 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -316,7 +316,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
// IsOnGround() only is false if the player is moving downwards
// TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain)
-
+ // Thanks to daniel0916
cEnchantments Enchantments = Player->GetEquippedItem().m_Enchantments;
int SharpnessLevel = Enchantments.GetLevel(cEnchantments::enchSharpness);
@@ -372,8 +372,27 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
{
BurnTicks += 4 * (FireAspectLevel - 1);
}
+ if (!IsMob() && !IsSubmerged() && !IsSwimming())
+ {
+ StartBurning(BurnTicks * 20);
+ }
+ else if (IsMob() && !IsSubmerged() && !IsSwimming())
+ {
+ cMonster * Monster = (cMonster *)this;
+ switch (Monster->GetMobType())
+ {
+ case cMonster::mtGhast:
+ case cMonster::mtZombiePigman:
+ case cMonster::mtMagmaCube:
+ {
+
+ break;
+ };
+ default:StartBurning(BurnTicks * 20);
+ }
+ }
- StartBurning(BurnTicks * 20);
+
}
if (!Player->IsOnGround())
@@ -410,7 +429,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
case 2: AdditionalSpeed.Set(8, 0.3, 8); break;
default: break;
}
- AddSpeed(a_TDI.Knockback + AdditionalSpeed);
+ SetSpeed(a_TDI.Knockback + AdditionalSpeed);
}
m_World->BroadcastEntityStatus(*this, esGenericHurt);
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index ab4ff3161..c1031907d 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -17,6 +17,7 @@
#include "../Chunk.h"
#include "../Items/ItemHandler.h"
#include "../Vector3.h"
+#include "../FastRandom.h"
#include "../WorldStorage/StatSerializer.h"
#include "../CompositeChat.h"
@@ -1962,7 +1963,26 @@ void cPlayer::UseEquippedItem(int a_Amount)
{
return;
}
+ cItem Item = GetEquippedItem();
+ int UnbreakingLevel = Item.m_Enchantments.GetLevel(cEnchantments::enchUnbreaking);
+ if (UnbreakingLevel > 0)
+ {
+ int chance;
+ if (ItemCategory::IsArmor(Item.m_ItemType))
+ {
+ chance = 60 + (40 / (UnbreakingLevel + 1));
+ }
+ else
+ {
+ chance = 100 / (UnbreakingLevel + 1);
+ }
+ cFastRandom Random;
+ if (Random.NextInt(100) <= chance)
+ {
+ return;
+ }
+ }
if (GetInventory().DamageEquippedItem(a_Amount))
{
m_World->BroadcastSoundEffect("random.break", GetPosX(), GetPosY(), GetPosZ(), 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));