Closed Lamfi closed 3 years ago
Hello, I'm sorry that I partly forgot it and I only succeed creating blocks on ancient versions of Minecraft (Maybe 1.0?). As I remembered,Firstly, You should create a custom class extends Block.
class MyBlock : public Block
{
MyBlock(std::string const& nameId,int digitId)
{
Block(nameId,digitId);
// ......
}
// Other virtual methods, for example
virtual bool isSolid()const
{
return false;
}
};
Then,hook static method Block::initBlocks() (or, Block::registerBlocks() ?). In the hook method,create a pointer of the block (std::shared_ptr
void hook_initBlocks()
{
real_initBlocks();
// Create pointer and add it to the Block::mBlockLookupMap
// You can also use the template method Block::registerBlock instead of creating a pointer and add it to the map
}
Don't forget to create a item for this block.Create a class extends BlockItem, register it in the Item::registerItems() (Or, Item::initItems() ?). Then create a pointer to this BlockItem and add it to the Item::mItemLookupMap.
That's all I could recall and they're too old for the modern versions of Minecraft. You can refer to the decompiled code in IDA to find out how the blocks were created.
Hello listery,maybe you know how to create block on 1.13-1.16. I trying using VanillaBlockTypes::registerBlocks , but what i need to do next?