CavEX/source/item/items.h

72 lines
1.6 KiB
C
Raw Normal View History

2022-12-17 06:30:52 -05:00
/*
Copyright (c) 2022 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/>.
*/
#ifndef ITEMS_H
#define ITEMS_H
#include <stdbool.h>
#include <stdint.h>
#include "../cglm/cglm.h"
struct item_data {
uint16_t id;
uint16_t durability;
uint8_t count;
};
2023-05-02 18:01:32 -04:00
#include "../block/blocks_data.h"
2023-05-13 13:41:42 -04:00
#include "../item/tool.h"
2023-05-02 18:01:32 -04:00
struct server_local;
struct item {
char name[32];
bool has_damage;
uint16_t max_damage;
uint8_t max_stack;
void (*renderItem)(struct item*, struct item_data*, mat4, bool);
2023-05-02 18:01:32 -04:00
bool (*onItemPlace)(struct server_local*, struct item_data*,
struct block_info*, struct block_info*, enum side);
2023-05-13 13:41:42 -04:00
struct item_tool {
enum tool_type type;
enum tool_tier tier;
} tool;
union {
struct {
uint8_t texture_x : 4;
uint8_t texture_y : 4;
} item;
struct {
bool has_default;
uint8_t default_metadata : 4;
uint8_t default_rotation : 2;
} block;
} render_data;
};
#define ITEMS_MAX 512
extern struct item* items[ITEMS_MAX];
void items_init(void);
struct item* item_get(struct item_data* item);
bool item_is_block(struct item_data* item);
#endif