<commit_before><?php

namespace BlockHorizons\BlockSniper\cloning;


use BlockHorizons\BlockSniper\Loader;
use pocketmine\block\Block;
use pocketmine\level\Position;
use pocketmine\math\Vector3;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\ByteArrayTag;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\Player;

class SchematicProcessor {

	private $loader;

	private $blocks = "";
	private $data = "";
	private $length = 1;
	private $width = 1;
	private $height = 1;

	public function __construct(Loader $loader) {
		$this->loader = $loader;
	}

	/**
	 * @param string $schematicName
	 *
	 * @return bool
	 */
	public function save(string $schematicName): bool {
		if(is_file($this->getSchematicFile($schematicName))) {
			return false;
		}
		$nbt = new NBT();
		$nbtCompound = new CompoundTag("Schematic", [
			new ByteArrayTag("Blocks", $this->blocks),
			new ByteArrayTag("Data", $this->data),
			new ShortTag("Length", $this->length),
			new ShortTag("Width", $this->width),
			new ShortTag("Height", $this->height),
			new StringTag("Materials", "Alpha")
		]);
		$nbt->setData($nbtCompound);

		file_put_contents($this->getSchematicFile($schematicName), $nbt->writeCompressed());
		foreach($this as $key => $value) {
			$key = null;
		}
		return true;
	}

	/**
	 * @param string $schematicName
	 *
	 * @return array|bool
	 */
	public function load(string $schematicName) {
		if(!is_file($this->getSchematicFile($schematicName))) {
			return false;
		}
		$nbt = new NBT();
		$nbt->readCompressed(file_get_contents($this->getSchematicFile($schematicName)));
		$values = $nbt->getData();

		var_dump($values);
		$this->blocks = $values->Blocks->getValue();
		$this->data = $values->Data->getValue();
		$this->height = (int) $values->Height->getValue();
		$this->width = (int) $values->Width->getValue();
		$this->length = (int) $values->Length->getValue();
		$blockInfo = [];

		for($x = 0; $x < $this->width; $x++) {
			for($y = 0; $y < $this->height; $y++) {
				for($z = 0; $z < $this->length; $z++) {
					$index = $y * $this->width * $this->length + $z * $this->width + $x;
					$blockInfo[] = [<commit_msg>Fixed schematic not finding any values.<commit_after><?php

namespace BlockHorizons\BlockSniper\cloning;


use BlockHorizons\BlockSniper\Loader;
use pocketmine\block\Block;
use pocketmine\level\Position;
use pocketmine\math\Vector3;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\ByteArrayTag;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\Player;

class SchematicProcessor {

	private $loader;

	private $blocks = "";
	private $data = "";
	private $length = 1;
	private $width = 1;
	private $height = 1;

	public function __construct(Loader $loader) {
		$this->loader = $loader;
	}

	/**
	 * @param string $schematicName
	 *
	 * @return bool
	 */
	public function save(string $schematicName): bool {
		if(is_file($this->getSchematicFile($schematicName))) {
			return false;
		}
		$nbt = new NBT();
		$nbtCompound = new CompoundTag("Schematic", [
			new ByteArrayTag("Blocks", $this->blocks),
			new ByteArrayTag("Data", $this->data),
			new ShortTag("Length", $this->length),
			new ShortTag("Width", $this->width),
			new ShortTag("Height", $this->height),
			new StringTag("Materials", "Alpha")
		]);
		$nbt->setData($nbtCompound);

		file_put_contents($this->getSchematicFile($schematicName), $nbt->writeCompressed());
		foreach($this as $key => $value) {
			$key = null;
		}
		return true;
	}

	/**
	 * @param string $schematicName
	 *
	 * @return array|bool
	 */
	public function load(string $schematicName) {
		if(!is_file($this->getSchematicFile($schematicName))) {
			return false;
		}
		$nbt = new NBT();
		$nbt->readCompressed(file_get_contents($this->getSchematicFile($schematicName)));
		$values = $nbt->getData();

		$this->blocks = $values["Blocks"];
		$this->data = $values["Data"];
		$this->height = (int) $values["Height"];
		$this->width = (int) $values["Width"];
		$this->length = (int) $values["Length"];
		$blockInfo = [];

		for($x = 0; $x < $this->width; $x++) {
			for($y = 0; $y < $this->height; $y++) {
				for($z = 0; $z < $this->length; $z++) {
					$index = $y * $this->width * $this->length + $z * $this->width + $x;
					$blockInfo[] = [
{'fraction_non_alphanumeric': 0.18557892304136817, 'fraction_numerical': 0.0032354980355904783, 'mean_word_length': 4.3432098765432094, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3138037', 'n_tokens_mistral': 1670, 'n_tokens_neox': 1520, 'n_words': 304}