CustomiesDevs / Customies

A PocketMine-MP plugin that implements support for custom blocks, items and entities.
MIT License
107 stars 48 forks source link

AsyncWorker#0 thread/CRITICAL]: ErrorException: "Invalid callback , no array or string given" (EXCEPTION) in "pmsrc/src/inventory/CreativeInventory" at line 122 #92

Closed ShadowMikado closed 6 months ago

ShadowMikado commented 11 months ago

Hi I've this error [AsyncWorker#0 thread/CRITICAL]: ErrorException: "Invalid callback , no array or string given" (EXCEPTION) in "pmsrc/src/inventory/CreativeInventory" at line 122

And this is my code

        $id = BlockTypeIds::newId();
        $creativeInfo = new CreativeInventoryInfo(CreativeInventoryInfo::CATEGORY_NATURE, CreativeInventoryInfo::GROUP_MISC_FOOD);
        CustomiesBlockFactory::getInstance()->registerBlock(
            static fn () => new MyCustomBlock(new BlockIdentifier($id), "Custom Block", new BlockTypeInfo(new BlockBreakInfo(1))),
            "customies:custom_block",
            null,
            $creativeInfo
        );

I've try an another plugin (not by me) and this error is always here

xLordShadow commented 11 months ago

I got this same issue, but it would only occur when running on windows. On linux it worked fine. (Same PMMP Version and Customies Version)

ShadowMikado commented 11 months ago

Oh, that's strange. Someone told me to remove line 180 in CustomiesBlockFactory (CreativeInventory::getInstance()->add($block->asItem())). It works, but the custom item is not in creative inventory. I myself found a temporary fix to have the item in the creative inventory:


public function onEnable(): void  {
        $id = BlockTypeIds::newId();
        $creativeInfo = new CreativeInventoryInfo(CreativeInventoryInfo::CATEGORY_NATURE, CreativeInventoryInfo::GROUP_MISC_FOOD);
        CustomiesBlockFactory::getInstance()->registerBlock(
            static fn () => new MyCustomBlock(new BlockIdentifier($id), "Custom Block", new BlockTypeInfo(new BlockBreakInfo(1))),
            "customies:custom_block",
            null,
            $creativeInfo
        );
CreativeInventory::getInstance()->add(CustomiesBlockFactory::getInstance()->get("customies:custom_block")->asItem())
}