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

◆ ItemCheck_UseMiningTools_TryPoundingTile()

void Terraria.Player.ItemCheck_UseMiningTools_TryPoundingTile ( Item sItem,
int tileHitId,
ref bool hitWall,
int x,
int y )
inlineprivate

Definition at line 45694 of file Player.cs.

45695 {
45696 Tile tile = Main.tile[x, y];
45697 bool num16 = sItem.hammer > 0 && tile.active() && poundRelease;
45698 bool vanillaSloping = Main.tileSolid[tile.type] || tile.type == 314 || tile.type == 351 || tile.type == 424 || tile.type == 442;
45699 if (num16 && (vanillaSloping || TileID.Sets.CanBeSloped[tile.type]))
45700 {
45701 hitWall = false;
45703 int damageAmount = 100;
45704 if (WorldGen.IsLockedDoor(x, y - 1) || WorldGen.IsLockedDoor(x, y + 1))
45705 {
45706 damageAmount = 0;
45707 }
45709 {
45710 ClearMiningCacheAt(x, y, 1);
45711 if (!poundRelease)
45712 {
45713 return;
45714 }
45715 if (!TileLoader.Slope(x, y, Main.tile[x, y].type))
45716 {
45717 if (TileID.Sets.Platforms[Main.tile[x, y].type])
45718 {
45719 if (tile.halfBrick())
45720 {
45721 WorldGen.PoundTile(x, y);
45722 if (Main.netMode == 1)
45723 {
45724 NetMessage.SendData(17, -1, -1, null, 7, x, y, 1f);
45725 }
45726 }
45727 else
45728 {
45729 int num = 1;
45730 int slope = 2;
45731 if (TileID.Sets.Platforms[Main.tile[x + 1, y - 1].type] || TileID.Sets.Platforms[Main.tile[x - 1, y + 1].type] || (WorldGen.SolidTile(x + 1, y) && !WorldGen.SolidTile(x - 1, y)))
45732 {
45733 num = 2;
45734 slope = 1;
45735 }
45736 if (Main.tile[x, y].slope() == 0)
45737 {
45738 WorldGen.SlopeTile(x, y, num);
45739 int num8 = Main.tile[x, y].slope();
45740 if (Main.netMode == 1)
45741 {
45742 NetMessage.SendData(17, -1, -1, null, 14, x, y, num8);
45743 }
45744 }
45745 else if (Main.tile[x, y].slope() == num)
45746 {
45747 WorldGen.SlopeTile(x, y, slope);
45748 int num9 = Main.tile[x, y].slope();
45749 if (Main.netMode == 1)
45750 {
45751 NetMessage.SendData(17, -1, -1, null, 14, x, y, num9);
45752 }
45753 }
45754 else
45755 {
45756 WorldGen.SlopeTile(x, y);
45757 int num10 = Main.tile[x, y].slope();
45758 if (Main.netMode == 1)
45759 {
45760 NetMessage.SendData(17, -1, -1, null, 14, x, y, num10);
45761 }
45762 WorldGen.PoundTile(x, y);
45763 if (Main.netMode == 1)
45764 {
45765 NetMessage.SendData(17, -1, -1, null, 7, x, y, 1f);
45766 }
45767 }
45768 }
45769 }
45770 else if (Main.tile[x, y].type == 314)
45771 {
45772 if (Minecart.FrameTrack(x, y, pound: true) && Main.netMode == 1)
45773 {
45774 NetMessage.SendData(17, -1, -1, null, 15, x, y, 1f);
45775 }
45776 }
45777 else if (Main.tile[x, y].type == 137)
45778 {
45779 int num11 = 0;
45780 switch (Main.tile[x, y].frameY / 18)
45781 {
45782 case 0:
45783 case 1:
45784 case 2:
45785 case 5:
45786 switch (Main.tile[x, y].frameX / 18)
45787 {
45788 case 0:
45789 num11 = 2;
45790 break;
45791 case 1:
45792 num11 = 3;
45793 break;
45794 case 2:
45795 num11 = 4;
45796 break;
45797 case 3:
45798 num11 = 5;
45799 break;
45800 case 4:
45801 num11 = 1;
45802 break;
45803 case 5:
45804 num11 = 0;
45805 break;
45806 }
45807 break;
45808 case 3:
45809 case 4:
45810 switch (Main.tile[x, y].frameX / 18)
45811 {
45812 case 0:
45813 case 1:
45814 num11 = 3;
45815 break;
45816 case 3:
45817 num11 = 2;
45818 break;
45819 case 2:
45820 num11 = 4;
45821 break;
45822 case 4:
45823 num11 = 0;
45824 break;
45825 }
45826 break;
45827 }
45828 Main.tile[x, y].frameX = (short)(num11 * 18);
45829 if (Main.netMode == 1)
45830 {
45831 NetMessage.SendTileSquare(-1, x, y);
45832 }
45833 }
45834 else if (Main.tile[x, y].type == 424)
45835 {
45836 if (Main.tile[x, y].frameX == 0)
45837 {
45838 Main.tile[x, y].frameX = 18;
45839 }
45840 else if (Main.tile[x, y].frameX == 18)
45841 {
45842 Main.tile[x, y].frameX = 36;
45843 }
45844 else
45845 {
45846 Main.tile[x, y].frameX = 0;
45847 }
45848 if (Main.netMode == 1)
45849 {
45850 NetMessage.SendTileSquare(-1, x, y);
45851 }
45852 }
45853 else if (Main.tile[x, y].type == 442)
45854 {
45855 Tile tile2 = Main.tile[x, y - 1];
45856 Tile tile3 = Main.tile[x, y + 1];
45857 Tile tile4 = Main.tile[x - 1, y];
45858 Tile tile5 = Main.tile[x + 1, y];
45859 Tile tile6 = Main.tile[x - 1, y + 1];
45860 Tile tile7 = Main.tile[x + 1, y + 1];
45861 Tile tile8 = Main.tile[x - 1, y - 1];
45862 Tile tile9 = Main.tile[x + 1, y - 1];
45863 int num12 = -1;
45864 int num13 = -1;
45865 int num14 = -1;
45866 int num15 = -1;
45867 int tree = -1;
45868 int tree2 = -1;
45869 int tree3 = -1;
45870 int tree4 = -1;
45871 if (tile2 != null && tile2.nactive() && !tile2.bottomSlope())
45872 {
45873 num13 = tile2.type;
45874 }
45875 if (tile3 != null && tile3.nactive() && !tile3.halfBrick() && !tile3.topSlope())
45876 {
45877 num12 = tile3.type;
45878 }
45879 if (tile4 != null && tile4.nactive() && (tile4.slope() == 0 || tile4.slope() % 2 != 1))
45880 {
45881 num14 = tile4.type;
45882 }
45883 if (tile5 != null && tile5.nactive() && (tile5.slope() == 0 || tile5.slope() % 2 != 0))
45884 {
45885 num15 = tile5.type;
45886 }
45887 if (tile6 != null && tile6.nactive())
45888 {
45889 tree = tile6.type;
45890 }
45891 if (tile7 != null && tile7.nactive())
45892 {
45893 tree2 = tile7.type;
45894 }
45895 if (tile8 != null && tile8.nactive())
45896 {
45897 tree3 = tile8.type;
45898 }
45899 if (tile9 != null && tile9.nactive())
45900 {
45901 tree4 = tile9.type;
45902 }
45903 bool flag = false;
45904 bool flag2 = false;
45905 bool flag3 = false;
45906 bool flag4 = false;
45907 if (num12 >= 0 && Main.tileSolid[num12] && (!Main.tileNoAttach[num12] || TileID.Sets.Platforms[num12]) && (tile3.bottomSlope() || tile3.slope() == 0) && !tile3.halfBrick())
45908 {
45909 flag4 = true;
45910 }
45911 if (num13 >= 0 && Main.tileSolid[num13] && (!Main.tileNoAttach[num13] || (TileID.Sets.Platforms[num13] && tile2.halfBrick())) && (tile2.topSlope() || tile2.slope() == 0 || tile2.halfBrick()))
45912 {
45913 flag = true;
45914 }
45915 if ((num14 >= 0 && Main.tileSolid[num14] && !Main.tileNoAttach[num14] && (tile4.leftSlope() || tile4.slope() == 0) && !tile4.halfBrick()) || (num14 >= 0 && TileID.Sets.IsBeam[num14]) || (WorldGen.IsTreeType(num14) && WorldGen.IsTreeType(tree3) && WorldGen.IsTreeType(tree)))
45916 {
45917 flag2 = true;
45918 }
45919 if ((num15 >= 0 && Main.tileSolid[num15] && !Main.tileNoAttach[num15] && (tile5.rightSlope() || tile5.slope() == 0) && !tile5.halfBrick()) || (num15 >= 0 && TileID.Sets.IsBeam[num15]) || (WorldGen.IsTreeType(num15) && WorldGen.IsTreeType(tree4) && WorldGen.IsTreeType(tree2)))
45920 {
45921 flag3 = true;
45922 }
45923 int num2 = Main.tile[x, y].frameX / 22;
45924 short num3 = -2;
45925 switch (num2)
45926 {
45927 case 0:
45928 num3 = (short)(flag2 ? 2 : (flag ? 1 : ((!flag3) ? (-1) : 3)));
45929 break;
45930 case 2:
45931 num3 = (short)(flag ? 1 : (flag3 ? 3 : ((!flag4) ? (-1) : 0)));
45932 break;
45933 case 1:
45934 num3 = (short)(flag3 ? 3 : ((!flag4) ? ((!flag2) ? (-1) : 2) : 0));
45935 break;
45936 case 3:
45937 num3 = (short)((!flag4) ? (flag2 ? 2 : (flag ? 1 : (-1))) : 0);
45938 break;
45939 }
45940 if (num3 != -1)
45941 {
45942 if (num3 == -2)
45943 {
45944 num3 = 0;
45945 }
45946 Main.tile[x, y].frameX = (short)(22 * num3);
45947 if (Main.netMode == 1)
45948 {
45949 NetMessage.SendTileSquare(-1, x, y);
45950 }
45951 }
45952 }
45953 else if ((Main.tile[x, y].halfBrick() || Main.tile[x, y].slope() != 0) && !Main.tileSolidTop[Main.tile[x, y].type])
45954 {
45955 int num4 = 1;
45956 int num5 = 1;
45957 int num6 = 2;
45958 if ((WorldGen.SolidTile(x + 1, y) || Main.tile[x + 1, y].slope() == 1 || Main.tile[x + 1, y].slope() == 3) && !WorldGen.SolidTile(x - 1, y))
45959 {
45960 num5 = 2;
45961 num6 = 1;
45962 }
45963 if (WorldGen.SolidTile(x, y - 1) && !WorldGen.SolidTile(x, y + 1))
45964 {
45965 num4 = -1;
45966 }
45967 if (num4 == 1)
45968 {
45969 if (Main.tile[x, y].slope() == 0)
45970 {
45971 WorldGen.SlopeTile(x, y, num5);
45972 }
45973 else if (Main.tile[x, y].slope() == num5)
45974 {
45975 WorldGen.SlopeTile(x, y, num6);
45976 }
45977 else if (Main.tile[x, y].slope() == num6)
45978 {
45979 WorldGen.SlopeTile(x, y, num5 + 2);
45980 }
45981 else if (Main.tile[x, y].slope() == num5 + 2)
45982 {
45983 WorldGen.SlopeTile(x, y, num6 + 2);
45984 }
45985 else
45986 {
45987 WorldGen.SlopeTile(x, y);
45988 }
45989 }
45990 else if (Main.tile[x, y].slope() == 0)
45991 {
45992 WorldGen.SlopeTile(x, y, num5 + 2);
45993 }
45994 else if (Main.tile[x, y].slope() == num5 + 2)
45995 {
45996 WorldGen.SlopeTile(x, y, num6 + 2);
45997 }
45998 else if (Main.tile[x, y].slope() == num6 + 2)
45999 {
46000 WorldGen.SlopeTile(x, y, num5);
46001 }
46002 else if (Main.tile[x, y].slope() == num5)
46003 {
46004 WorldGen.SlopeTile(x, y, num6);
46005 }
46006 else
46007 {
46008 WorldGen.SlopeTile(x, y);
46009 }
46010 int num7 = Main.tile[x, y].slope();
46011 if (Main.netMode == 1)
46012 {
46013 NetMessage.SendData(17, -1, -1, null, 14, x, y, num7);
46014 }
46015 }
46016 else
46017 {
46018 WorldGen.PoundTile(x, y);
46019 if (Main.netMode == 1)
46020 {
46021 NetMessage.SendData(17, -1, -1, null, 7, x, y, 1f);
46022 }
46023 }
46024 }
46025 poundRelease = false;
46026 }
46027 else
46028 {
46029 WorldGen.KillTile(x, y, fail: true, effectOnly: true);
46030 SoundEngine.PlaySound(0, x * 16, y * 16);
46031 }
46032 }
46033 else
46034 {
46035 poundRelease = false;
46036 }
46037 }
static SlotId PlaySound(in SoundStyle? style, Vector2? position=null, SoundUpdateCallback? updateCallback=null)
Attempts to play a sound style with the provided sound style (if it's not null), and returns a valid ...
int AddDamage(int tileId, int damageAmount, bool updateAmount=true)
Definition HitTile.cs:178
static bool[] IsBeam
Definition TileID.cs:217
static bool[] CanBeSloped
Allows non-solid tiles to be sloped (solid tiles can always be sloped, regardless of this set).
Definition TileID.cs:410
static bool[] Platforms
Definition TileID.cs:219
static bool Slope(int i, int j, int type)
This serves as the central class from which tile-related functions are supported and carried out.
Definition TileLoader.cs:23
bool poundRelease
Definition Player.cs:1672
HitTile hitTile
Definition Player.cs:1836
void ClearMiningCacheAt(int x, int y, int hitTileCacheType)
Definition Player.cs:54423
void ApplyItemTime(Item sItem, float multiplier=1f, bool? callUseItem=null)
Definition Player.cs:4907

References Terraria.Tile.active(), Terraria.HitTile.AddDamage(), Terraria.Player.ApplyItemTime(), Terraria.ID.TileID.Sets.CanBeSloped, Terraria.Player.ClearMiningCacheAt(), Terraria.Minecart.FrameTrack(), Terraria.Tile.halfBrick(), Terraria.Player.hitTile, Terraria.ID.TileID.Sets.IsBeam, Terraria.WorldGen.IsLockedDoor(), Terraria.WorldGen.IsTreeType(), Terraria.WorldGen.KillTile(), Terraria.Main.netMode, Terraria.ID.TileID.Sets.Platforms, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Player.poundRelease, Terraria.WorldGen.PoundTile(), Terraria.NetMessage.SendData(), Terraria.NetMessage.SendTileSquare(), Terraria.ModLoader.TileLoader.Slope(), Terraria.WorldGen.SlopeTile(), Terraria.WorldGen.SolidTile(), Terraria.Main.tile, Terraria.Main.tileNoAttach, Terraria.Main.tileSolid, Terraria.Main.tileSolidTop, and Terraria.Tile.type.

Referenced by Terraria.Player.ItemCheck_UseMiningTools_ActuallyUseMiningTool().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: