mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +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\Filesystem;
|
||||||
use pocketmine\utils\SingletonTrait;
|
use pocketmine\utils\SingletonTrait;
|
||||||
use pocketmine\utils\Utils;
|
use pocketmine\utils\Utils;
|
||||||
use Symfony\Component\Filesystem\Path;
|
|
||||||
use function array_keys;
|
use function array_keys;
|
||||||
use function gettype;
|
use function gettype;
|
||||||
use function is_array;
|
use function is_array;
|
||||||
use function is_string;
|
use function is_string;
|
||||||
use function json_decode;
|
use function json_decode;
|
||||||
use const JSON_THROW_ON_ERROR;
|
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
|
* Tracks Minecraft Bedrock item tags, and the item IDs which belong to them
|
||||||
@ -45,7 +43,7 @@ final class ItemTagToIdMap{
|
|||||||
use SingletonTrait;
|
use SingletonTrait;
|
||||||
|
|
||||||
private static function make() : self{
|
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)){
|
if(!is_array($map)){
|
||||||
throw new AssumptionFailedError("Invalid item tag map, expected array");
|
throw new AssumptionFailedError("Invalid item tag map, expected array");
|
||||||
}
|
}
|
||||||
|
@ -23,15 +23,14 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\data\bedrock\item;
|
namespace pocketmine\data\bedrock\item;
|
||||||
|
|
||||||
|
use pocketmine\data\bedrock\BedrockDataFiles;
|
||||||
use pocketmine\utils\AssumptionFailedError;
|
use pocketmine\utils\AssumptionFailedError;
|
||||||
use pocketmine\utils\Filesystem;
|
use pocketmine\utils\Filesystem;
|
||||||
use pocketmine\utils\SingletonTrait;
|
use pocketmine\utils\SingletonTrait;
|
||||||
use Symfony\Component\Filesystem\Path;
|
|
||||||
use function array_flip;
|
use function array_flip;
|
||||||
use function is_array;
|
use function is_array;
|
||||||
use function json_decode;
|
use function json_decode;
|
||||||
use const JSON_THROW_ON_ERROR;
|
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
|
* 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{
|
private static function make() : self{
|
||||||
$map = json_decode(
|
$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,
|
associative: true,
|
||||||
flags: JSON_THROW_ON_ERROR
|
flags: JSON_THROW_ON_ERROR
|
||||||
);
|
);
|
||||||
|
@ -25,9 +25,9 @@ namespace pocketmine\inventory;
|
|||||||
|
|
||||||
use pocketmine\crafting\CraftingManagerFromDataHelper;
|
use pocketmine\crafting\CraftingManagerFromDataHelper;
|
||||||
use pocketmine\crafting\json\ItemStackData;
|
use pocketmine\crafting\json\ItemStackData;
|
||||||
|
use pocketmine\data\bedrock\BedrockDataFiles;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\utils\SingletonTrait;
|
use pocketmine\utils\SingletonTrait;
|
||||||
use Symfony\Component\Filesystem\Path;
|
|
||||||
|
|
||||||
final class CreativeInventory{
|
final class CreativeInventory{
|
||||||
use SingletonTrait;
|
use SingletonTrait;
|
||||||
@ -37,7 +37,7 @@ final class CreativeInventory{
|
|||||||
|
|
||||||
private function __construct(){
|
private function __construct(){
|
||||||
$creativeItems = CraftingManagerFromDataHelper::loadJsonArrayOfObjectsFile(
|
$creativeItems = CraftingManagerFromDataHelper::loadJsonArrayOfObjectsFile(
|
||||||
Path::join(\pocketmine\BEDROCK_DATA_PATH, "creativeitems.json"),
|
BedrockDataFiles::CREATIVEITEMS_JSON,
|
||||||
ItemStackData::class
|
ItemStackData::class
|
||||||
);
|
);
|
||||||
foreach($creativeItems as $data){
|
foreach($creativeItems as $data){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user