Skip to content

Instantly share code, notes, and snippets.

@byteandahalf
Last active February 7, 2016 13:41
Show Gist options
  • Save byteandahalf/8634cf75fb2143b2a13e to your computer and use it in GitHub Desktop.
Save byteandahalf/8634cf75fb2143b2a13e to your computer and use it in GitHub Desktop.
Add a custom block to Minecraft Windows 10 Edition (not complete code)
static uintptr_t** mBlocks = (uintptr_t**) (((uint8_t*)baseAddr) + 0xA75750);
static TextureUVCoordinateSet myCustomTexture{0.0F,0.0F,0.0625F,0.0625F,16,16,1,1};
TextureUVCoordinateSet& customGetTexture()
{
return myCustomTexture;
}
uint32_t customGetColor()
{
return 0x0000FF00; // blue
}
void CreateCustomBlock(uint8_t blockId, std::string name)
{
uintptr_t* myBlock = (uintptr_t*) malloc(188); // one block = 188 bytes
uintptr_t* copyBlock = mBlocks[19]; // block id 19, sponge
memcpy(myBlock, copyBlock, 188);
*((uintptr_t***) myBlock) = (uintptr_t**) malloc(120*8); // 120 vtable entries * 8 bytes per entry
memcpy(*((uintptr_t***) myBlock), *((uintptr_t***) copyBlock), 120*8);
*(((uint8_t*) myBlock) + 88) = blockId;
// setup block vtable
(*((uintptr_t***) myBlock))[60] = (uintptr_t*) &customGetColor;
(*((uintptr_t***) myBlock))[11] = (uintptr_t*) &customGetTexture;
mBlocks[blockId] = myBlock;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment