mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-23 00:55:57 +00:00
Use BedrockDataFiles in more places
This commit is contained in:
parent
9ae830fd54
commit
7608d5f04e
@ -27,14 +27,12 @@ use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\utils\Filesystem;
|
||||
use pocketmine\utils\SingletonTrait;
|
||||
use pocketmine\utils\Utils;
|
||||
use Symfony\Component\Filesystem\Path;
|
||||
use function array_keys;
|
||||
use function gettype;
|
||||
use function is_array;
|
||||
use function is_string;
|
||||
use function json_decode;
|
||||
use const JSON_THROW_ON_ERROR;
|
||||
use const pocketmine\BEDROCK_DATA_PATH;
|
||||
|
||||
/**
|
||||
* Tracks Minecraft Bedrock item tags, and the item IDs which belong to them
|
||||
@ -45,7 +43,7 @@ final class ItemTagToIdMap{
|
||||
use SingletonTrait;
|
||||
|
||||
private static function make() : self{
|
||||
$map = json_decode(Filesystem::fileGetContents(Path::join(BEDROCK_DATA_PATH, 'item_tags.json')), true, flags: JSON_THROW_ON_ERROR);
|
||||
$map = json_decode(Filesystem::fileGetContents(BedrockDataFiles::ITEM_TAGS_JSON), true, flags: JSON_THROW_ON_ERROR);
|
||||
if(!is_array($map)){
|
||||
throw new AssumptionFailedError("Invalid item tag map, expected array");
|
||||
}
|
||||
|
@ -23,15 +23,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\data\bedrock\item;
|
||||
|
||||
use pocketmine\data\bedrock\BedrockDataFiles;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\utils\Filesystem;
|
||||
use pocketmine\utils\SingletonTrait;
|
||||
use Symfony\Component\Filesystem\Path;
|
||||
use function array_flip;
|
||||
use function is_array;
|
||||
use function json_decode;
|
||||
use const JSON_THROW_ON_ERROR;
|
||||
use const pocketmine\BEDROCK_DATA_PATH;
|
||||
|
||||
/**
|
||||
* Bidirectional map of block IDs to their corresponding blockitem IDs, used for storing items on disk
|
||||
@ -41,7 +40,7 @@ final class BlockItemIdMap{
|
||||
|
||||
private static function make() : self{
|
||||
$map = json_decode(
|
||||
Filesystem::fileGetContents(Path::join(BEDROCK_DATA_PATH, 'block_id_to_item_id_map.json')),
|
||||
Filesystem::fileGetContents(BedrockDataFiles::BLOCK_ID_TO_ITEM_ID_MAP_JSON),
|
||||
associative: true,
|
||||
flags: JSON_THROW_ON_ERROR
|
||||
);
|
||||
|
@ -25,9 +25,9 @@ namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\crafting\CraftingManagerFromDataHelper;
|
||||
use pocketmine\crafting\json\ItemStackData;
|
||||
use pocketmine\data\bedrock\BedrockDataFiles;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\utils\SingletonTrait;
|
||||
use Symfony\Component\Filesystem\Path;
|
||||
|
||||
final class CreativeInventory{
|
||||
use SingletonTrait;
|
||||
@ -37,7 +37,7 @@ final class CreativeInventory{
|
||||
|
||||
private function __construct(){
|
||||
$creativeItems = CraftingManagerFromDataHelper::loadJsonArrayOfObjectsFile(
|
||||
Path::join(\pocketmine\BEDROCK_DATA_PATH, "creativeitems.json"),
|
||||
BedrockDataFiles::CREATIVEITEMS_JSON,
|
||||
ItemStackData::class
|
||||
);
|
||||
foreach($creativeItems as $data){
|
||||
|
Loading…
x
Reference in New Issue
Block a user