Cuberite
A lightweight, fast and extensible game server for Minecraft
Private Types | Private Member Functions | Static Private Attributes | List of all members
cBlockStemsHandler< ProduceBlockType, StemPickupType > Class Template Referencefinal

Handler for stems from which produce grows in an adjacent block (melon, pumpkin) after it becomes ripe (meta == 7). More...

#include <BlockStems.h>

Inheritance diagram for cBlockStemsHandler< ProduceBlockType, StemPickupType >:
Inheritance graph
[legend]
Collaboration diagram for cBlockStemsHandler< ProduceBlockType, StemPickupType >:
Collaboration graph
[legend]

Private Types

using Super = cBlockPlant< true >
 

Private Member Functions

virtual void BearFruit (cChunk &a_Chunk, const Vector3i a_StemRelPos) const override
 Grows the final produce next to the stem at the specified position. More...
 
virtual bool CanBeAt (const cChunk &a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override
 Checks if the block can stay at the specified relative coords in the chunk. More...
 
virtual cItems ConvertToPickups (const NIBBLETYPE a_BlockMeta, const cItem *const a_Tool) const override
 Returns the pickups that would result if the block was mined by a_Digger using a_Tool. More...
 
virtual ColourID GetMapBaseColourID (NIBBLETYPE a_Meta) const override
 Returns the base colour ID of the block, as will be represented on a map, as per documentation: https://minecraft.wiki/w/Map_item_format. More...
 
virtual int Grow (cChunk &a_Chunk, Vector3i a_RelPos, int a_NumStages=1) const override
 Grows this block, if it supports growing, by the specified amount of stages (at most). More...
 

Static Private Attributes

static constexpr std::array< std::array< double, 4 >, 8 > m_AgeSeedDropProbability
 The array describes how many seed may be dropped at which age. More...
 

Additional Inherited Members

- Public Member Functions inherited from cBlockHandler
virtual bool CanSustainPlant (BLOCKTYPE a_Plant) const
 Checks whether the block has an effect on growing the plant. More...
 
constexpr cBlockHandler (BLOCKTYPE a_BlockType)
 
void Check (cChunkInterface &ChunkInterface, cBlockPluginInterface &a_PluginInterface, Vector3i a_RelPos, cChunk &a_Chunk) const
 Called when one of the neighbors gets set; equivalent to MC block update. More...
 
virtual bool DoesIgnoreBuildCollision (const cWorld &a_World, const cItem &a_HeldItem, Vector3i a_Position, NIBBLETYPE a_Meta, eBlockFace a_ClickedBlockFace, bool a_ClickedDirectly) const
 Checks if the player can build "inside" this block. More...
 
virtual cBoundingBox GetPlacementCollisionBox (BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP) const
 Returns the relative bounding box that must be entity-free in order for the block to be placed. More...
 
virtual bool IsInsideBlock (const Vector3d a_RelPosition, const NIBBLETYPE a_BlockMeta) const
 Tests if a_RelPosition is inside the block, where a_RelPosition is relative to the origin of the block. More...
 
virtual bool IsUseable (void) const
 Called to check whether this block supports a rclk action. More...
 
virtual NIBBLETYPE MetaMirrorXY (NIBBLETYPE a_Meta) const
 Mirrors a given block meta around the XY plane. More...
 
virtual NIBBLETYPE MetaMirrorXZ (NIBBLETYPE a_Meta) const
 Mirros a given block meta around the XZ plane. More...
 
virtual NIBBLETYPE MetaMirrorYZ (NIBBLETYPE a_Meta) const
 Mirros a given block meta around the YZ plane. More...
 
virtual NIBBLETYPE MetaRotateCCW (NIBBLETYPE a_Meta) const
 Rotates a given block meta counter-clockwise. More...
 
virtual NIBBLETYPE MetaRotateCW (NIBBLETYPE a_Meta) const
 Rotates a given block meta clockwise. More...
 
virtual void OnBroken (cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, const cEntity *a_Digger) const
 Called after a block gets broken (replaced with air), by natural means. More...
 
virtual void OnCancelRightClick (cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, const Vector3i a_BlockPos, eBlockFace a_BlockFace) const
 Called when a right click to this block is cancelled. More...
 
virtual void OnDigging (cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, const Vector3i a_BlockPos) const
 Called when the player starts digging the block. More...
 
virtual void OnNeighborChanged (cChunkInterface &a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const
 Called when a direct neighbor of this block has been changed. More...
 
virtual void OnPlaced (cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) const
 Called by cWorld::SetBlock() after the block has been set. More...
 
virtual bool OnUse (cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, const Vector3i a_BlockPos, eBlockFace a_BlockFace, const Vector3i a_CursorPos) const
 Called when the user right clicks the block and the block is useable. More...
 
- Static Public Member Functions inherited from cBlockHandler
static const cBlockHandlerFor (BLOCKTYPE a_BlockType)
 
static char FortuneDiscreteRandom (char a_MinDrop, char a_DefaultMax, unsigned char a_BonusMax, char a_DropCap=25)
 Returns a random number of drops taking into account fortune. More...
 
static void NeighborChanged (cChunkInterface &a_ChunkInterface, Vector3i a_NeighborPos, eBlockFace a_WhichNeighbor)
 Notifies the specified neighbor that the current block has changed. More...
 
static unsigned char ToolFortuneLevel (const cItem *a_Tool)
 Returns the fortune level of a tool, if it is a valid tool. More...
 
static bool ToolHasSilkTouch (const cItem *a_Tool)
 Returns true if the specified tool is valid and has a non-zero silk-touch enchantment. More...
 
- Protected Types inherited from cBlockPlant< true >
enum  PlantAction
 The action the plant can take on an update. More...
 
- Protected Member Functions inherited from cBlockPlant< true >
virtual PlantAction CanGrow (cChunk &a_Chunk, Vector3i a_RelPos) const
 Checks whether a plant can grow grow, based on what is returned from cBlockPlant::HasEnoughLight and a random check based on what is returned from cBlockPlant::GetGrowthChance. More...
 
virtual int GetGrowthChance (cChunk &a_Chunk, Vector3i a_RelPos) const
 Generates an int value between 4 and 25 based on surrounding blocks that affect how quickly the plant grows. More...
 
 ~cBlockPlant ()=default
 
- Protected Member Functions inherited from cBlockHandler
 ~cBlockHandler ()=default
 
- Static Protected Member Functions inherited from cBlockPlant< true >
static PlantAction HasEnoughLight (cChunk &a_Chunk, Vector3i a_RelPos)
 Checks whether there is enough light for the plant to grow. More...
 
- Protected Attributes inherited from cBlockHandler
const BLOCKTYPE m_BlockType
 

Detailed Description

template<BLOCKTYPE ProduceBlockType, ENUM_ITEM_TYPE StemPickupType>
class cBlockStemsHandler< ProduceBlockType, StemPickupType >

Handler for stems from which produce grows in an adjacent block (melon, pumpkin) after it becomes ripe (meta == 7).

ProduceBlockType is the blocktype for the produce to be grown. StemPickupType is the item type for the pickup resulting from breaking the stem.

Definition at line 14 of file BlockStems.h.

Member Typedef Documentation

◆ Super

template<BLOCKTYPE ProduceBlockType, ENUM_ITEM_TYPE StemPickupType>
using cBlockStemsHandler< ProduceBlockType, StemPickupType >::Super = cBlockPlant<true>
private

Definition at line 17 of file BlockStems.h.

Member Function Documentation

◆ BearFruit()

template<BLOCKTYPE ProduceBlockType, ENUM_ITEM_TYPE StemPickupType>
virtual void cBlockStemsHandler< ProduceBlockType, StemPickupType >::BearFruit ( cChunk a_Chunk,
const Vector3i  a_StemRelPos 
) const
inlineoverrideprivatevirtual

Grows the final produce next to the stem at the specified position.

Reimplemented from cBlockPlant< true >.

Definition at line 90 of file BlockStems.h.

◆ CanBeAt()

template<BLOCKTYPE ProduceBlockType, ENUM_ITEM_TYPE StemPickupType>
virtual bool cBlockStemsHandler< ProduceBlockType, StemPickupType >::CanBeAt ( const cChunk a_Chunk,
const Vector3i  a_Position,
const NIBBLETYPE  a_Meta 
) const
inlineoverrideprivatevirtual

Checks if the block can stay at the specified relative coords in the chunk.

Reimplemented from cBlockHandler.

Definition at line 59 of file BlockStems.h.

◆ ConvertToPickups()

template<BLOCKTYPE ProduceBlockType, ENUM_ITEM_TYPE StemPickupType>
virtual cItems cBlockStemsHandler< ProduceBlockType, StemPickupType >::ConvertToPickups ( const NIBBLETYPE  a_BlockMeta,
const cItem *const  a_Tool 
) const
inlineoverrideprivatevirtual

Returns the pickups that would result if the block was mined by a_Digger using a_Tool.

Doesn't do any actual block change / mining, only calculates the pickups. a_Digger is the entity that caused the conversion, usually the player digging. a_Tool is the tool used for the digging. The default implementation drops a single item created from m_BlockType and the current meta.

Reimplemented from cBlockHandler.

Definition at line 25 of file BlockStems.h.

◆ GetMapBaseColourID()

template<BLOCKTYPE ProduceBlockType, ENUM_ITEM_TYPE StemPickupType>
virtual ColourID cBlockStemsHandler< ProduceBlockType, StemPickupType >::GetMapBaseColourID ( NIBBLETYPE  a_Meta) const
inlineoverrideprivatevirtual

Returns the base colour ID of the block, as will be represented on a map, as per documentation: https://minecraft.wiki/w/Map_item_format.

Reimplemented from cBlockHandler.

Definition at line 68 of file BlockStems.h.

◆ Grow()

template<BLOCKTYPE ProduceBlockType, ENUM_ITEM_TYPE StemPickupType>
virtual int cBlockStemsHandler< ProduceBlockType, StemPickupType >::Grow ( cChunk a_Chunk,
Vector3i  a_RelPos,
int  a_NumStages = 1 
) const
inlineoverrideprivatevirtual

Grows this block, if it supports growing, by the specified amount of stages (at most).

Returns the number of stages actually grown, zero if not supported (default).

Reimplemented from cBlockHandler.

Definition at line 78 of file BlockStems.h.

Member Data Documentation

◆ m_AgeSeedDropProbability

template<BLOCKTYPE ProduceBlockType, ENUM_ITEM_TYPE StemPickupType>
constexpr std::array<std::array<double, 4>, 8> cBlockStemsHandler< ProduceBlockType, StemPickupType >::m_AgeSeedDropProbability
staticconstexprprivate
Initial value:
{
{
{
81.3, 17.42, 1.24, 0.03
},
{
65.1, 30.04, 4.62, 0.24
},
{
51.2, 38.4, 9.6, 0.8
},
{
39.44, 43.02, 15.64, 1.9
},
{
29.13, 44.44, 22.22, 3.7
},
{
21.6, 43.2, 28.8, 6.4
},
{
15.17, 39.82, 34.84, 10.16
},
{
10.16, 34.84, 39.82, 15.17
}
}
}

The array describes how many seed may be dropped at which age.

The inner arrays describe the probability to drop 0, 1, 2, 3 seeds. The outer describes the age of the stem.

Definition at line 178 of file BlockStems.h.


The documentation for this class was generated from the following file: