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

◆ ItemCheck_CutTiles()

void Terraria.Player.ItemCheck_CutTiles ( Item sItem,
Rectangle itemRectangle,
bool[] shouldIgnore )
inlineprivate

Definition at line 42452 of file Player.cs.

42453 {
42454 int minX = itemRectangle.X / 16;
42455 int maxX = (itemRectangle.X + itemRectangle.Width) / 16 + 1;
42456 int minY = itemRectangle.Y / 16;
42457 int maxY = (itemRectangle.Y + itemRectangle.Height) / 16 + 1;
42458 Utils.ClampWithinWorld(ref minX, ref minY, ref maxX, ref maxY);
42459 for (int i = minX; i < maxX; i++)
42460 {
42461 for (int j = minY; j < maxY; j++)
42462 {
42463 if (Main.tile[i, j] == null || !Main.tileCut[Main.tile[i, j].type] || shouldIgnore[Main.tile[i, j].type] || !WorldGen.CanCutTile(i, j, TileCuttingContext.AttackMelee))
42464 {
42465 continue;
42466 }
42467 if (sItem.type == 1786)
42468 {
42469 ushort type = Main.tile[i, j].type;
42470 WorldGen.KillTile(i, j);
42471 if (!Main.tile[i, j].active())
42472 {
42473 int num = 0;
42474 switch (type)
42475 {
42476 case 3:
42477 case 24:
42478 case 61:
42479 case 110:
42480 case 201:
42481 case 529:
42482 case 637:
42483 num = Main.rand.Next(1, 3);
42484 break;
42485 case 73:
42486 case 74:
42487 case 113:
42488 num = Main.rand.Next(2, 5);
42489 break;
42490 }
42491 if (num > 0)
42492 {
42493 int number = Item.NewItem(new EntitySource_ItemUse(this, sItem), i * 16, j * 16, 16, 16, 1727, num);
42494 if (Main.netMode == 1)
42495 {
42496 NetMessage.SendData(21, -1, -1, null, number, 1f);
42497 }
42498 }
42499 }
42500 if (Main.netMode == 1)
42501 {
42502 NetMessage.SendData(17, -1, -1, null, 0, i, j);
42503 }
42504 }
42505 else
42506 {
42507 WorldGen.KillTile(i, j);
42508 if (Main.netMode == 1)
42509 {
42510 NetMessage.SendData(17, -1, -1, null, 0, i, j);
42511 }
42512 }
42513 }
42514 }
42515 }

References Terraria.WorldGen.CanCutTile(), Terraria.Utils.ClampWithinWorld(), Terraria.WorldGen.KillTile(), Terraria.Main.netMode, Terraria.Item.NewItem(), Terraria.Main.rand, Terraria.NetMessage.SendData(), Terraria.Main.tile, Terraria.Main.tileCut, and System.type.