summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockTallGrass.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2019-10-16 10:06:34 +0200
committerGitHub <noreply@github.com>2019-10-16 10:06:34 +0200
commit221cc4ec5cb6301743e947eaabed3fecedba796f (patch)
tree4e44c8bb7523e5d1d04468fc906ae24674c10abc /src/Blocks/BlockTallGrass.h
parentFixed crash in hopper while pulling items from blockentity above itself (#4412) (diff)
downloadcuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar
cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.gz
cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.bz2
cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.lz
cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.xz
cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.zst
cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.zip
Diffstat (limited to 'src/Blocks/BlockTallGrass.h')
-rw-r--r--src/Blocks/BlockTallGrass.h69
1 files changed, 30 insertions, 39 deletions
diff --git a/src/Blocks/BlockTallGrass.h b/src/Blocks/BlockTallGrass.h
index aa369f0cf..c4b7194b5 100644
--- a/src/Blocks/BlockTallGrass.h
+++ b/src/Blocks/BlockTallGrass.h
@@ -8,64 +8,51 @@
-class cBlockTallGrassHandler :
+class cBlockTallGrassHandler:
public cBlockHandler
{
- typedef cBlockHandler super;
+ using super = cBlockHandler;
+
public:
- cBlockTallGrassHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
+
+ cBlockTallGrassHandler(BLOCKTYPE a_BlockType):
+ super(a_BlockType)
{
}
+
+
+
+
virtual bool DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) override
{
return true;
}
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+
+
+
+
+ virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override
{
- // Drop seeds, sometimes
- if (GetRandomProvider().RandBool(0.125))
+ // If using shears, drop self:
+ if ((a_Tool != nullptr) && (a_Tool->m_ItemType == E_ITEM_SHEARS))
{
- a_Pickups.push_back(cItem(E_ITEM_SEEDS, 1, 0));
+ return cItem(m_BlockType, 1, a_BlockMeta);
}
- }
- 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 != nullptr) && (a_Digger->GetEquippedWeapon().m_ItemType == E_ITEM_SHEARS))
+ // Drop seeds, sometimes:
+ if (GetRandomProvider().RandBool(0.125))
{
- 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())
- {
- auto & r1 = GetRandomProvider();
-
- // 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.RandReal<double>(-0.5, 0.5);
- MicroZ += r1.RandReal<double>(-0.5, 0.5);
-
- a_WorldInterface.SpawnItemPickups(Drops, MicroX, MicroY, MicroZ);
- }
- return;
+ return cItem(E_ITEM_SEEDS);
}
-
- super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_CanDrop);
+ return {};
}
+
+
+
+
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
if (a_RelY <= 0)
@@ -77,6 +64,10 @@ public:
return IsBlockTypeOfDirt(BelowBlock);
}
+
+
+
+
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);