1
0
- Changed m_TicksLeftBurning > 0 for IsOnFire()
- Tried to do the changes in BlockHandler.cpp
- Removed m_Creator in ArrowEntity
- Added m_Enchantments in ProjectileEntity CreatorData
- Added blank lines between functions
This commit is contained in:
Jaume Aloy 2014-08-19 17:57:32 +02:00
parent 07350de514
commit 596203e692
6 changed files with 51 additions and 50 deletions

View File

@ -427,10 +427,14 @@ void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterfac
// Thanks to daniel0916
cPlayer * Player = (cPlayer *)a_Digger;
cEnchantments Enchantments = Player->GetInventory().GetEquippedItem().m_Enchantments;
if (a_CanDrop)
{
if (!a_DropVerbatim)
{
if (Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0)
{
BLOCKTYPE Type = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ);
switch (Type)
switch (m_BlockType)
{
case E_BLOCK_CAKE:
case E_BLOCK_CARROTS:
@ -451,18 +455,16 @@ void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterfac
{
// Silktouch can't be used for this blocks
ConvertToPickups(Pickups, Meta);
break;
};
default: 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
@ -470,8 +472,6 @@ 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);

View File

@ -18,7 +18,6 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a
m_HitGroundTimer(0),
m_HasTeleported(false),
m_bIsCollected(false),
m_Creator(a_Creator),
m_HitBlockPos(Vector3i(0, 0, 0))
{
SetSpeed(a_Speed);
@ -44,7 +43,6 @@ cArrowEntity::cArrowEntity(cPlayer & a_Player, double a_Force) :
m_HitGroundTimer(0),
m_HasTeleported(false),
m_bIsCollected(false),
m_Creator(&a_Player),
m_HitBlockPos(0, 0, 0)
{
if (a_Player.IsGameModeCreative())
@ -70,6 +68,9 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const
}
void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
{
if (GetSpeed().EqualsEps(Vector3d(0, 0, 0), 0.0000001))
@ -90,7 +91,7 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa
// Broadcast arrow hit sound
m_World->BroadcastSoundEffect("random.bowhit", (double)X, (double)Y, (double)Z, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
if ((m_World->GetBlock(Hit) == E_BLOCK_TNT) && (m_TicksLeftBurning > 0))
if ((m_World->GetBlock(Hit) == E_BLOCK_TNT) && (IsOnFire()))
{
m_World->SetBlock(X, Y, Z, E_BLOCK_AIR, 0);
m_World->SpawnPrimedTNT(X, Y, Z);
@ -110,7 +111,7 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
Damage += m_World->GetTickRandomNumber(Damage / 2 + 2);
}
int PowerLevel = m_Creator->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchPower);
int PowerLevel = m_CreatorData.m_Enchantments.GetLevel(cEnchantments::enchPower);
if (PowerLevel > 0)
{
int ExtraDamage = 0.25 * (PowerLevel + 1);
@ -118,10 +119,10 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
}
int KnockbackAmount = 1;
int PunchLevel = m_Creator->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchPunch);
int PunchLevel = m_CreatorData.m_Enchantments.GetLevel(cEnchantments::enchPunch);
if (PunchLevel > 0)
{
Vector3f LookVector = m_Creator->GetLookVector();
Vector3f LookVector = Vector3d(0, 0, 0);
Vector3f FinalSpeed = Vector3f(0, 0, 0);
switch (PunchLevel)
{
@ -134,7 +135,7 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, KnockbackAmount);
if ((m_TicksLeftBurning > 0 && !a_EntityHit.IsSubmerged() && !a_EntityHit.IsSwimming()))
if ((IsOnFire() && !a_EntityHit.IsSubmerged() && !a_EntityHit.IsSwimming()))
{
a_EntityHit.StartBurning(100);
}

View File

@ -91,9 +91,6 @@ 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
Vector3i m_HitBlockPos;

View File

@ -222,7 +222,8 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a
m_ProjectileKind(a_Kind),
m_CreatorData(
((a_Creator != NULL) ? a_Creator->GetUniqueID() : -1),
((a_Creator != NULL) ? (a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "") : "")
((a_Creator != NULL) ? (a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "") : ""),
((a_Creator != NULL) ? a_Creator->GetEquippedWeapon().m_Enchantments : cEnchantments())
),
m_IsInGround(false)
{
@ -235,7 +236,7 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a
cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height) :
super(etProjectile, a_Pos.x, a_Pos.y, a_Pos.z, a_Width, a_Height),
m_ProjectileKind(a_Kind),
m_CreatorData(a_Creator->GetUniqueID(), a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : ""),
m_CreatorData(a_Creator->GetUniqueID(), a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "", a_Creator->GetEquippedWeapon().m_Enchantments),
m_IsInGround(false)
{
SetSpeed(a_Speed);

View File

@ -94,14 +94,16 @@ protected:
*/
struct CreatorData
{
CreatorData(int a_UniqueID, const AString & a_Name) :
CreatorData(int a_UniqueID, const AString & a_Name, cEnchantments a_Enchantments) :
m_UniqueID(a_UniqueID),
m_Name(a_Name)
m_Name(a_Name),
m_Enchantments(a_Enchantments)
{
}
const int m_UniqueID;
AString m_Name;
cEnchantments m_Enchantments;
};
/** The type of projectile I am */

View File

@ -84,7 +84,7 @@ public:
}
else
{
Arrow->SetPickupState(cArrowEntity::ePickupState::psNoPickup);
Arrow->SetPickupState(cArrowEntity::psNoPickup);
}