summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
author12xx12 <44411062+12xx12@users.noreply.github.com>2020-11-06 16:00:59 +0100
committerGitHub <noreply@github.com>2020-11-06 16:00:59 +0100
commit36a67df105ab4774d2a250ef3c7d6336cb50566e (patch)
tree2725a48a3c8a8de5f6ef062d9415d019042ba486 /src/Entities
parentPlayers are no longer kicked when clicking on bedrock (#5023) (diff)
downloadcuberite-36a67df105ab4774d2a250ef3c7d6336cb50566e.tar
cuberite-36a67df105ab4774d2a250ef3c7d6336cb50566e.tar.gz
cuberite-36a67df105ab4774d2a250ef3c7d6336cb50566e.tar.bz2
cuberite-36a67df105ab4774d2a250ef3c7d6336cb50566e.tar.lz
cuberite-36a67df105ab4774d2a250ef3c7d6336cb50566e.tar.xz
cuberite-36a67df105ab4774d2a250ef3c7d6336cb50566e.tar.zst
cuberite-36a67df105ab4774d2a250ef3c7d6336cb50566e.zip
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/EnderCrystal.cpp53
-rw-r--r--src/Entities/EnderCrystal.h22
-rw-r--r--src/Entities/ProjectileEntity.cpp3
3 files changed, 62 insertions, 16 deletions
diff --git a/src/Entities/EnderCrystal.cpp b/src/Entities/EnderCrystal.cpp
index 269714b58..4c21a794d 100644
--- a/src/Entities/EnderCrystal.cpp
+++ b/src/Entities/EnderCrystal.cpp
@@ -10,8 +10,19 @@
-cEnderCrystal::cEnderCrystal(Vector3d a_Pos, bool a_ShowBottom):
+cEnderCrystal::cEnderCrystal(Vector3d a_Pos, bool a_ShowBottom) :
+ cEnderCrystal(a_Pos, {}, false, a_ShowBottom)
+{
+}
+
+
+
+
+
+cEnderCrystal::cEnderCrystal(Vector3d a_Pos, Vector3i a_BeamTarget, bool a_DisplayBeam, bool a_ShowBottom) :
Super(etEnderCrystal, a_Pos, 1.0, 1.0),
+ m_BeamTarget(a_BeamTarget),
+ m_DisplayBeam(a_DisplayBeam),
m_ShowBottom(a_ShowBottom)
{
SetMaxHealth(5);
@@ -21,9 +32,40 @@ cEnderCrystal::cEnderCrystal(Vector3d a_Pos, bool a_ShowBottom):
+void cEnderCrystal::SetShowBottom(bool a_ShowBottom)
+{
+ m_ShowBottom = a_ShowBottom;
+ m_World->BroadcastEntityMetadata(*this);
+}
+
+
+
+
+
+void cEnderCrystal::SetBeamTarget(Vector3i a_BeamTarget)
+{
+ m_BeamTarget = a_BeamTarget;
+ m_World->BroadcastEntityMetadata(*this);
+}
+
+
+
+
+
+void cEnderCrystal::SetDisplayBeam(bool a_DisplayBeam)
+{
+ m_DisplayBeam = a_DisplayBeam;
+ m_World->BroadcastEntityMetadata(*this);
+}
+
+
+
+
+
void cEnderCrystal::SpawnOn(cClientHandle & a_ClientHandle)
{
a_ClientHandle.SendSpawnEntity(*this);
+ a_ClientHandle.SendEntityMetadata(*this);
}
@@ -33,10 +75,9 @@ void cEnderCrystal::SpawnOn(cClientHandle & a_ClientHandle)
void cEnderCrystal::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
UNUSED(a_Dt);
- // No further processing (physics e.t.c.) is needed
- if (m_World->GetDimension() == dimEnd)
+ if ((m_World->GetDimension() == dimEnd) && (m_World->GetBlock(POS_TOINT) != E_BLOCK_FIRE))
{
- m_World->SetBlock(POS_TOINT.addedY(1), E_BLOCK_FIRE, 0);
+ m_World->SetBlock(POS_TOINT, E_BLOCK_FIRE, 0);
}
}
@@ -48,11 +89,11 @@ void cEnderCrystal::KilledBy(TakeDamageInfo & a_TDI)
{
Super::KilledBy(a_TDI);
- m_World->DoExplosionAt(6.0, GetPosX(), GetPosY(), GetPosZ(), true, esEnderCrystal, this);
+ m_World->DoExplosionAt(6.0, GetPosX(), GetPosY() + (GetHeight() / 2.0), GetPosZ(), true, esEnderCrystal, this);
Destroy();
- m_World->SetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT, E_BLOCK_FIRE, 0);
+ m_World->SetBlock(POS_TOINT, E_BLOCK_FIRE, 0);
}
diff --git a/src/Entities/EnderCrystal.h b/src/Entities/EnderCrystal.h
index b2a28c517..7e783ffd2 100644
--- a/src/Entities/EnderCrystal.h
+++ b/src/Entities/EnderCrystal.h
@@ -19,26 +19,30 @@ public:
CLASS_PROTODEF(cEnderCrystal)
cEnderCrystal(Vector3d a_Pos, bool a_ShowBottom);
+ cEnderCrystal(Vector3d a_Pos, Vector3i a_BeamTarget, bool a_DisplayBeam, bool a_ShowBottom);
- // Getters and Setters
- bool ShowsBottom() const { return m_ShowBottom; }
- void SetShowBottom(bool a_ShowBottom) { m_ShowBottom = a_ShowBottom; }
+ // tolua_begin
Vector3i GetBeamTarget() const { return m_BeamTarget; }
- void SetBeamTarget(Vector3i a_BeamTarget) { m_BeamTarget = a_BeamTarget; }
+ void SetBeamTarget(Vector3i a_BeamTarget);
- /** If the EnderCrystal should send it's beam to the client and store to disk. */
+ /** If the EnderCrystal should send it's beam to the client and save it. */
bool DisplaysBeam() const { return m_DisplayBeam; }
- void SetDisplayBeam(bool a_DisplayBeam) { m_DisplayBeam = a_DisplayBeam; }
+ void SetDisplayBeam(bool a_DisplayBeam);
-private:
+ bool ShowsBottom() const { return m_ShowBottom; }
+ void SetShowBottom(bool a_ShowBottom);
- // If the bedrock base should be displayed
- bool m_ShowBottom;
+ // tolua_end
+
+private:
Vector3i m_BeamTarget;
bool m_DisplayBeam;
+ // If the bedrock base should be displayed.
+ bool m_ShowBottom;
+
// cEntity overrides:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index 1887e32a6..c72cebaaf 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -167,7 +167,8 @@ public:
!a_Entity.IsPlayer() ||
static_cast<cPlayer &>(a_Entity).IsGameModeSpectator()
) &&
- !a_Entity.IsBoat()
+ !a_Entity.IsBoat() &&
+ !a_Entity.IsEnderCrystal()
)
{
// Not an entity that interacts with a projectile