aboutsummaryrefslogtreecommitdiff
path: root/src/shared/item/block.hh
diff options
context:
space:
mode:
authorNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-12 21:57:46 +1100
committerNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-12 21:57:46 +1100
commite4483eca01b48b943cd0461e24a74ae1a3139ed4 (patch)
treeed58c3c246e3af1af337697695d780aa31f6ad9a /src/shared/item/block.hh
parent1cc08c51eb4b0f95c30c0a98ad1fc5ad3459b2df (diff)
Update to most recent version (old initial commit)
Diffstat (limited to 'src/shared/item/block.hh')
-rw-r--r--src/shared/item/block.hh41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/shared/item/block.hh b/src/shared/item/block.hh
new file mode 100644
index 0000000..2aa7cef
--- /dev/null
+++ b/src/shared/item/block.hh
@@ -0,0 +1,41 @@
+#ifndef SHARED_ITEM_BLOCK_HH_
+#define SHARED_ITEM_BLOCK_HH_
+
+#include "shared/item/item.hh"
+#include "shared/world/block.hh"
+
+namespace shared {
+namespace item {
+
+class block : virtual public shared::item::item {
+public:
+ // Blocks are offset by 256 in their type so they do not collide with tools
+ // I'd prefer it was the other way around so TODO
+ static constexpr auto type_offset{std::numeric_limits<std::uint8_t>::max()};
+
+public:
+ enum shared::world::block::type type;
+
+public:
+ static type_t get_type(const enum shared::world::block::type&) noexcept;
+
+public:
+ virtual type_t get_type() const noexcept;
+
+public:
+ template <typename... Args>
+ block(const enum shared::world::block::type& type, Args&&... args) noexcept
+ : item(get_type(type), std::forward<Args>(args)...), type(type) {}
+
+ template <typename... Args>
+ block(const shared::item::item::type_t& type, Args&&... args) noexcept
+ : item(type, std::forward<Args>(args)...),
+ type(static_cast<enum shared::world::block::type>(type -
+ type_offset)) {}
+ virtual ~block() noexcept {}
+};
+
+} // namespace item
+} // namespace shared
+
+#endif