• Stars
    star
    206
  • Rank 190,504 (Top 4 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 5 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PHP library to automatically detect and remove unused chunks from Minecraft worlds.

Thanos

About

Thanos is a PHP library to automatically detect and remove unused chunks from Minecraft worlds. This can reduce the file size of a world by more than 50%.

Other than existing tools, this library does not use blocklists. Instead, the inhabited time value is used to determine whether a chunk is used or not. This prevents used chunks from sometimes being removed by accident and makes this library compatible with most mods and plugins.

Currently, only the Minecraft Anvil world format (Minecraft Java Edition) is supported.

Installation

composer require aternos/thanos

Usage

CLI tool

This library includes a simple cli tool.

./thanos.php /path/to/world/directory [/path/to/output/directory]

Worlds

A world object represents a Minecraft world with all its files. It allows iteration over all chunks and provides a function to copy all non-region files to the output directory.

$world = new Aternos\Thanos\World\AnvilWorld("/path/to/world/directory", "/path/to/output/directory");
$world->copyOtherFiles(); //copy non-region files

foreach ($world as $chunk){
  echo $chunk->getInhabitedTime() . "\n"; //output inhabited time for each chunk
}

After iterating over all chunks of a region file, it will be automatically saved to the output directory.

Methods

getPath() : string Get world directory path

getDestination() : string Get world output directory

getOtherFiles() : string[] Get all files, that are not region directories

copyOtherFiles() : void Copy all files, that are not region directories, to the output directory

static isWorld(string $path) : bool Check if $path is world directory

Chunks

A chunk object represents a Minecraft world chunk. Due to performance reasons, chunk data is not completely parsed but only used to find metadata that helps to determine whether a chunk is used.

if($chunk->getInhabitedTime() > 0){
  $chunk->save();
}

If a chunk is not marked as saved, it will not be written to the output directory.

Methods

getOffset() : int Get offset of chunk data within the region file

getLength() : int Get length of raw chunk data

getData() : string Get raw chunk data

getInhabitedTime() : int Get InhabitedTime value from chunk data. Returns -1 if InhabitedTime could not be read.

getLastUpdate() : int Get LastUpdate value from chunk data. Returns -1 if LastUpdate could not be read.

setTimestamp(int $timestamp) : void Set last modification time

getTimestamp() : int Get last modification time

save() : void Mark chunk as saved

isSaved() : bool Check whether this chunk is marked as saved

Thanos

Thanos automatically finds unused chunks in a world and reduces them to atoms.

$thanos = new Aternos\Thanos\Thanos();
$thanos->setMaxInhabitedTime(0);
$world = new Aternos\Thanos\World\AnvilWorld("/path/to/world/directory", "/path/to/output/directory");
$removedChunks = $thanos->snap($world);
echo "Removed $removedChunks chunks\n";

Methods

setMinInhabitedTime(int $minInhabitedTime) : void Set min inhabited time for a chunk to not be removed

getMinInhabitedTime() : int Get min inhabited time

snap(WorldInterface $world) : int Remove unused chunks, returns the amount of chunks removed

More Repositories

1

mclogs

Paste, share and analyse Minecraft logs
PHP
178
star
2

modbot

An open source moderation bot with advanced features developed by Aternos.
JavaScript
125
star
3

codex-minecraft

PHP library to read, parse, print and analyse Minecraft log files.
PHP
31
star
4

php-etcd

PHP gRPC client for etcd v3
PHP
24
star
5

php-model

PHP library for simple and complex database models.
PHP
17
star
6

renderchest

PHP library for rendering icons for Minecraft items directly from Minecraft's assets
PHP
17
star
7

curseforge-api

Simple CurseForge API
JavaScript
14
star
8

php-nbt

A full PHP implementation of Minecraft's Named Binary Tag (NBT) format.
PHP
14
star
9

mclogs-fabric

A Fabric mod to easily share and analyse your server logs with mclo.gs
Java
12
star
10

codex

PHP library to read, parse, print and analyse log files.
PHP
10
star
11

mclogs-bukkit

A Bukkit plugin to easily share and analyse your server logs with mclo.gs
Java
10
star
12

hawk

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

armarius

A JavaScript library to read, write, and merge ZIP archives in web browsers.
JavaScript
8
star
14

mclogs-java

Java library for mclogs
Java
8
star
15

mclogs-forge

A Forge mod to easily share and analyse your server logs with mclo.gs
Java
6
star
16

consul-leader

Consul leader election and retirement.
JavaScript
6
star
17

php-lock

Distributed exclusive and shared resource locking based on etcd
PHP
5
star
18

plop

Generate Minecraft function files to make structures plop into existence in Vanilla Minecraft
PHP
5
star
19

taskmaster

Object-oriented PHP library for running tasks in parallel
PHP
4
star
20

php-curseforge-api

PHP Client for the CurseForge API.
PHP
4
star
21

motdgg-bukkit

Java
3
star
22

sherlock

PHP library to apply minecraft mappings to log files
PHP
3
star
23

php-hangar-api

PHP Client for the Hangar API. This client is based on the openapi spec.
PHP
2
star
24

docker-bedrock-server-environment

A docker image for running bedrock servers
Dockerfile
1
star
25

php-rados-ffi

An object oriented PHP library for using librados with FFI.
PHP
1
star
26

php-modrinth-api

PHP Client for the Modrinth API. This client is based on the openapi spec.
PHP
1
star
27

php-serializer

A PHP library for (de-)serialization using attributes and reflection
PHP
1
star