Skip to content

Instantly share code, notes, and snippets.

@byteandahalf
Created December 31, 2014 05:49
Show Gist options
  • Save byteandahalf/94e7d02c0e3e33364eaa to your computer and use it in GitHub Desktop.
Save byteandahalf/94e7d02c0e3e33364eaa to your computer and use it in GitHub Desktop.
Adding a new item in C++ MCPE
static Item* newItem() {
Item* myItem = (Item*) ::operator new((std::size_t) 76); // allocate memory
Item::Item(myItem, 55); // call the MCPE Item constructor
Item::items[55] = myItem; // Add the item to MCPE's global item list
*((void***) myItem) = *((void***) Item::items[259]); // give it a normal item vtable, in this case we steal it from flint and steel
Item::setDescriptionId("myitem"); // give it a name
I18n::_strings["item.myitem.name"] = "My YOLO itemmm"; // register the name
myItem->maxStackSize = 30; // max stack of 30 lololol
return myItem;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment