PHPackages                             aternos/hawk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. aternos/hawk

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

aternos/hawk
============

PHP library to get, replace and delete blocks/entities out of Minecraft region files

v1.7.0(2mo ago)93.0k↓72.7%2MITPHPPHP &gt;=8.0CI failing

Since May 31Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/aternosorg/hawk)[ Packagist](https://packagist.org/packages/aternos/hawk)[ RSS](/packages/aternos-hawk/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (4)Versions (17)Used By (0)

Hawk
====

[](#hawk)

### About

[](#about)

Hawk is a PHP library to get and/or replace blocks and get and/or delete entities in Minecraft region files. This allows the user to replace blocks or delete entities that will crash the server when loaded.

Currently, following versions are supported:

```
1.12+ for entities
1.16+ for blocks

```

### Installation

[](#installation)

```
composer require aternos/hawk
```

Usage
-----

[](#usage)

### Class File

[](#class-file)

How to get a file from disk:

```
$file = new File("your/region/file");
```

How to use setContent() to set up a file stream and getContent() to get the content out of the stream:

```
$file = new File();
$file->setContent(file_get_contents("your/region/file"));
$file->setFileName("your/file/name");
"...do stuff here..."
$contentToBeWritten = $file->getContent();
```

### Class Hawk

[](#class-hawk)

#### Setups:

[](#setups)

Setup for blocks and block entities in any supported version:

```
// New block coordinates
$blockPos = new McCoordinates3D(1, 2, 3);

// Path to your region file and calculating the filename from the coordinates
$inputPath = "/your/world/region/directory";
$blockFiles[] = new File($inputPath . "/" . Region::getRegionFileNameFromBlock($blockPos));

// Instantiating Hawk only with blockFiles
$hawk = new Hawk(blockFiles: $blockFiles);
```

Setup for entities prior 1.17:

```
// New entity coordinates
$entityPos = new McCoordinatesFloat(1.2, 2.3, 3.4);

// Path to your region file and calculating the filename from the coordinates
$inputPath = "/your/world/region/directory";
$entitiesFiles[] = new File($inputPath . "/" . Region::getRegionFileNameFromBlock(McCoordinatesFloat::get3DCoordinates($entityPos)));

// Instantiating Hawk only with blockFiles because entities used to be in the same file
$hawk = new Hawk(blockFiles: $entitiesFiles);
```

Setup for entities starting from 1.17:

```
// Path to your entities directory and calculating the filename from the coordinates
$inputPath = "/your/world/entities/directory";
$entitiesFiles[] = new File($inputPath . "/" . Region::getRegionFileNameFromBlock(McCoordinatesFloat::get3DCoordinates($entityPos)));

$hawk = new Hawk(entitiesFiles: $entitiesFiles);
```

#### How to read a block:

[](#how-to-read-a-block)

```
$block = $hawk->getBlock($blockPos);
```

#### How to replace a block at x = 1, y = 2, z = 3 with wool(default is minecraft:stone):

[](#how-to-replace-a-block-at-x--1-y--2-z--3-with-wooldefault-is-minecraftstone)

```
$hawk->replaceBlock($blockPos, "minecraft:wool");
$hawk->save();
```

#### Get all entities in a specific chunk:

[](#get-all-entities-in-a-specific-chunk)

```
$entities = $hawk->getAllEntitiesFromChunk(McCoordinatesFloat::get3DCoordinates($entityPos));
```

#### How to get all entities next to float coordinates (there could be more than just one):

[](#how-to-get-all-entities-next-to-float-coordinates-there-could-be-more-than-just-one)

```
$entities = $hawk->getEntities($entityName,$entityPos);
```

#### How to delete an entity:

[](#how-to-delete-an-entity)

```
$entities = $hawk->getEntities($entityName,$entityPos);
$hawk->deleteEntity($entities[0]);
$hawk->save();
```

#### Get all block entities in a specific chunk:

[](#get-all-block-entities-in-a-specific-chunk)

```
$entities = $hawk->getAllBlockEntitiesFromChunk(McCoordinatesFloat::get3DCoordinates($entityPos));
```

#### How to get all block entities next to float coordinates (there could be more than just one):

[](#how-to-get-all-block-entities-next-to-float-coordinates-there-could-be-more-than-just-one)

```
$entities = $hawk->getBlockEntities($entityName,$entityPos);
```

#### How to delete a block entity:

[](#how-to-delete-a-block-entity)

```
$entities = $hawk->getBlockEntities($entityName,$entityPos);
$hawk->deleteBlockEntity($entities[0]);
$hawk->save();
```

For more information see these examples: [getBlock.php](examples/getBlock.php), [replaceBlock.php](examples/replaceBlock.php), [getEntity.php](examples/getEntity.php), [getAllEntitiesInChunk.php](examples/getAllEntitiesInChunk.php), [deleteEntity.php](examples/deleteEntity.php).

#### Methods

[](#methods)

NameReturn typeDescriptionloadBlockRegions([File](src/File.php)\[\] $files)voidLoad extra "block"("world/region") regions from $files into HawkloadEntitiesRegions([File](src/File.php)\[\] $files)voidLoad extra "entities"("world/entities") regions from $files into HawkgetBlockRegionFromBlock([McCoordinates3D](src/McCoordinates3D.php) $coordinates)[Region](src/BlockRegion.php)Get block region from block at $coordinatesgetEntitiesRegionFromBlock([McCoordinates3D](src/McCoordinates3D.php) $coordinates)[Region](src/BlockRegion.php)Get entities region from block at $coordinates (see McCoordinatesFloat::get3DCoordinates for entity coords)getBlock([McCoordinates3D](src/McCoordinates3D.php) $coordinates)[DataBlock](src/DataBlock.php)Get block at $coordinatesreplaceBlock([McCoordinates3D](src/McCoordinates3D.php) $coordinates, string $blockName = "minecraft:stone")voidReplace block at $coordinates with block $blockNamegetEntities(string $name, [McCoordinatesFloat](src/McCoordinatesFloat.php) $coordinates)[Entity](src/Entity.php)\[\]Gets one or multiple entities at $coordinatesgetAllEntitiesFromChunk([McCoordinates3D](src/McCoordinates3D.php) $blockCoordinates)[Entity](src/Entity.php)\[\]Gets all entities in chunk based on $coordinatesdeleteEntity([Entity](src/Entity.php) $entity)voidDeletes an entity objectgetEntities(string $name, [McCoordinatesFloat](src/McCoordinatesFloat.php) $coordinates)[Entity](src/Entity.php)\[\]Gets one or multiple entities at $coordinatesgetAllEntitiesFromChunk([McCoordinates3D](src/McCoordinates3D.php) $blockCoordinates)[Entity](src/Entity.php)\[\]Gets all entities in chunk based on $coordinatesdeleteEntity([Entity](src/Entity.php) $entity)voidDeletes an entity objectsave()voidSave changes to file### Class Region

[](#class-region)

A region object represents a Minecraft region file. The main tasks of a region object is to read/decompress and write/compress chunks from/to its region file. Additionally, it provides static functions to calculate region coordinates and its file name.

#### Methods

[](#methods-1)

NameReturn typeDescriptionstatic getRegionFileNameFromBlock([McCoordinates3D](src/McCoordinates3D.php) $coordinates)stringGet region file name out of block coordinatesstatic getRegionCoordinatesFromFile([AbstractFile](src/AbstractFile.php) $file)[McCoordinates2D](src/McCoordinates2D.php)Get region coordinates from file namestatic getRegionCoordinatesFromBlockCoordinates([McCoordinates3D](src/McCoordinates3D.php) $coordinates)[McCoordinates2D](src/McCoordinates2D.php)Get region coordinates from block coordinatesstatic getRegionCoordinatesFromChunkCoordinates([McCoordinates2D](src/McCoordinates2D.php) $coordinates)[McCoordinates2D](src/McCoordinates2D.php)Get region coordinates from chunk coordinates### Class Chunk

[](#class-chunk)

A chunk object represents a Minecraft chunk in Mojangs [chunk format](https://minecraft.fandom.com/wiki/Chunk_format). The main task of a chunk object is to replace the sections tag of the NBT structure, compress the new chunk data and provide it to its region. Additionally, it provides a static function to calculate chunk coordinates.

#### Methods

[](#methods-2)

NameReturn typeDescriptionstatic getChunkCoordinates([McCoordinates3D](src/McCoordinates3D.php) $coordinates)[McCoordinates2D](src/McCoordinates2D.php)Get chunk coordinates from block coordinates### Class Section

[](#class-section)

A section object represents a single section tag.

#### Methods

[](#methods-3)

NameReturn typeDescriptionstatic getSectionCoordinates([McCoordinates3D](src/McCoordinates3D.php) $coordinates)[McCoordinates3D](src/McCoordinates3D.php)Get section coordinates from block coordinatesstatic getBlockCoordinates([McCoordinates3D](src/McCoordinates3D.php) $coordinates)[McCoordinates3D](src/McCoordinates3D.php)Get block coordinates relative to its section

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance84

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 70.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~116 days

Recently: every ~274 days

Total

13

Last Release

89d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/182e603c02f308d1036a1ecaba0b994665e87d13a86ff4550a96c9189a92c544?d=identicon)[aternos](/maintainers/aternos)

---

Top Contributors

[![rico132](https://avatars.githubusercontent.com/u/83093843?v=4)](https://github.com/rico132 "rico132 (55 commits)")[![matthi4s](https://avatars.githubusercontent.com/u/8943286?v=4)](https://github.com/matthi4s "matthi4s (20 commits)")[![pavog](https://avatars.githubusercontent.com/u/4786628?v=4)](https://github.com/pavog "pavog (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aternos-hawk/health.svg)

```
[![Health](https://phpackages.com/badges/aternos-hawk/health.svg)](https://phpackages.com/packages/aternos-hawk)
```

###  Alternatives

[aternos/thanos

Simple library to detect and remove unused chunks from a Minecraft world.

267587.5k](/packages/aternos-thanos)[endclothing/prometheus_client_php

Prometheus instrumentation library for PHP applications.

1511.9M10](/packages/endclothing-prometheus-client-php)[tuupola/base58

Base58 encoder and decoder for arbitrary data

56651.7k25](/packages/tuupola-base58)[skywarth/chaotic-schedule

Randomize scheduled command execution time and date intervals

12252.0k](/packages/skywarth-chaotic-schedule)[glpi-project/tools

Various tools for GLPI and its plugins

13743.2k4](/packages/glpi-project-tools)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
