Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ PlaceChest()

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

Definition at line 48835 of file WorldGen.cs.

48836 {
48837 int num = -1;
48838 if (TileID.Sets.Boulders[Main.tile[x, y + 1].type] || TileID.Sets.Boulders[Main.tile[x + 1, y + 1].type])
48839 {
48840 return -1;
48841 }
48842 if (TileObject.CanPlace(x, y, type, style, 1, out var objectData))
48843 {
48844 bool flag = true;
48845 if (notNearOtherChests && Chest.NearOtherChests(x - 1, y - 1))
48846 {
48847 flag = false;
48848 }
48849 if (flag)
48850 {
48851 TileObject.Place(objectData);
48852 num = Chest.CreateChest(objectData.xCoord, objectData.yCoord);
48853 }
48854 }
48855 else
48856 {
48857 num = -1;
48858 }
48859 if (num != -1 && Main.netMode == 1 && type == 21)
48860 {
48861 NetMessage.SendData(34, -1, -1, null, 0, x, y, style);
48862 }
48863 if (num != -1 && Main.netMode == 1 && type == 467)
48864 {
48865 NetMessage.SendData(34, -1, -1, null, 4, x, y, style);
48866 }
48867 return num;
48868 }
static bool[] Boulders
Definition TileID.cs:123

References Terraria.ID.TileID.Sets.Boulders, Terraria.TileObject.CanPlace(), Terraria.Chest.CreateChest(), Terraria.Chest.NearOtherChests(), Terraria.Main.netMode, Terraria.TileObject.Place(), Terraria.NetMessage.SendData(), Terraria.Main.tile, and System.type.

Referenced by Terraria.MessageBuffer.GetData().