Jump to content

[1.8][Solved] World Generation Replacing Blocks Other Than Stone


Toxicshadow

Recommended Posts

Hey, so I have a mod and it was working fine, I could generate blocks without an issue. However it only replaces stone. And so I took a look in 'WorldGenMinable' and there seems to be a magic number for what it replaces, which is only stone. So I tried to do some googling and all that came up were outdated, useless tutorials that use old code for WorldGenMinable that didn't have a magic number.

 

So, can anyone point me in the right direction of how to generate blocks that replaces something other than stone? Even if it's just someone's code on github, anything will help. Thanks!

 

Solution: Add a new parameter for the item to replace, then in your call to WorldGenMinable, use BlockHelper.forBlock(replace)

 

Link to comment
Share on other sites

Yea, 1.8 pretty much takes the idea of "Magic Numbers" and hides them.  No more block or item IDs, Entity IDs are almost irrelevant, metadata is now IBlockState...

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Yea, 1.8 pretty much takes the idea of "Magic Numbers" and hides them.  No more block or item IDs, Entity IDs are almost irrelevant, metadata is now IBlockState...

WorldGenMinable actually doesn't have any "magic number". In 1.8 it takes a Predicate<IBlockState> (which you can think of as a method that takes a IBlockState and returns a boolean) that determines whether a certain block should be replaced or not.

If you just want to replace a single Block, Minecraft has a default implementation for this Predicate, called "BlockHelper". Use BlockHelper.forBlock to get an instance of it for a specific block.

Okay thanks. I saw the Predicate but the lack of naming tripped me up. The actual part I got confused on was:

    public WorldGenMinable(IBlockState p_i45630_1_, int p_i45630_2_)
    {
        this(p_i45630_1_, p_i45630_2_, BlockHelper.forBlock(Blocks.stone));
    }

I thought this was the only definition of something to replace. But I now see that I missed

    public WorldGenMinable(IBlockState p_i45631_1_, int p_i45631_2_, Predicate p_i45631_3_)
    {
        this.oreBlock = p_i45631_1_;
        this.numberOfBlocks = p_i45631_2_;
        this.field_175919_c = p_i45631_3_;
    }

 

Thank you guys!

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.



×
×
  • Create New...

Important Information

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