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/>.
|
|
|
|
*/
|
|
|
|
|
2022-12-17 06:09:30 -05:00
|
|
|
#ifndef ITEMS_H
|
|
|
|
#define ITEMS_H
|
|
|
|
|
2022-12-21 18:34:49 -05:00
|
|
|
#include <stdbool.h>
|
2022-12-17 06:09:30 -05:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2022-12-21 18:34:49 -05:00
|
|
|
#include "../cglm/cglm.h"
|
2022-12-17 06:09:30 -05:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2022-12-21 18:34:49 -05:00
|
|
|
struct item {
|
|
|
|
char name[32];
|
|
|
|
bool has_damage;
|
2023-08-08 05:15:37 -04:00
|
|
|
uint16_t max_damage;
|
2022-12-21 18:34:49 -05:00
|
|
|
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;
|
2022-12-21 18:34:49 -05:00
|
|
|
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);
|
2022-12-17 06:09:30 -05:00
|
|
|
|
|
|
|
#endif
|