mirror of
https://github.com/xtreme8000/CavEX.git
synced 2025-01-22 17:23:20 -05:00
106 lines
2.8 KiB
C
106 lines
2.8 KiB
C
/*
|
|
Copyright (c) 2023 ByteBit/xtreme8000
|
|
|
|
This file is part of CavEX.
|
|
|
|
CavEX is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
CavEX is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with CavEX. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "blocks.h"
|
|
|
|
static enum block_material getMaterial(struct block_info* this) {
|
|
return MATERIAL_WOOD;
|
|
}
|
|
|
|
static bool getBoundingBox(struct block_info* this, bool entity,
|
|
struct AABB* x) {
|
|
if(this->block->metadata & 0x04) {
|
|
switch(this->block->metadata & 0x03) {
|
|
case 0:
|
|
aabb_setsize(x, 1.0F, 1.0F, 0.1875F);
|
|
aabb_translate(x, 0, 0, 0.40625F);
|
|
break;
|
|
case 1:
|
|
aabb_setsize(x, 1.0F, 1.0F, 0.1875F);
|
|
aabb_translate(x, 0, 0, -0.40625F);
|
|
break;
|
|
case 2:
|
|
aabb_setsize(x, 0.1875F, 1.0F, 1.0F);
|
|
aabb_translate(x, 0.40625F, 0, 0);
|
|
break;
|
|
case 3:
|
|
aabb_setsize(x, 0.1875F, 1.0F, 1.0F);
|
|
aabb_translate(x, -0.40625F, 0, 0);
|
|
break;
|
|
}
|
|
} else {
|
|
aabb_setsize(x, 1.0F, 0.1875F, 1.0F);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
static struct face_occlusion*
|
|
getSideMask(struct block_info* this, enum side side, struct block_info* it) {
|
|
if(this->block->metadata & 0x04) {
|
|
// could be improved
|
|
return face_occlusion_empty();
|
|
} else {
|
|
switch(side) {
|
|
case SIDE_TOP: return face_occlusion_empty();
|
|
case SIDE_BOTTOM:
|
|
return (it->block->type == this->block->type) ?
|
|
face_occlusion_full() :
|
|
face_occlusion_empty();
|
|
default: return face_occlusion_rect(3);
|
|
}
|
|
}
|
|
}
|
|
|
|
static enum block_render_type getRenderType(struct block_info* this) {
|
|
return RENDERTYPE_FULL;
|
|
}
|
|
|
|
static uint8_t getTextureIndex(struct block_info* this, enum side side) {
|
|
return TEXTURE_INDEX(8, 3);
|
|
}
|
|
|
|
static uint32_t getBaseColor(struct block_info* this, enum side side) {
|
|
return 0xFFFFFF;
|
|
}
|
|
|
|
struct block block_trapdoor = {
|
|
.name = "Trapdoor",
|
|
.getRenderType = getRenderType,
|
|
.getSideMask = getSideMask,
|
|
.getBoundingBox = getBoundingBox,
|
|
.getMaterial = getMaterial,
|
|
.getTextureIndex = getTextureIndex,
|
|
.transparent = false,
|
|
.getBaseColor = getBaseColor,
|
|
.renderBlock = render_block_trapdoor,
|
|
.renderBlockAlways = NULL,
|
|
.luminance = 0,
|
|
.double_sided = false,
|
|
.can_see_through = true,
|
|
.opacity = 1,
|
|
.ignore_lighting = false,
|
|
.flammable = false,
|
|
.block_item = {
|
|
.has_damage = false,
|
|
.max_stack = 64,
|
|
.renderItem = render_item_block,
|
|
.render_data.block.has_default = false,
|
|
},
|
|
};
|