Bundled fixes [SEE DESC]
* BoundingBox now returns FACE_NONE + Arrows can be picked up * Arrows dug up resume physics simulations * Added sound effects for bows, lava to stone, and arrows * Fixed SoundParticleEffect on <1.7 protocols
This commit is contained in:
parent
f713780db3
commit
347162a82f
@ -243,11 +243,11 @@ bool cBoundingBox::CalcLineIntersection(const Vector3d & a_Min, const Vector3d &
|
|||||||
{
|
{
|
||||||
// The starting point is inside the bounding box.
|
// The starting point is inside the bounding box.
|
||||||
a_LineCoeff = 0;
|
a_LineCoeff = 0;
|
||||||
a_Face = BLOCK_FACE_YM; // Make it look as the top face was hit, although none really are.
|
a_Face = BLOCK_FACE_NONE; // No faces hit
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
char Face = 0;
|
char Face = BLOCK_FACE_NONE;
|
||||||
double Coeff = Vector3d::NO_INTERSECTION;
|
double Coeff = Vector3d::NO_INTERSECTION;
|
||||||
|
|
||||||
// Check each individual bbox face for intersection with the line, remember the one with the lowest coeff
|
// Check each individual bbox face for intersection with the line, remember the one with the lowest coeff
|
||||||
|
@ -1679,9 +1679,9 @@ void cChunk::CollectPickupsByPlayer(cPlayer * a_Player)
|
|||||||
|
|
||||||
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
|
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
|
||||||
{
|
{
|
||||||
if (!(*itr)->IsPickup())
|
if ((!(*itr)->IsPickup()) && (!(*itr)->IsProjectile()))
|
||||||
{
|
{
|
||||||
continue; // Only pickups
|
continue; // Only pickups and projectiles
|
||||||
}
|
}
|
||||||
float DiffX = (float)((*itr)->GetPosX() - PosX );
|
float DiffX = (float)((*itr)->GetPosX() - PosX );
|
||||||
float DiffY = (float)((*itr)->GetPosY() - PosY );
|
float DiffY = (float)((*itr)->GetPosY() - PosY );
|
||||||
@ -1695,7 +1695,14 @@ void cChunk::CollectPickupsByPlayer(cPlayer * a_Player)
|
|||||||
);
|
);
|
||||||
*/
|
*/
|
||||||
MarkDirty();
|
MarkDirty();
|
||||||
(reinterpret_cast<cPickup *>(*itr))->CollectedBy( a_Player );
|
if ((*itr)->IsPickup())
|
||||||
|
{
|
||||||
|
(reinterpret_cast<cPickup *>(*itr))->CollectedBy(a_Player);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
(reinterpret_cast<cProjectileEntity *>(*itr))->CollectedBy(a_Player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (SqrDist < 5 * 5)
|
else if (SqrDist < 5 * 5)
|
||||||
{
|
{
|
||||||
|
@ -371,6 +371,16 @@ void cProjectileEntity::SpawnOn(cClientHandle & a_Client)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cProjectileEntity::CollectedBy(cPlayer * a_Dest)
|
||||||
|
{
|
||||||
|
// Overriden in arrow
|
||||||
|
UNUSED(a_Dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// cArrowEntity:
|
// cArrowEntity:
|
||||||
|
|
||||||
@ -378,7 +388,10 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a
|
|||||||
super(pkArrow, a_Creator, a_X, a_Y, a_Z, 0.5, 0.5),
|
super(pkArrow, a_Creator, a_X, a_Y, a_Z, 0.5, 0.5),
|
||||||
m_PickupState(psNoPickup),
|
m_PickupState(psNoPickup),
|
||||||
m_DamageCoeff(2),
|
m_DamageCoeff(2),
|
||||||
m_IsCritical(false)
|
m_IsCritical(false),
|
||||||
|
m_Timer(0),
|
||||||
|
m_bIsCollected(false),
|
||||||
|
m_HitBlockPos(Vector3i(0, 0, 0))
|
||||||
{
|
{
|
||||||
SetSpeed(a_Speed);
|
SetSpeed(a_Speed);
|
||||||
SetMass(0.1);
|
SetMass(0.1);
|
||||||
@ -398,7 +411,10 @@ cArrowEntity::cArrowEntity(cPlayer & a_Player, double a_Force) :
|
|||||||
super(pkArrow, &a_Player, a_Player.GetThrowStartPos(), a_Player.GetThrowSpeed(a_Force * 1.5 * 20), 0.5, 0.5),
|
super(pkArrow, &a_Player, a_Player.GetThrowStartPos(), a_Player.GetThrowSpeed(a_Force * 1.5 * 20), 0.5, 0.5),
|
||||||
m_PickupState(psInSurvivalOrCreative),
|
m_PickupState(psInSurvivalOrCreative),
|
||||||
m_DamageCoeff(2),
|
m_DamageCoeff(2),
|
||||||
m_IsCritical((a_Force >= 1))
|
m_IsCritical((a_Force >= 1)),
|
||||||
|
m_Timer(0),
|
||||||
|
m_bIsCollected(false),
|
||||||
|
m_HitBlockPos(0, 0, 0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,7 +440,28 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const
|
|||||||
|
|
||||||
void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace)
|
void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace)
|
||||||
{
|
{
|
||||||
|
if (a_HitFace == BLOCK_FACE_NONE)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
super::OnHitSolidBlock(a_HitPos, a_HitFace);
|
super::OnHitSolidBlock(a_HitPos, a_HitFace);
|
||||||
|
int a_X = (int)a_HitPos.x, a_Y = (int)a_HitPos.y, a_Z = (int)a_HitPos.z;
|
||||||
|
|
||||||
|
if (a_HitFace != BLOCK_FACE_YP)
|
||||||
|
{
|
||||||
|
AddFaceDirection(a_X, a_Y, a_Z, a_HitFace);
|
||||||
|
}
|
||||||
|
else if (a_HitFace == BLOCK_FACE_YP) // These conditions because xoft got a little confused on block face directions, so AddFace works with all but YP & YM
|
||||||
|
{
|
||||||
|
a_Y--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
a_Y++;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_HitBlockPos = Vector3i(a_X, a_Y, a_Z);
|
||||||
|
|
||||||
// Broadcast arrow hit sound
|
// Broadcast arrow hit sound
|
||||||
m_World->BroadcastSoundEffect("random.bowhit", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
|
m_World->BroadcastSoundEffect("random.bowhit", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
|
||||||
@ -442,7 +479,7 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace)
|
|||||||
|
|
||||||
void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
|
void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
|
||||||
{
|
{
|
||||||
if (!a_EntityHit.IsMob() && !a_EntityHit.IsMinecart() && !a_EntityHit.IsPlayer())
|
if (!a_EntityHit.IsMob() && !a_EntityHit.IsMinecart() && !a_EntityHit.IsPlayer() && !a_EntityHit.IsBoat())
|
||||||
{
|
{
|
||||||
// Not an entity that interacts with an arrow
|
// Not an entity that interacts with an arrow
|
||||||
return;
|
return;
|
||||||
@ -455,6 +492,9 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
|
|||||||
}
|
}
|
||||||
a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1);
|
a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1);
|
||||||
|
|
||||||
|
// Broadcast successful hit sound
|
||||||
|
m_World->BroadcastSoundEffect("random.successful_hit", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
|
||||||
|
|
||||||
Destroy();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,6 +502,67 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cArrowEntity::CollectedBy(cPlayer * a_Dest)
|
||||||
|
{
|
||||||
|
if ((m_IsInGround) && (!m_bIsCollected) && (CanPickup(*a_Dest)))
|
||||||
|
{
|
||||||
|
int NumAdded = a_Dest->GetInventory().AddItem(E_ITEM_ARROW);
|
||||||
|
if (NumAdded > 0) // Only play effects if there was space in inventory
|
||||||
|
{
|
||||||
|
m_World->BroadcastCollectPickup((const cPickup &)*this, *a_Dest);
|
||||||
|
// Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;)
|
||||||
|
m_World->BroadcastSoundEffect("random.pop", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
|
||||||
|
m_bIsCollected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
||||||
|
{
|
||||||
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
m_Timer += a_Dt;
|
||||||
|
|
||||||
|
if (m_bIsCollected)
|
||||||
|
{
|
||||||
|
if (m_Timer > 500.f) // 0.5 seconds
|
||||||
|
{
|
||||||
|
Destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (m_Timer > 1000 * 60 * 5) // 5 minutes
|
||||||
|
{
|
||||||
|
Destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_IsInGround)
|
||||||
|
{
|
||||||
|
int RelPosX = m_HitBlockPos.x - a_Chunk.GetPosX() * cChunkDef::Width;
|
||||||
|
int RelPosZ = m_HitBlockPos.z - a_Chunk.GetPosZ() * cChunkDef::Width;
|
||||||
|
cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(RelPosX, RelPosZ);
|
||||||
|
|
||||||
|
if (Chunk == NULL)
|
||||||
|
{
|
||||||
|
// Inside an unloaded chunk, abort
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Chunk->GetBlock(RelPosX, m_HitBlockPos.y, RelPosZ) == E_BLOCK_AIR) // Block attached to was destroyed?
|
||||||
|
{
|
||||||
|
m_IsInGround = false; // Yes, begin simulating physics again
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// cThrownEggEntity:
|
// cThrownEggEntity:
|
||||||
|
|
||||||
|
@ -53,6 +53,9 @@ public:
|
|||||||
/// Called by the physics blocktracer when the entity hits another entity
|
/// Called by the physics blocktracer when the entity hits another entity
|
||||||
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) {}
|
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) {}
|
||||||
|
|
||||||
|
/// Called by Chunk when the projectile is eligible for player collection
|
||||||
|
virtual void CollectedBy(cPlayer * a_Dest);
|
||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
|
|
||||||
/// Returns the kind of the projectile (fast class identification)
|
/// Returns the kind of the projectile (fast class identification)
|
||||||
@ -153,9 +156,20 @@ protected:
|
|||||||
/// If true, the arrow deals more damage
|
/// If true, the arrow deals more damage
|
||||||
bool m_IsCritical;
|
bool m_IsCritical;
|
||||||
|
|
||||||
|
/// Timer for pickup collection animation or five minute timeout
|
||||||
|
float m_Timer;
|
||||||
|
|
||||||
|
/// If true, the arrow is in the process of being collected - don't go to anyone else
|
||||||
|
bool m_bIsCollected;
|
||||||
|
|
||||||
|
/// Stores the block position that arrow is lodged into, sets m_IsInGround to false if it becomes air
|
||||||
|
Vector3i m_HitBlockPos;
|
||||||
|
|
||||||
// cProjectileEntity overrides:
|
// cProjectileEntity overrides:
|
||||||
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) override;
|
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) override;
|
||||||
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
|
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
|
||||||
|
virtual void CollectedBy(cPlayer * a_Player) override;
|
||||||
|
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
} ;
|
} ;
|
||||||
|
@ -72,7 +72,7 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
a_Player->GetWorld()->BroadcastSpawnEntity(*Arrow);
|
a_Player->GetWorld()->BroadcastSpawnEntity(*Arrow);
|
||||||
a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)a_Player->GetPosX() * 8, (int)a_Player->GetPosY() * 8, (int)a_Player->GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((Arrow->GetUniqueID() * 23) % 32)) / 64));
|
a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)a_Player->GetPosX() * 8, (int)a_Player->GetPosY() * 8, (int)a_Player->GetPosZ() * 8, 0.5, Force);
|
||||||
|
|
||||||
if (!a_Player->IsGameModeCreative())
|
if (!a_Player->IsGameModeCreative())
|
||||||
{
|
{
|
||||||
|
@ -392,9 +392,9 @@ void cProtocol132::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_Src
|
|||||||
cCSLock Lock(m_CSPacket);
|
cCSLock Lock(m_CSPacket);
|
||||||
WriteByte(PACKET_SOUND_PARTICLE_EFFECT);
|
WriteByte(PACKET_SOUND_PARTICLE_EFFECT);
|
||||||
WriteInt (a_EffectID);
|
WriteInt (a_EffectID);
|
||||||
WriteInt (a_SrcX / 8);
|
WriteInt (a_SrcX);
|
||||||
WriteByte(a_SrcY / 8);
|
WriteByte(a_SrcY);
|
||||||
WriteInt (a_SrcZ / 8);
|
WriteInt (a_SrcZ);
|
||||||
WriteInt (a_Data);
|
WriteInt (a_Data);
|
||||||
Flush();
|
Flush();
|
||||||
}
|
}
|
||||||
|
@ -109,9 +109,9 @@ void cProtocol142::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_Src
|
|||||||
cCSLock Lock(m_CSPacket);
|
cCSLock Lock(m_CSPacket);
|
||||||
WriteByte(PACKET_SOUND_PARTICLE_EFFECT);
|
WriteByte(PACKET_SOUND_PARTICLE_EFFECT);
|
||||||
WriteInt (a_EffectID);
|
WriteInt (a_EffectID);
|
||||||
WriteInt (a_SrcX / 8);
|
WriteInt (a_SrcX);
|
||||||
WriteByte(a_SrcY / 8);
|
WriteByte(a_SrcY);
|
||||||
WriteInt (a_SrcZ / 8);
|
WriteInt (a_SrcZ);
|
||||||
WriteInt (a_Data);
|
WriteInt (a_Data);
|
||||||
WriteBool(0);
|
WriteBool(0);
|
||||||
Flush();
|
Flush();
|
||||||
|
@ -820,9 +820,13 @@ void cProtocol172::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_Bloc
|
|||||||
|
|
||||||
void cProtocol172::SendWeather(eWeather a_Weather)
|
void cProtocol172::SendWeather(eWeather a_Weather)
|
||||||
{
|
{
|
||||||
|
{
|
||||||
cPacketizer Pkt(*this, 0x2b); // Change Game State packet
|
cPacketizer Pkt(*this, 0x2b); // Change Game State packet
|
||||||
Pkt.WriteByte((a_Weather == wSunny) ? 2 : 1); // begin rain / end rain
|
Pkt.WriteByte((a_Weather == wSunny) ? 1 : 2); // End rain / begin rain
|
||||||
Pkt.WriteFloat(0); // unused
|
Pkt.WriteFloat(0); // Unused for weather
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Fade effect, somehow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -224,9 +224,7 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
|
|||||||
ItemTypeToString(NewBlock).c_str()
|
ItemTypeToString(NewBlock).c_str()
|
||||||
);
|
);
|
||||||
a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
|
a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
|
||||||
|
m_World.BroadcastSoundEffect("random.fizz", a_RelX * 8, a_RelY * 8, a_RelZ * 8, 0.5f, 1.5f);
|
||||||
// TODO: Sound effect
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,9 +238,7 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
|
|||||||
a_RelX, a_RelY, a_RelZ, ItemTypeToString(NewBlock).c_str()
|
a_RelX, a_RelY, a_RelZ, ItemTypeToString(NewBlock).c_str()
|
||||||
);
|
);
|
||||||
a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
|
a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
|
||||||
|
m_World.BroadcastSoundEffect("random.fizz", a_RelX * 8, a_RelY * 8, a_RelZ * 8, 0.5f, 1.5f);
|
||||||
// TODO: Sound effect
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user