Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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?

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

.

  • Author

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;
}

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

).

  • Author

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?

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;

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/

  • Author

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.

  • Author

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.

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.

  • Author

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.

  • Author

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;
}

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.

  • Author

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!

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 :) .

  • Author

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 :) .

Done and done ^_^

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.