Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to register a new block Furnace ? #102

Open
benda95280 opened this issue Aug 23, 2023 · 2 comments
Open

How to register a new block Furnace ? #102

benda95280 opened this issue Aug 23, 2023 · 2 comments

Comments

@benda95280
Copy link

Hi,

I've tried to register a new Furnace, I've the error below :

[22:56:16.535] [Server thread/CRITICAL]: pocketmine\data\bedrock\block\BlockStateSerializeException: "No serializer registered for pocketmine\block\UnknownBlock with type ID 10709" (EXCEPTION) in "pmsrc/src/data/bedrock/block/convert/BlockObjectToStateSerializer" at line 252
--- Stack trace ---
  #0 pmsrc/src/data/bedrock/block/convert/BlockObjectToStateSerializer(210): pocketmine\data\bedrock\block\convert\BlockObjectToStateSerializer->serializeBlock(object pocketmine\block\UnknownBlock#174257)
  #1 pmsrc/src/world/format/io/leveldb/LevelDB(228): pocketmine\data\bedrock\block\convert\BlockObjectToStateSerializer->serialize(int 2741717)
  #2 pmsrc/src/world/format/io/leveldb/LevelDB(761): pocketmine\world\format\io\leveldb\LevelDB->serializeBlockPalette(object pocketmine\utils\BinaryStream#101609, object pocketmine\world\format\PalettedBlockArray#103515)
  #3 pmsrc/src/world/World(2868): pocketmine\world\format\io\leveldb\LevelDB->saveChunk(int -4, int 0, object pocketmine\world\format\io\ChunkData#71891, int -1)
  #4 pmsrc/src/world/World(626): pocketmine\world\World->unloadChunk(int -4, int 0, false)
  #5 pmsrc/src/world/WorldManager(163): pocketmine\world\World->onUnload()
  #6 pmsrc/src/Server(1467): pocketmine\world\WorldManager->unloadWorld(object pocketmine\world\World#184561, true)
  #7 pmsrc/src/Server(1659): pocketmine\Server->forceShutdown()
  #8 pmsrc/src/Server(1556): pocketmine\Server->crashDump()
  #9 pmsrc/src/Server(1067): pocketmine\Server->exceptionHandler(object pocketmine\data\bedrock\block\BlockStateSerializeException#126885)

My test code is now as below :

            $blockFactory->registerBlock(static fn($id) => new TestFurnace    (new BlockIdentifier(BlockTypeIds::newId(),TileNormalFurnace::class), ucwords(str_replace('_', ' ', "test_furnace")),    new BlockTypeInfo(BlockBreakInfo::pickaxe(3.5, ToolTier::WOOD()))), $namespace . "test_furnace",  null,new CreativeInventoryInfo(CreativeInventoryInfo::CATEGORY_CONSTRUCTION, CreativeInventoryInfo::NONE),static fn($block) => BlockStateSerializerHelper::encodeFurnace($block, $namespace . "test_furnace", "minecraft:lit_furnace"), static fn($in) => CustomiesBlockFactory::getInstance()->get($namespace . "test_furnace")->setFacing($in->readHorizontalFacing())->setLit(false));

            #$tileFactory = TileFactory::getInstance();
            #$tileFactory->register(TileNormalFurnace::class,[$namespace."test_furnace", ucwords(str_replace('_', ' ', "test_furnace"))]);

My TestFurnace is as below :

final class TestFurnace extends Furnace {

    public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
        parent::__construct($idInfo, $name, $typeInfo, FurnaceType::FURNACE());
    }
}
``

I'm not able to get texture on my furnace too.
@benda95280
Copy link
Author

benda95280 commented Aug 24, 2023

I've found the problem with '$id', i was using it wrongly :

$blockFactory->registerBlock(static fn($id) => new TestFurnace    (new BlockIdentifier($id,TileNormalFurnace::class), ucwords(str_replace('_', ' ', "test_furnace")),    new BlockTypeInfo(BlockBreakInfo::pickaxe(3.5, ToolTier::WOOD()))), $namespace . "test_furnace",  null,new CreativeInventoryInfo(CreativeInventoryInfo::CATEGORY_CONSTRUCTION, CreativeInventoryInfo::NONE),static fn($block) => BlockStateSerializerHelper::encodeFurnace($block, $namespace . "test_furnace", "minecraft:lit_furnace"), static fn($in) => CustomiesBlockFactory::getInstance()->get($namespace . "test_furnace")->setFacing($in->readHorizontalFacing())->setLit(false));

Furnace inventory is opening immediatly closing.

@xSuperr
Copy link

xSuperr commented Sep 2, 2023

Create a new inventory with invmenu or something of the likes and use that instead of pocketmine furnace inventory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants