CustomiesDevs / Customies

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

Server crashes on load block #96

Open Nat392 opened 11 months ago

Nat392 commented 11 months ago

Hello, I've had this crash for a few days and I can't find the cause. It happens about 1 out of every 3 reboots, with the same ID and block.

A PLUGIN WAS INVOLVED IN THIS CRASH
BAD PLUGIN: Customies

Thread: AsyncWorker#1
Error: Block ID 10811 is already used by another block
File: pmsrc/src/block/RuntimeBlockStateRegistry
Line: 93
Type: InvalidArgumentException
Backtrace:
#0 /home/container/plugins/Customies/src/block/CustomiesBlockFactory(88): pocketmine\block\RuntimeBlockStateRegistry->register(object sulfu\core\block\SulfuOre#45127)
#1 /home/container/plugins/Customies/src/task/AsyncRegisterBlocksTask(39): customiesdevs\customies\block\CustomiesBlockFactory->registerBlock(object Closure#17, string[19] customies:sulfu_ore, null, null, object Closure#45144, object Closure#45142)
#2 pmsrc/src/scheduler/AsyncTask(82): customiesdevs\customies\task\AsyncRegisterBlocksTask->onRun()
#3 (): pocketmine\scheduler\AsyncTask->run()
        $id = BlockTypeIds::newId();
        CustomiesBlockFactory::getInstance()->registerBlock(
            static fn() => new SulfuOre(new BI($id), "sulfu_ore", new BlockTypeInfo(new BlockBreakInfo(0.3))),
            BlockIdentifier::SULFU_ORE,
            new Model(
                [
                    new Material(Material::TARGET_ALL, "sulfu_ore", Material::RENDER_METHOD_ALPHA_TEST)
                ],
                "geometry.block",
                new Vector3(-8, 0, -8),
                new Vector3(16, 16, 16),
                1
            ),
            new CreativeInventoryInfo(CreativeInventoryInfo::CATEGORY_ITEMS, CreativeInventoryInfo::NONE)
        );

And apparently, I'm not the only one this happens to, according to a reply I got on the discord.

Thanks!

TitaniumLB6571 commented 11 months ago

you have to create a new id everytime you make a new block, by every new instance just add $id = BlockTypeIds::newId();

Otherwise you will register the blocks with the same $Id variable, do you understand?

if not here is example

$id = 1;

registerBlock($id (which = 1))

registering a new block with same $id variable

registerBlock($id (which = 1))

then you get that error

so just create new $Id variable above the instance of registering the block like so

$id = 1;

registerBlock($id (which = 1))

$id = 2;

registerBlock($id (which = 2))

Nat392 commented 11 months ago

That's what I do, but it doesn't change anything.

Nat392 commented 11 months ago

$id is only for the first block, after $id2, etc.

Phqzing commented 1 month ago

same problem as mine