mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add block size check to ContentLoader
This commit is contained in:
parent
45a793d647
commit
b984e363ea
1 changed files with 11 additions and 6 deletions
|
|
@ -241,17 +241,22 @@ void ContentLoader::loadBlock(
|
|||
// block light emission [r, g, b] where r,g,b in range [0..15]
|
||||
if (auto found = root.at("emission")) {
|
||||
const auto& emissionarr = *found;
|
||||
def.emission[0] = emissionarr[0].asNumber();
|
||||
def.emission[1] = emissionarr[1].asNumber();
|
||||
def.emission[2] = emissionarr[2].asNumber();
|
||||
def.emission[0] = emissionarr[0].asInteger();
|
||||
def.emission[1] = emissionarr[1].asInteger();
|
||||
def.emission[2] = emissionarr[2].asInteger();
|
||||
}
|
||||
|
||||
// block size
|
||||
if (auto found = root.at("size")) {
|
||||
const auto& sizearr = *found;
|
||||
def.size.x = sizearr[0].asNumber();
|
||||
def.size.y = sizearr[1].asNumber();
|
||||
def.size.z = sizearr[2].asNumber();
|
||||
def.size.x = sizearr[0].asInteger();
|
||||
def.size.y = sizearr[1].asInteger();
|
||||
def.size.z = sizearr[2].asInteger();
|
||||
if (def.size.x < 1 || def.size.y < 1 || def.size.z < 1) {
|
||||
throw std::runtime_error(
|
||||
"block " + util::quote(def.name) + ": invalid block size"
|
||||
);
|
||||
}
|
||||
if (def.model == BlockModel::block &&
|
||||
(def.size.x != 1 || def.size.y != 1 || def.size.z != 1)) {
|
||||
def.model = BlockModel::aabb;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue