summaryrefslogtreecommitdiffstats
path: root/src/World
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2018-07-24 01:33:21 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2018-07-24 19:26:40 +0200
commitdd432af298e0bcaf165ac826613723f1dce4b10d (patch)
treee70207e996731a5b4a46a2d2903ede07b19bba73 /src/World
parentfed9c21f5ef44496d20b788035119860e76505f8 (diff)
downloadMinedMap-dd432af298e0bcaf165ac826613723f1dce4b10d.tar
MinedMap-dd432af298e0bcaf165ac826613723f1dce4b10d.zip
Resolve pre-1.13 block types by mapping them to 1.13 types
Diffstat (limited to 'src/World')
-rw-r--r--src/World/Block.cpp23
-rw-r--r--src/World/Chunk.cpp4
2 files changed, 17 insertions, 10 deletions
diff --git a/src/World/Block.cpp b/src/World/Block.cpp
index c47e2bc..06017fd 100644
--- a/src/World/Block.cpp
+++ b/src/World/Block.cpp
@@ -25,22 +25,21 @@
#include "Block.hpp"
-#include "../Resource/BlockType.hpp"
#include "../Resource/Biome.hpp"
+#include "../Resource/BlockType.hpp"
namespace MinedMap {
namespace World {
uint32_t Block::getColor() const {
- const Resource::BlockType &t = Resource::BLOCK_TYPES[id][data];
-
- if (!t.opaque)
+ const Resource::BlockType *type = Resource::LEGACY_BLOCK_TYPES.types[id][data];
+ if (!type || !type->opaque)
return 0;
- unsigned r = uint8_t(t.color >> 16);
- unsigned g = uint8_t(t.color >> 8);
- unsigned b = uint8_t(t.color);
+ float r = type->color.r;
+ float g = type->color.g;
+ float b = type->color.b;
float heightCoef = height/255.0f + 0.5f;
@@ -48,7 +47,7 @@ uint32_t Block::getColor() const {
g *= heightCoef;
b *= heightCoef;
- if (t.green) {
+ if (type->green) {
const Resource::Biome &biomeDef = Resource::BIOMES[biome];
r *= biomeDef.r;
@@ -56,11 +55,17 @@ uint32_t Block::getColor() const {
b *= biomeDef.b;
}
+ if (type->blue) {
+ r *= 0.265;
+ g *= 0.382;
+ b *= 1.379;
+ }
+
if (r > 255) r = 255;
if (g > 255) g = 255;
if (b > 255) b = 255;
- return (r << 24) | (g << 16) | (b << 8) | 0xff;
+ return ((unsigned)r << 24) | ((unsigned)g << 16) | ((unsigned)b << 8) | 0xff;
}
}
diff --git a/src/World/Chunk.cpp b/src/World/Chunk.cpp
index 38ca496..d4c6029 100644
--- a/src/World/Chunk.cpp
+++ b/src/World/Chunk.cpp
@@ -128,7 +128,9 @@ Chunk::Blocks Chunk::getTopLayer() const {
uint8_t id = getBlockAt(x, y, z);
uint8_t data = getDataAt(x, y, z);
- if (!Resource::BLOCK_TYPES[id][data].opaque)
+
+ const Resource::BlockType *type = Resource::LEGACY_BLOCK_TYPES.types[id][data];
+ if (!type || !type->opaque)
continue;
ret.blocks[x][z] = getBlock(x, y, z);