Jump to content

[SOLVED] Set Direction of Block (chest) during generate()


gottsch

Recommended Posts

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.

Link to comment
Share on other sites

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.

 

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.