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