Posted September 19, 201411 yr Hi. I have a WorldGenerator that generates a chest, however, I can't seem to set the direction it is pointing. I've tried this to set a random direction: this.setBlockAndNotifyAdequately(world, x, y, z, Blocks.chest, random.nextInt(5) + 2); But the chest is always pointing South. Any ideas? I'm sure it's a pretty simple fix, I'm just missing it.
September 19, 201411 yr once you set the block you have to set the block metadata after using world.setBlockMetadataWithNotify(). I'm not sure if this works with chests but it should work The proud(ish) developer of Ancients
September 19, 201411 yr world.setBlock(x, y, z, Blocks.chest, random.nextInt(5)+2, 2) Check out my mod, Realms of Chaos, here. If I helped you, be sure to press the "Thank You" button!
September 19, 201411 yr Author world.setBlock(x, y, z, Blocks.chest, random.nextInt(5)+2, 2) Thanks, that did the trick. The metadata for chests are 2-5. Your method generates values between 2 and 6. Also: what does that method do? Thanks for catching that. The method comes from WorldGenerator: protected void setBlockAndNotifyAdequately(World p_150516_1_, int p_150516_2_, int p_150516_3_, int p_150516_4_, Block p_150516_5_, int p_150516_6_) { if (this.doBlockNotify) { p_150516_1_.setBlock(p_150516_2_, p_150516_3_, p_150516_4_, p_150516_5_, p_150516_6_, 3); } else { p_150516_1_.setBlock(p_150516_2_, p_150516_3_, p_150516_4_, p_150516_5_, p_150516_6_, 2); } } It seems to place the block and either use flag 3 or 2 depending on the doBlockNotify, which is false by default. So in essence it *should* have done exactly as Eternaldoom suggested, but it didn't seem to be working for me.
September 20, 201411 yr The problem is that chests automatically set their own metadata once placed in the world, so the value you use in the initial setBlock is actually ignored - to get around the problem, you just have to set the metadata after the block is placed, as memcallen mentioned earlier. http://i.imgur.com/NdrFdld.png[/img]
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.