Jump to content

Slight Issue with World Gen [solution inside]


Naiakoa

Recommended Posts

Forge Version: 9.11.1.952

Minecraft: 1.6.4

 

For short I was testing out what blocks work and what do not when it comes to world generation, so far everything works except for pressure pads, redstone and pistons. The issue is that the pressure pads do not spawn along with the redstone. And the pistons end up facing the wrong direction. Been sitting here for a day or two trying many means of spawning the blocks but no luck on the redstone and stuff. Am I missing something or am I doing something completely wrong? o,O

 

World gen trigger:

 

 

public class NexionWorldGen implements IWorldGenerator

{

public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)

{

switch (world.provider.dimensionId) {

case -1: generateNether(world, random, chunkX * 16, chunkZ * 16);

case 0: generateSurface(world, random, chunkX * 16, chunkZ * 16);

}

}

 

private void generateSurface(World world, Random random, int blockX,int blockZ)

{

int Xcoord1 = blockX + random.nextInt(16);

int Ycoord1 = random.nextInt(65);

int Zcoord1 = blockZ + random.nextInt(16);

 

(new TestGen()).generate(world, random, Xcoord1, Ycoord1, Zcoord1);

}

}

 

 

 

 

The block placement code:

 

 

package Naiakoa.Nexion.WorldGen;

import java.util.Random;

 

import net.minecraft.block.Block;

import net.minecraft.world.World;

import net.minecraft.world.gen.feature.WorldGenerator;

 

public class TestGen extends WorldGenerator

{

protected int[] GetValidSpawnBlocks() {

return new int[] {

Block.grass.blockID

};

}

 

public boolean LocationIsValidSpawn(World world, int i, int j, int k){

int distanceToAir = 0;

int checkID = world.getBlockId(i, j, k);

 

while (checkID != 0){

distanceToAir++;

checkID = world.getBlockId(i, j + distanceToAir, k);

}

 

if (distanceToAir > 3){

return false;

}

j += distanceToAir - 1;

 

int blockID = world.getBlockId(i, j, k);

int blockIDAbove = world.getBlockId(i, j+1, k);

int blockIDBelow = world.getBlockId(i, j-1, k);

for (int x : GetValidSpawnBlocks()){

if (blockIDAbove != 0){

return false;

}

if (blockID == x){

return true;

}else if (blockID == Block.snow.blockID && blockIDBelow == x){

return true;

}

}

return false;

}

 

public TestGen() { }

 

public boolean generate(World world, Random rand, int i, int j, int k) {

//check that each corner is one of the valid spawn blocks

if(!LocationIsValidSpawn(world, i, j, k) || !LocationIsValidSpawn(world, i + 7, j, k) || !LocationIsValidSpawn(world, i + 7, j, k + 5) || !LocationIsValidSpawn(world, i, j, k + 5))

{

return false;

}

 

world.setBlock(i + 0, j + 0, k + 0, Block.blockNetherQuartz.blockID);

world.setBlock(i + 0, j + 0, k + 1, Block.blockNetherQuartz.blockID);

world.setBlock(i + 0, j + 0, k + 2, Block.blockNetherQuartz.blockID);

world.setBlock(i + 0, j + 0, k + 3, Block.blockNetherQuartz.blockID);

world.setBlock(i + 0, j + 0, k + 4, Block.blockNetherQuartz.blockID);

world.setBlock(i + 0, j + 0, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 0, j + 1, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 0, j + 2, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 0, j + 3, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 0, j + 4, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 1, j + 0, k + 0, Block.blockNetherQuartz.blockID);

world.setBlock(i + 1, j + 0, k + 1, Block.blockNetherQuartz.blockID);

world.setBlock(i + 1, j + 0, k + 2, Block.blockNetherQuartz.blockID);

world.setBlock(i + 1, j + 0, k + 3, Block.blockNetherQuartz.blockID);

world.setBlock(i + 1, j + 0, k + 4, Block.blockNetherQuartz.blockID);

world.setBlock(i + 1, j + 0, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 1, j + 1, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 1, j + 2, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 1, j + 3, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 1, j + 4, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 2, j + 0, k + 0, Block.blockNetherQuartz.blockID);

world.setBlock(i + 2, j + 0, k + 1, Block.blockNetherQuartz.blockID);

world.setBlock(i + 2, j + 0, k + 2, Block.blockNetherQuartz.blockID);

world.setBlock(i + 2, j + 0, k + 3, Block.blockNetherQuartz.blockID);

world.setBlock(i + 2, j + 0, k + 4, Block.blockNetherQuartz.blockID);

world.setBlock(i + 2, j + 0, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 2, j + 1, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 2, j + 2, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 2, j + 3, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 2, j + 4, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 3, j + 0, k + 0, Block.blockNetherQuartz.blockID);

world.setBlock(i + 3, j + 0, k + 1, Block.blockNetherQuartz.blockID);

world.setBlock(i + 3, j + 0, k + 2, Block.blockNetherQuartz.blockID);

world.setBlock(i + 3, j + 0, k + 3, Block.blockNetherQuartz.blockID);

world.setBlock(i + 3, j + 0, k + 4, Block.blockNetherQuartz.blockID);

world.setBlock(i + 3, j + 0, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 3, j + 1, k + 4, Block.blockNetherQuartz.blockID);

world.setBlock(i + 3, j + 2, k + 4, Block.blockNetherQuartz.blockID);

world.setBlock(i + 3, j + 3, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 3, j + 4, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 4, j + 0, k + 0, Block.blockNetherQuartz.blockID);

world.setBlock(i + 4, j + 0, k + 1, Block.blockNetherQuartz.blockID);

world.setBlock(i + 4, j + 0, k + 2, Block.blockNetherQuartz.blockID);

world.setBlock(i + 4, j + 0, k + 3, Block.blockNetherQuartz.blockID);

world.setBlock(i + 4, j + 0, k + 4, Block.blockNetherQuartz.blockID);

world.setBlock(i + 4, j + 0, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 4, j + 2, k + 4, Block.pistonStickyBase.blockID);

world.setBlock(i + 4, j + 1, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 4, j + 2, k + 4, Block.pistonStickyBase.blockID);

world.setBlock(i + 4, j + 2, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 4, j + 3, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 4, j + 4, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 5, j + 0, k + 0, Block.blockNetherQuartz.blockID);

world.setBlock(i + 5, j + 0, k + 1, Block.blockNetherQuartz.blockID);

world.setBlock(i + 5, j + 0, k + 2, Block.blockNetherQuartz.blockID);

world.setBlock(i + 5, j + 0, k + 3, Block.blockNetherQuartz.blockID);

world.setBlock(i + 5, j + 0, k + 4, Block.blockNetherQuartz.blockID);

world.setBlock(i + 5, j + 0, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 5, j + 1, k + 4, Block.blockNetherQuartz.blockID);

world.setBlock(i + 5, j + 1, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 5, j + 2, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 5, j + 3, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 5, j + 4, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 6, j + 0, k + 0, Block.blockNetherQuartz.blockID);

world.setBlock(i + 6, j + 0, k + 1, Block.blockNetherQuartz.blockID);

world.setBlock(i + 6, j + 0, k + 2, Block.blockNetherQuartz.blockID);

world.setBlock(i + 6, j + 0, k + 3, Block.blockNetherQuartz.blockID);

world.setBlock(i + 6, j + 0, k + 4, Block.blockNetherQuartz.blockID);

world.setBlock(i + 6, j + 0, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 6, j + 1, k + 4, Block.blockNetherQuartz.blockID);

world.setBlock(i + 6, j + 1, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 6, j + 2, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 6, j + 3, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 6, j + 4, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 7, j + 0, k + 0, Block.blockNetherQuartz.blockID);

world.setBlock(i + 7, j + 0, k + 1, Block.blockNetherQuartz.blockID);

world.setBlock(i + 7, j + 0, k + 2, Block.blockNetherQuartz.blockID);

world.setBlock(i + 7, j + 0, k + 3, Block.blockNetherQuartz.blockID);

world.setBlock(i + 7, j + 0, k + 4, Block.blockNetherQuartz.blockID);

world.setBlock(i + 7, j + 0, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 7, j + 1, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 7, j + 2, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 7, j + 3, k + 5, Block.blockNetherQuartz.blockID);

world.setBlock(i + 7, j + 4, k + 5, Block.blockNetherQuartz.blockID);

world.setBlockMetadataWithNotify(i + 3, j + 1, k + 2, Block.pressurePlateStone.blockID, 0);

world.setBlockMetadataWithNotify(i + 4, j + 1, k + 2, Block.redstoneWire.blockID, 0);

world.setBlockMetadataWithNotify(i + 5, j + 1, k + 2, Block.redstoneWire.blockID, 0);

world.setBlockMetadataWithNotify(i + 5, j + 2, k + 4, Block.redstoneWire.blockID, 0);

world.setBlockMetadataWithNotify(i + 6, j + 1, k + 2, Block.redstoneWire.blockID, 0);

world.setBlockMetadataWithNotify(i + 6, j + 1, k + 3, Block.redstoneWire.blockID, 0);

world.setBlockMetadataWithNotify(i + 6, j + 2, k + 4, Block.redstoneWire.blockID, 0);

 

return true;

}

}

 

 

 

And here is a screenshot to see what actually generates.

 

 

4OkOmXR.png

 

 

 

Edit: issues solved with the following:

 

 

Piston rotation:

world.setBlock(i + 4, j + 1, k + 4, Block.pistonStickyBase.blockID, 1, 2);

world.setBlock(i + 4, j + 1, k + 4, Block.pistonStickyBase.blockID, 2, 2);

world.setBlock(i + 4, j + 1, k + 4, Block.pistonStickyBase.blockID, 3, 2);

world.setBlock(i + 4, j + 1, k + 4, Block.pistonStickyBase.blockID, 4, 2);

world.setBlock(i + 4, j + 1, k + 4, Block.pistonStickyBase.blockID, 5, 2);

world.setBlock(i + 4, j + 1, k + 4, Block.pistonStickyBase.blockID, 6, 2);

 

Redstone and pressureplate spawn fixes:

world.setBlock(i + 3, j + 1, k + 2, Block.pressurePlateStone.blockID, 0, 0);

world.setBlock(i + 4, j + 1, k + 2, Block.redstoneWire.blockID, 0, 0);

 

 

A modder uses search for solutions, a coder asks for help only after looking into the main source of the game modding. A master java programmer has solutions and is helpful. Be friendly to others, they will be friendly to you (depending on how their day goes ;) )

Link to comment
Share on other sites

World#setBlockMetadataWithNotify() sets, like the name suggests, the block metadata. It doesn't change the block id. To pass a metadata along with setBlock, you can use the following World#setBlock:

World#setBlock(int x, int y, int z, int blockID, int metadata, int updateFlags);

Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.

Link to comment
Share on other sites

ok that helped with the non spawning blocks but what about rotating the pistons? x.x (sorry if I seem bit stupid or missing something obvious lack of sleep is a derp)

A modder uses search for solutions, a coder asks for help only after looking into the main source of the game modding. A master java programmer has solutions and is helpful. Be friendly to others, they will be friendly to you (depending on how their day goes ;) )

Link to comment
Share on other sites

Well, you were close when you were using a method related to metadata: Play with the metadata parameter of the setBlock method of the piston, you'll see the piston's rotation is defined by that.

Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.

Link to comment
Share on other sites

Yea...lol got arround to getting it...Thanks for quick reply, lack of sleep screws with the mind ignoring the obvious stuff haha.

A modder uses search for solutions, a coder asks for help only after looking into the main source of the game modding. A master java programmer has solutions and is helpful. Be friendly to others, they will be friendly to you (depending on how their day goes ;) )

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.