summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-10-21 18:06:44 +0200
committerHowaner <franzi.moos@googlemail.com>2014-10-21 18:06:44 +0200
commitf800f3c99830ee4486602d69611f40f99e704b9f (patch)
treea7ba3aaec6538edc8a98fd8195e726a908e128d7 /src
parentMerge branch 'master' into BlockFixes (diff)
downloadcuberite-f800f3c99830ee4486602d69611f40f99e704b9f.tar
cuberite-f800f3c99830ee4486602d69611f40f99e704b9f.tar.gz
cuberite-f800f3c99830ee4486602d69611f40f99e704b9f.tar.bz2
cuberite-f800f3c99830ee4486602d69611f40f99e704b9f.tar.lz
cuberite-f800f3c99830ee4486602d69611f40f99e704b9f.tar.xz
cuberite-f800f3c99830ee4486602d69611f40f99e704b9f.tar.zst
cuberite-f800f3c99830ee4486602d69611f40f99e704b9f.zip
Diffstat (limited to 'src')
-rw-r--r--src/Blocks/BlockTallGrass.h37
-rw-r--r--src/Items/ItemShears.h9
2 files changed, 37 insertions, 9 deletions
diff --git a/src/Blocks/BlockTallGrass.h b/src/Blocks/BlockTallGrass.h
index 3ef2d804d..8e821b899 100644
--- a/src/Blocks/BlockTallGrass.h
+++ b/src/Blocks/BlockTallGrass.h
@@ -2,6 +2,7 @@
#pragma once
#include "BlockHandler.h"
+#include "ChunkInterface.h"
@@ -10,6 +11,7 @@
class cBlockTallGrassHandler :
public cBlockHandler
{
+ typedef cBlockHandler super;
public:
cBlockTallGrassHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType)
@@ -34,6 +36,41 @@ public:
}
+ virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop) override
+ {
+ if (a_CanDrop && (a_Digger != NULL) && (a_Digger->GetEquippedWeapon().m_ItemType == E_ITEM_SHEARS))
+ {
+ NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ cItems Drops;
+ Drops.Add(m_BlockType, 1, Meta);
+
+ // Allow plugins to modify the pickups:
+ a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Drops);
+
+ // Spawn the pickups:
+ if (!Drops.empty())
+ {
+ MTRand r1;
+
+ // Mid-block position first
+ double MicroX, MicroY, MicroZ;
+ MicroX = a_BlockX + 0.5;
+ MicroY = a_BlockY + 0.5;
+ MicroZ = a_BlockZ + 0.5;
+
+ // Add random offset second
+ MicroX += r1.rand(1) - 0.5;
+ MicroZ += r1.rand(1) - 0.5;
+
+ a_WorldInterface.SpawnItemPickups(Drops, MicroX, MicroY, MicroZ);
+ }
+ return;
+ }
+
+ super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_CanDrop);
+ }
+
+
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
if (a_RelY <= 0)
diff --git a/src/Items/ItemShears.h b/src/Items/ItemShears.h
index e0c5c6623..73343f629 100644
--- a/src/Items/ItemShears.h
+++ b/src/Items/ItemShears.h
@@ -77,15 +77,6 @@ public:
NIBBLETYPE BlockMeta;
a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, Block, BlockMeta);
- if ((Block == E_BLOCK_TALL_GRASS) && !a_Player->IsGameModeCreative())
- {
- cItems Drops;
- Drops.Add(Block, 1, BlockMeta);
- a_World->SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ);
- a_Player->UseEquippedItem();
- return;
- }
-
super::OnBlockDestroyed(a_World, a_Player, a_Item, a_BlockX, a_BlockY, a_BlockZ);
switch (Block)
{