From 55b5e60b189490c33b415e3c956800da21064e3b Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Wed, 8 Aug 2018 07:30:01 +0500 Subject: Basic BlockState support --- src/Block.cpp | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'src/Block.cpp') diff --git a/src/Block.cpp b/src/Block.cpp index 303909b..98f1b0a 100644 --- a/src/Block.cpp +++ b/src/Block.cpp @@ -1,5 +1,7 @@ #include "Block.hpp" +#include + Block::~Block() {} Block::Block(unsigned short id, unsigned char state, @@ -13,5 +15,34 @@ bool operator==(const BlockId& lhs, const BlockId &rhs) { } bool operator<(const BlockId& lhs, const BlockId &rhs) { - return (lhs.id < rhs.id); -} \ No newline at end of file + if (lhs.id < rhs.id) + return true; + return lhs.state < rhs.state; +} + +std::pair TransformBlockIdToBlockStateName(BlockId blockId) { + switch (blockId.id) { + case 1: { + if (blockId.state > 6) + break; + static const std::pair ids[] = { + std::pair("stone", "normal"), + std::pair("granite", "normal"), + std::pair("smooth_granite", "normal"), + std::pair("diorite", "normal"), + std::pair("smooth_diorite", "normal"), + std::pair("andesite", "normal"), + std::pair("smooth_andesite", "normal"), + }; + return ids[blockId.state]; + } + case 2: { + return std::make_pair("grass", "snowy=false"); + } + + default: + break; + } + + return std::make_pair("", ""); +} -- cgit v1.2.3