Added more enchantments and some fixes
- Removed Debug messages - Added Punch enchantment effect - Added Silk Touch enchantment - Added Unbreaking enchantment effect
This commit is contained in:
parent
d3fd63c9eb
commit
1897f678f9
@ -424,6 +424,28 @@ void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterfac
|
||||
cItems Pickups;
|
||||
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
|
||||
// Thanks to daniel0916
|
||||
cPlayer * Player = (cPlayer *)a_Digger;
|
||||
cEnchantments Enchantments = Player->GetInventory().GetEquippedItem().m_Enchantments;
|
||||
if (Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0)
|
||||
{
|
||||
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
|
||||
{
|
||||
Pickups.Add(m_BlockType, 1, Meta);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (a_CanDrop)
|
||||
{
|
||||
if (!a_DropVerbatim)
|
||||
@ -437,6 +459,8 @@ void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterfac
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Allow plugins to modify the pickups:
|
||||
a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups);
|
||||
|
||||
|
@ -31,6 +31,9 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
cEnchantments Enchantments = a_Player->GetInventory().GetEquippedItem().m_Enchantments;
|
||||
if (Enchantments.GetLevel(cEnchantments::enchSilkTouch) == 0)
|
||||
{
|
||||
BLOCKTYPE BlockBelow = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ);
|
||||
if (!cBlockInfo::FullyOccupiesVoxel(BlockBelow) && !IsBlockLiquid(BlockBelow))
|
||||
{
|
||||
@ -40,8 +43,5 @@ public:
|
||||
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
|
||||
}
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
||||
if (m_TicksLeftBurning > 0)
|
||||
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 && !a_EntityHit.IsSubmerged() && !a_EntityHit.IsSwimming()))
|
||||
{
|
||||
a_EntityHit.StartBurning(100);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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,9 +372,28 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user