Ok, this is my first try modding and I'm trying to make some houses generate. I got everything working & got it to generate cobblestone "totempoles". So then I tried to make it make a rectangle with these. It compiles fine but when I try to generate a world in crashes. This is my code for generating houses:
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode
package net.minecraft.src;
import java.util.Random;
// Referenced classes of package net.minecraft.src:
// WorldGenerator, World, Block
public class WorldGenHouse extends WorldGenerator
{
public WorldGenHouse()
{
}
public boolean generate(World world, Random random, int i, int j, int k)
{
for(int l = 0; l < 2; l++)
{
int i1 = (i + random.nextInt(8)) - random.nextInt(8);
int j1 = (j + random.nextInt(4)) - random.nextInt(4);
int k1 = (k + random.nextInt(8)) - random.nextInt(8);
if(world.isAirBlock(i1, j1 - 1, k1))
{
continue;
}
int l1 = 5;
for( int a1 = 0; a1 < 10; a1 ++ )
{
for( int b1 = 0; b1 < 5; b1 ++ )
{
if(a1 > 0 && a1 < 9 && b1 > 0 && b1 < 4)
{
continue;
}
for(int i2 = 0; i2 < l1; i2++)
{
if(Block.cobblestone.canBlockStay(world, i1 + a1, j1 + i2, k1 + b1))
{
world.setBlock(i1 + a1, j1 + i2, k1 + b1, Block.cobblestone.blockID);
}
}
}
}
}
return true;
}
}
I suggest that you don't make the houses in clusters first(some cactus code is remaining).
What I would do first is to make a new function for generating a house. Move your loopset inside that new function and make generate call it instead with the desired coordinates.
What I can point out is wrong with your code is that your setBlock does not use the correct coordinates. The input most also include the primary locations; i, j and k.
It might not be what's causing the crashes, but whenever you report a crash you need to post the error report.
Ok I changed it to only make 1 house, but I still got the error:
java.lang.RuntimeException: Already decorating!!
at net.minecraft.src.BiomeDecorator.decorate(BiomeDecorator.java:55)
at net.minecraft.src.BiomeGenBase.func_35477_a(BiomeGenBase.java:179)
at net.minecraft.src.ChunkProviderGenerate.populate(ChunkProviderGenerate.java:406)
at net.minecraft.src.ChunkProvider.populate(ChunkProvider.java:158)
at net.minecraft.src.Chunk.populateChunk(Chunk.java:873)
at net.minecraft.src.ChunkProvider.loadChunk(ChunkProvider.java:78)
at net.minecraft.src.ChunkProvider.provideChunk(ChunkProvider.java:88)
at net.minecraft.src.World.getChunkFromChunkCoords(World.java:397)
at net.minecraft.src.World.setBlock(World.java:437)
at net.minecraft.src.WorldGenHouse.generate(WorldGenHouse.java:43)
at net.minecraft.src.BiomeDecorator.decorate_do(BiomeDecorator.java:89)
at net.minecraft.src.BiomeDecorator.decorate(BiomeDecorator.java:62)
at net.minecraft.src.BiomeGenBase.func_35477_a(BiomeGenBase.java:179)
at net.minecraft.src.ChunkProviderGenerate.populate(ChunkProviderGenerate.java:406)
at net.minecraft.src.ChunkProvider.populate(ChunkProvider.java:158)
at net.minecraft.src.Chunk.populateChunk(Chunk.java:873)
at net.minecraft.src.ChunkProvider.loadChunk(ChunkProvider.java:78)
at net.minecraft.src.ChunkProvider.provideChunk(ChunkProvider.java:88)
at net.minecraft.src.World.getChunkFromChunkCoords(World.java:397)
at net.minecraft.src.World.getBlockId(World.java:333)
at net.minecraft.client.Minecraft.preloadWorld(Minecraft.java:1405)
at net.minecraft.client.Minecraft.changeWorld(Minecraft.java:1318)
at net.minecraft.client.Minecraft.changeWorld2(Minecraft.java:1276)
at net.minecraft.client.Minecraft.startWorld(Minecraft.java:1210)
at net.minecraft.src.GuiCreateWorld.actionPerformed(GuiCreateWorld.java:145)
at net.minecraft.src.GuiScreen.mouseClicked(GuiScreen.java:73)
at net.minecraft.src.GuiCreateWorld.mouseClicked(GuiCreateWorld.java:202)
at net.minecraft.src.GuiScreen.handleMouseInput(GuiScreen.java:120)
at net.minecraft.src.GuiScreen.handleInput(GuiScreen.java:110)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:988)
at net.minecraft.client.Minecraft.run(Minecraft.java:483)
at java.lang.Thread.run(Thread.java:662)
Aren't my coordinates correct? i1,j1,k1 all have i,j,k in them and then I'm simply adding a1,b1,and i2.
Aren't my coordinates correct? i1,j1,k1 all have i,j,k in them and then I'm simply adding a1,b1,and i2.
Yes but i1, j1 and k1 are i j and k with randoms (like glenn said). If this worked you'd get parts of your house randomly generated everywhere. Try commenting out the randoms for now like so:
int i1 = i; //(i + random.nextInt(8)) - random.nextInt(8);
int j1 = j; //(j + random.nextInt(4)) - random.nextInt(4);
int k1 = k; //(k + random.nextInt(8)) - random.nextInt(8);
This is ofc temporary to see if it fixes the problem. If not, I think it has to do with timing; biomeDecorator is very picky if something generates before it is finished. I don't know what to tell you to fix it though, did you do anything fancy to the generation call in your mod_ file?
EDIT: I am also not seeing a check to make sure your house is not in a cliffside. I see that it will not generate parts if it is, but it will still generate the outside half (assuming there's an air block under the spot it decided to spawn, say a close-to-surface underwater pool?). Result would be a sliced house lol.
EDIT2: Glenn, what is the difference between setBlock and setBlockWithNotify? I have been using the latter as occasionally the first makes block show up as invisible until they are updated. Another question I have is, is GenerateNether a bit laggy? No matter what I do nor how complex my gen code is I always get more lag in the nether using that function.
Yes but i1, j1 and k1 are i j and k with randoms (like glenn said). If this worked you'd get parts of your house randomly generated everywhere. Try commenting out the randoms for now like so:
int i1 = i; //(i + random.nextInt(8)) - random.nextInt(8);
int j1 = j; //(j + random.nextInt(4)) - random.nextInt(4);
int k1 = k; //(k + random.nextInt(8)) - random.nextInt(8);
This is ofc temporary to see if it fixes the problem. If not, I think it has to do with timing; biomeDecorator is very picky if something generates before it is finished. I don't know what to tell you to fix it though, did you do anything fancy to the generation call in your mod_ file?
EDIT: I am also not seeing a check to make sure your house is not in a cliffside. I see that it will not generate parts if it is, but it will still generate the outside half (assuming there's an air block under the spot it decided to spawn, say a close-to-surface underwater pool?). Result would be a sliced house lol.
Urg, commented out random part, got same error. I'm not using any fancy stuff. I'm also not using modloader, is that a problem?
"Already decorating" is an exception that is printed whenever a chunk which is already being processed is added blocks to by a decoration from another chunk, I believe. It's not serious, so I just commented it out.
I haven't studied the setBlockWithNotfiy/setBlock, but I guess WithNotify runs a few extra onBlockAdded and block updates.
"Already decorating" is an exception that is printed whenever a chunk which is already being processed is added blocks to by a decoration from another chunk, I believe. It's not serious, so I just commented it out.
Sorry for being a noob, but where can I comment this out?
Alright, sorry for the late reply. I tried commenting it out, but the only difference was it gave me java.lang.null or some such. I don't have the files for the mod anymore (that's why no exact error report), but I would like to know this for when I remake it.
I don't know what I'm doing wrong...
What I would do first is to make a new function for generating a house. Move your loopset inside that new function and make generate call it instead with the desired coordinates.
What I can point out is wrong with your code is that your setBlock does not use the correct coordinates. The input most also include the primary locations; i, j and k.
It might not be what's causing the crashes, but whenever you report a crash you need to post the error report.
Aren't my coordinates correct? i1,j1,k1 all have i,j,k in them and then I'm simply adding a1,b1,and i2.
Yes but i1, j1 and k1 are i j and k with randoms (like glenn said). If this worked you'd get parts of your house randomly generated everywhere. Try commenting out the randoms for now like so:
This is ofc temporary to see if it fixes the problem. If not, I think it has to do with timing; biomeDecorator is very picky if something generates before it is finished. I don't know what to tell you to fix it though, did you do anything fancy to the generation call in your mod_ file?
EDIT: I am also not seeing a check to make sure your house is not in a cliffside. I see that it will not generate parts if it is, but it will still generate the outside half (assuming there's an air block under the spot it decided to spawn, say a close-to-surface underwater pool?). Result would be a sliced house lol.
EDIT2: Glenn, what is the difference between setBlock and setBlockWithNotify? I have been using the latter as occasionally the first makes block show up as invisible until they are updated. Another question I have is, is GenerateNether a bit laggy? No matter what I do nor how complex my gen code is I always get more lag in the nether using that function.
Urg, commented out random part, got same error. I'm not using any fancy stuff. I'm also not using modloader, is that a problem?
I haven't studied the setBlockWithNotfiy/setBlock, but I guess WithNotify runs a few extra onBlockAdded and block updates.
Sorry for being a noob, but where can I comment this out?