# Block Coordinates

Minecraft saves a block's location with integer coordinates. This means that there are no decimals in each block's coordinates, while Skript uses decimals (+0.5) to get the exact centre of the block. They both work perfectly, the only trouble is in forgetting to convert from one to the other.

A visual representation of the points Minecraft and Skript use to represent a block's location:

<figure><img src="/files/oooLfYV5uzwxWeurfEYa" alt=""><figcaption></figcaption></figure>

When converting between the two you can add or subtract `0.5` respectively. The greatest integer (or floor) function can also be used to purge the decimal digits from a number.

Here is an example in code:

{% code overflow="wrap" lineNumbers="true" fullWidth="false" %}

```java
set {_location} to location of player's targeted block

#: Skript:
  set {_x} to {_location}'s x-coord
  set {_y} to {_location}'s y-coord
  set {_z} to {_location}'s z-coord

  set block at location({_x}, {_y}, {_z}, world "world") to diamond block

#: Minecraft:
  #: This will not work
  set {_x} to {_location}'s x-coord
  set {_y} to {_location}'s y-coord
  set {_z} to {_location}'s z-coord
  execute console command "/setblock %{_x}% %{_y}% %{_z}% diamond_block"

  #: This will work
  set {_x} to floor({_location}'s x-coord)
  set {_y} to floor({_location}'s y-coord)
  set {_z} to floor({_location}'s z-coord)
  execute console command "/setblock %{_x}% %{_y}% %{_z}% diamond_block"
```

{% endcode %}

... b/c ppl dont realise set block effect exists, set vars to coords and console commands


---

# 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://x8ight.gitbook.io/syntask/unfinished/block-coordinates.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.
