From 9518a273570e8d38438c2a29aa10f987e7d44ce1 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 21 Dec 2020 13:54:04 +0000 Subject: Prepare for 1.15+ (#4856) + Add type-safe container for states * Split registry Blocks into BlockTypes, BlockStates so the block types enumeration can be #included without too much penalty * Ensure Registry uses type-safe container --- src/BlockState.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/BlockState.h (limited to 'src/BlockState.h') diff --git a/src/BlockState.h b/src/BlockState.h new file mode 100644 index 000000000..0928dad83 --- /dev/null +++ b/src/BlockState.h @@ -0,0 +1,27 @@ +#pragma once + +#include "Registries/BlockTypes.h" + +struct BlockState +{ + constexpr BlockState(uint_least16_t StateID) : + ID(StateID) + { + } + + /** Gets the block type of this block state. */ + BlockType Type() const; + + bool operator == (BlockState Block) const + { + return ID == Block.ID; + } + + bool operator != (BlockState Block) const + { + return ID != Block.ID; + } + + /** The state ID of the block state. */ + uint_least16_t ID; +}; -- cgit v1.2.3