Posted July 28, 201411 yr Hello i need help with world gen, i want my scructure to spawn on surface. This is my current code and structure that i have spawning inside stone, i want to have my structure on surface ( grass ). EDIT: FULL CODE N/A import static net.minecraftforge.common.ChestGenHooks.DUNGEON_CHEST; import java.util.Random; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.WeightedRandomChestContent; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; import net.minecraftforge.common.ChestGenHooks; public class WorldGenNA extends WorldGenerator { public boolean generate(World world, Random rand, int x, int y, int z) { if(world.getBlock(x, y, z) != Blocks.grass || world.getBlock(x + 5, y + 5, z + 5) != Blocks.grass || world.getBlock(x, y + 5, z + 5) != Blocks.grass|| world.getBlock(x + 5, y, z) != Blocks.grass) { return false; } world.setBlock(x + 0, y + 0, z + 0, Blocks.bedrock); world.setBlock(x + 0, y + 0, z + 1, Blocks.bedrock); world.setBlock(x + 0, y + 0, z + 2, Blocks.bedrock); world.setBlock(x + 0, y + 0, z + 3, Blocks.bedrock); world.setBlock(x + 0, y + 0, z + 4, Blocks.bedrock); world.setBlock(x + 0, y + 1, z + 0, Blocks.bedrock); world.setBlock(x + 0, y + 1, z + 1, Blocks.bedrock); world.setBlock(x + 0, y + 1, z + 2, Blocks.bedrock); world.setBlock(x + 0, y + 1, z + 3, Blocks.bedrock); world.setBlock(x + 0, y + 1, z + 4, Blocks.bedrock); world.setBlock(x + 0, y + 2, z + 0, Blocks.bedrock); world.setBlock(x + 0, y + 2, z + 1, Blocks.bedrock); world.setBlock(x + 0, y + 2, z + 2, Blocks.bedrock); world.setBlock(x + 0, y + 2, z + 3, Blocks.bedrock); world.setBlock(x + 0, y + 2, z + 4, Blocks.bedrock); world.setBlock(x + 0, y + 3, z + 0, Blocks.bedrock); world.setBlock(x + 0, y + 3, z + 1, Blocks.bedrock); world.setBlock(x + 0, y + 3, z + 2, Blocks.bedrock); world.setBlock(x + 0, y + 3, z + 3, Blocks.bedrock); world.setBlock(x + 0, y + 3, z + 4, Blocks.bedrock); world.setBlock(x + 1, y + 0, z + 0, Blocks.bedrock); world.setBlock(x + 1, y + 0, z + 1, Blocks.bedrock); world.setBlock(x + 1, y + 0, z + 2, Blocks.bedrock); world.setBlock(x + 1, y + 0, z + 3, Blocks.bedrock); world.setBlock(x + 1, y + 0, z + 4, Blocks.bedrock); world.setBlock(x + 1, y + 1, z + 0, Blocks.bedrock); world.setBlock(x + 1, y + 1, z + 4, Blocks.bedrock); world.setBlock(x + 1, y + 2, z + 0, Blocks.bedrock); world.setBlock(x + 1, y + 2, z + 4, Blocks.bedrock); world.setBlock(x + 1, y + 3, z + 0, Blocks.bedrock); world.setBlock(x + 1, y + 3, z + 1, Blocks.bedrock); world.setBlock(x + 1, y + 3, z + 2, Blocks.bedrock); world.setBlock(x + 1, y + 3, z + 3, Blocks.bedrock); world.setBlock(x + 1, y + 3, z + 4, Blocks.bedrock); world.setBlock(x + 2, y + 0, z + 0, Blocks.bedrock); world.setBlock(x + 2, y + 0, z + 1, Blocks.bedrock); world.setBlock(x + 2, y + 0, z + 2, Blocks.bedrock); world.setBlock(x + 2, y + 0, z + 3, Blocks.bedrock); world.setBlock(x + 2, y + 0, z + 4, Blocks.bedrock); world.setBlock(x + 2, y + 1, z + 0, Blocks.bedrock); world.setBlock(x + 2, y + 1, z + 4, Blocks.bedrock); world.setBlock(x + 2, y + 2, z + 0, Blocks.bedrock); world.setBlock(x + 2, y + 2, z + 4, Blocks.bedrock); world.setBlock(x + 2, y + 3, z + 0, Blocks.bedrock); world.setBlock(x + 2, y + 3, z + 1, Blocks.bedrock); world.setBlock(x + 2, y + 3, z + 2, Blocks.bedrock); world.setBlock(x + 2, y + 3, z + 3, Blocks.bedrock); world.setBlock(x + 2, y + 3, z + 4, Blocks.bedrock); return true; } EDIT: This on top or if anyone knows if i can just make chests spawn around the world with custom items inside. Or any other blocks to spawn around the world like trees.
July 28, 201411 yr Author More code please? added full code of the file. Here is a ChunkProvider: // NA if(rand.nextInt(15) == 0) { for(k1 = 0; k1 < 8; ++k1) { l1 = k + this.rand.nextInt(16) + 8; i2 = this.rand.nextInt(256); int j2 = l + this.rand.nextInt(16) + 8; (new WorldGenNA()).generate(this.worldObj, this.rand, l1, i2, j2); } } //
July 28, 201411 yr Author well, you are checking for stone. If you want it to spawn on grass... maybe check for grass? Yeah i did that, and well it kinda doesnt spawn.
July 28, 201411 yr Author You are checking 5 blocks up and 5 blocks down. Imagine that... no minecraft world has grass at those positions. Grass is just the top layer. So how would then that go, X Y Z. isnt "Z" for UP and DOWN ?! da hell, was i looking at google pictures. if(world.getBlock(x, y, z) != Blocks.dirt || world.getBlock(x + 0, y + 0, z + 1) != Blocks.dirt || world.getBlock(x, y + 0, z + 1) != Blocks.dirt|| world.getBlock(x + 0, y, z) != Blocks.dirt) Like this then ?!
July 28, 201411 yr You are checking 5 blocks up and 5 blocks down. Imagine that... no minecraft world has grass at those positions. Grass is just the top layer. So how would then that go, X Y Z. isnt "Z" for UP and DOWN ?! da hell, was i looking at google pictures. if(world.getBlock(x, y, z) != Blocks.dirt || world.getBlock(x + 0, y + 0, z + 1) != Blocks.dirt || world.getBlock(x, y + 0, z + 1) != Blocks.dirt|| world.getBlock(x + 0, y, z) != Blocks.dirt) Like this then ?! In Minecraft, the coordinate system is weird. X is for east/west, Y is for up/down and Z is for north/south. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
July 28, 201411 yr Author You are checking 5 blocks up and 5 blocks down. Imagine that... no minecraft world has grass at those positions. Grass is just the top layer. So how would then that go, X Y Z. isnt "Z" for UP and DOWN ?! da hell, was i looking at google pictures. if(world.getBlock(x, y, z) != Blocks.dirt || world.getBlock(x + 0, y + 0, z + 1) != Blocks.dirt || world.getBlock(x, y + 0, z + 1) != Blocks.dirt|| world.getBlock(x + 0, y, z) != Blocks.dirt) Like this then ?! In Minecraft, the coordinate system is weird. X is for east/west, Y is for up/down and Z is for north/south. So if i am not wrong then my code should be like this 5 block left 5 block right + 1 block high Z - 5, X -5, Y -1
July 28, 201411 yr Author if(world.getBlock(x, y, z) != Blocks.grass || world.getBlock(x + 1, y + 1, z + 1) != Blocks.grass) This is my code, and it spawns sometimes buts its odd. Is there any other code that checks if there is grass even if its one block and then it spawns building ?!
July 29, 201411 yr 1. To get the topmost block during generation, use world.getTopSolidOrLiquidBlock(x, z) 2. Please use descriptive names for your variables. Stuff like i2 or j1 is just confusing. 3. Ever considered using for loops instead of this chunk of repeating setBlock calls you have? Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
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.