#include <Block/SpriteBlock/FarmLand/FarmLand.hpp>
#include <Item/StatelessItem/BasicItem/CheatFertilizer/CheatFertilizer.hpp>
#include <World/LocalWorld/LocalWorld.hpp>

CheatFertilizer::CheatFertilizer(std::string name) : BasicItem(name, "Cheat Fertilizer", Material::cheatFertilizer)
{
    setMaxStackSize(1);
}

void CheatFertilizer::onUse(LocalWorld &world, IWorldActor &actor, ItemStack &stack, glm::ivec3 pos, Side side)
{
    FarmLand *farmLand = dynamic_cast<FarmLand*>(world.getBlockAt(pos));
    if (farmLand == nullptr)
    {
        return;
    }

    uint8_t meta = *world.getBlockMeta(pos);
    meta |= 3;
    world.setBlockMeta(pos, meta);
}