Jump to content

[1.7.2] [Beginner] Get a chunk's borders


otter

Recommended Posts

Hey,

beginner here, a short question concerning 1.7.2 I couldn't figure out myself by reading the code or Google.

 

How do I get the current chunk's borders?

 

This is my current approach:

	@Override
public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)
   {
if(p_149727_1_.isRemote) return false;

	int x = p_149727_2_;
	int y = p_149727_3_;
	int z = p_149727_4_;

	Chunk currentChunk = p_149727_1_.getChunkFromChunkCoords(x,y);
	ChunkCoordIntPair CCIP = currentChunk.getChunkCoordIntPair();
	int x_border = CCIP.chunkXPos;
	int z_border = CCIP.chunkZPos;
	int y_border = currentChunk.heightMap[x_border << 4 | z_border]; // TODO: crash; taken from canBlockSeeTheSky
//... 

I did some testing and these coordinates definitely aren't the chunks borders but rather the current block's coords. Also, my y_border-method crashes the game via a ArrayIndexOutOfBoundsException (haven't looked into this too much, as soon as I see bit-shifting my mind crashes as well...).

 

Thanks in advance.

Link to comment
Share on other sites

Thank you. This did the job:

 

		int x_mod = x % 16;
	int x1_border = x;
	int c = 0;
	while (x_mod != 0 && c <= 16) {
		x1_border++;
		c++;
		x_mod = (x1_border) % 16;
		if (debugPlacer)
			p_149727_1_.setBlock(x1_border, y, z, Blocks.redstone_torch);
	}

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.