6 #include "../Entities/Player.h"
7 #include "../Blocks/BlockCocoaPod.h"
29 const cItem & a_HeldItem,
66 auto CocoaPos =
AddFaceDirection(a_ClickedBlockPos, a_ClickedBlockFace,
false);
118 if (a_World.
GrowPlantAt(a_BlockPos, NumStages) <= 0)
227 auto DoubleGrassCount = Random.RandInt(8U);
228 auto GrassCount = Random.RandInt(8U, 24U);
229 auto FlowerCount = Random.RandInt(8U);
232 while ((DoubleGrassCount > 0) || (GrassCount > 0) || (FlowerCount > 0))
235 if (DoubleGrassCount != 0)
237 FindAdjacentGrassAnd<&GrowDoubleTallGrass>(a_World, a_Position);
244 FindAdjacentGrassAnd<&GrowTallGrass>(a_World, a_Position);
249 if (FlowerCount != 0)
251 FindAdjacentGrassAnd<&GrowFlower>(a_World, a_Position);
262 const auto Above = a_Position.
addedY(1);
282 switch (Random.RandInt(8))
305 switch (Random.RandInt(8))
335 switch (Random.RandInt(1))
347 template <auto Planter>
351 auto Position = a_Position;
361 Random.RandInt(-1, 1),
362 Random.RandInt(-1, 1) * (Random.RandInt(2) / 2),
363 Random.RandInt(-1, 1)
373 Position = a_Position;
379 const auto TwoAbove = Position.
addedY(2);
387 const auto PlantBase = Position.
addedY(1);
394 Planter(a_World, PlantBase);
@ E_META_TALL_GRASS_GRASS
@ E_META_FLOWER_RED_TULIP
@ E_META_BIG_FLOWER_ROSE_BUSH
@ E_META_FLOWER_OXEYE_DAISY
@ E_META_BIG_FLOWER_SUNFLOWER
@ E_META_BIG_FLOWER_DOUBLE_TALL_GRASS
@ E_META_FLOWER_PINK_TULIP
@ E_META_FLOWER_WHITE_TULIP
@ E_META_BIG_FLOWER_LILAC
@ E_META_FLOWER_ORANGE_TULIP
@ E_META_FLOWER_BLUE_ORCHID
@ E_META_BIG_FLOWER_PEONY
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.
@ PARTICLE_HAPPY_VILLAGER
MTRand & GetRandomProvider()
Returns the current thread's random number source.
static NIBBLETYPE BlockFaceToMeta(eBlockFace a_BlockFace)
This interface is used to decouple block handlers from the cPluginManager dependency through cWorld.
static bool IsValidHeight(Vector3i a_BlockPosition)
Validates a height-coordinate.
bool IsGameModeSurvival(void) const
Returns true if the player is in Survival mode, either explicitly, or by inheriting from current worl...
cInventory & GetInventory(void)
bool IsGameModeAdventure(void) const
Returns true if the player is in Adventure mode, either explicitly, or by inheriting from current wor...
bool PlaceBlock(Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Attempts to place the block in the world with a call to PlaceBlocks.
IntType RandInt(IntType a_Min, IntType a_Max)
Return a random IntType in the range [a_Min, a_Max].
bool RemoveOneEquippedItem(void)
Removes one item out of the currently equipped item stack, returns true if successful,...
This class bridges a vector of cItem for safe access via Lua.
void Add(const cItem &a_Item)
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.
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).
static void GrowPlantsAround(cWorld &a_World, const Vector3i a_Position)
Grows new plants around the specified block.
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 funct...
static bool FertilizePlant(cWorld &a_World, Vector3i a_BlockPos)
Attempts to use the bonemeal on the plant at the specified (absolute) position.
static void GrowTallGrass(cWorld &a_World, const Vector3i a_Position)
constexpr cItemHandler(int a_ItemType)
Vector3< T > addedY(T a_AddY) const
Returns a copy of this vector moved by the specified amount on the y axis.
int GrowPlantAt(Vector3i a_BlockPos, int a_NumStages=1)
Grows the plant at the specified position by at most a_NumStages.
BLOCKTYPE GetBlock(Vector3i a_BlockPos) const
Returns the block type at the specified position.
bool GetBlockTypeMeta(Vector3i a_BlockPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
Retrieves the block type and meta at the specified coords.
virtual void BroadcastSoundParticleEffect(const EffectID a_EffectID, Vector3i a_SrcPos, int a_Data, const cClientHandle *a_Exclude=nullptr) override
void SpawnItemPickups(const cItems &a_Pickups, Vector3i a_BlockPos, double a_FlyAwaySpeed=1.0, bool a_IsPlayerCreated=false)
Spawns item pickups for each item in the list.
EMCSBiome GetBiomeAt(int a_BlockX, int a_BlockZ)
Returns the biome at the specified coords.
void SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.