otter Posted May 15, 2014 Posted May 15, 2014 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. Quote
muddyfish Posted May 15, 2014 Posted May 15, 2014 I would do some modular arithmetic to find the x and z boundarys... int x_lower = x%16 int z_lower = z%16 int x_upper = x_lower+16 int z_upper = z_lower+16 Quote
otter Posted May 17, 2014 Author Posted May 17, 2014 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); } Quote
Recommended Posts
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.