Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <ItemHandler.h>
Classes | |
struct | FoodInfo |
Public Types | |
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... | |
Public Member Functions | |
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... | |
virtual bool | OnItemUse (cWorld *a_World, cPlayer *a_Player, cBlockPluginInterface &a_PluginInterface, const cItem &a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace) const |
Called when the player tries to use the item (right mouse button). 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... | |
Protected Member Functions | |
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 | |
static const cItemHandler & | For (int a_ItemType) |
Protected Attributes | |
const int | m_ItemType |
Friends | |
class | cItem |
Definition at line 21 of file ItemHandler.h.
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.
Enumerator | |
---|---|
dlaAttackEntity | |
dlaBreakBlock | |
dlaBreakBlockInstant |
Definition at line 30 of file ItemHandler.h.
|
inlineconstexpr |
Definition at line 37 of file ItemHandler.h.
|
protecteddefault |
|
virtual |
Returns whether this tool / item can harvest a specific block (e.g.
iron pickaxe can harvest diamond ore, but wooden one can't). Defaults to false unless overridden.
Reimplemented in cItemSwordHandler, cItemShovelHandler, cItemShearsHandler, and cItemPickaxeHandler.
Definition at line 1343 of file ItemHandler.cpp.
|
virtual |
Can the anvil repair this item, when a_Item is the second input?
Reimplemented in cItemSwordHandler, cItemShovelHandler, cItemPickaxeHandler, and cItemArmorHandler.
Definition at line 1333 of file ItemHandler.cpp.
|
protectedvirtual |
Performs the actual placement of this placeable item.
The descendant handler should call a_Player.PlaceBlock(s) supplying correct values for the newly placed block. The default handler uses the stored block type and meta copied from the lowest 4 bits of the player's equipped item's damage value. Handlers return what a_Player.PlaceBlock(s) returns, indicating whether the placement was successful.
Reimplemented in cItemTorchHandler, cItemLadderHandler, cSimplePlaceableItemHandler, cItemVinesHandler, cItemTripwireHookHandler, cItemTrapdoorHandler, cItemStairsHandler, cItemSnowHandler, cItemSlabHandler, cItemSignHandler, cItemSidewaysHandler, cItemSeedsHandler, cItemSaplingHandler, cItemRedstoneRepeaterHandler, cItemRedstoneDustHandler, cItemRailHandler, cItemQuartzHandler, cItemPumpkinHandler, cItemPlanksHandler, cItemPistonHandler, cItemObserverHandler, cItemNetherWartHandler, cItemMobHeadHandler, cItemLeverHandler, cItemLeavesHandler, cItemJackOLanternHandler, cItemHopperHandler, cItemGlazedTerracottaHandler, cItemFurnaceHandler, cItemFenceGateHandler, cItemEndPortalFrameHandler, cItemEnderChestHandler, cItemEnchantingTableHandler, cItemDropSpenserHandler, cItemDoorHandler, cItemComparatorHandler, cItemChestHandler, cItemButtonHandler, cItemBigFlowerHandler, cItemBedHandler, cItemBannerHandler, and cItemAnvilHandler.
Definition at line 1475 of file ItemHandler.cpp.
Lets the player eat a selected item.
Returns true if the player ate the item
Reimplemented in cItemSpiderEyeHandler, cItemSoupHandler, cItemRottenFleshHandler, cItemRawFishHandler, cItemRawChickenHandler, cItemPotionHandler, cItemPoisonousPotatoHandler, cItemMilkHandler, cItemGoldenAppleHandler, cItemFoodSeedsHandler, cItemFoodHandler, and cItemChorusFruitHandler.
Definition at line 1446 of file ItemHandler.cpp.
|
staticprotected |
Definition at line 569 of file ItemHandler.cpp.
|
virtual |
Returns the strength to break a specific block.
Defaults to 1 unless overriden.
Reimplemented in cItemSwordHandler, cItemShovelHandler, cItemShearsHandler, cItemPickaxeHandler, and cItemAxeHandler.
Definition at line 1466 of file ItemHandler.cpp.
|
virtual |
Get the durability lost which the item will get, when a specified action was performed.
This is only relevant for uses where the damage taken may depend on the item used.
Reimplemented in cItemSwordHandler, cItemShovelHandler, cItemShearsHandler, cItemPickaxeHandler, cItemHoeHandler, and cItemAxeHandler.
Definition at line 1164 of file ItemHandler.cpp.
|
virtual |
Returns the FoodInfo for this item.
(FoodRecovery and Saturation)
Reimplemented in cItemRawFishHandler, cItemFoodSeedsHandler, cItemFoodHandler, and cItemCookedFishHandler.
Definition at line 1456 of file ItemHandler.cpp.
|
virtual |
Returns the maximum stack size for a given item.
Definition at line 1175 of file ItemHandler.cpp.
|
virtual |
Indicates if this item is drinkable.
Reimplemented in cItemPotionHandler, and cItemMilkHandler.
Definition at line 1312 of file ItemHandler.cpp.
|
virtual |
Indicates if this item is food.
Reimplemented in cItemFoodSeedsHandler, and cItemFoodHandler.
Definition at line 1303 of file ItemHandler.cpp.
|
virtual |
Blocks simply get placed.
Reimplemented in cSimplePlaceableItemHandler, cItemSignHandler, cItemSeedsHandler, cItemRedstoneDustHandler, cItemNetherWartHandler, cItemMobHeadHandler, cItemLilypadHandler, cItemEnchantingTableHandler, cItemDoorHandler, cItemComparatorHandler, cItemBedHandler, cItemBannerHandler, and cItemRedstoneRepeaterHandler.
Definition at line 1323 of file ItemHandler.cpp.
|
virtual |
Called while the player digs a block using this item.
Reimplemented in cItemShearsHandler.
Definition at line 1122 of file ItemHandler.cpp.
|
virtual |
Called when a player attacks an entity with this item in hand.
Definition at line 1143 of file ItemHandler.cpp.
|
virtual |
Called after the player has eaten this item.
Definition at line 1153 of file ItemHandler.cpp.
|
inlinevirtual |
Called when the client sends the SHOOT status in the lclk packet (releasing the bow).
Reimplemented in cItemBowHandler.
Definition at line 61 of file ItemHandler.h.
|
virtual |
Called when the player tries to use the item (right mouse button).
Descendants can return false to abort the usage (default behavior).
Reimplemented in cItemEyeOfEnderHandler, cItemFireworkHandler, cItemThrowableHandler, cItemSpawnEggHandler, cItemPotionHandler, cItemPaintingHandler, cItemMinecartHandler, cItemLilypadHandler, cItemLighterHandler, cItemItemFrameHandler, cItemHoeHandler, cItemFishingRodHandler, cItemEmptyMapHandler, cItemDyeHandler, cItemBucketHandler, cItemBowHandler, cItemBottleHandler, cItemBoatHandler, cItemArmorHandler, and cItemEndCrystalHandler.
Definition at line 1103 of file ItemHandler.cpp.
void cItemHandler::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).
a_ClickedPosition is the block that has been clicked to place this item. a_ClickedBlockFace is the face has been clicked to place this item. a_CursorPosition is the position of the player's cursor within a_ClickedBlockFace. If the block placement is refused inside this call, it will automatically revert the client-side changes.
Definition at line 1045 of file ItemHandler.cpp.
|
inlinevirtual |
Called every tick while the item is on the player's inventory (used by maps, for example) - For now, called only for equipped items.
Reimplemented in cItemMapHandler.
Definition at line 68 of file ItemHandler.h.
|
friend |
Definition at line 25 of file ItemHandler.h.
|
protected |
Definition at line 141 of file ItemHandler.h.