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

◆ AfterPlacement_Hook()

static int Terraria.Chest.AfterPlacement_Hook ( int x,
int y,
int type = 21,
int style = 0,
int direction = 1,
int alternate = 0 )
inlinestatic

Definition at line 607 of file Chest.cs.

608 {
609 Point16 baseCoords = new Point16(x, y);
611 int num = FindEmptyChest(baseCoords.X, baseCoords.Y);
612 if (num == -1)
613 {
614 return -1;
615 }
616 if (Main.netMode != 1)
617 {
618 Chest chest = new Chest();
619 chest.x = baseCoords.X;
620 chest.y = baseCoords.Y;
621 for (int i = 0; i < 40; i++)
622 {
623 chest.item[i] = new Item();
624 }
625 Main.chest[num] = chest;
626 }
627 else
628 {
629 switch (type)
630 {
631 case 21:
632 NetMessage.SendData(34, -1, -1, null, 0, x, y, style);
633 break;
634 case 467:
635 NetMessage.SendData(34, -1, -1, null, 4, x, y, style);
636 break;
637 default:
638 NetMessage.SendData(34, -1, -1, null, 2, x, y, style);
639 break;
640 }
641 }
642 return num;
643 }
Chest(bool bank=false)
Definition Chest.cs:59
static int FindEmptyChest(int x, int y, int type=21, int style=0, int direction=1, int alternate=0)
Definition Chest.cs:570
static void OriginToTopLeft(int type, int style, ref Point16 baseCoords)

References Terraria.Chest.Chest(), Terraria.Main.chest, Terraria.Chest.FindEmptyChest(), Terraria.Chest.item, Terraria.Main.netMode, Terraria.ObjectData.TileObjectData.OriginToTopLeft(), Terraria.NetMessage.SendData(), Terraria.Chest.x, and Terraria.Chest.y.

Referenced by Terraria.ObjectData.TileObjectData.Initialize().