Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Static Public Member Functions | Private Types | List of all members
cItemDyeHandler Class Referencefinal

#include <ItemDye.h>

Inheritance diagram for cItemDyeHandler:
Inheritance graph
[legend]
Collaboration diagram for cItemDyeHandler:
Collaboration graph
[legend]

Public Member Functions

virtual bool OnItemUse (cWorld *a_World, cPlayer *a_Player, cBlockPluginInterface &a_PluginInterface, const cItem &a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace) const override
 Called when the player tries to use the item (right mouse button). More...
 
- Public Member Functions inherited from cItemHandler
virtual bool CanHarvestBlock (BLOCKTYPE a_BlockType) const
 Returns whether this tool / item can harvest a specific block (e.g. More...
 
virtual bool CanRepairWithRawMaterial (short a_ItemType) const
 Can the anvil repair this item, when a_Item is the second input? More...
 
constexpr cItemHandler (int a_ItemType)
 
virtual bool EatItem (cPlayer *a_Player, cItem *a_Item) const
 Lets the player eat a selected item. More...
 
virtual float GetBlockBreakingStrength (BLOCKTYPE a_Block) const
 Returns the strength to break a specific block. More...
 
virtual short GetDurabilityLossByAction (eDurabilityLostAction a_Action) const
 Get the durability lost which the item will get, when a specified action was performed. More...
 
virtual FoodInfo GetFoodInfo (const cItem *a_Item) const
 Returns the FoodInfo for this item. More...
 
virtual char GetMaxStackSize (void) const
 Returns the maximum stack size for a given item. More...
 
virtual bool IsDrinkable (short a_ItemDamage) const
 Indicates if this item is drinkable. More...
 
virtual bool IsFood (void) const
 Indicates if this item is food. More...
 
virtual bool IsPlaceable (void) const
 Blocks simply get placed. More...
 
virtual bool OnDiggingBlock (cWorld *a_World, cPlayer *a_Player, const cItem &a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace) const
 Called while the player digs a block using this item. More...
 
virtual void OnEntityAttack (cPlayer *a_Attacker, cEntity *a_AttackedEntity) const
 Called when a player attacks an entity with this item in hand. More...
 
virtual void OnFoodEaten (cWorld *a_World, cPlayer *a_Player, cItem *a_Item) const
 Called after the player has eaten this item. More...
 
virtual void OnItemShoot (cPlayer *, const Vector3i a_BlockPos, eBlockFace a_BlockFace) const
 Called when the client sends the SHOOT status in the lclk packet (releasing the bow). More...
 
void OnPlayerPlace (cPlayer &a_Player, const cItem &a_HeldItem, Vector3i a_ClickedPosition, BLOCKTYPE a_ClickedBlockType, NIBBLETYPE a_ClickedBlockMeta, eBlockFace a_ClickedBlockFace, Vector3i a_CursorPosition) const
 Called when the player tries to place the item (right mouse button, IsPlaceable() == true). More...
 
virtual void OnUpdate (cWorld *a_World, cPlayer *a_Player, const cItem &a_Item) const
 Called every tick while the item is on the player's inventory (used by maps, for example) - For now, called only for equipped items. More...
 

Static Public Member Functions

static bool FertilizePlant (cWorld &a_World, Vector3i a_BlockPos)
 Attempts to use the bonemeal on the plant at the specified (absolute) position. More...
 
template<auto Planter>
static void FindAdjacentGrassAnd (cWorld &a_World, const Vector3i a_Position)
 Walks adjacent grass blocks up to 7 taxicab distance away from a_Position and calls the Planter function on the first suitable one found. More...
 
static void GrowDoubleTallGrass (cWorld &a_World, const Vector3i a_Position)
 
static void GrowFlower (cWorld &a_World, const Vector3i a_Position)
 Grows a biome-dependent flower according to https://minecraft.wiki/w/Flower#Flower_biomes. More...
 
static void GrowPlantsAround (cWorld &a_World, const Vector3i a_Position)
 Grows new plants around the specified block. More...
 
static void GrowTallGrass (cWorld &a_World, const Vector3i a_Position)
 

Private Types

using Super = cItemHandler
 

Additional Inherited Members

- Public Types inherited from cItemHandler
enum  eDurabilityLostAction { dlaAttackEntity , dlaBreakBlock , dlaBreakBlockInstant }
 Actions that may cause durability of an item may be lost, where the magnitude of the loss depends on the specific item used to perform the action. More...
 
- Protected Member Functions inherited from cItemHandler
virtual bool CommitPlacement (cPlayer &a_Player, const cItem &a_HeldItem, Vector3i a_PlacePosition, eBlockFace a_ClickedBlockFace, Vector3i a_CursorPosition) const
 Performs the actual placement of this placeable item. More...
 
 ~cItemHandler ()=default
 
- Static Protected Member Functions inherited from cItemHandler
static const cItemHandlerFor (int a_ItemType)
 
- Protected Attributes inherited from cItemHandler
const int m_ItemType
 

Detailed Description

Definition at line 13 of file ItemDye.h.

Member Typedef Documentation

◆ Super

Definition at line 16 of file ItemDye.h.

Member Function Documentation

◆ FertilizePlant()

static bool cItemDyeHandler::FertilizePlant ( cWorld a_World,
Vector3i  a_BlockPos 
)
inlinestatic

Attempts to use the bonemeal on the plant at the specified (absolute) position.

The effect of fertilization depends on the plant: https://minecraft.wiki/w/Bone_Meal#Fertilizer

  • grow a few stages
  • grow 1 stage with a chance
  • drop pickups without destroying the plant
  • grow more plants in the vicinity If fertilized succesfully, spawn appropriate particle effects, too. Returns true if the plant was fertilized successfully, false if not / not a plant. Note that successful fertilization doesn't mean successful growth - for blocks that have only a chance to grow, fertilization success is reported even in the case when the chance fails (bonemeal still needs to be consumed).

Definition at line 100 of file ItemDye.h.

◆ FindAdjacentGrassAnd()

template<auto Planter>
static void cItemDyeHandler::FindAdjacentGrassAnd ( cWorld a_World,
const Vector3i  a_Position 
)
inlinestatic

Walks adjacent grass blocks up to 7 taxicab distance away from a_Position and calls the Planter function on the first suitable one found.

Does nothing if no position suitable for growing was found.

Definition at line 348 of file ItemDye.h.

◆ GrowDoubleTallGrass()

static void cItemDyeHandler::GrowDoubleTallGrass ( cWorld a_World,
const Vector3i  a_Position 
)
inlinestatic

Definition at line 257 of file ItemDye.h.

◆ GrowFlower()

static void cItemDyeHandler::GrowFlower ( cWorld a_World,
const Vector3i  a_Position 
)
inlinestatic

Grows a biome-dependent flower according to https://minecraft.wiki/w/Flower#Flower_biomes.

Definition at line 274 of file ItemDye.h.

◆ GrowPlantsAround()

static void cItemDyeHandler::GrowPlantsAround ( cWorld a_World,
const Vector3i  a_Position 
)
inlinestatic

Grows new plants around the specified block.

Places up to 40 new plants, with the following probability:

  • 0 up to 8 big grass (2-block tall grass)
  • 8 up tp 24 tall grass (1-block tall grass)
  • 0 up to 8 flowers (biome dependent variants) The new plants are spawned within 7 taxicab distance of a_Position, on a grass block. Broadcasts a particle for each new spawned plant.

Definition at line 223 of file ItemDye.h.

◆ GrowTallGrass()

static void cItemDyeHandler::GrowTallGrass ( cWorld a_World,
const Vector3i  a_Position 
)
inlinestatic

Definition at line 267 of file ItemDye.h.

◆ OnItemUse()

virtual bool cItemDyeHandler::OnItemUse ( cWorld a_World,
cPlayer a_Player,
cBlockPluginInterface a_PluginInterface,
const cItem a_HeldItem,
const Vector3i  a_ClickedBlockPos,
eBlockFace  a_ClickedBlockFace 
) const
inlineoverridevirtual

Called when the player tries to use the item (right mouse button).

Descendants can return false to abort the usage (default behavior).

Reimplemented from cItemHandler.

Definition at line 25 of file ItemDye.h.


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