Jump to content

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


Recommended Posts

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?

Posted

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

.

Posted

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

Posted

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

).

Posted

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?

Posted

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;

Posted

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/

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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

Posted

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.

Posted

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

×   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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Back then there was a number which determined the tier of an item and block. If the block tier is lower or equal to the item number, the block would be mined. this however, has changed and now it goes by "needs_netherite_tool" which is fine, until you realized that some mods had items and blocks that exceeded these values. You can make you own "needs_mod_tool" but I feel that this is more limiting(and just more work) than before. So is there anyway to use something similar to the old tier system while also still being compatible with a lot of other mod tools?
    • Well, when I log in to the server, sometimes within an hour, sometimes within a minute, the server closes and informs me that there was a Ticking entity error. Below is the crash report
    • Try switching to Windowed or Borderless Window mode in Minecraft. These modes make it easier for the recorder to capture gameplay, as it still has access to the display without the game taking up all of the graphics resources.
    • This forum is for Forge, not NeoForge. Please go to them for support.
    • Forge version: 55.0.0 Minecraft version: 1.21.5 Downloads: As this is the start of a new version, it is recommended that you check the downloads page and use the latest version to receive any bug fixes. Downloads page Intro: Good evening! Today, we have released our initial build of Forge 55.0 for Minecraft 1.21.5. 1.21.5 is the newest member of the 1.21 family of versions, which was released yesterday on March 25, 2025. As a reminder, the first minor (X.0) of a Forge version is a beta. Forge betas are marked as such on the bottom left of the title screen and are candidates for any breaking changes. Additionally, there are a couple of important things to note about this update, which I've made sure to mention in this post as well. Feel free to chat with us about bugs or these implementation changes on GitHub and in our Discord server. As always, we will continue to keep all versions of 1.21 and 1.20 in active support as covered by our tiered support policy. Cheers, happy modding, and good luck porting! Rendering Refactor For those who tuned in to Minecraft Live on March 22, 2025, you may already know that Mojang have announced their intention to bring their new Vibrant Visuals overhaul to Java in the future. They've taken the first steps toward this by refactoring how rendering pipelines and render types are handled internally. This has, in turn, made many of Forge's rendering APIs that have existed for years obsolete, as they (for the most part) can be done directly in vanilla. If there was a rendering API that was provided by Forge which you believe should be re-implemented, we're happy to discuss on GitHub through an issue or a pull request. Deprecation of weapon-like ToolActions In 1.21.5, Minecraft added new data components for defining the characteristics of weapons in data. This includes attack speed, block tags which define efficient blocks, and more. As such, we will begin marking our ToolActions solution for this as deprecated. ToolActions were originally added to address the problem of creating modded tools that needed to perform the same actions as vanilla tools. There are still a few tool actions that will continue to be used, such as the shears tool action for example. There are some existing Forge tool actions that are currently obsolete and have no effect given the way the new data components are implemented. We will continue to work on these deprecations and invite you to chat with us on GitHub or Discord if you have any questions.
  • Topics

×
×
  • Create New...

Important Information

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