5 #include "../Entities/Player.h"
6 #include "../FastRandom.h"
7 #include "../BlockInServerPluginInterface.h"
92 #include "../Blocks/BlockHandler.h"
1037 ASSERT(
"Unknown item type!");
1038 return ItemAirHandler;
1050 if (
cBlockHandler::For(a_ClickedBlockType).DoesIgnoreBuildCollision(
World, a_HeldItem, a_ClickedPosition, a_ClickedBlockMeta, a_ClickedBlockFace,
true))
1053 if (!
CommitPlacement(a_Player, a_HeldItem, a_ClickedPosition, a_ClickedBlockFace, a_CursorPosition))
1064 const auto PlacePosition =
AddFaceDirection(a_ClickedPosition, a_ClickedBlockFace);
1074 if (!
cBlockHandler::For(PlaceBlock).DoesIgnoreBuildCollision(
World, a_HeldItem, PlacePosition, PlaceMeta, a_ClickedBlockFace,
false))
1084 if (!
CommitPlacement(a_Player, a_HeldItem, PlacePosition, a_ClickedBlockFace, a_CursorPosition))
1110 UNUSED(a_PluginInterface);
1112 UNUSED(a_ClickedBlockPos);
1113 UNUSED(a_ClickedBlockFace);
1125 const cItem & a_HeldItem,
1133 UNUSED(a_ClickedBlockPos);
1134 UNUSED(a_ClickedBlockFace);
1145 UNUSED(a_AttackedEntity);
1345 switch (a_BlockType)
1438 default:
return true;
@ E_BLOCK_ORANGE_GLAZED_TERRACOTTA
@ E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE
@ E_BLOCK_REDSTONE_LAMP_OFF
@ E_BLOCK_WHITE_SHULKER_BOX
@ E_BLOCK_NETHER_BRICK_STAIRS
@ E_BLOCK_PINK_SHULKER_BOX
@ E_BLOCK_PINK_GLAZED_TERRACOTTA
@ E_BLOCK_REDSTONE_TORCH_ON
@ E_BLOCK_STONE_PRESSURE_PLATE
@ E_BLOCK_BLUE_SHULKER_BOX
@ E_BLOCK_GRAY_GLAZED_TERRACOTTA
@ E_BLOCK_OAK_WOOD_STAIRS
@ E_BLOCK_STANDING_BANNER
@ E_BLOCK_DAYLIGHT_SENSOR
@ E_BLOCK_REDSTONE_REPEATER_ON
@ E_BLOCK_MAX_TYPE_ID
Maximum BlockType number used.
@ E_BLOCK_BROWN_SHULKER_BOX
@ E_BLOCK_DOUBLE_WOODEN_SLAB
@ E_BLOCK_COBBLESTONE_STAIRS
@ E_BLOCK_STATIONARY_LAVA
@ E_BLOCK_LIGHT_BLUE_SHULKER_BOX
@ E_BLOCK_BIRCH_FENCE_GATE
@ E_BLOCK_DARK_OAK_WOOD_STAIRS
@ E_BLOCK_REPEATING_COMMAND_BLOCK
@ E_BLOCK_BLACK_GLAZED_TERRACOTTA
@ E_BLOCK_ACACIA_FENCE_GATE
@ E_BLOCK_STONE_BRICK_STAIRS
@ E_BLOCK_ENCHANTMENT_TABLE
@ E_BLOCK_END_PORTAL_FRAME
@ E_BLOCK_PRISMARINE_BLOCK
@ E_BLOCK_RED_NETHER_BRICK
@ E_BLOCK_BLOCK_OF_REDSTONE
@ E_BLOCK_MOSSY_COBBLESTONE
@ E_BLOCK_STAINED_GLASS_PANE
@ E_BLOCK_MAGENTA_SHULKER_BOX
@ E_BLOCK_REDSTONE_ORE_GLOWING
@ E_BLOCK_BLUE_GLAZED_TERRACOTTA
@ E_BLOCK_BIRCH_WOOD_STAIRS
@ E_BLOCK_CYAN_SHULKER_BOX
@ E_BLOCK_LIME_SHULKER_BOX
@ E_BLOCK_CHAIN_COMMAND_BLOCK
@ E_BLOCK_NETHER_WART_BLOCK
@ E_BLOCK_PURPLE_SHULKER_BOX
@ E_BLOCK_PISTON_EXTENSION
@ E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB
@ E_BLOCK_JUNGLE_WOOD_STAIRS
@ E_BLOCK_YELLOW_GLAZED_TERRACOTTA
@ E_BLOCK_MAGENTA_GLAZED_TERRACOTTA
@ E_BLOCK_ACACIA_WOOD_STAIRS
@ E_BLOCK_ORANGE_SHULKER_BOX
@ E_BLOCK_CYAN_GLAZED_TERRACOTTA
@ E_BLOCK_INACTIVE_COMPARATOR
@ E_BLOCK_DOUBLE_STONE_SLAB
@ E_BLOCK_ACTIVE_COMPARATOR
@ E_BLOCK_RED_SANDSTONE_STAIRS
@ E_BLOCK_PISTON_MOVED_BLOCK
@ E_BLOCK_STRUCTURE_BLOCK
@ E_BLOCK_SPRUCE_FENCE_GATE
@ E_BLOCK_GRAY_SHULKER_BOX
@ E_BLOCK_LIGHT_BLUE_GLAZED_TERRACOTTA
@ E_BLOCK_SPRUCE_WOOD_STAIRS
@ E_BLOCK_YELLOW_SHULKER_BOX
@ E_BLOCK_DARK_OAK_FENCE_GATE
@ E_BLOCK_CONCRETE_POWDER
@ E_BLOCK_JUNGLE_FENCE_GATE
@ E_BLOCK_PURPLE_GLAZED_TERRACOTTA
@ E_BLOCK_HUGE_BROWN_MUSHROOM
@ E_BLOCK_WOODEN_PRESSURE_PLATE
@ E_BLOCK_HUGE_RED_MUSHROOM
@ E_BLOCK_GREEN_SHULKER_BOX
@ E_BLOCK_BLACK_SHULKER_BOX
@ E_BLOCK_REDSTONE_TORCH_OFF
@ E_BLOCK_LIGHT_GRAY_GLAZED_TERRACOTTA
@ E_BLOCK_NETHER_QUARTZ_ORE
@ E_BLOCK_LIGHT_GRAY_SHULKER_BOX
@ E_BLOCK_GREEN_GLAZED_TERRACOTTA
@ E_BLOCK_SANDSTONE_STAIRS
@ E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE
@ E_BLOCK_REDSTONE_REPEATER_OFF
@ E_BLOCK_PURPUR_DOUBLE_SLAB
@ E_BLOCK_LIME_GLAZED_TERRACOTTA
@ E_BLOCK_REDSTONE_LAMP_ON
@ E_BLOCK_INVERTED_DAYLIGHT_SENSOR
@ E_BLOCK_WHITE_GLAZED_TERRACOTTA
@ E_BLOCK_STATIONARY_WATER
@ E_BLOCK_COBBLESTONE_WALL
@ E_BLOCK_BROWN_GLAZED_TERRACOTTA
@ E_BLOCK_NETHER_BRICK_FENCE
@ E_BLOCK_RED_SANDSTONE_SLAB
@ E_BLOCK_RED_SHULKER_BOX
@ E_BLOCK_RED_GLAZED_TERRACOTTA
@ E_ITEM_POISONOUS_POTATO
@ E_ITEM_PRISMARINE_CRYSTALS
@ E_ITEM_MINECART_WITH_TNT
@ E_ITEM_IRON_HORSE_ARMOR
@ E_ITEM_GOLD_HORSE_ARMOR
@ E_ITEM_DIAMOND_CHESTPLATE
@ E_ITEM_MINECART_WITH_HOPPER
@ E_ITEM_MINECART_WITH_COMMAND_BLOCK
@ E_ITEM_REDSTONE_REPEATER
@ E_ITEM_DIAMOND_HORSE_ARMOR
@ E_ITEM_LINGERING_POTION
@ E_ITEM_DIAMOND_LEGGINGS
@ E_ITEM_FURNACE_MINECART
@ E_ITEM_GLISTERING_MELON
@ E_ITEM_TOTEM_OF_UNDYING
@ E_ITEM_CHAIN_CHESTPLATE
@ E_ITEM_PRISMARINE_SHARD
@ E_ITEM_BOTTLE_O_ENCHANTING
@ E_ITEM_POPPED_CHORUS_FRUIT
@ E_ITEM_FERMENTED_SPIDER_EYE
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
void AddFaceDirection(int &a_BlockX, int &a_BlockY, int &a_BlockZ, eBlockFace a_BlockFace, bool a_bInverse)
Modifies the specified coords so that they point to the block adjacent to the one specified through i...
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
Utilities to allow casting a cWorld to one of its interfaces without including World....
static const cBlockHandler & For(BLOCKTYPE a_BlockType)
This interface is used to decouple block handlers from the cPluginManager dependency through cWorld.
static bool IsValidHeight(Vector3i a_BlockPosition)
Validates a height-coordinate.
cWorld * GetWorld(void) const
bool Feed(int a_Food, double a_Saturation)
Adds to FoodLevel and FoodSaturationLevel, returns true if any food has been consumed,...
bool IsGameModeSurvival(void) const
Returns true if the player is in Survival mode, either explicitly, or by inheriting from current worl...
cInventory & GetInventory(void)
void SendBlocksAround(Vector3i a_BlockPos, int a_Range=1)
Sends the block in the specified range around the specified coord to the client as a block change pac...
void UseEquippedItem(short a_Damage=1)
Damage the player's equipped item by a_Damage, possibly less if the equipped item is enchanted.
bool PlaceBlock(Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Attempts to place the block in the world with a call to PlaceBlocks.
void SendEquippedSlot()
Sends the equipped item slot to the client.
bool RemoveOneEquippedItem(void)
Removes one item out of the currently equipped item stack, returns true if successful,...
virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) const
Returns the strength to break a specific block.
virtual void OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item) const
Called after the player has eaten this item.
virtual void OnEntityAttack(cPlayer *a_Attacker, cEntity *a_AttackedEntity) const
Called when a player attacks an entity with this item in hand.
static const cItemHandler & For(int a_ItemType)
virtual FoodInfo GetFoodInfo(const cItem *a_Item) const
Returns the FoodInfo for this item.
virtual bool IsDrinkable(short a_ItemDamage) const
Indicates if this item is drinkable.
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).
virtual bool CanRepairWithRawMaterial(short a_ItemType) const
Can the anvil repair this item, when a_Item is the second input?
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.
eDurabilityLostAction
Actions that may cause durability of an item may be lost, where the magnitude of the loss depends on ...
virtual bool IsPlaceable(void) const
Blocks simply get placed.
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.
virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) const
Get the durability lost which the item will get, when a specified action was performed.
virtual char GetMaxStackSize(void) const
Returns the maximum stack size for a given item.
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).
virtual bool EatItem(cPlayer *a_Player, cItem *a_Item) const
Lets the player eat a selected item.
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) const
Returns whether this tool / item can harvest a specific block (e.g.
virtual bool IsFood(void) const
Indicates if this item is food.
Handler for blocks that have 3 orientations (hay bale, log), specified by the upper 2 bits in meta.