-
-
Save byteandahalf/f67ca550c3b5b4c473fe to your computer and use it in GitHub Desktop.
Override Lava Bucket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
class TextureUVCoordinateSet; | |
struct Item { | |
void** vtable; // 0 | |
static void initItems(); | |
static TextureUVCoordinateSet getTextureUVCoordinateSet(const std::string&, int); | |
static Item* mItems[512]; | |
}; | |
const TextureUVCoordinateSet& _myGetIcon(Item* ptr, int data, int, bool) { | |
switch(data) { | |
case 1: // Milk | |
return Item::getTextureUVCoordinateSet("bucket", 1); | |
case 8: // Water | |
return Item::getTextureUVCoordinateSet("bucket", 2); | |
case 10: // Lava | |
return Item::getTextureUVCoordinateSet("coal", 0); // Return a custom texture for lava. | |
default: // Empty | |
return Item::getTextureUVCoordinateSet("bucket", 0); | |
} | |
} | |
void (*_Item$initItems)(); | |
void Item$initItems() { | |
// Call the real pointer so that all Items will be initialized | |
_Item$initItems(); | |
// Get the BucketItem vtable and replace the 45th function (_ZNK4Item7getIconEiib) with our own code. | |
Item::mItems[325]->vtable[45] = (void*) &_myGetItem; | |
} | |
// Add this into your JNI_OnLoad in your addon. | |
MSHookFunction((void*) &Item::initItems, (void*) &Item$initItems, (void**) &_Item$initItems); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks for the example!