2026-03-01 12:16:08 +08:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
#include "net.minecraft.world.entity.player.h"
|
|
|
|
|
#include "net.minecraft.h"
|
|
|
|
|
#include "net.minecraft.world.level.h"
|
|
|
|
|
#include "SeedFoodItem.h"
|
|
|
|
|
|
|
|
|
|
SeedFoodItem::SeedFoodItem(int id, int nutrition, float saturationMod, int resultId, int targetLand) : FoodItem(id, nutrition, saturationMod, false)
|
|
|
|
|
{
|
|
|
|
|
this->resultId = resultId;
|
|
|
|
|
this->targetLand = targetLand;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-02 17:37:16 +07:00
|
|
|
bool SeedFoodItem::useOn(shared_ptr<ItemInstance> instance, shared_ptr<Player> player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly)
|
2026-03-01 12:16:08 +08:00
|
|
|
{
|
|
|
|
|
if (face != Facing::UP) return false;
|
|
|
|
|
|
2026-03-03 03:04:10 +08:00
|
|
|
if (!player->mayUseItemAt(x, y, z, face, instance) || !player->mayUseItemAt(x, y + 1, z, face, instance)) return false;
|
2026-03-01 12:16:08 +08:00
|
|
|
int targetType = level->getTile(x, y, z);
|
|
|
|
|
|
|
|
|
|
if (targetType == targetLand && level->isEmptyTile(x, y + 1, z))
|
|
|
|
|
{
|
|
|
|
|
if(!bTestUseOnOnly)
|
|
|
|
|
{
|
2026-03-03 03:04:10 +08:00
|
|
|
level->setTileAndUpdate(x, y + 1, z, resultId);
|
2026-03-01 12:16:08 +08:00
|
|
|
instance->count--;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|