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

◆ ItemCheck_UseMiningTools_ActuallyUseMiningTool()

void Terraria.Player.ItemCheck_UseMiningTools_ActuallyUseMiningTool ( Item sItem,
out bool canHitWalls,
int x,
int y )
inlineprivate

Definition at line 43435 of file Player.cs.

43436 {
43437 int num = -1;
43438 int num2 = 0;
43439 canHitWalls = true;
43440 Tile tile = Main.tile[x, y];
43441 if (!tile.active())
43442 {
43443 return;
43444 }
43445 if ((sItem.pick > 0 && !Main.tileAxe[tile.type] && !Main.tileHammer[tile.type]) || (sItem.axe > 0 && Main.tileAxe[tile.type]) || (sItem.hammer > 0 && Main.tileHammer[tile.type]))
43446 {
43447 canHitWalls = false;
43448 }
43449 num = hitTile.HitObject(x, y, 1);
43450 if (Main.tileNoFail[tile.type])
43451 {
43452 num2 = 100;
43453 }
43454 if (Main.tileHammer[tile.type])
43455 {
43456 canHitWalls = false;
43457 if (sItem.hammer > 0)
43458 {
43459 num2 += sItem.hammer;
43460 if (!WorldGen.CanKillTile(x, y))
43461 {
43462 num2 = 0;
43463 }
43464 if (tile.type == 26 && (sItem.hammer < 80 || !Main.hardMode))
43465 {
43466 num2 = 0;
43468 }
43469 AchievementsHelper.CurrentlyMining = true;
43470 if (hitTile.AddDamage(num, num2) >= 100)
43471 {
43472 ClearMiningCacheAt(x, y, 1);
43473 WorldGen.KillTile(x, y);
43474 if (Main.netMode == 1)
43475 {
43476 NetMessage.SendData(17, -1, -1, null, 0, x, y);
43477 }
43478 }
43479 else
43480 {
43481 WorldGen.KillTile(x, y, fail: true);
43482 if (Main.netMode == 1)
43483 {
43484 NetMessage.SendData(17, -1, -1, null, 0, x, y, 1f);
43485 }
43486 }
43487 if (num2 != 0)
43488 {
43489 hitTile.Prune();
43490 }
43492 AchievementsHelper.CurrentlyMining = false;
43493 }
43494 }
43495 else if (Main.tileAxe[tile.type])
43496 {
43497 num2 = ((tile.type != 80) ? (num2 + (int)((float)sItem.axe * 1.2f)) : (num2 + (int)((float)(sItem.axe * 3) * 1.2f)));
43498 if (Main.getGoodWorld)
43499 {
43500 num2 = (int)((double)num2 * 1.3);
43501 }
43502 if (sItem.axe > 0)
43503 {
43504 AchievementsHelper.CurrentlyMining = true;
43505 if (!WorldGen.CanKillTile(x, y))
43506 {
43507 num2 = 0;
43508 }
43509 if (Main.dontStarveWorld && Main.myPlayer == whoAmI && num2 > 0 && tile.type == 80)
43510 {
43511 Hurt(PlayerDeathReason.ByOther(3), Main.DamageVar(6f, luck), 0, pvp: false, quiet: false, Crit: false, 0);
43512 }
43513 if (hitTile.AddDamage(num, num2) >= 100)
43514 {
43515 if (whoAmI == Main.myPlayer && sItem.type == 5095 && (TileID.Sets.IsATreeTrunk[tile.type] || tile.type == 323 || tile.type == 80))
43516 {
43518 if (TileID.Sets.CountsAsGemTree[tile.type])
43519 {
43520 source = LucyAxeMessage.MessageSource.ChoppedGemTree;
43521 }
43522 if (tile.type == 80)
43523 {
43524 source = LucyAxeMessage.MessageSource.ChoppedCactus;
43526 }
43527 else
43528 {
43529 LucyAxeMessage.Create(source, base.Top, new Vector2(direction * 7, -7f));
43530 }
43531 }
43532 ClearMiningCacheAt(x, y, 1);
43533 bool flag = IsBottomOfTreeTrunkNoRoots(x, y);
43534 WorldGen.KillTile(x, y);
43535 if (Main.netMode == 1)
43536 {
43537 NetMessage.SendData(17, -1, -1, null, 0, x, y);
43538 }
43539 if (sItem.type == 5295 && flag)
43540 {
43542 }
43543 }
43544 else
43545 {
43546 WorldGen.KillTile(x, y, fail: true);
43547 if (Main.netMode == 1)
43548 {
43549 NetMessage.SendData(17, -1, -1, null, 0, x, y, 1f);
43550 }
43551 }
43552 if (num2 != 0)
43553 {
43554 hitTile.Prune();
43555 }
43557 AchievementsHelper.CurrentlyMining = false;
43558 }
43559 }
43560 else if (sItem.pick > 0)
43561 {
43562 PickTile(x, y, sItem.pick);
43563 }
43564 if (sItem.pick > 0)
43565 {
43566 itemTime = (int)((float)sItem.useTime * pickSpeed);
43567 }
43569 }
static PlayerDeathReason ByOther(int type)
static void TryCreatingMessageWithCooldown(MessageSource messageSource, Vector2 position, Vector2 velocity, int cooldownTimeInTicks)
static void Create(MessageSource source, Vector2 position, Vector2 velocity)
int AddDamage(int tileId, int damageAmount, bool updateAmount=true)
Definition HitTile.cs:177
int HitObject(int x, int y, int hitType)
Definition HitTile.cs:141
static bool[] CountsAsGemTree
Definition TileID.cs:89
static bool[] IsATreeTrunk
Definition TileID.cs:91
void ApplyItemTime(Item sItem)
Definition Player.cs:3752
float pickSpeed
Definition Player.cs:2049
HitTile hitTile
Definition Player.cs:1323
void TryReplantingTree()
Definition Player.cs:43592
void ClearMiningCacheAt(int x, int y, int hitTileCacheType)
Definition Player.cs:50311
bool IsBottomOfTreeTrunkNoRoots(int x, int y)
Definition Player.cs:43571
double Hurt(PlayerDeathReason damageSource, int Damage, int hitDirection, bool pvp=false, bool quiet=false, bool Crit=false, int cooldownCounter=-1, bool dodgeable=true)
Definition Player.cs:36134
void PickTile(int x, int y, int pickPower)
Definition Player.cs:50232
void ItemCheck_UseMiningTools_TryPoundingTile(Item sItem, int tileHitId, ref bool hitWall, int x, int y)
Definition Player.cs:43746

References Terraria.Tile.active(), Terraria.DataStructures.PlayerDeathReason.ByOther(), Terraria.WorldGen.CanKillTile(), Terraria.ID.TileID.Sets.CountsAsGemTree, Terraria.GameContent.LucyAxeMessage.Create(), Terraria.Main.DamageVar(), Terraria.Main.dontStarveWorld, Terraria.Main.getGoodWorld, Terraria.Main.hardMode, Terraria.ID.TileID.Sets.IsATreeTrunk, Terraria.WorldGen.KillTile(), Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.NetMessage.SendData(), System.source, Terraria.Main.tile, Terraria.Main.tileAxe, Terraria.Main.tileHammer, Terraria.Main.tileNoFail, Terraria.GameContent.LucyAxeMessage.TryCreatingMessageWithCooldown(), and Terraria.Tile.type.