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,49 +427,49 @@ void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterfac
// Thanks to daniel0916 // Thanks to daniel0916
cPlayer * Player = (cPlayer *)a_Digger; cPlayer * Player = (cPlayer *)a_Digger;
cEnchantments Enchantments = Player->GetInventory().GetEquippedItem().m_Enchantments; cEnchantments Enchantments = Player->GetInventory().GetEquippedItem().m_Enchantments;
if (Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0)
if (a_CanDrop)
{ {
BLOCKTYPE Type = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ); if (!a_DropVerbatim)
switch (Type)
{ {
case E_BLOCK_CAKE: if (Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0)
case E_BLOCK_CARROTS:
case E_BLOCK_COCOA_POD:
case E_BLOCK_DOUBLE_STONE_SLAB:
case E_BLOCK_DOUBLE_WOODEN_SLAB:
case E_BLOCK_FIRE:
case E_BLOCK_FARMLAND:
case E_BLOCK_MELON_STEM:
case E_BLOCK_MOB_SPAWNER:
case E_BLOCK_NETHER_WART:
case E_BLOCK_POTATOES:
case E_BLOCK_PUMPKIN_STEM:
case E_BLOCK_SNOW:
case E_BLOCK_SUGARCANE:
case E_BLOCK_TALL_GRASS:
case E_BLOCK_CROPS:
{ {
// Silktouch can't be used for this blocks switch (m_BlockType)
ConvertToPickups(Pickups, Meta); {
}; case E_BLOCK_CAKE:
default: Pickups.Add(m_BlockType, 1, Meta); case E_BLOCK_CARROTS:
} case E_BLOCK_COCOA_POD:
} case E_BLOCK_DOUBLE_STONE_SLAB:
else case E_BLOCK_DOUBLE_WOODEN_SLAB:
{ case E_BLOCK_FIRE:
if (a_CanDrop) case E_BLOCK_FARMLAND:
{ case E_BLOCK_MELON_STEM:
if (!a_DropVerbatim) case E_BLOCK_MOB_SPAWNER:
{ case E_BLOCK_NETHER_WART:
ConvertToPickups(Pickups, Meta); case E_BLOCK_POTATOES:
case E_BLOCK_PUMPKIN_STEM:
case E_BLOCK_SNOW:
case E_BLOCK_SUGARCANE:
case E_BLOCK_TALL_GRASS:
case E_BLOCK_CROPS:
{
// Silktouch can't be used for this blocks
ConvertToPickups(Pickups, Meta);
break;
};
default: Pickups.Add(m_BlockType, 1, Meta);
}
} }
else else
{ {
// TODO: Add a proper overridable function for this ConvertToPickups(Pickups, Meta);
Pickups.Add(m_BlockType, 1, Meta);
} }
} }
else
{
// TODO: Add a proper overridable function for this
Pickups.Add(m_BlockType, 1, Meta);
}
} }
// Allow plugins to modify the pickups: // Allow plugins to modify the pickups:

View File

@ -18,7 +18,6 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a
m_HitGroundTimer(0), m_HitGroundTimer(0),
m_HasTeleported(false), m_HasTeleported(false),
m_bIsCollected(false), m_bIsCollected(false),
m_Creator(a_Creator),
m_HitBlockPos(Vector3i(0, 0, 0)) m_HitBlockPos(Vector3i(0, 0, 0))
{ {
SetSpeed(a_Speed); SetSpeed(a_Speed);
@ -44,7 +43,6 @@ cArrowEntity::cArrowEntity(cPlayer & a_Player, double a_Force) :
m_HitGroundTimer(0), m_HitGroundTimer(0),
m_HasTeleported(false), m_HasTeleported(false),
m_bIsCollected(false), m_bIsCollected(false),
m_Creator(&a_Player),
m_HitBlockPos(0, 0, 0) m_HitBlockPos(0, 0, 0)
{ {
if (a_Player.IsGameModeCreative()) 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) void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
{ {
if (GetSpeed().EqualsEps(Vector3d(0, 0, 0), 0.0000001)) 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 // 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)); 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->SetBlock(X, Y, Z, E_BLOCK_AIR, 0);
m_World->SpawnPrimedTNT(X, Y, Z); 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); 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) if (PowerLevel > 0)
{ {
int ExtraDamage = 0.25 * (PowerLevel + 1); int ExtraDamage = 0.25 * (PowerLevel + 1);
@ -118,10 +119,10 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
} }
int KnockbackAmount = 1; 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) if (PunchLevel > 0)
{ {
Vector3f LookVector = m_Creator->GetLookVector(); Vector3f LookVector = Vector3d(0, 0, 0);
Vector3f FinalSpeed = Vector3f(0, 0, 0); Vector3f FinalSpeed = Vector3f(0, 0, 0);
switch (PunchLevel) switch (PunchLevel)
{ {
@ -134,7 +135,7 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, KnockbackAmount); 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); 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 /// If true, the arrow is in the process of being collected - don't go to anyone else
bool m_bIsCollected; 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 /// Stores the block position that arrow is lodged into, sets m_IsInGround to false if it becomes air
Vector3i m_HitBlockPos; Vector3i m_HitBlockPos;

View File

@ -222,7 +222,8 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a
m_ProjectileKind(a_Kind), m_ProjectileKind(a_Kind),
m_CreatorData( m_CreatorData(
((a_Creator != NULL) ? a_Creator->GetUniqueID() : -1), ((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) 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) : 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), super(etProjectile, a_Pos.x, a_Pos.y, a_Pos.z, a_Width, a_Height),
m_ProjectileKind(a_Kind), 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) m_IsInGround(false)
{ {
SetSpeed(a_Speed); SetSpeed(a_Speed);

View File

@ -94,14 +94,16 @@ protected:
*/ */
struct CreatorData 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_UniqueID(a_UniqueID),
m_Name(a_Name) m_Name(a_Name),
m_Enchantments(a_Enchantments)
{ {
} }
const int m_UniqueID; const int m_UniqueID;
AString m_Name; AString m_Name;
cEnchantments m_Enchantments;
}; };
/** The type of projectile I am */ /** The type of projectile I am */

View File

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