# Structure Spawning in 1.8?

## 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?

##### 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?

##### Share on other sites

Check out BlockPos.north BlockPos.east BlockPos.up etc :b

##### 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

## 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.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

### Announcements

×

• #### Activity

×
• Create New...