Shovel: Flatten grass blocks to paths
This commit is contained in:
parent
5dbc36142c
commit
a713b568e1
@ -98,4 +98,45 @@ public:
|
|||||||
}
|
}
|
||||||
return Super::GetBlockBreakingStrength(a_Block);
|
return Super::GetBlockBreakingStrength(a_Block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
if ((a_ClickedBlockFace == BLOCK_FACE_NONE) || (a_ClickedBlockPos.y >= cChunkDef::Height))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Need air above the flattened block to transform it:
|
||||||
|
BLOCKTYPE UpperBlockType = a_World->GetBlock(a_ClickedBlockPos.addedY(1));
|
||||||
|
if (UpperBlockType != E_BLOCK_AIR)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can only transform grass blocks:
|
||||||
|
BLOCKTYPE BlockType;
|
||||||
|
NIBBLETYPE BlockMeta;
|
||||||
|
a_World->GetBlockTypeMeta(a_ClickedBlockPos, BlockType, BlockMeta);
|
||||||
|
if (BlockType != E_BLOCK_GRASS)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transform:
|
||||||
|
a_World->SetBlock(a_ClickedBlockPos, E_BLOCK_GRASS_PATH, 0);
|
||||||
|
a_World->BroadcastSoundEffect("item.shovel.flatten", a_ClickedBlockPos + Vector3d(0.5, 0.5, 0.5), 1.0f, 0.8f);
|
||||||
|
a_Player->UseEquippedItem();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user