Botcraft 26.3
Loading...
Searching...
No Matches
PositionSource.cpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
2
7
8#include <stdexcept>
9
10namespace ProtocolCraft
11{
14
15#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
16 std::shared_ptr<PositionSource> PositionSource::CreatePositionSource(const PositionSourceType position_source_type)
17 {
18 switch (position_source_type)
19 {
21 return std::make_shared<BlockPositionSource>();
23 return std::make_shared<EntityPositionSource>();
24 default:
25 throw std::runtime_error("Unable to create position source with type: " + std::to_string(static_cast<int>(position_source_type)));
26 return nullptr;
27 }
28 }
29#else
30 std::shared_ptr<PositionSource> PositionSource::CreatePositionSource(const Identifier& position_source_type)
31 {
32 if (position_source_type.GetName() == "block")
33 {
34 return std::make_shared<BlockPositionSource>();
35 }
36 else if (position_source_type.GetName() == "entity")
37 {
38 return std::make_shared<EntityPositionSource>();
39 }
40 else
41 {
42 throw std::runtime_error("Unable to create position source with type: " + position_source_type.GetFull());
43 return nullptr;
44 }
45 }
46#endif
47}
48#endif
#define DEFINE_NETWORK_TYPE(ClassName)
std::string GetFull() const
std::string GetName() const
static std::shared_ptr< PositionSource > CreatePositionSource(const PositionSourceType position_source_type)