-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinventory.h
40 lines (34 loc) · 1.08 KB
/
inventory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef INVENTORY_H
#define INVENTORY_H
#include <stdlib.h>
typedef struct Slot {
short id;
char count;
short damage;
short nbt_len;
char *nbt;
} Slot;
Slot * Slot_read(char *data, size_t *read);
char * Slot_encode(Slot *slot, size_t *len);
void Slot_free(Slot *slot);
char Slot_is_empty(Slot *slot);
Slot * Slot_new_empty();
Slot * Slot_new_basic(short id, char count, short damage);
Slot * Slot_copy(Slot *slot);
int Slot_can_add(Slot *slot, Slot *other);
size_t Slot_encoded_size(Slot *slot);
typedef struct Inventory {
size_t size;
Slot **slots;
} Inventory;
Inventory * Inventory_new_empty(size_t size);
/* This WILL free all of the slots associated with the inventory.
* You should remove or duplicate anything which you wish to keep
* before freeing the inventory. */
void Inventory_free(Inventory *i);
/* Sets a slot in the inventory.
* This WILL free whatever was there before.*/
void Inventory_set(Inventory *inv, Slot *slot, size_t index);
Slot *Inventory_get(Inventory *inv, size_t index);
int Inventory_player_add_item(Inventory *inv, Slot *slot);
#endif