Restrict item overdraw placement

isolation_bkp/dynres
Dominik Madarász 2021-11-03 16:41:42 +01:00
parent 2695bbf32d
commit 37cbaa4a3c
1 changed files with 7 additions and 1 deletions

View File

@ -54,7 +54,13 @@ void item_use(ecs_world_t *ecs, ItemDrop *it, Position p, uint64_t udata) {
case UKIND_HOLD: /* NOOP */ break; case UKIND_HOLD: /* NOOP */ break;
case UKIND_PLACE:{ case UKIND_PLACE:{
world_block_lookup l = world_block_from_realpos(p.x, p.y); world_block_lookup l = world_block_from_realpos(p.x, p.y);
if (l.block_id > 0) { if (l.is_outer && l.block_id > 0) {
// NOTE(zaklaus): Check if block is a placeable item, cancel the placement if not met
asset_id item_asset = blocks_get_asset(l.block_id);
uint16_t item_asset_id = item_find(item_asset);
if (item_asset_id == ASSET_INVALID) return;
if (item_get_usage(item_asset_id) > UKIND_END_PLACE) return;
world_chunk_destroy_block(p.x, p.y, true); world_chunk_destroy_block(p.x, p.y, true);
} }
world_chunk_replace_block(l.chunk_id, l.id, blocks_find(desc->place.kind + (asset_id)udata)); world_chunk_replace_block(l.chunk_id, l.id, blocks_find(desc->place.kind + (asset_id)udata));