2026-03-01 12:16:08 +08:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
#include "Item.h"
|
|
|
|
|
#include "net.minecraft.world.entity.player.h"
|
|
|
|
|
#include "net.minecraft.world.level.h"
|
|
|
|
|
#include "net.minecraft.world.level.tile.h"
|
|
|
|
|
#include "ItemInstance.h"
|
|
|
|
|
#include "SeedItem.h"
|
|
|
|
|
|
|
|
|
|
SeedItem::SeedItem(int id, int resultId, int targetLand) : Item(id)
|
|
|
|
|
{
|
2026-03-03 03:04:10 +08:00
|
|
|
this->resultId = resultId;
|
2026-03-01 12:16:08 +08:00
|
|
|
this->targetLand = targetLand;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-02 17:37:16 +07:00
|
|
|
bool SeedItem::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
|
|
|
{
|
|
|
|
|
// 4J-PB - Adding a test only version to allow tooltips to be displayed
|
2026-03-03 03:04:10 +08:00
|
|
|
if (face != 1) return false;
|
2026-03-01 12:16:08 +08:00
|
|
|
|
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
|
|
|
|
2026-03-03 03:04:10 +08:00
|
|
|
int targetType = level->getTile(x, y, z);
|
2026-03-01 12:16:08 +08:00
|
|
|
|
2026-03-03 03:04:10 +08:00
|
|
|
if (targetType == targetLand && level->isEmptyTile(x, y + 1, z))
|
2026-03-01 12:16:08 +08:00
|
|
|
{
|
|
|
|
|
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--;
|
|
|
|
|
}
|
2026-03-03 03:04:10 +08:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2026-03-01 12:16:08 +08:00
|
|
|
}
|