tModLoader v2024.09
A mod to make and play Terraria mods
WorldGen Class Reference

Classes

struct  CheckTreeSettings
 
struct  GrowTreeSettings
 
class  Hooks
 
class  SavedOreTiers
 
class  Spread
 
class  TenthAnniversaryWorldInfo
 
struct  TileMergeCullCache
 
class  WorldSize
 

Public Types

enum  SpecialKillTileContext { None , MowingTheGrass }
 

Public Member Functions

delegate void GenPassDetour (orig_GenPassDetour orig, object self, GenerationProgress progress, GameConfiguration configuration)
 
delegate bool GetTreeFoliageDataMethod (int i, int j, int xoffset, ref int treeFrame, ref int treeStyle, out int floorY, out int topTextureFrameWidth, out int topTextureFrameHeight)
 
delegate void orig_GenPassDetour (object self, GenerationProgress progress, GameConfiguration configuration)
 

Static Public Member Functions

static bool ActiveAndWalkableTile (int i, int j)
 
static bool AddBuriedChest (int i, int j, int contain=0, bool notNearOtherChests=false, int Style=-1, bool trySlope=false, ushort chestTileType=0)
 Attempts to place a chest and fill it with typical loot according to the style (Style ) and depth. Without any parameters, a regular, gold, or locked shadow chest will be created, depending on the depth. You can pass in an item type (contain ) and the first item in the chest will be that item. Unlike PlaceChest(int, int, ushort, bool, int), the resulting chest will be placed with the bottom right corner at the given coordinates (i , j ). In addition, if the given j coordinate isn't suitable, AddBuriedChest will search down from the given coordinate to find the first solid tile it encounters and attempt to place there. This method returns true if a chest was successfully placed, but be aware that the chest might not be exactly at the coordinates you provide. This makes further adjusting the chest contents directly difficult. A video guide can be found on the World Generation wiki page. It shows an example of running the method with the default parameters WorldGen.AddBuriedChest(x, y);. Notice how the chest style changes according to depth and how the chest is placed on the floor directly below the provided coordinates if possible. More...
 
static bool AddBuriedChest (Point point, int contain=0, bool notNearOtherChests=false, int Style=-1)
 
static void AddHellHouses ()
 
static bool AddLifeCrystal (int i, int j)
 
static void AddShadowOrb (int x, int y)
 
static void AddTrees (bool undergroundOnly=false)
 
static void AddUpAlignmentCounts (bool clearCounts=false)
 
static bool AllowsSandfall (Tile tileTopCache)
 
static bool AnchorValid (Tile tileCache, AnchorType anchor)
 
static bool AshTreeGroundTest (int tileType)
 
static bool AttemptReorientingStinkbugBlocker (int x, int y, int wall, ref int style)
 
static bool AttemptToGrowTreeFromSapling (int x, int y, bool underground)
 
static bool BiomeTileCheck (int x, int y)
 
static bool BlockBelowMakesSandConvertIntoHardenedSand (int i, int j)
 
static bool BlockBelowMakesSandFall (int i, int j)
 
static bool BottomEdgeCanBeAttachedTo (int i, int j)
 
static void BroadcastText (NetworkText text, byte r, byte g, byte b)
 
static void BroadcastText (NetworkText text, Color color)
 
static void BroadcastText (NetworkText text, int r, int g, int b)
 
static void BroadcastText (NetworkText text, Vector3 color)
 
static void BroadcastText (NetworkText text, Vector4 color)
 
static bool BunnyCannonCanFire ()
 
static void CactusFrame (int i, int j)
 
static bool CanCutTile (int x, int y, TileCuttingContext context)
 
static bool CanKillTile (int i, int j)
 
static bool CanKillTile (int i, int j, out bool blockDamaged)
 
static bool CanKillTile (int i, int j, SpecialKillTileContext context)
 
static int CanPlaceProjectilePressurePad (int x, int y, int type=442, int style=0, int direction=0, int alternate=0)
 
static bool CanPlaceSink (int x, int y, ushort type, int style)
 
static bool CanPoundTile (int x, int y)
 
static bool CanUnderwaterPlantGrowHere (ushort type, int x, int y, bool ignoreSelf)
 
static void CaveOpenater (int i, int j)
 
static void Caverer (int X, int Y)
 
static void Cavinator (int i, int j, int steps)
 
static void ChasmRunner (int i, int j, int steps, bool makeOrb=false)
 
static void ChasmRunnerSideways (int i, int j, int direction, int steps)
 
static void Check1x1 (int x, int y, int type)
 
static void Check1x2 (int x, int j, ushort type)
 
static void Check1x2Top (int x, int j, ushort type)
 
static void Check1xX (int x, int j, short type)
 
static void Check2x1 (int i, int y, ushort type)
 
static void Check2x2 (int i, int j, int type)
 
static void Check2x2Style (int i, int j, int type)
 
static void Check2x3Wall (int x, int y)
 
static void Check2x5 (int i, int j, int type)
 
static void Check2xX (int i, int j, ushort type)
 
static void Check3x1 (int i, int j, int type)
 
static void Check3x2 (int i, int j, int type)
 
static void Check3x2Wall (int x, int y)
 
static void Check3x3 (int i, int j, int type)
 
static void Check3x3Wall (int x, int y)
 
static void Check3x4 (int i, int j, int type)
 
static void Check3x5 (int i, int j, int type)
 
static void Check3x6 (int i, int j, int type)
 
static void Check4x2 (int i, int j, int type)
 
static void Check4x3Wall (int x, int y)
 
static void Check5x4 (int i, int j, int type)
 
static void Check6x3 (int i, int j, int type)
 
static void Check6x4Wall (int x, int y)
 
static void CheckAchievement_RealEstateAndTownSlimes ()
 
static void CheckAlch (int x, int y)
 
static void CheckBamboo (int x, int y)
 
static void CheckBanner (int x, int j, byte type)
 
static bool CheckBoulderChest (int i, int j)
 
static bool CheckCactus (int i, int j)
 
static void CheckCannon (int i, int j, int type)
 
static void CheckCatTail (int x, int j)
 
static void CheckChand (int i, int j, int type)
 
static void CheckChest (int i, int j, int type)
 
static void CheckDye (int x, int y)
 
static void CheckFoodPlatter (int x, int y, int type)
 
static void CheckGnome (int x, int j)
 
static void CheckGolf1x1 (int x, int y, int type)
 
static void CheckJunglePlant (int i, int j, int type)
 
static void CheckLilyPad (int x, int y)
 
static void CheckLogicTiles (int x, int y, int type)
 
static void CheckMan (int i, int j)
 
static void CheckMB (int i, int j, int type)
 
static void CheckOasisPlant (int i, int j, int type=530)
 
static void CheckOnTable1x1 (int x, int y, int type)
 
static void CheckOrb (int i, int j, int type)
 
static void CheckPalmTree (int i, int j)
 
static void CheckPile (int i, int y)
 
static void CheckPot (int i, int j, int type=28)
 
static void CheckProjectilePressurePad (int i, int j)
 
static void CheckRockGolemHead (int x, int y)
 
static void CheckRoom (int x, int y)
 
static void CheckSign (int x, int y, ushort type)
 
static bool CheckSpecialTownNPCSpawningConditions (int type)
 
static void CheckStinkbugBlocker (int x, int y)
 
static void CheckSunflower (int i, int j, int type=27)
 
static void CheckSuper (int x, int y, int type)
 
static void CheckTallGate (int x, int y, int type)
 
static void CheckTight (int x, int j)
 
static bool CheckTileAnchors (int sx, int sy, int w, int h, int mode, AnchorType anchor)
 
static int CheckTileBreakability (int x, int y)
 
static bool CheckTileBreakability2_ShouldTileSurvive (int x, int y)
 
static bool CheckTileFrames (int type, int sx, int sy, int w, int h, int styleX, int frameXinc, int styleY, int frameYinc)
 
static void CheckTorch (int x, int y)
 
static void CheckTrapDoor (int x, int y, int type)
 
static void CheckTree (int i, int j)
 
static void CheckTreeWithSettings (int x, int y, CheckTreeSettings settings)
 
static bool checkUnderground (int x, int y)
 
static void CheckUnderwaterPlant (ushort type, int x, int y)
 
static void CheckWeaponsRack (int i, int j)
 
static void CheckWoman (int i, int j)
 
static void CheckXmasTree (int x, int y)
 
static int checkXmasTreeDrop (int x, int y, int obj)
 
static bool Chlorophyte (int i, int j)
 
static void ChlorophyteDefense (int x, int y)
 
static void ClearAllBrokenTraps ()
 
static void ClearBrokenTraps (Point startTileCoords, List< Point > pointsWeAlreadyWentOver)
 
static void clearWorld ()
 
static bool CloseDoor (int i, int j, bool forced=false)
 
static void CloudIsland (int i, int j)
 
static void CloudLake (int i, int j)
 
static Color coatingColor (int coating)
 
static List< Color > coatingColors (Tile tile, bool block)
 
static void ConsumePostGenActions (StructureMap structures)
 
static void Convert (int i, int j, int conversionType, int size=4)
 Converts biome variant tiles and walls to a target biome.
Converts a 9x9 square by default, but can be adjusted with the size parameter. More...
 
static int countDirtTiles (int x, int y)
 
static int CountNearBlocksTypes (int i, int j, int radius, int cap=0, params int[] tiletypes)
 
static void CountTiles (int X)
 
static int countTiles (int x, int y, bool jungle=false, bool lavaOk=false)
 
static void CountTileTypesInArea (int[] tileTypeCounts, int startX, int endX, int startY, int endY)
 
static int[] CountTileTypesInWorld (params int[] oreTypes)
 
static int countWires (int x, int y, int size)
 
static Task CreateNewWorld (GenerationProgress progress=null)
 
static void CrimEnt (Vector2D position, int crimDir)
 
static void CrimPlaceHearts ()
 
static void CrimStart (int i, int j)
 
static void CrimVein (Vector2D position, Vector2D velocity)
 
static bool DefaultTreeWallTest (int wallType)
 
static void DesertCloudIsland (int i, int j)
 
static void DestroyHeart (int i, int j)
 
static void DetourPass (PassLegacy pass, GenPassDetour hookDelegate)
 
static void DiamondTileFrame (int i, int j)
 
static Vector2D digTunnel (double X, double Y, double xDir, double yDir, int Steps, int Size, bool Wet=false)
 
static void DirtyRockRunner (int i, int j)
 
static void do_worldGenCallBack (object threadContext)
 
static bool DoesWindBlowAtThisHeight (int tileY)
 
static void DontStarveTryWateringTile (int x, int y)
 
static void DropDoorItem (int x, int y, int doorStyle)
 
static void dropMeteor ()
 
static void dropXmasTree (int x, int y, int obj)
 
static void DungeonEnt (int i, int j, ushort tileType, int wallType)
 
static void DungeonHalls (int i, int j, ushort tileType, int wallType, bool forceX=false)
 
static bool DungeonPitTrap (int i, int j, ushort tileType, int wallType)
 
static void DungeonRoom (int i, int j, ushort tileType, int wallType)
 
static void DungeonStairs (int i, int j, ushort tileType, int wallType)
 
static bool EmptyLiquid (int x, int y)
 
static bool EmptyTileCheck (int startX, int endX, int startY, int endY, int ignoreID=-1)
 
static void EveryTileFrame ()
 
static void ExplodeMine (int i, int j, bool fromWiring)
 
static void FillWallHolesInArea (Rectangle worldCoordsArea)
 
static void FixChand (int i, int j)
 
static void FixChands ()
 
static void FixHeart (int i, int j)
 
static void FixHearts ()
 
static void FixSunflower (int i, int j)
 
static void FixSunflowers ()
 
static void FloatingIsland (int i, int j)
 
static void gemCave (int x, int y)
 
static bool GemTreeGroundTest (int tileType)
 
static bool GemTreeWallTest (int wallType)
 
static bool GeneratePlanteraBulbOnAllMechsDefeated ()
 
static void GenerateWorld (int seed, GenerationProgress customProgressObject=null)
 
static void GERunner (int i, int j, double speedX=0.0, double speedY=0.0, bool good=true)
 
static bool GetAshTreeFoliageData (int i, int j, int xoffset, ref int treeFrame, ref int treeStyle, out int floorY, out int topTextureFrameWidth, out int topTextureFrameHeight)
 
static void GetBiomeInfluence (int startX, int endX, int startY, int endY, out int corruptCount, out int crimsonCount, out int hallowedCount)
 
static void GetCactusType (int tileX, int tileY, int frameX, int frameY, out bool evil, out bool good, out bool crimson)
 
static void GetCactusType (int tileX, int tileY, int frameX, int frameY, out bool evil, out bool good, out bool crimson, out int type)
 
static void GetCactusType (int tileX, int tileY, int frameX, int frameY, out int type)
 
static bool GetCommonTreeFoliageData (int i, int j, int xoffset, ref int treeFrame, ref int treeStyle, out int floorY, out int topTextureFrameWidth, out int topTextureFrameHeight)
 
static bool GetGemTreeFoliageData (int i, int j, int xoffset, ref int treeFrame, ref int treeStyle, out int floorY, out int topTextureFrameWidth, out int topTextureFrameHeight)
 
static int GetHollowTreeFoliageStyle ()
 
static int GetItemDrop_Benches (int style)
 
static int GetItemDrop_Chair (int style)
 
static int GetItemDrop_PicnicTables (int style)
 
static int GetItemDrop_Toilet (int style)
 
static IEntitySource GetItemSource_FromTileBreak (int x, int y)
 
static IEntitySource GetItemSource_FromTreeShake (int x, int y)
 
static IEntitySource GetItemSource_FromWallBreak (int x, int y)
 
static TileChangeType GetLiquidChangeType (int liquidType, int otherLiquidType)
 
static int GetNextJungleChestItem ()
 
static EntitySource_ShakeTree GetNPCSource_ShakeTree (int x, int y)
 
static void GetRidOfCultists ()
 
static void GetSectionBounds (int sectionStartX, int sectionStartY, int sectionEndXInclusive, int sectionEndYInclusive, out int tileStartX, out int tileEndX, out int tileStartY, out int tileEndY)
 
static int GetTileMossColor (int tileType)
 
static int GetTileTypeCountByCategory (int[] tileTypeCounts, TileScanGroup group)
 
static ? Rectangle GetTileVisualHitbox (int x, int y)
 
static Point GetTopLeftAndStyles (ref int x, ref int y, int w, int h, int frameXinc, int frameYinc)
 
static void GetTreeBottom (int i, int j, out int x, out int y)
 
static int GetTreeFrame (Tile t)
 
static void GetTreeLeaf (int x, Tile topTile, Tile t, ref int treeHeight, out int treeFrame, out int passStyle)
 
static TreeTypes GetTreeType (int tileType)
 
static bool GetVanityTreeFoliageData (int i, int j, int xoffset, ref int treeFrame, ref int treeStyle, out int floorY, out int topTextureFrameWidth, out int topTextureFrameHeight)
 
static int GetWorldSize ()
 
static double GetWorldUpdateRate ()
 
static void GrowAlch (int x, int y)
 
static void GrowCactus (int i, int j)
 
static void GrowCatTail (int x, int j)
 
static void GrowCheckSeaweed (int x, int y)
 
static bool GrowDungeonTree (int i, int j, bool patch=false)
 
static bool GrowEpicTree (int i, int y)
 
static bool GrowLivingTree (int i, int j, bool patch=false)
 
static bool GrowPalmTree (int i, int y)
 
static void GrowPumpkin (int i, int j, int type)
 
static bool GrowShroom (int i, int y)
 
static void GrowSpike (int i, int j, ushort spikeType, ushort landType)
 
static bool GrowTree (int i, int y)
 
static bool GrowTreeWithSettings (int checkedX, int checkedY, GrowTreeSettings settings)
 
static void GrowUndergroundTree (int i, int y)
 
static void hardUpdateWorld (int i, int j)
 
static bool HasAnyWireNearby (int sourceX, int sourceY, int boxSpread)
 
static void HellFort (int i, int j, ushort tileType=75, byte wallType=14)
 
static void HellHouse (int i, int j, byte type=76, byte wall=13)
 
static void HellRoom (int i, int j, int width, int height, byte type=76, byte wall=13)
 
static void Housing_GetTestedRoomBounds (out int startX, out int endX, out int startY, out int endY)
 
static bool InAPlaceWithWind (int x, int y, int width, int height)
 
static bool InAPlaceWithWind (Vector2 position, int width, int height)
 
static bool InWorld (int x, int y, int fluff=0)
 Returns true if the provided tile coordinates are within the world bounds. When dealing with random coordinates combined with addition or subtraction, there is a chance you might construct coordinates outside the bounds of the world. This will crash world generation, so it is important that you check that the coordinates are suitable before attempting to do things at those coordinates. Use this method to check if the given coordinates fall inside the world. The fluff parameter further checks that the coordinates are at least that many tiles away from the edge, which is useful for world generation actions that could affect large areas of tiles. More...
 
static bool IsAContainer (Tile t)
 
static bool IsBackgroundConsideredTheSame (int oldBG, int newBG)
 
static bool IsBelowANonHammeredPlatform (int x, int y)
 
static bool IsChestRigged (int x, int y)
 
static bool IsFitToPlaceFlowerIn (int x, int y, int typeAttemptedToPlace)
 
static bool IsHarvestableHerbWithSeed (int type, int style)
 
static bool IsItATrap (Tile tile)
 
static bool IsItATrigger (Tile tile)
 
static void IslandHouse (int i, int j, int islandStyle)
 
static bool IsLockedDoor (int x, int y)
 
static bool IsLockedDoor (Tile t)
 
static bool IsNPCEvictable (int n)
 
static bool IsOpenDoorAnchorFrame (int x, int y)
 
static bool IsPalmOasisTree (int x)
 
static bool IsRope (int x, int y)
 
static bool IsSafeFromRain (int startX, int startY)
 
static bool IsThereASpawnablePrioritizedTownNPC (int x, int y, ref bool canSpawnNewTownNPC)
 
static bool IsThereASpawnablePrioritizedTownNPC_Old (int x, int y)
 
static bool IsThisAMushroomTree (int i, int j)
 
static bool IsTileALeafyTreeTop (int i, int j)
 
static bool IsTileNearby (int x, int y, int type, int distance)
 
static bool IsTileReplacable (int x, int y)
 
static bool IsTileTypeFitForTree (ushort type)
 
static bool IsTreeType (int tree)
 
static void JustQuit ()
 
static void kickOut (int n)
 
static bool KillActuator (int i, int j)
 
static void KillTile (int i, int j, bool fail=false, bool effectOnly=false, bool noItem=false)
 Attempts to destroy the tile at the provided tile coordinates.Callers can use fail , effectOnly , and noItem to dictate if the intention is to not actually kill the tile, only spawn kill tile effects, and not drop items respectively. For example, worms typically use fail: true, effectOnly: true to spawn dust indicating the worm burrowing through the ground. ModTile.KillTile(int, int, ref bool, ref bool, ref bool) and GlobalTile.KillTile(int, int, int, ref bool, ref bool, ref bool) will be called to modify those values.Note that this method will destroy a single tile and then call the tile framing code. The noItem parameter is only relevant for 1x1 tiles, not multi-tiles. The tile framing code is what triggers multi-tiles to destroy all of their remaining tiles and drop their placement item. GlobalTile.Drop(int, int, int) must be used by the caller if the intention is to prevent item drops from a multi-tile. More...
 
static int KillTile_GetTileDustAmount (bool fail, Tile tileCache, int x, int y)
 
static int KillTile_MakeTileDust (int i, int j, Tile tileCache)
 
static void KillTile_PlaySounds (int i, int j, bool fail, Tile tileCache)
 
static void KillWall (int i, int j, bool fail=false)
 
static bool KillWire (int i, int j)
 
static bool KillWire2 (int i, int j)
 
static bool KillWire3 (int i, int j)
 
static bool KillWire4 (int i, int j)
 
static void Lakinater (int i, int j, double strengthMultiplier=1.0)
 
static void LaunchRocket (int x, int y, bool fromWiring)
 
static void LaunchRocketSmall (int x, int y, bool fromWiring)
 
static bool LeftEdgeCanBeAttachedTo (int i, int j)
 
static void MakeDungeon (int x, int y)
 
static void makeTemple (int x, int y)
 
static void MakeWateryIceThing (int i, int j)
 
static bool MarblePileWithStatues (int X, int Y)
 
static bool mayanTrap (int x2, int y2)
 
static void MessageLunarApocalypse ()
 
static bool meteor (int i, int j, bool ignorePlayers=false)
 
static void MineHouse (int i, int j)
 
static void ModifyPass (PassLegacy pass, ILContext.Manipulator callback)
 
static void Mountinater (int i, int j)
 
static void moveRoom (int x, int y, int n)
 
static bool MoveTownNPC (int x, int y, int n)
 
static void MudWallRunner (int i, int j)
 
static bool NearFriendlyWall (int x, int y)
 
static bool nearPicture (int x, int y)
 
static bool nearPicture2 (int x, int y)
 
static void neonMossBiome (int i, int j, int maxY=99999)
 
static void nextCount (int x, int y, bool jungle=false, bool lavaOk=false)
 
static void nextDirtCount (int x, int y)
 
static void oceanCave (int i, int j)
 
static bool oceanDepths (int x, int y)
 
static bool OpenDoor (int i, int j, int direction)
 
static void OreHelper (int X, int Y)
 
static bool OrePatch (int X, int Y)
 
static void OreRunner (int i, int j, double strength, int steps, ushort type)
 Similar to TileRunner(int, int, double, int, int, bool, double, double, bool, bool, int), but without many of the options. OreRunner places small splotches of the specified tile (type ) starting at the coordinates (i and j in tile coordinates). OreRunner only replaces active tiles (Tile.HasTile) that are either TileID.Sets.CanBeClearedDuringOreRunner or Main.tileMoss, making it suitable to be used even after FrameImportant tiles (Main.tileFrameImportant) exist in the world. If you have a tile that should be susceptible to being replaced when additional ores are spawned in the world, set TileID.Sets.CanBeClearedDuringOreRunner to true for that ModTile. Vanilla code only uses this method when spawning hardmode ores. This method is suitable for use in-game and in multiplayer as it both frames and syncs tile changes. More...
 
static void outerTempled (int x, int y)
 
static void paintCoatEffect (int x, int y, byte paintCoatId, List< Color > oldColors)
 
static bool paintCoatTile (int x, int y, byte paintCoatId, bool broadcast=false)
 
static bool paintCoatWall (int x, int y, byte paintCoatId, bool broadcast=false)
 
static Color paintColor (int color)
 
static void paintEffect (int x, int y, byte color, byte oldColor)
 
static bool paintTile (int x, int y, byte color, bool broadCast=false)
 
static bool paintWall (int x, int y, byte color, bool broadCast=false)
 
static void Place1x1 (int x, int y, int type, int style=0)
 
static void Place1x2 (int x, int y, ushort type, int style)
 
static void Place1x2Top (int x, int y, ushort type, int style)
 
static void Place1xX (int x, int y, ushort type, int style=0)
 
static void Place2x1 (int x, int y, ushort type, int style=0)
 
static void Place2x2 (int x, int y, ushort type, int style)
 
static bool Place2x2Horizontal (int x, int y, ushort type, int Style=0)
 
static void Place2x2Style (int x, int y, ushort type, int style=0)
 
static void Place2x3Wall (int x, int y, ushort type, int style)
 
static void Place2xX (int x, int y, ushort type, int style=0)
 
static void Place3x1 (int x, int y, ushort type, int style=0)
 
static void Place3x2 (int x, int y, ushort type, int style=0)
 
static void Place3x2Wall (int x, int y, ushort type, int style)
 
static void Place3x3 (int x, int y, ushort type, int style=0)
 
static void Place3x3Wall (int x, int y, ushort type, int style)
 
static void Place3x4 (int x, int y, ushort type, int style)
 
static void Place4x2 (int x, int y, ushort type, int direction=-1, int style=0)
 
static void Place4x3Wall (int x, int y, ushort type, int style)
 
static void Place5x4 (int x, int y, ushort type, int style)
 
static void Place6x3 (int x, int y, ushort type, int direction=-1, int style=0)
 
static void Place6x4Wall (int x, int y, ushort type, int style)
 
static bool PlaceActuator (int i, int j)
 
static bool PlaceAlch (int x, int y, int style)
 
static void PlaceBanner (int x, int y, ushort type, int style=0)
 
static void PlaceCannon (int x, int y, ushort type, int style=0)
 
static Point PlaceCatTail (int x, int j)
 
static void PlaceChand (int x, int y, ushort type, int style=0)
 
static int PlaceChest (int x, int y, ushort type=21, bool notNearOtherChests=false, int style=0)
 Attempts to place a chest at the given tile coordinates. The coordinate provided (x , y ) will be the bottom left corner of the resulting chest, if the method succeeds. type is the tile type to place, and style is the tile style to place. For vanilla chests, you can count from zero starting from the left in the Tiles_21.png image after extracting the vanilla texturesto find the style you want to place. Another option is to follow the Tile IDs wiki guideto find the style. notNearOtherChests can be set to true to prevent the chest from placing if another chest exists within 25 tiles left or right and 8 tiles up or down. This method returns the chest index (the index within Main.chest) of the chest that was successfully placed or -1 if placing the chest failed. Chest placement can fail for many reasons, such as if existing tiles block the space, or if there isn't 2 suitable solid tiles directly below the intended location. See the "Try Until Success" section of the World Generation wiki guidefor an approach to using this method. See the "Placing Items in Chests" section of the World Generation wiki guidefor info on placing items in the chest. The AddBuriedChest(int, int, int, bool, int, bool, ushort) method places a chest and fills it with the default items for that chest. More...
 
static void PlaceChestDirect (int x, int y, ushort type, int style, int id)
 Used for network syncing. Modders should use PlaceChest(int, int, ushort, bool, int) if attempting to place a chest.
 
static bool PlaceDoor (int i, int j, int type, int style=0)
 
static void PlaceDresserDirect (int x, int y, ushort type, int style, int id)
 
static void PlaceDye (int x, int y, int style)
 
static void PlaceGnome (int x, int y, int style)
 
static void PlaceJunglePlant (int X2, int Y2, ushort type, int styleX, int styleY)
 
static bool placeLavaTrap (int x, int y)
 
static bool PlaceLilyPad (int x, int j)
 
static bool PlaceLiquid (int x, int y, byte liquidType, byte amount)
 
static void PlaceLogicTiles (int x, int y, int type, int style=0)
 
static void PlaceMan (int i, int j, int dir)
 
static void PlaceMB (int X, int y, ushort type, int style)
 
static bool PlaceOasis (int X, int Y)
 
static void PlaceOasisPlant (int X, int Y, ushort type=530)
 
static bool PlaceObject (int x, int y, int type, bool mute=false, int style=0, int alternate=0, int random=-1, int direction=-1)
 
static void PlaceOnTable1x1 (int x, int y, int type, int style=0)
 
static bool PlacePot (int x, int y, ushort type=28, int style=0)
 
static void PlacePumpkin (int x, int superY)
 
static bool PlaceSandTrap (int i, int j)
 
static bool PlaceSign (int x, int y, ushort type, int Style=0)
 
static bool PlaceSmallPile (int i, int j, int X, int Y, ushort type=185)
 Places TileID.SmallPiles tiles. This tile is special and doesn't follow the normal style rules and won't place with PlaceTile. i and j are the coordinates. X and Y are the count and row indexes of the specific tile in the texture file. Indexes count from left to right and start at 0. So for example the Sapphire Stash would have Y=1 (second row) and X=21 (22nd 2x1 tile). More...
 
static void PlaceStatueTrap (int x, int y)
 
static void PlaceSunflower (int x, int y, ushort type=27)
 
static void PlaceTight (int x, int y, bool spiders=false)
 
static bool PlaceTile (int i, int j, int Type, bool mute=false, bool forced=false, int plr=-1, int style=0)
 PlaceTile is the main way to place individual tiles while obeying anchor considerations. Most of the other PlaceX methods in the WorldGen class are called by this method. i and j are the tile coordinates. These coordinates relate to the origin of the tile, not necessarily the top left corner of the tile. Read the Basic Tile wiki guideto familiarize yourself with the concepts of Anchors and Origins. mute indicates if a sound should be made, this only applies to in-game usage as sounds are all muted during world gen. forced attempts to place the tile even if other tiles are already at the coordinates, but it is unreliable. plr does nothing except affect bathtubs. style refers to the style of the tile type provided. Styles are explained in the Basic Tile guide. PlaceTile returns a bool indicating placement success. Unfortunately, it doesn't work, don't use it. Checking the coordinates after calling PlaceTile is a good way to check if the placement was a success: if(Main.tile[x, y].TileType == TileID.Campfire) PlaceTile doesn't expose everything. For example, attempting to place a tile with a specific style will be ignored by many of the underlying methods. Another issue is that it is impossible to place a tile that has left and right placement orientations facing right. In these situations, you might need to manually place each tile in the multitile or use PlaceObject(int, int, int, bool, int, int, int, int) instead. WorldGen.PlaceObject requires more input. For example, placing Coral with PlaceObject means you have to manually specify the style, as the random style (TileObjectData.RandomStyleRange) choosing is a feature of PlaceTile. If called in-game, the changed tiles would need to be synced if placement is successful. See NetMessage.SendTileSquare(int, int, int, int, int, TileChangeType) for more information and examples. More...
 
static bool placeTrap (int x2, int y2, int type=-1)
 
static void PlaceUncheckedStalactite (int x, int y, bool preferSmall, int variation, bool spiders)
 
static void PlaceUnderwaterPlant (ushort type, int x, int y)
 
static void PlaceWall (int i, int j, int type, bool mute=false)
 
static bool PlaceWire (int i, int j)
 
static bool PlaceWire2 (int i, int j)
 
static bool PlaceWire3 (int i, int j)
 
static bool PlaceWire4 (int i, int j)
 
static void PlaceWoman (int i, int j, int dir)
 
static void PlaceXmasTree (int x, int y, ushort type=171)
 
static int PlaceXmasTree_Direct (int x, int y, int type, int style, int dir, int alternate)
 
static void PlantAlch ()
 
static void PlantCactus (int i, int j)
 
static void PlantCheck (int x, int y)
 
static void plantDye (int i, int j, bool exoticPlant=false)
 
static int PlatformProperSides (int x, int y, bool acceptNonOpposing=false)
 
static bool PlatformProperTopFrame (short frameX)
 
static bool PlayerLOS (int x, int y)
 
static void PlayLiquidChangeSound (TileChangeType eventType, int x, int y, int count=1)
 
static void playWorld ()
 
static void playWorldCallBack (object threadContext)
 
static void PoundPlatform (int x, int y)
 
static bool PoundTile (int i, int j)
 
static bool Pyramid (int i, int j)
 
static void QueuePostGenAction (Action< StructureMap > action)
 
static void QuickFindHome (int npc)
 
static PaintingEntry RandBonePicture ()
 
static int randGem ()
 
static ushort randGemTile ()
 
static PaintingEntry RandHellPicture ()
 
static PaintingEntry RandHousePicture ()
 
static PaintingEntry RandHousePictureDesert ()
 
static void randMoss (bool justNeon=false)
 
static void RandomizeBackgroundBasedOnPlayer (UnifiedRandom random, Player player)
 
static void RandomizeBackgrounds (UnifiedRandom random)
 
static void RandomizeCaveBackgrounds ()
 
static void RandomizeMoonState (UnifiedRandom random, bool garenteeNewStyle=false)
 
static void RandomizeTreeStyle ()
 
static void RandomizeWeather ()
 
static Point RandomRectanglePoint (int x, int y, int width, int height)
 
static Point RandomRectanglePoint (Rectangle rectangle)
 
static Point RandomWorldPoint (int padding)
 
static Point RandomWorldPoint (int top=0, int right=0, int bottom=0, int left=0)
 Generates a random tile coordinate within the world bounds. The optional parameters define additional padding, avoiding the edges or defining a target area. Point point = WorldGen.RandomWorldPoint((int)Main.worldSurface, 40, 500, 60) is equivalent to More...
 
static PaintingEntry RandPictureTile ()
 
static void RangeFrame (int startX, int startY, int endX, int endY)
 
static void Reframe (int x, int y, bool resetFrame=false)
 
static void RefreshSection (int sectionX, int sectionY)
 
static void RefreshSections (int startX, int startY, int endX, int endY)
 
static void RefreshStrip (int xStart, int yStart, int xEnd, int yEnd, ref int totalEcho, ref int totalFramed)
 
static void RenameWorld (WorldFileData data, string newName, Action< string > callback=null)
 
static void RenameWorldCallBack (object threadContext)
 
static bool ReplaceTile (int x, int y, ushort targetType, int targetStyle)
 
static bool ReplaceWall (int x, int y, ushort targetWall)
 
static void ResetTreeShakes ()
 
static bool RightEdgeCanBeAttachedTo (int i, int j)
 
static bool RoomNeeds (int npcType)
 
static void saveAndPlay ()
 
static void saveAndPlayCallBack (object threadContext)
 
static void SaveAndQuit (Action callback=null)
 
static void SaveAndQuitCallBack (object threadContext)
 
static void saveToonWhilePlaying ()
 
static void saveToonWhilePlayingCallBack (object threadContext)
 
static void ScoreRoom (int ignoreNPC=-1, int npcTypeAskingToScoreRoom=-1)
 
static void SectionTileFrame (int sectionStartX, int sectionStartY, int sectionEndXInclusive, int sectionEndYInclusive)
 
static void SectionTileFrameWithCheck (int startX, int startY, int endX, int endY)
 
static Task serverLoadWorld ()
 
static void serverLoadWorldCallBack ()
 
static void setBG (int bg, int style)
 
static void setMoss (int x, int y)
 
static void SetupStatueList ()
 
static void setWorldSize ()
 
static void setXmasTree (int x, int y, int obj, int style)
 
static bool ShellPile (int X, int Y)
 
static bool ShiftTallGate (int x, int y, bool closing, bool forced=false)
 
static bool ShiftTrapdoor (int x, int y, bool playerAbove, int onlyCloseOrOpen=-1)
 
static void Shimmerator (int x, int y, bool jungle=false, bool lavaOk=false)
 
static bool ShimmerMakeBiome (int X, int Y)
 
static void ShimmerRemoveWater ()
 
static void ShootFromCannon (int x, int y, int angle, int ammo, int Damage, float KnockBack, int owner, bool fromWire)
 
static void ShroomPatch (int i, int j)
 
static bool SlopeTile (int i, int j, int slope=0, bool noEffects=false)
 
static void SmashAltar (int i, int j)
 
static void smCallBack (object threadContext)
 
static void SnowCloudIsland (int i, int j)
 
static bool SolidOrSlopedTile (int x, int y)
 
static bool SolidOrSlopedTile (Tile tile)
 
static bool SolidTile (int i, int j, bool noDoors=false)
 
static bool SolidTile (Point p)
 
static bool SolidTile (Tile testTile)
 
static bool SolidTile2 (int i, int j)
 
static bool SolidTile2 (Tile testTile)
 
static bool SolidTile3 (int i, int j)
 
static bool SolidTile3 (Tile t)
 
static bool SolidTileAllowBottomSlope (int i, int j)
 
static bool SolidTileAllowLeftSlope (int i, int j)
 
static bool SolidTileAllowRightSlope (int i, int j)
 
static bool SolidTileAllowTopSlope (int i, int j)
 
static bool SolidTileNoAttach (int i, int j)
 
static void SonOfLakinater (int i, int j, double strengthMultiplier=1.0)
 
static bool SpawnFallingBlockProjectile (int i, int j, Tile tileCache, Tile tileTopCache, Tile tileBottomCache, int type)
 
static void SpawnPlanteraThorns (Vector2 position)
 
static TownNPCSpawnResult SpawnTownNPC (int x, int y)
 
static void SpawnTravelNPC ()
 
static void SpreadDesertWalls (int wallDist, int i, int j)
 
static void SpreadGrass (int i, int j, int dirt=0, int grass=2, bool repeat=true, TileColorCache color=default(TileColorCache))
 
static void SquareTileFrame (int i, int j, bool resetFrame=true)
 
static void SquareWallFrame (int i, int j, bool resetFrame=true)
 
static void StartHardmode ()
 
static void StartImpendingDoom (int countdownTime)
 
static bool StartRoomCheck (int x, int y)
 
static bool Statue (int x, int y, byte paint)
 
static bool StonePatch (int X, int Y)
 
static void SwitchCannon (int i, int j)
 
static void SwitchFountain (int i, int j)
 
static void SwitchMB (int i, int j)
 
static void SwitchMonolith (int i, int j)
 
static void templeCleaner (int x, int y)
 
static void templePart2 ()
 
static Vector2D templePather (Vector2D templePath, int destX, int destY)
 
static void tileCountAndDestroy ()
 
static int tileCounter (int x, int y)
 
static void tileCounterKill ()
 
static void tileCounterNext (int x, int y)
 
static bool TileEmpty (int i, int j)
 
static void TileFrame (int i, int j, bool resetFrame=false, bool noBreak=false)
 
static bool TileIsExposedToAir (int x, int y)
 
static void TileMergeAttempt (int myType, bool[] lookfor, bool[] exclude, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
 
static void TileMergeAttempt (int myType, bool[] lookfor, ref int up, ref int down, ref int left, ref int right)
 
static void TileMergeAttempt (int myType, bool[] lookfor, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
 
static void TileMergeAttempt (int myType, int lookfor, ref int up, ref int down, ref int left, ref int right)
 
static void TileMergeAttempt (int myType, int lookfor, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
 
static void TileMergeAttemptFrametest (int i, int j, int myType, bool[] lookfor, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
 
static void TileMergeAttemptFrametest (int i, int j, int myType, int lookfor, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
 
static void TileMergeAttemptWeird (int myType, int changeTo, bool[] exclude, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
 
static void TileRunner (int i, int j, double strength, int steps, int type, bool addTile=false, double speedX=0.0, double speedY=0.0, bool noYChange=false, bool overRide=true, int ignoreTileType=-1)
 Places small splotches of the specified tile starting at the designated coordinates. This should only be used early in world generation code. OreRunner(int, int, double, int, ushort) is a safer version that can be used anytime without corrupting tiles. More detailed information and a video guide can be found on the World Generation wiki page
 
static int TileType (int x, int y)
 
static void ToggleGemLock (int i, int j, bool on)
 
static bool TopEdgeCanBeAttachedTo (int i, int j)
 
static void TreeGrowFX (int x, int y, int height, int treeGore, bool hitTree=false)
 
static void TreeGrowFXCheck (int x, int y)
 
static void TriggerLunarApocalypse ()
 
static bool TryGrowingTreeByType (int treeTileType, int checkedX, int checkedY)
 
static bool TryKillingReplaceableTile (int x, int y, int tileType)
 
static bool TryKillingTreesAboveIfTheyWouldBecomeInvalid (int i, int j, int newFloorType)
 
static void TryProtectingSpawnedItems ()
 
static bool TryToggleLight (int x, int y, bool? forcedState, bool skipWires)
 
static void UndoSpawnedItemProtection ()
 
static void UnlockDoor (int i, int j)
 
static void UnspawnTravelNPC ()
 
static void UpdateDesertHiveBounds (int x, int y)
 
static void UpdateLunarApocalypse ()
 
static bool UpdateMapTile (int i, int j, bool addToList=true)
 
static bool UpdateStalagtiteStyle (int x, int j)
 
static void UpdateWorld ()
 
static bool VanityTreeGroundTest (int tileType)
 
static void WaterCheck ()
 
static void WavyCaverer (int startX, int startY, double waveStrengthScalar, double wavePercentScalar, int steps, int type)
 
static bool WillWaterPlacedHereStayPut (int x, int y)
 
static void worldGenCallback (object threadContext)
 
static bool WouldTileReplacementBeBlockedByLiquid (int x, int y, int liquidType)
 
static bool WouldTileReplacementWork (ushort attemptingToReplaceWith, int x, int y)
 

Static Public Attributes

static UnifiedRandom _genRand
 
static int _genRandSeed = -2
 
static int _lastSeed
 
static bool AllowedToSpreadInfections = true
 
static int altarCount
 
static BackgroundChangeFlashInfo BackgroundsCache = new BackgroundChangeFlashInfo()
 
static readonly int beachDistance = 380
 
static int bestX
 
static int bestY
 
const bool BUBBLES_SOLID_STATE_FOR_HOUSING = true
 
static readonly int cactusWaterHeight = 25
 
static readonly int cactusWaterLimit = 25
 
static readonly int cactusWaterWidth = 50
 
static bool canSpawn
 
static int corruptBG
 
static Dictionary< Point, bool > CountedTiles = new Dictionary<Point, bool>(maxTileCount)
 
static bool crimson
 Indicates the selected world evil. If true, the world is a Crimson world, when false the world is a Corruption world.
 
static int crimsonBG
 
static string currentWorldSeed
 
static int desertBG
 
static bool destroyObject
 
static bool dontStarveWorldGen = false
 If true, the world is generating with the The Constantsecret world seed. See also Main.dontStarveWorld.
 
static bool drunkWorldGen = false
 If true, the world is generating with the Drunk worldsecret world seed. See also Main.drunkWorld.
 
static bool drunkWorldGenText = false
 
static bool everythingWorldGen = false
 If true, the world is generating with the Get fixed boi (aka Zenith)secret world seed. This seed combines multiple secret seeds. Note that the other secret world seed bools inherited by this seed will be set as well, so there is no need to specifically check both those bools and this bool. See also Main.zenithWorld.
 
static Queue< Point > ExploitDestroyQueue = new Queue<Point>()
 
static volatile bool gen
 
static bool generatingWorld = false
 
static bool getGoodWorldGen = false
 If true, the world is generating with the For the worthysecret world seed. See also Main.getGoodWorld.
 
static int grassSpread
 
static int hallowBG
 
static int hiScore
 
static bool[] houseTile = new bool[TileID.Count]
 
static int iceCount
 
const int InfectionAndGrassSpreadOuterWorldBuffer = 10
 
static bool IsGeneratingHardMode
 
static int jungleBG
 
static int lavaCount
 
static bool loadBackup = false
 
static bool loadFailed = false
 
static bool loadSuccess = false
 
static int maxRoomTiles = 750
 
static int maxTileCount = 3500
 
static int maxWallOut2 = 5000
 
static int mushroomBG
 
static MysticLogFairiesEvent mysticLogsEvent = new MysticLogFairiesEvent()
 
static bool noLiquidCheck
 
static bool noMapUpdate
 
static bool noMapUpdateRefresh = false
 
static bool noTileActions
 
static bool noTrapsWorldGen = false
 If true, the world is generating with the No trapssecret world seed. See also Main.noTrapsWorld.
 
static bool notTheBees = false
 If true, the world is generating with the Not the beessecret world seed. See also Main.notTheBeesWorld.
 
static int numRoomTiles
 
static int numTileCount
 
static int oceanBG
 
static readonly int oceanDistance = 250
 
static bool placingTraps = false
 
static int prioritizedTownNPCType
 
static bool remixWorldGen = false
 If true, the world is generating with the Don't dig up (aka Remix)secret world seed. See also Main.remixWorld.
 
static int rockCount
 
static int roomCeilingsCount
 
static int[] roomCeilingX = new int[maxRoomTiles]
 
static int[] roomCeilingY = new int[maxRoomTiles]
 
static TownNPCRoomCheckFailureReason roomCheckFailureReason = TownNPCRoomCheckFailureReason.None
 
static int[] roomX = new int[maxRoomTiles]
 
static int roomX1
 
static int roomX2
 
static int[] roomY = new int[maxRoomTiles]
 
static int roomY1
 
static int roomY2
 
static int sandCount
 
static int shadowOrbCount
 
static bool shadowOrbSmashed
 
static readonly int shimmerSafetyDistance = 150
 
static int shroomCount
 
static int SmallConsecutivesEliminated = 0
 
static int SmallConsecutivesFound = 0
 
static int snowBG
 
static int spawnDelay
 
static bool spawnEye
 
static int spawnHardBoss
 
static bool spawnMeteor
 
static string statusText = ""
 
static byte tBlood
 
static bool tempRemixWorldGen = false
 
static bool tempTenthAnniversaryWorldGen = false
 
static bool tenthAnniversaryWorldGen = false
 If true, the world is generating with the Celebrationmk10secret world seed. See also Main.tenthAnniversaryWorld.
 
static byte tEvil
 
static byte tGood
 
static int[] tileCounts = new int[TileID.Count]
 
static int tileReframeCount
 
static int totalBlood
 
static int totalBlood2
 
static int totalD
 
static int totalEvil
 
static int totalEvil2
 
static int totalGood
 
static int totalGood2
 
static int totalSolid
 
static int totalSolid2
 
static int totalX
 
static TownRoomManager TownManager = new TownRoomManager()
 
static int treeBG1
 
static int treeBG2
 
static int treeBG3
 
static int treeBG4
 
static TreeTopsInfo TreeTops = new TreeTopsInfo()
 
static int underworldBG
 
const bool USE_FRAMING_SKIP_FOR_UNIMPORTANT_TILES_IN_WORLDGEN = false
 
static bool worldBackup
 
static bool worldCleared
 
static int WorldGenParam_Evil = -1
 
const int WorldSizeLargeX = 8400
 
const int WorldSizeLargeY = 2400
 
const int WorldSizeMediumX = 6400
 
const int WorldSizeMediumY = 1800
 
const int WorldSizeSmallX = 4200
 
const int WorldSizeSmallY = 1200
 

Properties

static UnifiedRandom genRand [get]
 The random number generator for world generation. It is important to use this instead of Main.rand for all world generation randomness to make the world seed feature reliable.
 
static double oceanLevel [get]
 
static bool SkipFramingBecauseOfGen [get]
 
static IReadOnlyDictionary< string, GenPassVanillaGenPasses [get]
 

Member Function Documentation

◆ AddBuriedChest()

static bool WorldGen.AddBuriedChest ( int  i,
int  j,
int  contain = 0,
bool  notNearOtherChests = false,
int  Style = -1,
bool  trySlope = false,
ushort  chestTileType = 0 
)
static

Attempts to place a chest and fill it with typical loot according to the style (Style ) and depth. Without any parameters, a regular, gold, or locked shadow chest will be created, depending on the depth. You can pass in an item type (contain ) and the first item in the chest will be that item. Unlike PlaceChest(int, int, ushort, bool, int), the resulting chest will be placed with the bottom right corner at the given coordinates (i , j ). In addition, if the given j coordinate isn't suitable, AddBuriedChest will search down from the given coordinate to find the first solid tile it encounters and attempt to place there. This method returns true if a chest was successfully placed, but be aware that the chest might not be exactly at the coordinates you provide. This makes further adjusting the chest contents directly difficult. A video guide can be found on the World Generation wiki page. It shows an example of running the method with the default parameters WorldGen.AddBuriedChest(x, y);. Notice how the chest style changes according to depth and how the chest is placed on the floor directly below the provided coordinates if possible.

Parameters
i
j
contain
notNearOtherChests
Style
trySlope
chestTileType
Returns

◆ Convert()

static void WorldGen.Convert ( int  i,
int  j,
int  conversionType,
int  size = 4 
)
static

Converts biome variant tiles and walls to a target biome.
Converts a 9x9 square by default, but can be adjusted with the size parameter.

For an easily-viewable usage example, refer to the code for projectile AI style 31 (used for the Clentaminator's solutions).

Parameters
iThe X coordinate of the target tile.
jThe Y coordinate of the target tile.
conversionTypeThe biome that you wish to convert to. See BiomeConversionID Setting this to 0 (Purity) returns affected tiles to their default states (e.g. Ebonstone, Crimstone, and Pearlstone will be converted back into normal Stone Blocks).
sizeWhen using this method to convert tiles, a square centered on the target tile is converted into those of the target biome.
This optional parameter, which defaults to 4, determines the "radius" of that square in tiles, counting outward from the central tile.
Set to 0 if you only want to convert a single tile. In other cases, use this parameter wisely.

◆ InWorld()

static bool WorldGen.InWorld ( int  x,
int  y,
int  fluff = 0 
)
static

Returns true if the provided tile coordinates are within the world bounds. When dealing with random coordinates combined with addition or subtraction, there is a chance you might construct coordinates outside the bounds of the world. This will crash world generation, so it is important that you check that the coordinates are suitable before attempting to do things at those coordinates. Use this method to check if the given coordinates fall inside the world. The fluff parameter further checks that the coordinates are at least that many tiles away from the edge, which is useful for world generation actions that could affect large areas of tiles.

Parameters
x
y
fluff
Returns

◆ KillTile()

static void WorldGen.KillTile ( int  i,
int  j,
bool  fail = false,
bool  effectOnly = false,
bool  noItem = false 
)
static

Attempts to destroy the tile at the provided tile coordinates.Callers can use fail , effectOnly , and noItem to dictate if the intention is to not actually kill the tile, only spawn kill tile effects, and not drop items respectively. For example, worms typically use fail: true, effectOnly: true to spawn dust indicating the worm burrowing through the ground. ModTile.KillTile(int, int, ref bool, ref bool, ref bool) and GlobalTile.KillTile(int, int, int, ref bool, ref bool, ref bool) will be called to modify those values.Note that this method will destroy a single tile and then call the tile framing code. The noItem parameter is only relevant for 1x1 tiles, not multi-tiles. The tile framing code is what triggers multi-tiles to destroy all of their remaining tiles and drop their placement item. GlobalTile.Drop(int, int, int) must be used by the caller if the intention is to prevent item drops from a multi-tile.

Parameters
i
j
failPrevents the tile from being destroyed, but still plays a hit sound
effectOnlyPrevents the tile from being destroyed but still spawns hit dust and prevents the hit sound.
noItemPrevents the item from dropping. Only relevant for 1x1 tiles.

◆ OreRunner()

static void WorldGen.OreRunner ( int  i,
int  j,
double  strength,
int  steps,
ushort  type 
)
static

Similar to TileRunner(int, int, double, int, int, bool, double, double, bool, bool, int), but without many of the options. OreRunner places small splotches of the specified tile (type ) starting at the coordinates (i and j in tile coordinates). OreRunner only replaces active tiles (Tile.HasTile) that are either TileID.Sets.CanBeClearedDuringOreRunner or Main.tileMoss, making it suitable to be used even after FrameImportant tiles (Main.tileFrameImportant) exist in the world. If you have a tile that should be susceptible to being replaced when additional ores are spawned in the world, set TileID.Sets.CanBeClearedDuringOreRunner to true for that ModTile. Vanilla code only uses this method when spawning hardmode ores. This method is suitable for use in-game and in multiplayer as it both frames and syncs tile changes.

Parameters
i
j
strength
steps
type

◆ PlaceChest()

static int WorldGen.PlaceChest ( int  x,
int  y,
ushort  type = 21,
bool  notNearOtherChests = false,
int  style = 0 
)
static

Attempts to place a chest at the given tile coordinates. The coordinate provided (x , y ) will be the bottom left corner of the resulting chest, if the method succeeds. type is the tile type to place, and style is the tile style to place. For vanilla chests, you can count from zero starting from the left in the Tiles_21.png image after extracting the vanilla texturesto find the style you want to place. Another option is to follow the Tile IDs wiki guideto find the style. notNearOtherChests can be set to true to prevent the chest from placing if another chest exists within 25 tiles left or right and 8 tiles up or down. This method returns the chest index (the index within Main.chest) of the chest that was successfully placed or -1 if placing the chest failed. Chest placement can fail for many reasons, such as if existing tiles block the space, or if there isn't 2 suitable solid tiles directly below the intended location. See the "Try Until Success" section of the World Generation wiki guidefor an approach to using this method. See the "Placing Items in Chests" section of the World Generation wiki guidefor info on placing items in the chest. The AddBuriedChest(int, int, int, bool, int, bool, ushort) method places a chest and fills it with the default items for that chest.

Parameters
x
y
type
notNearOtherChests
style
Returns

◆ PlaceSmallPile()

static bool WorldGen.PlaceSmallPile ( int  i,
int  j,
int  X,
int  Y,
ushort  type = 185 
)
static

Places TileID.SmallPiles tiles. This tile is special and doesn't follow the normal style rules and won't place with PlaceTile. i and j are the coordinates. X and Y are the count and row indexes of the specific tile in the texture file. Indexes count from left to right and start at 0. So for example the Sapphire Stash would have Y=1 (second row) and X=21 (22nd 2x1 tile).

Parameters
i
j
X
Y
type
Returns

◆ PlaceTile()

static bool WorldGen.PlaceTile ( int  i,
int  j,
int  Type,
bool  mute = false,
bool  forced = false,
int  plr = -1,
int  style = 0 
)
static

PlaceTile is the main way to place individual tiles while obeying anchor considerations. Most of the other PlaceX methods in the WorldGen class are called by this method. i and j are the tile coordinates. These coordinates relate to the origin of the tile, not necessarily the top left corner of the tile. Read the Basic Tile wiki guideto familiarize yourself with the concepts of Anchors and Origins. mute indicates if a sound should be made, this only applies to in-game usage as sounds are all muted during world gen. forced attempts to place the tile even if other tiles are already at the coordinates, but it is unreliable. plr does nothing except affect bathtubs. style refers to the style of the tile type provided. Styles are explained in the Basic Tile guide. PlaceTile returns a bool indicating placement success. Unfortunately, it doesn't work, don't use it. Checking the coordinates after calling PlaceTile is a good way to check if the placement was a success: if(Main.tile[x, y].TileType == TileID.Campfire) PlaceTile doesn't expose everything. For example, attempting to place a tile with a specific style will be ignored by many of the underlying methods. Another issue is that it is impossible to place a tile that has left and right placement orientations facing right. In these situations, you might need to manually place each tile in the multitile or use PlaceObject(int, int, int, bool, int, int, int, int) instead. WorldGen.PlaceObject requires more input. For example, placing Coral with PlaceObject means you have to manually specify the style, as the random style (TileObjectData.RandomStyleRange) choosing is a feature of PlaceTile. If called in-game, the changed tiles would need to be synced if placement is successful. See NetMessage.SendTileSquare(int, int, int, int, int, TileChangeType) for more information and examples.

Parameters
i
j
Type
mute
forced
plr
style
Returns

◆ RandomWorldPoint()

static Point WorldGen.RandomWorldPoint ( int  top = 0,
int  right = 0,
int  bottom = 0,
int  left = 0 
)
static

Generates a random tile coordinate within the world bounds. The optional parameters define additional padding, avoiding the edges or defining a target area. Point point = WorldGen.RandomWorldPoint((int)Main.worldSurface, 40, 500, 60) is equivalent to

int x = WorldGen.genRand.Next(60, Main.maxTilesX - 40); int y = WorldGen.genRand.Next((int)Main.worldSurface, Main.maxTilesY - 500);

Parameters
top
right
bottom
left
Returns