Jump to content

[1.7.10][SOLVED] Need help with a 1 layer flat chunk generator


nexusrightsi

Recommended Posts

Hey there, I'm working on a custom dimension but for my dimension i need a chunk provider that makes it so it only generates a custom block 1 layer above the void. Although I've tried reading into guides/tutrials about world generation i could not put my head around it. Would someone be able to help me out as I find the world generating code quite confusing?

Link to comment
Share on other sites

In your dimension's

IChunkProvider

in

provideChunk

method, create new

Chunk

with

Block[]

in arguments. Pas it as

Block[]

blocks

where

Block[] blocks = new Block[655536]

. Before creating new

Chunk

, fill

blocks

with blocks you need, where you need, using this to set block:

blocks[blockXPos <<11 | blockZPos << 7 | blockYPos] = blockYouWantThere

.

Link to comment
Share on other sites

I assume you meant something like this?

 

public Chunk provideChunk(int par1, int par2)
{
	Block[] blocks = new Block[655536];
	Chunk chunk = new Chunk(world, blocks, par2, par2);
	for(int x = 0; x < 16; x++)
	{
		for(int z = 0; z < 16; z++)
		{
			blocks[0] = BlockHandler.MossDirt;
		}
	}
	return chunk;
}

Link to comment
Share on other sites

I assume you meant something like this?

 

public Chunk provideChunk(int par1, int par2)
{
	Block[] blocks = new Block[655536];
	Chunk chunk = new Chunk(world, blocks, par2, par2);
	for(int x = 0; x < 16; x++)
	{
		for(int z = 0; z < 16; z++)
		{
			blocks[0] = BlockHandler.MossDirt;
		}
	}
	return chunk;
}

Nearly. Apply changes to

blocks

before

Chunk chunk = new Chunk

. Also, below i told you how to convert x, y and inside chunk to position in

blocks

(

x<<11 | z<< 7 | y

).

Link to comment
Share on other sites

I honestly don't get it. the "below i told you how to convert x, y and inside chunk to position in blocks (x<<11 | z<< 7 | y)" confuses me of what to do. could you perhaps give me some pseudo-code example?

Ok, let's say that i want to set some blocks blocks at (x, y, z) to diamond blocks.

In here, i'm putting diamond blocks at (0, 0, 0), (12, 128, 16) and (7, 245, 11):

blocks[0<<11 | 0<< 7 | 0] = Blocks.diamondBlock;
blocks[12<<11 | 16<< 7 | 128] = Blocks.diamondBlock;
blocks[7<<11 | 11<< 7 | 245] = Blocks.diamondBlock;

Link to comment
Share on other sites

You don't want 655536, but 16*16*128=65536, see the extra 5?

 

Also, he told you to populate the

blocks

array before making a new chunk, else you would create an empty Chunk and than populate an array which will never be used again in that method.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

right got that, while i was at it i tried testing out to see if i was able to enter the dimension. Although the teleporter tp'd me back onto the exact same spot i already was in the overworld...

if(!world.isRemote)
	{

		FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().transferPlayerToDimension( (EntityPlayerMP) player,
				0, new TeleportTo(MinecraftServer.getServer().worldServerForDimension(ARMain.dimensionId))); 
	}

was used to tp to my dimension. its called upon activating a block.

Link to comment
Share on other sites

You don't want 655536, but 16*16*128=65536, see the extra 5?

Yes, not 655536... But neither 16*16*128 (=32768) xD...

You want 16*16*256=65536...

 

I figured xD ah well thanks anyways for the help, i just assume that I switch out the coords with the ints of my for loops so it runs through the entire chunk.

Link to comment
Share on other sites

You don't want 655536, but 16*16*128=65536, see the extra 5?

Yes, not 655536... But neither 16*16*128 (=32768) xD...

You want 16*16*256=65536...

 

I figured xD ah well thanks anyways for the help, i just assume that I switch out the coords with the ints of my for loops so it runs through the entire chunk.

Yup. But do you need to run through entire chunk? Or just through y=1? Don't do unnecessary operations. Null blocks in [] will be automatically read as air.

Link to comment
Share on other sites

You don't want 655536, but 16*16*128=65536, see the extra 5?

Yes, not 655536... But neither 16*16*128 (=32768) xD...

You want 16*16*256=65536...

 

I figured xD ah well thanks anyways for the help, i just assume that I switch out the coords with the ints of my for loops so it runs through the entire chunk.

Yup. But do you need to run through entire chunk? Or just through y=1? Don't do unnecessary operations. Null blocks in [] will be automatically read as air.

 

Oh no, not at all. I'm just running through the x and z's of the chunk because the y is always constant. also  while i was at it i tried testing out to see if i was able to enter the dimension. Although the teleporter tp'd me back onto the exact same spot i already was in the overworld...

if(!world.isRemote)
	{

		FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().transferPlayerToDimension( (EntityPlayerMP) player,
				0, new TeleportTo(MinecraftServer.getServer().worldServerForDimension(ARMain.dimensionId))); 
	}

was used to tp to my dimension. its called upon activating a block.

Link to comment
Share on other sites

I seem to have a new problem now where it only places 1 block per chunk instead of running through my for loops for the entire x and z square coords. X6oUi3b.png

 

public Chunk provideChunk(int par1, int par2)
{
	Block[] blocks = new Block[65536];
	blocks[0] = BlockHandler.MossDirt;
	Chunk chunk = new Chunk(world, blocks, par1, par2);
	for(int x = 0; x < 15; x++)
	{
		for(int z = 0; z < 15; z++)
		{
			blocks[x<<11 | z<< 7 | 0] = BlockHandler.MossDirt;
		}
	}
	chunk.generateSkylightMap();

	return chunk;
}

Link to comment
Share on other sites

I seem to have a new problem now where it only places 1 block per chunk instead of running through my for loops for the entire x and z square coords. X6oUi3b.png

 

public Chunk provideChunk(int par1, int par2)
{
	Block[] blocks = new Block[65536];
	blocks[0] = BlockHandler.MossDirt;
	Chunk chunk = new Chunk(world, blocks, par1, par2);
	for(int x = 0; x < 15; x++)
	{
		for(int z = 0; z < 15; z++)
		{
			blocks[x<<11 | z<< 7 | 0] = BlockHandler.MossDirt;
		}
	}
	chunk.generateSkylightMap();

	return chunk;
}

Didn't i say that you run your loops before

Chunk chunk = new Chunk

? Or was it on another thread about dimensions? Anyway, you must run your loops before creating new chunk.

Link to comment
Share on other sites

Thank you, that fixed it ^_^also, nah you only told me to do the blocks array before the actual chunk creation. but thanks a lot!

Ok. If it is fixed, add [sOLVED] to the title after mc version. Like that, everybody knows that this problem is solved :) .

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.

Announcements



×
×
  • Create New...

Important Information

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