the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "net.minecraft.world.entity.player.h"
3#include "net.minecraft.world.level.h"
4#include "net.minecraft.world.level.tile.h"
5#include "ItemInstance.h"
6#include "HoeItem.h"
7
8HoeItem::HoeItem(int id, const Tier *tier) : Item(id)
9{
10 this->tier = tier;
11 maxStackSize = 1;
12 setMaxDamage(tier->getUses());
13}
14
15bool HoeItem::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)
16{
17 if (!player->mayUseItemAt(x, y, z, face, instance)) return false;
18
19 // 4J-PB - Adding a test only version to allow tooltips to be displayed
20
21 int targetType = level->getTile(x, y, z);
22 int above = level->getTile(x, y + 1, z);
23
24 if (face != 0 && above == 0 && (targetType == Tile::grass_Id || targetType == Tile::dirt_Id))
25 {
26 if(!bTestUseOnOnly)
27 {
28 Tile *tile = Tile::farmland;
29 level->playSound(x + 0.5f, y + 0.5f, z + 0.5f, tile->soundType->getStepSound(), (tile->soundType->getVolume() + 1) / 2, tile->soundType->getPitch() * 0.8f);
30
31 if (level->isClientSide) return true;
32 level->setTileAndUpdate(x, y, z, tile->id);
33 instance->hurtAndBreak(1, player);
34 }
35 return true;
36 }
37
38 return false;
39}
40
41bool HoeItem::isHandEquipped()
42{
43 return true;
44}
45
46const Item::Tier *HoeItem::getTier()
47{
48 return tier;
49}