Sorry if this is some super easy solution but I THINK I'm having some weirdness when getting chunks generated, that or something I can't notice is wrong with where I decide a proper place to put the flower.
Even though I fly in the +Z direction, as seen here,
Ignore the blue line lol. Well using the code I'll put at the bottom, I get this output. (I'm not multiplying chunkX or chunkZ by anything, for testing purposes. I know normally you would multiply by 16 but
I'm super confused, the Z value is staying exactly the same, yet the X value changes a ton, when in reality (Me flying towards +Z) the X is the one staying the same. Now I understand that the X would also change a ton cause it's generating all around me, but why is the Z staying exactly the same?
As for the overall purpose of this, it's to make some flowers spawn on top of netherrack throughout the nether, but for them to be pretty rare. So if you notice anything I'm doing stupidly wrong then say something as well. (Just using dandelions for testing, will use my block later.)
And here is my code, and I call it using this
GameRegistry.registerWorldGenerator(new FlowerGen(), 50000);
I set a really high value since it said that higher values would be done last (Well heavier values, which I can only assume means higher).
Now the main code.
package com.theundertaker11.demonicintervention.worldgen;
import java.util.Random;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraftforge.fml.common.IWorldGenerator;
public class FlowerGen implements IWorldGenerator {
@Override
public void generate(Random rand, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
if (world.provider.getDimension() == -1) {
int x = chunkX;
int z = chunkZ;
int y = 128;
System.out.println("Attempting at X, z: " + x + ", " + z);
boolean done = false;
int counter = 0;
while(!done) {
if(counter >= (y-3)) break;
BlockPos pos = new BlockPos(x, y - counter, z);
if(world.getBlockState(pos).getBlock() == Blocks.AIR && world.getBlockState(pos).getBlock() == Blocks.NETHERRACK) {
if(true || rand.nextInt(3) < 2) { // I know just want to make sure there isn't a chance thing atm
IBlockState state = Blocks.YELLOW_FLOWER.getDefaultState();
world.setBlockState(pos, state);
System.out.println("Generated flower at Pos " + pos.getX() + "," + pos.getY() + "," + pos.getZ());
break;
}
}
counter++;
}
}
}
Also sorry but I won't be able to reply quickly anyone sees this soon, as it is almost 5am for me and I need some sleep!