Hi, I'm minecraftmuse3, and this thread is hopefully gonna give you a step up in addon making. I'm gonna post a few useful tutorials on this thread. In addition to this, you can also ask some questions in the comments down below and I will try to the best of my abiltity to answer them. Note: You will need some experience in C++ modding before using this tutorial.
So lets get started!
Tutorials
Modifiying MCPE's inbuilt village gen code:
Ok, so the aim of this tutorial is to modify the humble house that appears in your MCPE villages.
So basically, VillagePiece::placeBlock places a block for the structure, VillagePiece::generateBox generates a box, as VillagePiece::postProcess is the function where the structure is created.
Please give me an Internet. Please. Pretty Please with sprinkles on top
I have a twitter!! Follow me for regular updates on my mods! https://twitter.com/DamienMiller11
Hi, I'm minecraftmuse3, and this thread is hopefully gonna give you a step up in addon making. I'm gonna post a few useful tutorials on this thread. In addition to this, you can also ask some questions in the comments down below and I will try to the best of my abiltity to answer them. Note: You will need some experience in C++ modding before using this tutorial.
So lets get started!
Tutorials
Modifiying MCPE's inbuilt village gen code:
Ok, so the aim of this tutorial is to modify the humble house that appears in your MCPE villages.
Functions we are going to use:
So basically, VillagePiece::placeBlock places a block for the structure, VillagePiece::generateBox generates a box, as VillagePiece::postProcess is the function where the structure is created.
Once you've set up your headers (find them at https://github.com/minecraftmuse3/ExampleVillageGen), we are going to want to include our header files into the main project file.
Next you're going to want to set up your functions to replace the existing ones
[/p] [p]void (*_SimpleHouse$postProcess)(SimpleHouse* self, BlockSource*, Random&, BoundingBox const&); void SimpleHouse$postProcess(SimpleHouse* self, BlockSource* region, Random& rand, BoundingBox const& bounds) { self->generateBox(region, bounds, 0, 0, 0, 3, 3, 3, {Block::mBrick->blockId, 0}, {Block::mBrick->blockId}, false); self->generateBox(region, bounds, 0, 3, 0, 3, 6, 3, {Block::mWoodPlanks->blockId, 0}, {Block::mWoodPlanks->blockId}, false); }[/p] [p]Lastly, you're going to want to hook your functions
JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { void* handle = dlopen("libminecraftpe.so", RTLD_LAZY); void* SimpleHouse$postProcess_ = dlsym(handle, "_ZN11SimpleHouse11postProcessEP11BlockSourceR6RandomRK11BoundingBox"); MSHookFunction(SimpleHouse$postProcess_, (void*) &SimpleHouse$postProcess, (void**) &_SimpleHouse$postProcess); return JNI_VERSION_1_2; }Full file:
[/p] [p]#include <jni.h> #include <dlfcn.h> #include <Substrate.h>[/p] [p]#include "mcpe/CommonTypes.h" #include "mcpe/block/Block.h" #include "mcpe/structure/village/components/SimpleHouse.h"[/p] [p]void (*_SimpleHouse$postProcess)(SimpleHouse* self, BlockSource*, Random&, BoundingBox const&); void SimpleHouse$postProcess(SimpleHouse* self, BlockSource* region, Random& rand, BoundingBox const& bounds) { //We generate a basic wall self->generateBox(region, bounds, 0, 0, 0, 4, 4, 0, {Block::mBrick->blockId, 0}, {Block::mBrick->blockId}, false); self->generateBox(region, bounds, 1, 1, 0, 3, 3, 0, {Block::mWoodPlanks->blockId, 0}, {Block::mWoodPlanks->blockId}, false); }[/p] [p]JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { void* handle = dlopen("libminecraftpe.so", RTLD_LAZY); void* SimpleHouse$postProcess_ = dlsym(handle, "_ZN11SimpleHouse11postProcessEP11BlockSourceR6RandomRK11BoundingBox");[/p] [p] MSHookFunction(SimpleHouse$postProcess_, (void*) &SimpleHouse$postProcess, (void**) &_SimpleHouse$postProcess);[/p] [p] return JNI_VERSION_1_2; }[/p] [p]All you need to do now is load up a NEW world and find a village!
Results:
Here is a hut that I made using this code:
A single, solitary stone block:
So that's about it! Remember to leave a comment and drop a like!
Contact me with any Questions/Queries/Concerns at https://twitter.com/DamienMiller11
And as always,
Have fun!
I have a twitter!! Follow me for regular updates on my mods!
https://twitter.com/DamienMiller11
If anybody wants to see the full code you csn find it here:
https://github.com/minecraftmuse3/ExampleVillageGen