#include <Block/SpriteBlock/BasicBlock/LogBlock/LogBlock.hpp>
#include <BlockRegistry/BlockRegistry.hpp>
#include <TextureVoxelizer/TextureVoxelizer.hpp>
#include <World/LocalWorld/LocalWorld.hpp>

LogBlock::LogBlock(std::string name, std::string displayName, std::string typeName, std::string saplingName) :
    BasicBlock(
        name,
        displayName,
        200.0f,
        {
            formatString("$+LogSide", typeName),
            formatString("$+LogSide", typeName),
            formatString("$+LogSide", typeName),
            formatString("$+LogSide", typeName),
            formatString("$+LogTopBottom", typeName),
            formatString("$+LogTopBottom", typeName),
        }
    ),
    saplingName(saplingName)
{
    if (!isPrefixed("cactus"))
    {
        withWoodSounds();
        withBreakingSound(Sound::logBreak);
    }
}

void LogBlock::getHarvestedStacks(LocalWorld &world, glm::ivec3 pos, std::vector<ItemStack> &stacks)
{
    BasicBlock::getHarvestedStacks(world, pos, stacks);

    if (!saplingName.empty() && world.probably(saplingDroppingChance))
    {
        stacks.push_back(blockRegistry.getBlockByName(saplingName).toItemStack());
    }
}