diff --git a/src/dat/nbt.c b/src/dat/nbt.c index 668de65..2ca6d5f 100644 --- a/src/dat/nbt.c +++ b/src/dat/nbt.c @@ -98,3 +98,17 @@ int nbt_prim_tagsize(u8 tag) { default: return -1; } } + +int nbt_isprim(u8 tag) { + switch (tag) { + case NBT_I8: + case NBT_I16: + case NBT_I32: + case NBT_F32: + case NBT_I64: + case NBT_F64: + return 1; + default: + return 0; + } +} diff --git a/src/dat/nbt.h b/src/dat/nbt.h index 0295f40..be32a77 100644 --- a/src/dat/nbt.h +++ b/src/dat/nbt.h @@ -36,5 +36,10 @@ enum nbt_tagid { int nbt_proc(void **restrict datout, u8 const *restrict buf, size_t len); +/* checks whether the tag is a primitive data tag. (not recommended for filtering tags, use a `switch`) + * returns a boolean value. */ +atrb_const int nbt_isprim(u8 tag); + + /* gets the tag size of primitive types, returns `>0` on success, `<0` on failure */ atrb_const int nbt_prim_tagsize(u8 tag);