Jump to content

Structure Spawning in 1.8?


SureenInk

Recommended Posts

I'm trying to figure out how to update my 1.7 mod to 1.8. I have most of the stuff up-to-date, but I can't figure out structure spawning. I found another topic on here about it that was solved, but I still couldn't figure it out following his coding. I think I missed a step or something that he figured out on his own, thus didn't need to ask for help on. What I'm stuck on is how to determine the BlockPosition so that it puts the blocks in the right spot. Here's the 1.7 code:

public boolean generate(World world, Random rand, int i, int j, int k) {
world.setBlock(i + 0, j + 0, k + 0, Blocks.air);
return true;
}

And here's what I've managed to figure out so far for 1.8:

public boolean generate(World worldIn, Random random, BlockPos pos) {		
worldIn.setBlockState(new BlockPos(x + 0, y + 0, z + 0), (IBlockState)Blocks.air.getBlockState());
return true;
}

What I'm stuck on is...how do I make it determine x, y, and z? If I initialize variables x, y, and z as "0" isn't that going to just set them to coordinates 0, 0, 0?

Link to comment
Share on other sites

Well, the example I have above is just the code I put together... my actual code for the structures I need to build are 700+ lines of code long... But how do I add to pos? Like, if I'm making a structure, I need to place a block at things like "x+1, y+0, z+0", "x+0, y+1, z+0", etc. How do I do that with just "pos"? Is there a way to determine the three numbers that are "pos"? I'm unfortunately struggling very much with the json and BlockPos/BlockState things... My mind just can't seem to understand how they work. I do have a learning disability, so that could be part of it, but still... How do I add to only one direction of "pos"? If I do "pos+1" wouldn't that just add to all 3 spots?

Link to comment
Share on other sites

Or, if you don't want to convert all of those lines to 'new BlockPos(i+x, j+y, k+z)', just make a wrapper method and use your editor's replace function to replace all of the 'world.setBlock(...)' to 'MyHelper.setBlock(world, ', e.g.:

public static void setBlock(World world, int x, int y, int z, Block block, int meta) {
world.setBlockState(new BlockPos(x, y, z), block.getStateFromMeta(meta), 3);
}

Something like that anyway, coding from memory ;)

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.