tModLoader Modding Tutorial: World Generation

Did this thread help you?

  • Yes it did!

    Votes: 54 93.1%
  • No, it didn't.

    Votes: 4 6.9%

  • Total voters
    58
  • Poll closed .
I tried to do:

Code:
for (int k = 0; k < 50; k++)

                {
                    WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.rockLayerHigh (int)WorldGen.rockLayerLow), (double)WorldGen.genRand.Next(6, 8), WorldGen.genRand.Next(6, 8), mod.TileType("PandaBlockOre"), false, 0f, 0f, false, true);
                }

When I tried to generate a new world, the game crashed saying:

'minValue' cannot be greater than maxValue.
Parameter name: minValue
at System.Random.Next(Int32 minValue, Int32 maxValue)
at PandaMod.ModWord.<ModifyWorldGenTasks>b__1(GenerationProgress progress)
at Terraria.GameContent.Generation.PassLegacy.Apply(GenerationProgress progress)
at Terraria.World.Generation.WorldGenerator.GenerateWorld(GenerationProgress progress)
at Terraria.WorldGen.generateWorld(Int32 seed, GenerationProgress customProgressObject)
at Terraria.WorldGen.do_worldGenCallBack(Object threadContext)
at Terraria.WorldGen.worldGenCallBack(Object threadContext)
 
Tried and same error

EDIT: It worked
[doublepost=1474914497,1474914301][/doublepost]The game loads but the ore does not spawn. Cant find it anywhere
 
I'll add that to the main post (in a while), it's not that hard ;)

Edit: Added! Look at the bottom of the post. It's not too cool looking, but it works :p
 
Last edited:
I'm having a bit of issues with this tutorial (probably due to my lack of C# syntax knowledge), are you able to make code where during world generation (or add a consumable item to do so), it auto generates a stone house with a door, chest, workbench, bed, chair, and chandelier?
Pretty would be better, but if you can make a basic skeleton mod of this, I could add/edit the lines to make what I want.
 
I've done something similar to this already. You don't need to have your WorldGen code in your ModWorld, just put it in your ModItem's UseItem method. Try that before I make a little file :p
 
Here's a request: How would i either add items to vanilla chest (new items to place in for example wooden chests) and/or make a dungeon chest?
 
I did, it's in the spoiler. Apart from that, it just uses WorldGen.KillTile in the area specified, not sure what else to say.
 
Back
Top Bottom