# IBlock

| Methods                |
| ---------------------- |
| GetId                  |
| GetMetadata            |
| GetLocation            |
| GetBlockEntityData     |
| MoveTo                 |
| MoveToRange            |
| MoveToInteractionRange |
| IsBotStandingOn        |
| IsEntityStandingOn     |
| IsInteractiveRange     |
| GetVisibleFaces        |
| GetVisibleFacesFrom    |
| GetPlaceableFaces      |
| IsInvisible            |
| IsInvisibleFrom        |
| IsSafeToMine           |
| IsBlockDangerous       |
| IsSolid                |
| IsLiquid               |
| IsMineable             |
| IsAir                  |
| IsTransparent          |
| IsUndesirableForPath   |
| Use                    |
| Dig                    |
| Hit                    |
| LookAt                 |
| LookAtSmooth           |
| PlaceOn                |
| PlaceAt                |

## Methods

### GetId

Returns the Minecraft Block ID of the block.\
References: <https://minecraft-ids.grahamedgecombe.com/>

```csharp
ushort GetId();
```

### GetMetadata

Returns the Metadata of the block as a byte (0-255).

```csharp
byte GetMetadata();
```

### GetLocation

Returns the location of the block.

```csharp
ILocation GetLocation();
```

### GetBlockEntityData

Returns block entity data (e.g.: sign text) for blocks that have it, otherwise null is returned. The returned type is IBlockEntity data which by it self has a Type property, which further specifies the entity data type (e.g.: sign).\
A full list of BlockEntity types can be found [here](https://github.com/OnlyQubes/OQ.MineBot.PluginBase/tree/master/Classes/Blocks/BlockEntities).

```csharp
IBlockEntity GetBlockEntityData();
// the result is a generic type which can then be converted like this:
// if(blockEntityData.Type == BlockEntityType.Sign) {
//     var convertedData = (SignBlockEntity)blockEntityData;
//     var signText = convertedData.GetContinuousText();
// }
```

### MoveTo

Attempts to move the bot onto this block. This is a wrapper function for [Player.MoveTo](https://docs.minecraftbot.com/api/context/player#moveto), for more information check that.

```csharp
IMoveTask MoveTo(MapOptions options = null);
```

### MoveToRange

Attempts to move the bot into the specified range of this block. You must specify the max distance that we can be from this block to still be considered in range. This is a wrapper function for [Player.MoveToRange](https://docs.minecraftbot.com/api/context/player#movetorange), for more information check that.

```csharp
IMoveTask MoveToRange(int maxRange, MapOptions options = null);
```

### MoveToInteractionRange

Attempts to move the bot to a location that it can interact with this block from. The function considers the visibility and bot's reach. This is a wrapper function for [Player.MoveToInteractionRange](https://docs.minecraftbot.com/api/context/player#movetointeractionrange), for more information check that.

```csharp
IMoveTask MoveToInteractionRange(MapOptions options = null);
```

### IsBotStandingOn

Returns true if this bot is standing on the given block, otherwise false.

```csharp
bool IsBotStandingOn();
```

### IsEntityStandingOn

Returns true if there is an entity that is standing on the block, otherwise false. If the output is true then the out parameter entities will contain a list of entities that are on the block.\
Note: *this does not include this bot's entity.*

```csharp
bool IsEntityStandingOn(out IEntity[] entities);
```

### IsInInteractionRange

Returns True if the block is within the interaction range (around 5 blocks) of the bot, otherwise false.

```csharp
bool IsInInteractionRange();
```

### GetVisibleFaces

Returns the faces (sides) that the bot can see from the current location of this block. This will be at most 3 faces.&#x20;

```csharp
FaceData[] GetVisibleFaces();
```

### GetVisibleFacesFrom

Returns the faces (sides) of this block that the bot could see from the given eye position. Eye position for the player is `feetPosition + 1.65`. This will be at most 3 faces.

```csharp
FaceData[] GetVisibleFacesFrom(IPosition eyePosition);
```

### GetPlaceableFaces

Returns the faces of this block that can be placed on (i.e.: don't have a block already attached to it).

```csharp
FaceData[] GetPlaceableFaces();
```

### IsVisibleFrom

Returns true if the bot would have direct line-of-sight to this block at a given eye position, otherwise false. Eye position for the player is `feetPosition + 1.65`.

```csharp
bool IsVisibleFrom(IPosition eyePosition);
```

### IsVisible

Wrapper function for **IsVisibleFrom** where IsVisibleFrom gets called with the bot's current eye position.

```csharp
bool IsVisible();
```

### IsSafeToMine

Returns true if mining this block would harm us in any way, otherwise false. By default this only considers the current bot instance, however the parameter regardOtherBots can enable checks for other bots safety as well.\
Note: *This accounts for things such as lava flowing into us, sand falling ontop of us, us falling down a cave, and almost any scenario where it would harm us.*

```csharp
bool IsSafeToMine(bool regardOtherBots = false);
```

### IsBlockDangerous

Returns true if the block will damage the player if we are near it or stand on it, otherwise false.\
Note: *Examples include Lava, Cactus, Magma Block, etc.*

```csharp
bool IsBlockDangerous();
```

### IsSolid

Returns true if the block is solid, otherwise false.\
Note: *Examples include stone, dirt, wooden planks, etc.*

```csharp
bool IsSolid();
```

### IsLiquid

Returns true if the block is a liquid (water or lava), otherwise false.

```csharp
bool IsLiquid();
```

### IsMineable

Returns true if the block is mineable, otherwise false.\
Note: *This does not account for tool inequality such as mining obsidian with iron pickaxes, this is just for if the block will ever be mineable such as mining water, bedrock, void, etc.*

```csharp
bool IsMineable();
```

### IsAir

Returns true if the block is an Air block (empty), otherwise false.

```csharp
bool IsAir();
```

### IsTransparent

Returns true if the block is transparent, otherwise false.\
Note: *Examples include torches, rails, signs, pressure plates, etc.*

```csharp
bool IsTransparent();
```

### IsUndesireableForPath

Returns true if there are any objects in the path that can slow the bot down, harm it, or get it stuck.\
Note: *This includes things like slime blocks, mob heads, lava, fences, etc.*

```csharp
bool IsUndesirableForPath();
```

### Use

Right clicks on the given block. This will consider visibility of the faces (sides) and will rotate the bots head to face the correct face (side), however it will not move the bot to the block (that is up to the developer to do).

```csharp
Task Use();
```

### Dig

Attempts to break this block. You can optionally specify the face (side) that will be used to dig the block. This does rotate the bots head to the appropriate block's face.\
If no face data is specified and no visible face is found then it will default to breaking the block using the Top (+Y) face.

The function returns `Task<IDigAction>` which completes once the block is broken or instantly if the dig action was invalid (e.g.: attempting to break bedrock). The variables `cancelled` and/or `completed` can be used to determine the dig actions outcome.

```csharp
Task<IDigAction> Dig();
Task<IDigAction> Dig(sbyte face);
Task<IDigAction> Dig(FaceData faceData);
```

### Hit

Hits (left clicks) the given block. This will consider visibility of the faces (sides) and will rotate the bots head to face the correct face (side), however it will not move the bot to the block (that is up to the developer to do).

```csharp
Task Hit();
```

### LookAt

Looks at the given block. If no parameter is provided then the bot will look at the center of the block, however optionally you can specify the face (side) of the block to look at.\
Note: *you can find a list of the faces and their corresponding information* [*here*](https://docs.minecraftbot.com/api/context/world#placeon)*.*

```csharp
Task LookAt(FaceData faceData = null);
Task LookAt(sbyte face);
```

### LookAtSmooth

Smoothly (slowly, per multiple ticks) looks at the given block. If no parameter is provided then the bot will look at the center of the block, however optionally you can specify the face (side) of the block to look at. You should await for this function to complete, as the rotation time is dynamic. You can optionally specify the look speed, however it is recommended to leave it as 'auto'.

```csharp
Task LookAtSmooth(FaceData faceData = null, LookSpeed speed = LookSpeed.auto);
Task LookAtSmooth(sbyte face, LookSpeed speed = LookSpeed.auto);
```

### PlaceAt

Attempts to place a block that the bot is currently holding (does not validate if the bot is holding a block, that is up to the developer) at this location. This is done by getting the nearby block faces and checking whether we can place on them. **This does consider the visibility of faces**. If no visible face is found then false is returned, otherwise true.\
Note: *this does not check whether the server cancelled the block placement (removed the placed block), nor does this function move the player to the range of the block (that is up to developer to do).*

```csharp
Task<bool> PlaceAt();
```

### PlaceOn

Attempts to place a block that the bot is currently holding by right clicking on this block's specified face (side). The visibility of a face is not verified.\
Note: *this function does not move the player to the range of the block (that is up to developer to do).*\
*You can find a list of the faces and their corresponding information* [*here*](https://docs.minecraftbot.com/api/context/world#placeon)*.*

```csharp
Task PlaceOn(FaceData faceData);
Task PlaceOn(sbyte face);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.minecraftbot.com/api/context/world/iblock.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
