# Block API

## Setup

{% tabs %}
{% tab title="Gradle" %}

```gradle
repositories {
    mavenCentral()
}

dependencies {
    modImplementation 'dev.creoii.creoapi:creo-block-api:<VERSION>'
}
```

{% endtab %}

{% tab title="Kotlin" %}

```gradle
repositories {
    mavenCentral()
}

dependencies {
    modImplementation("dev.creoii.creoapi:creo-block-api:<VERSION>")
}
```

{% endtab %}
{% endtabs %}

## CreoBlock

{% code title="CreoBlock.java" %}

```java
// Called when an entity is looking at the block.
void onLookedAt(World world, BlockState state, BlockHitResult hitResult, Entity looker, double squaredDistance);

// Called when a block is placed by a structure block, after data structure blocks have been processed.
void onPlacedByStructure(ServerWorldAccess world, BlockPos pos, BlockState state, FluidState fluidState, Random random, BlockPos pivot, StructureTemplate structureTemplate, StructurePlacementData placementData, StructureTemplate.StructureBlockInfo structureBlockInfo);

// Determines whether CreoBlock#onAdjacentEntityCollision can be called.
boolean canEntityCollideAdjacent(Entity entity, BlockState state, BlockPos pos);

// Called when an entity is next to a block but not actually colliding with it.
void onAdjacentEntityCollision(Entity entity, BlockState state, BlockPos pos);

// Called client-side to render a blockstate as an overlay to the block.
BlockState getOverlayState(BlockState state, BlockPos pos, Random random);
```

{% endcode %}

## Spreadable


---

# 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.creoii.dev/creo-api/packages/block-api.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.
