mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-06 01:54:51 +01:00
Resolve pre-1.13 block types by mapping them to 1.13 types
This commit is contained in:
parent
fed9c21f5e
commit
dd432af298
4 changed files with 87 additions and 4622 deletions
File diff suppressed because it is too large
Load diff
|
@ -27,17 +27,33 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace MinedMap {
|
namespace MinedMap {
|
||||||
namespace Resource {
|
namespace Resource {
|
||||||
|
|
||||||
struct BlockType {
|
struct BlockType {
|
||||||
|
private:
|
||||||
|
static const std::unordered_map<std::string, BlockType> Types;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static const BlockType * lookup(const std::string &name);
|
||||||
|
|
||||||
bool opaque;
|
bool opaque;
|
||||||
bool green;
|
bool green;
|
||||||
uint32_t color;
|
bool blue;
|
||||||
|
struct {
|
||||||
|
uint8_t r, g, b;
|
||||||
|
} color;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const BlockType BLOCK_TYPES[256][16];
|
|
||||||
|
struct LegacyPalette {
|
||||||
|
const BlockType *types[256][16];
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const LegacyPalette LEGACY_BLOCK_TYPES;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,22 +25,21 @@
|
||||||
|
|
||||||
|
|
||||||
#include "Block.hpp"
|
#include "Block.hpp"
|
||||||
#include "../Resource/BlockType.hpp"
|
|
||||||
#include "../Resource/Biome.hpp"
|
#include "../Resource/Biome.hpp"
|
||||||
|
#include "../Resource/BlockType.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace MinedMap {
|
namespace MinedMap {
|
||||||
namespace World {
|
namespace World {
|
||||||
|
|
||||||
uint32_t Block::getColor() const {
|
uint32_t Block::getColor() const {
|
||||||
const Resource::BlockType &t = Resource::BLOCK_TYPES[id][data];
|
const Resource::BlockType *type = Resource::LEGACY_BLOCK_TYPES.types[id][data];
|
||||||
|
if (!type || !type->opaque)
|
||||||
if (!t.opaque)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
unsigned r = uint8_t(t.color >> 16);
|
float r = type->color.r;
|
||||||
unsigned g = uint8_t(t.color >> 8);
|
float g = type->color.g;
|
||||||
unsigned b = uint8_t(t.color);
|
float b = type->color.b;
|
||||||
|
|
||||||
float heightCoef = height/255.0f + 0.5f;
|
float heightCoef = height/255.0f + 0.5f;
|
||||||
|
|
||||||
|
@ -48,7 +47,7 @@ uint32_t Block::getColor() const {
|
||||||
g *= heightCoef;
|
g *= heightCoef;
|
||||||
b *= heightCoef;
|
b *= heightCoef;
|
||||||
|
|
||||||
if (t.green) {
|
if (type->green) {
|
||||||
const Resource::Biome &biomeDef = Resource::BIOMES[biome];
|
const Resource::Biome &biomeDef = Resource::BIOMES[biome];
|
||||||
|
|
||||||
r *= biomeDef.r;
|
r *= biomeDef.r;
|
||||||
|
@ -56,11 +55,17 @@ uint32_t Block::getColor() const {
|
||||||
b *= biomeDef.b;
|
b *= biomeDef.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type->blue) {
|
||||||
|
r *= 0.265;
|
||||||
|
g *= 0.382;
|
||||||
|
b *= 1.379;
|
||||||
|
}
|
||||||
|
|
||||||
if (r > 255) r = 255;
|
if (r > 255) r = 255;
|
||||||
if (g > 255) g = 255;
|
if (g > 255) g = 255;
|
||||||
if (b > 255) b = 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,9 @@ Chunk::Blocks Chunk::getTopLayer() const {
|
||||||
|
|
||||||
uint8_t id = getBlockAt(x, y, z);
|
uint8_t id = getBlockAt(x, y, z);
|
||||||
uint8_t data = getDataAt(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;
|
continue;
|
||||||
|
|
||||||
ret.blocks[x][z] = getBlock(x, y, z);
|
ret.blocks[x][z] = getBlock(x, y, z);
|
||||||
|
|
Loading…
Add table
Reference in a new issue