Jump to content

[Solved][1.12.2] Having trouble with IWorldGenerator in the Nether


TheUnderTaker11

Recommended Posts

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, image.thumb.png.65d37bc54ad06e8b59e70ee5da70d211.png

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
image.thumb.png.9b4545f12d3a445646d19fc4a55a34b1.png

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!

Edited by TheUnderTaker11
Forgot to add MC version., and solved I was just dumb
Link to comment
Share on other sites

39 minutes ago, TheUnderTaker11 said:

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?

You are seeing a normal behaviour. First of all the Z value IS changing, even in your screenshot it goes from 55 to 56. Secondly imagine how the world generation works in your case. Say you moved 1 chunk in the positive Z direction and the render distance is 10. The game now loads 21 new chunks(x, y)

  • -10, 11
  • -9, 11
  • -8,  11
  • -7, 11
  • -6, 11
  • ...

As you can see the X is the one changing, not the Z which is logical. You will see the reverse happen if you go in the X direction.

 

42 minutes ago, TheUnderTaker11 said:

normally you would multiply by 16 but

No, you wouldn't. You would bitshift to the left by 4.

 

Also in your implementation the yellow flower placed by the generator would immediately pop up and drop itself since it can't stay on top of bedrock.

Link to comment
Share on other sites

Oh well thanks, then the example I got it from had it wrong. Like I said yellow flower is just for testing, but I'm still having the problem where it never places, any idea why that is?

 

Also realized I never used the boolean done, just broke out anyways lol. (So made it a for loop using the if statement, tired code is weird code.)

Edited by TheUnderTaker11
Link to comment
Share on other sites

11 hours ago, TheUnderTaker11 said:

multiply by 16

 

11 hours ago, V0idWa1k3r said:

bitshift to the left by 4

This is very important

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.