#include "ItemStack.h"
#include "Utils/MemoryUtils.h"

#include "Datas/PointerDatas.h"

auto ItemStack::getItem() -> Item** {
	return *reinterpret_cast<Item***>((uintptr_t)this + 0x8);
}

auto ItemStack::getBlock() -> Block* {
	return *reinterpret_cast<Block**>((uintptr_t)this + 0x18);
}

auto ItemStack::getCount() -> uint8_t {
	return *reinterpret_cast<uint8_t*>((uintptr_t)this + 0x22);
}

auto ItemStack::getEnchantValue(int8_t type) -> int32_t {
	if (Datas::Pointer::itemstack_getenchantvalue) {
		static auto func = reinterpret_cast<int(__fastcall*)(int8_t, ItemStack*)>(Datas::Pointer::itemstack_getenchantvalue);
		return func(type, this);
	}
	return 0;
}

auto ItemStack::getCustomName() -> std::string {
	if (Datas::Pointer::itemstack_getcustomname) {
		std::string32 out;
		static auto func = (void(__fastcall*)(ItemStack*, std::string32*))Datas::Pointer::itemstack_getcustomname;
		func(this, &out);
		return out.c_str();
	}
	return _("");
}
