summaryrefslogtreecommitdiffstats
path: root/src/Items/ItemMinecart.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2020-04-21 22:19:22 +0200
committerGitHub <noreply@github.com>2020-04-21 22:19:22 +0200
commit487f9a2aa9b5497495cef1ac3b9c7a603e69f862 (patch)
tree054a846942f414060e29c72f4a717c8a89e70893 /src/Items/ItemMinecart.h
parentDelet SpawnObject params (diff)
downloadcuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar
cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.gz
cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.bz2
cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.lz
cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.xz
cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.zst
cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.zip
Diffstat (limited to '')
-rw-r--r--src/Items/ItemMinecart.h26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/Items/ItemMinecart.h b/src/Items/ItemMinecart.h
index 603d3f9c5..d108c2ca8 100644
--- a/src/Items/ItemMinecart.h
+++ b/src/Items/ItemMinecart.h
@@ -1,8 +1,6 @@
#pragma once
-#include "../Entities/Minecart.h"
-
@@ -21,18 +19,25 @@ public:
+
+
virtual bool OnItemUse(
- cWorld * a_World, cPlayer * a_Player, cBlockPluginInterface & a_PluginInterface, const cItem & a_Item,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace
+ cWorld * a_World,
+ cPlayer * a_Player,
+ cBlockPluginInterface & a_PluginInterface,
+ const cItem & a_HeldItem,
+ const Vector3i a_ClickedBlockPos,
+ eBlockFace a_ClickedBlockFace
) override
{
- if (a_BlockFace < 0)
+ // Must be used on a block
+ if (a_ClickedBlockFace < 0)
{
return false;
}
// Check that there's rail in there:
- BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+ BLOCKTYPE Block = a_World->GetBlock(a_ClickedBlockPos);
switch (Block)
{
case E_BLOCK_MINECART_TRACKS:
@@ -50,15 +55,14 @@ public:
}
}
- double x = static_cast<double>(a_BlockX) + 0.5;
- double y = static_cast<double>(a_BlockY) + 0.5;
- double z = static_cast<double>(a_BlockZ) + 0.5;
-
- if (a_World->SpawnMinecart(x, y, z, m_ItemType) == cEntity::INVALID_ID)
+ // Spawn the minecart:
+ auto SpawnPos = Vector3d(a_ClickedBlockPos) + Vector3d(0.5, 0.5, 0.5);
+ if (a_World->SpawnMinecart(SpawnPos, m_ItemType) == cEntity::INVALID_ID)
{
return false;
}
+ // Remove the item from inventory:
if (!a_Player->IsGameModeCreative())
{
a_Player->GetInventory().RemoveOneEquippedItem();