aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/HoeItem.cpp
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/HoeItem.cpp
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.World/HoeItem.cpp')
-rw-r--r--Minecraft.World/HoeItem.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/Minecraft.World/HoeItem.cpp b/Minecraft.World/HoeItem.cpp
new file mode 100644
index 00000000..50dde305
--- /dev/null
+++ b/Minecraft.World/HoeItem.cpp
@@ -0,0 +1,51 @@
+#include "stdafx.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 "HoeItem.h"
+
+HoeItem::HoeItem(int id, const Tier *tier) : Item(id)
+{
+ this->tier = tier;
+ maxStackSize = 1;
+ setMaxDamage(tier->getUses());
+}
+
+bool 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)
+{
+ if (!player->mayBuild(x, y, z)) return false;
+
+ // 4J-PB - Adding a test only version to allow tooltips to be displayed
+
+ int targetType = level->getTile(x, y, z);
+ // Material above = level.getMaterial(x, y + 1, z);
+ int above = level->getTile(x, y + 1, z);
+
+ // 4J-PB - missing parentheses
+ if (face != 0 && above == 0 && (targetType == Tile::grass_Id || targetType == Tile::dirt_Id))
+ {
+ if(!bTestUseOnOnly)
+ {
+ Tile *tile = Tile::farmland;
+ level->playSound(x + 0.5f, y + 0.5f, z + 0.5f, tile->soundType->getStepSound(), (tile->soundType->getVolume() + 1) / 2, tile->soundType->getPitch() * 0.8f);
+
+ if (level->isClientSide) return true;
+ level->setTile(x, y, z, tile->id);
+ instance->hurt(1, player);
+ }
+ return true;
+ }
+
+ return false;
+}
+
+bool HoeItem::isHandEquipped()
+{
+ return true;
+}
+
+const Item::Tier *HoeItem::getTier()
+{
+ return tier;
+}