Ender Crytal Fix and report proper cmake file for luabindingscheck fail (#5017)
* fixed network fixed explosion fixed ticking added network broadcast to Setter method added nullptr protection using macros in 1.10 Protocol_1_10.cpp revealed functions to LUA API small fixups, typos, less functions used fixed more doc readded info that saving is done only if the beam is displayed made the constructor transfer all needed members fixed wrong commit removed default parameters on SpawnEnderCrystal fixed wrong metadata moved call to destroy in the right place fixed some typos Fixed Ender Crystal * fixed documentation * fixed doc and added proper error message * Parameters, arrows * Parameters Co-authored-by: 12xx12 <12xx12100@gmail.com> Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
This commit is contained in:
parent
645fea4237
commit
36a67df105
@ -46,6 +46,7 @@ function(enable_bindings_generation)
|
||||
Entities/ArrowEntity.h
|
||||
Entities/Entity.h
|
||||
Entities/ExpOrb.h
|
||||
Entities/EnderCrystal.h
|
||||
Entities/EntityEffect.h
|
||||
Entities/ExpBottleEntity.h
|
||||
Entities/FallingBlock.h
|
||||
|
@ -9539,6 +9539,79 @@ a_Player:OpenWindow(Window);
|
||||
},
|
||||
Inherits = "cEntity",
|
||||
},
|
||||
cEnderCrystal =
|
||||
{
|
||||
Desc = [[
|
||||
This class represents an ender crystal. This entity can be spawned by using {{cWorld#SpawnEnderCrystal_1|cWorld:SpawnEnderCrystal}}.
|
||||
]],
|
||||
Functions =
|
||||
{
|
||||
DisplaysBeam =
|
||||
{
|
||||
Returns =
|
||||
{
|
||||
{
|
||||
Type = "boolean",
|
||||
},
|
||||
Notes = "Returns true if the ender crystal displays its beam.",
|
||||
},
|
||||
},
|
||||
GetBeamTarget =
|
||||
{
|
||||
Returns =
|
||||
{
|
||||
{
|
||||
Type = "Vector3i",
|
||||
},
|
||||
},
|
||||
Notes = "Returns the Block position the beam is pointing to.",
|
||||
},
|
||||
SetBeamTarget =
|
||||
{
|
||||
Params =
|
||||
{
|
||||
{
|
||||
Name = "BeamTarget",
|
||||
Type = "Vector3i",
|
||||
},
|
||||
},
|
||||
Notes = "Sets the target of the beam of this ender crystal.",
|
||||
},
|
||||
SetDisplayBeam =
|
||||
{
|
||||
Params =
|
||||
{
|
||||
{
|
||||
Name = "DisplaysBeam",
|
||||
Type = "boolean",
|
||||
},
|
||||
Notes = "Sets if the ender crystal should display its beam.",
|
||||
},
|
||||
},
|
||||
SetShowBottom =
|
||||
{
|
||||
Params =
|
||||
{
|
||||
{
|
||||
Name = "ShowsBottom",
|
||||
Type = "boolean",
|
||||
},
|
||||
Notes = "Sets if the ender crystal should broadcast its bedrock base.",
|
||||
},
|
||||
},
|
||||
ShowsBottom =
|
||||
{
|
||||
Returns =
|
||||
{
|
||||
{
|
||||
Type = "boolean",
|
||||
},
|
||||
Notes = "Returns true if the bedrock base is displayed.",
|
||||
},
|
||||
},
|
||||
},
|
||||
Inherits = "cEntity",
|
||||
},
|
||||
cExpOrb =
|
||||
{
|
||||
Desc = [[
|
||||
|
@ -3317,7 +3317,7 @@ function OnAllChunksAvailable()</pre> All return values from the callbacks are i
|
||||
{
|
||||
Name = "ShowBottom",
|
||||
Type = "boolean",
|
||||
}
|
||||
},
|
||||
},
|
||||
Returns =
|
||||
{
|
||||
|
@ -74,6 +74,8 @@ $cfile "../UUID.h"
|
||||
|
||||
// Entities:
|
||||
$cfile "../Entities/Entity.h"
|
||||
|
||||
$cfile "../Entities/EnderCrystal.h"
|
||||
$cfile "../Entities/Boat.h"
|
||||
$cfile "../Entities/Pawn.h"
|
||||
$cfile "../Entities/ProjectileEntity.h"
|
||||
|
@ -99,7 +99,7 @@ local cmakeFiles = getCMakeListsFiles()
|
||||
local numMissingFiles = 0
|
||||
for _, fnam in ipairs(pkgFiles) do
|
||||
if not(cmakeFiles[fnam]) then
|
||||
io.stderr:write("Bindings dependency file ", fnam, " is not listed in src/Bindings/CMakeLists.txt\n")
|
||||
io.stderr:write("Bindings dependency file ", fnam, " is not listed in CMake/GenerateBindings.cmake\n")
|
||||
numMissingFiles = numMissingFiles + 1
|
||||
end
|
||||
end
|
||||
|
@ -11,7 +11,18 @@
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
||||
bool ShowsBottom() const { return m_ShowBottom; }
|
||||
void SetShowBottom(bool a_ShowBottom);
|
||||
|
||||
// tolua_end
|
||||
|
||||
private:
|
||||
|
||||
// If the bedrock base should be displayed
|
||||
bool m_ShowBottom;
|
||||
|
||||
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;
|
||||
|
@ -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
|
||||
|
@ -543,14 +543,14 @@ void cProtocol_1_10_0::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity &
|
||||
case cEntity::etEnderCrystal:
|
||||
{
|
||||
const auto & EnderCrystal = static_cast<const cEnderCrystal &>(a_Entity);
|
||||
a_Pkt.WriteBEUInt8(7);
|
||||
a_Pkt.WriteBEUInt8(ENDER_CRYSTAL_BEAM_TARGET);
|
||||
a_Pkt.WriteBEUInt8(METADATA_TYPE_OPTIONAL_POSITION);
|
||||
a_Pkt.WriteBool(EnderCrystal.DisplaysBeam());
|
||||
if (EnderCrystal.DisplaysBeam())
|
||||
{
|
||||
a_Pkt.WriteXYZPosition64(EnderCrystal.GetBeamTarget());
|
||||
}
|
||||
a_Pkt.WriteBEUInt8(8);
|
||||
a_Pkt.WriteBEUInt8(ENDER_CRYSTAL_SHOW_BOTTOM);
|
||||
a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL);
|
||||
a_Pkt.WriteBool(EnderCrystal.ShowsBottom());
|
||||
break;
|
||||
|
@ -809,14 +809,14 @@ void cProtocol_1_11_0::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity &
|
||||
case cEntity::etEnderCrystal:
|
||||
{
|
||||
const auto & EnderCrystal = static_cast<const cEnderCrystal &>(a_Entity);
|
||||
a_Pkt.WriteBEUInt8(7);
|
||||
a_Pkt.WriteBEUInt8(METADATA_TYPE_OPTIONAL_POSITION);
|
||||
a_Pkt.WriteBool(EnderCrystal.DisplaysBeam());
|
||||
if (EnderCrystal.DisplaysBeam())
|
||||
{
|
||||
a_Pkt.WriteBEUInt8(ENDER_CRYSTAL_BEAM_TARGET);
|
||||
a_Pkt.WriteBEUInt8(METADATA_TYPE_OPTIONAL_POSITION);
|
||||
a_Pkt.WriteBool(true); // Dont do a second check if it should display the beam
|
||||
a_Pkt.WriteXYZPosition64(EnderCrystal.GetBeamTarget());
|
||||
}
|
||||
a_Pkt.WriteBEUInt8(8);
|
||||
a_Pkt.WriteBEUInt8(ENDER_CRYSTAL_SHOW_BOTTOM);
|
||||
a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL);
|
||||
a_Pkt.WriteBool(EnderCrystal.ShowsBottom());
|
||||
break;
|
||||
|
@ -522,14 +522,14 @@ void cProtocol_1_12::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_
|
||||
case cEntity::etEnderCrystal:
|
||||
{
|
||||
const auto & EnderCrystal = static_cast<const cEnderCrystal &>(a_Entity);
|
||||
a_Pkt.WriteBEUInt8(7);
|
||||
a_Pkt.WriteBEUInt8(METADATA_TYPE_OPTIONAL_POSITION);
|
||||
a_Pkt.WriteBool(EnderCrystal.DisplaysBeam());
|
||||
if (EnderCrystal.DisplaysBeam())
|
||||
{
|
||||
a_Pkt.WriteBEUInt8(ENDER_CRYSTAL_BEAM_TARGET);
|
||||
a_Pkt.WriteBEUInt8(METADATA_TYPE_OPTIONAL_POSITION);
|
||||
a_Pkt.WriteBool(true); // Dont do a second check if it should display the beam
|
||||
a_Pkt.WriteXYZPosition64(EnderCrystal.GetBeamTarget());
|
||||
}
|
||||
a_Pkt.WriteBEUInt8(8);
|
||||
a_Pkt.WriteBEUInt8(ENDER_CRYSTAL_SHOW_BOTTOM);
|
||||
a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL);
|
||||
a_Pkt.WriteBool(EnderCrystal.ShowsBottom());
|
||||
break;
|
||||
|
@ -891,10 +891,10 @@ void cProtocol_1_13::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_
|
||||
case cEntity::etEnderCrystal:
|
||||
{
|
||||
const auto & EnderCrystal = static_cast<const cEnderCrystal &>(a_Entity);
|
||||
WriteEntityMetadata(a_Pkt, EntityMetadata::EnderCrystalBeamTarget, EntityMetadataType::OptPosition);
|
||||
a_Pkt.WriteBool(EnderCrystal.DisplaysBeam());
|
||||
if (EnderCrystal.DisplaysBeam())
|
||||
{
|
||||
WriteEntityMetadata(a_Pkt, EntityMetadata::EnderCrystalBeamTarget, EntityMetadataType::OptPosition);
|
||||
a_Pkt.WriteBool(true); // Dont do a second check if it should display the beam
|
||||
a_Pkt.WriteXYZPosition64(EnderCrystal.GetBeamTarget());
|
||||
}
|
||||
WriteEntityMetadata(a_Pkt, EntityMetadata::EnderCrystalShowBottom, EntityMetadataType::Boolean);
|
||||
|
@ -1731,14 +1731,14 @@ void cProtocol_1_9_0::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a
|
||||
case cEntity::etEnderCrystal:
|
||||
{
|
||||
const auto & EnderCrystal = static_cast<const cEnderCrystal &>(a_Entity);
|
||||
a_Pkt.WriteBEUInt8(7);
|
||||
a_Pkt.WriteBEUInt8(5);
|
||||
a_Pkt.WriteBEUInt8(METADATA_TYPE_OPTIONAL_POSITION);
|
||||
a_Pkt.WriteBool(EnderCrystal.DisplaysBeam());
|
||||
if (EnderCrystal.DisplaysBeam())
|
||||
{
|
||||
a_Pkt.WriteXYZPosition64(EnderCrystal.GetBeamTarget());
|
||||
}
|
||||
a_Pkt.WriteBEUInt8(8);
|
||||
a_Pkt.WriteBEUInt8(6);
|
||||
a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL);
|
||||
a_Pkt.WriteBool(EnderCrystal.ShowsBottom());
|
||||
break;
|
||||
|
@ -654,7 +654,7 @@ public:
|
||||
|
||||
/** Spawns a new ender crystal at the specified block coords.
|
||||
Returns the UniqueID of the created entity, or cEntity::INVALID_ID on failure. */
|
||||
UInt32 SpawnEnderCrystal(Vector3d a_Pos, bool a_ShowBottom = false);
|
||||
UInt32 SpawnEnderCrystal(Vector3d a_Pos, bool a_ShowBottom);
|
||||
|
||||
// tolua_end
|
||||
|
||||
|
@ -1718,19 +1718,14 @@ void cWSSAnvil::LoadBoatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N
|
||||
|
||||
void cWSSAnvil::LoadEnderCrystalFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
|
||||
{
|
||||
auto EnderCrystal = std::make_unique<cEnderCrystal>(Vector3d(), false);
|
||||
if (!LoadEntityBaseFromNBT(*EnderCrystal.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool DisplayBeam = false, ShowBottom = false;
|
||||
Vector3i BeamTarget;
|
||||
int CurrentLine = a_NBT.FindChildByName(a_TagIdx, "BeamTarget");
|
||||
if (CurrentLine > 0)
|
||||
{
|
||||
EnderCrystal->SetDisplayBeam(true);
|
||||
DisplayBeam = true;
|
||||
if (a_NBT.GetType(CurrentLine) == TAG_Compound)
|
||||
{
|
||||
Vector3d BeamTarget = {0, 0, 0};
|
||||
int CoordinateLine = a_NBT.FindChildByName(CurrentLine, "X");
|
||||
if (CoordinateLine > 0)
|
||||
{
|
||||
@ -1751,7 +1746,13 @@ void cWSSAnvil::LoadEnderCrystalFromNBT(cEntityList & a_Entities, const cParsedN
|
||||
CurrentLine = a_NBT.FindChildByName(a_TagIdx, "ShowBottom");
|
||||
if (CurrentLine > 0)
|
||||
{
|
||||
EnderCrystal->SetShowBottom(a_NBT.GetByte(CurrentLine) == 1);
|
||||
ShowBottom = a_NBT.GetByte(CurrentLine) == 1;
|
||||
}
|
||||
|
||||
auto EnderCrystal = std::make_unique<cEnderCrystal>(Vector3d(), BeamTarget, DisplayBeam, ShowBottom);
|
||||
if (!LoadEntityBaseFromNBT(*EnderCrystal.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.emplace_back(std::move(EnderCrystal));
|
||||
|
Loading…
Reference in New Issue
Block a user