Now to make sure this code is actually used, you must add it to the
SamEventHandler class. This plant generates on grass and, therefore, several things are required for it to work. First, it only generates in the overworld. Second, it only generates around the ground level because that’s the only place with grass.
The code to add generation for classes like
WorldGenSamPlant is very similar to what’s inside of the
addOreSpawn method from the previous hour. There is a random x, y, and z and a line that calls the
generate method in
WorldGenSamPlant. All of this code can be added in a
for loop to make the plant more common. The code required should look similar to this:
int posX = x + ...