TModLoader v1.4.4.9
TModLoader 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 45370 of file Player.cs.

45371 {
45372 //IL_038f: Unknown result type (might be due to invalid IL or missing references)
45373 //IL_03a2: Unknown result type (might be due to invalid IL or missing references)
45374 //IL_0368: Unknown result type (might be due to invalid IL or missing references)
45375 //IL_037b: Unknown result type (might be due to invalid IL or missing references)
45376 int num = -1;
45377 int num2 = 0;
45378 canHitWalls = true;
45379 Tile tile = Main.tile[x, y];
45380 if (!tile.active())
45381 {
45382 return;
45383 }
45384 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]))
45385 {
45386 canHitWalls = false;
45387 }
45388 num = hitTile.HitObject(x, y, 1);
45389 if (Main.tileNoFail[tile.type])
45390 {
45391 num2 = 100;
45392 }
45393 if (Main.tileHammer[tile.type])
45394 {
45395 canHitWalls = false;
45396 if (sItem.hammer > 0)
45397 {
45398 ModTile modTile = TileLoader.GetTile(tile.type);
45399 num2 = ((modTile == null) ? (num2 + sItem.hammer) : (num2 + (int)((float)sItem.hammer / modTile.MineResist)));
45400 if (!WorldGen.CanKillTile(x, y))
45401 {
45402 num2 = 0;
45403 }
45404 if (tile.type == 26 && (sItem.hammer < 80 || !Main.hardMode))
45405 {
45406 num2 = 0;
45408 }
45409 AchievementsHelper.CurrentlyMining = true;
45410 if (hitTile.AddDamage(num, num2) >= 100)
45411 {
45412 ClearMiningCacheAt(x, y, 1);
45413 WorldGen.KillTile(x, y);
45414 if (Main.netMode == 1)
45415 {
45416 NetMessage.SendData(17, -1, -1, null, 0, x, y);
45417 }
45418 }
45419 else
45420 {
45421 WorldGen.KillTile(x, y, fail: true);
45422 if (Main.netMode == 1)
45423 {
45424 NetMessage.SendData(17, -1, -1, null, 0, x, y, 1f);
45425 }
45426 }
45427 if (num2 != 0)
45428 {
45429 hitTile.Prune();
45430 }
45432 AchievementsHelper.CurrentlyMining = false;
45433 }
45434 }
45435 else if (Main.tileAxe[tile.type])
45436 {
45437 ModTile modTile2 = TileLoader.GetTile(tile.type);
45438 if (modTile2 != null)
45439 {
45440 num2 += (int)((float)sItem.axe / modTile2.MineResist);
45441 }
45442 else
45443 {
45444 num2 = ((tile.type != 80) ? (num2 + (int)((float)sItem.axe * 1.2f)) : (num2 + (int)((float)(sItem.axe * 3) * 1.2f)));
45445 if (Main.getGoodWorld)
45446 {
45447 num2 = (int)((double)num2 * 1.3);
45448 }
45449 }
45450 if (sItem.axe > 0)
45451 {
45452 AchievementsHelper.CurrentlyMining = true;
45453 if (!WorldGen.CanKillTile(x, y))
45454 {
45455 num2 = 0;
45456 }
45457 if (Main.dontStarveWorld && Main.myPlayer == whoAmI && num2 > 0 && tile.type == 80)
45458 {
45459 Hurt(PlayerDeathReason.ByOther(3), Main.DamageVar(6f, luck), 0, pvp: false, quiet: false, Crit: false, 0);
45460 }
45461 if (hitTile.AddDamage(num, num2) >= 100)
45462 {
45463 if (whoAmI == Main.myPlayer && sItem.type == 5095 && (TileID.Sets.IsATreeTrunk[tile.type] || tile.type == 323 || tile.type == 80))
45464 {
45466 if (TileID.Sets.CountsAsGemTree[tile.type])
45467 {
45468 source = LucyAxeMessage.MessageSource.ChoppedGemTree;
45469 }
45470 if (tile.type == 80)
45471 {
45472 source = LucyAxeMessage.MessageSource.ChoppedCactus;
45473 LucyAxeMessage.TryCreatingMessageWithCooldown(source, base.Top, new Vector2((float)(direction * 7), -7f), 420);
45474 }
45475 else
45476 {
45477 LucyAxeMessage.Create(source, base.Top, new Vector2((float)(direction * 7), -7f));
45478 }
45479 }
45480 ClearMiningCacheAt(x, y, 1);
45481 bool flag = IsBottomOfTreeTrunkNoRoots(x, y);
45482 WorldGen.KillTile(x, y);
45483 if (Main.netMode == 1)
45484 {
45485 NetMessage.SendData(17, -1, -1, null, 0, x, y);
45486 }
45487 if (sItem.type == 5295 && flag)
45488 {
45489 TryReplantingTree(x, y);
45490 }
45491 }
45492 else
45493 {
45494 WorldGen.KillTile(x, y, fail: true);
45495 if (Main.netMode == 1)
45496 {
45497 NetMessage.SendData(17, -1, -1, null, 0, x, y, 1f);
45498 }
45499 }
45500 if (num2 != 0)
45501 {
45502 hitTile.Prune();
45503 }
45505 AchievementsHelper.CurrentlyMining = false;
45506 }
45507 }
45508 else if (sItem.pick > 0)
45509 {
45510 PickTile(x, y, sItem.pick);
45511 }
45512 if (sItem.pick > 0)
45513 {
45515 }
45517 }
static PlayerDeathReason ByOther(int type, int playerIndex=-1)
int whoAmI
The index of this Entity within its specific array. These arrays track the entities in the world....
Definition Entity.cs:16
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:178
int HitObject(int x, int y, int hitType)
Definition HitTile.cs:142
static bool[] CountsAsGemTree
If true for a given tile type (P:Terraria.Tile.TileType), then that tile is categorized as a Gem Tree...
Definition TileID.cs:107
static bool[] IsATreeTrunk
If true for a given tile type (P:Terraria.Tile.TileType), then that tile is categorized as a tree tru...
Definition TileID.cs:114
This class represents a type of tile that can be added by a mod. Only one instance of this class will...
Definition ModTile.cs:19
static ModTile GetTile(int type)
Gets the ModTile instance with the given type. If no ModTile with the given type exists,...
This serves as the central class from which tile-related functions are supported and carried out.
Definition TileLoader.cs:23
void TryReplantingTree(int x, int y)
Definition Player.cs:45539
float pickSpeed
Definition Player.cs:2616
HitTile hitTile
Definition Player.cs:1836
int statLife
The current health of this player. Capped at F:Terraria.Player.statLifeMax2. If you increase this v...
Definition Player.cs:2102
void ClearMiningCacheAt(int x, int y, int hitTileCacheType)
Definition Player.cs:54423
bool IsBottomOfTreeTrunkNoRoots(int x, int y)
Definition Player.cs:45519
double Hurt(PlayerDeathReason damageSource, int Damage, int hitDirection, bool pvp, bool quiet, bool Crit, int cooldownCounter, bool dodgeable=true, float armorPenetration=0f)
Definition Player.cs:36998
void ApplyItemTime(Item sItem, float multiplier=1f, bool? callUseItem=null)
Definition Player.cs:4907
void PickTile(int x, int y, int pickPower)
Definition Player.cs:54333
void ItemCheck_UseMiningTools_TryPoundingTile(Item sItem, int tileHitId, ref bool hitWall, int x, int y)
Definition Player.cs:45694

References Terraria.Tile.active(), Terraria.HitTile.AddDamage(), Terraria.Player.ApplyItemTime(), Terraria.DataStructures.PlayerDeathReason.ByOther(), Terraria.WorldGen.CanKillTile(), Terraria.Player.ClearMiningCacheAt(), Terraria.ID.TileID.Sets.CountsAsGemTree, Terraria.GameContent.LucyAxeMessage.Create(), Terraria.Main.DamageVar(), Terraria.Entity.direction, Terraria.Main.dontStarveWorld, Terraria.Main.getGoodWorld, Terraria.ModLoader.TileLoader.GetTile(), Terraria.Main.hardMode, Terraria.HitTile.HitObject(), Terraria.Player.hitTile, Terraria.Player.Hurt(), Terraria.ID.TileID.Sets.IsATreeTrunk, Terraria.Player.IsBottomOfTreeTrunkNoRoots(), Terraria.Player.ItemCheck_UseMiningTools_TryPoundingTile(), Terraria.WorldGen.KillTile(), Terraria.Player.luck, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.Player.pickSpeed, Terraria.Player.PickTile(), Terraria.HitTile.Prune(), Terraria.NetMessage.SendData(), Terraria.Player.statLife, Terraria.Main.tile, Terraria.Main.tileAxe, Terraria.Main.tileHammer, Terraria.Main.tileNoFail, Terraria.GameContent.LucyAxeMessage.TryCreatingMessageWithCooldown(), Terraria.Player.TryReplantingTree(), Terraria.Tile.type, and Terraria.Entity.whoAmI.

Referenced by Terraria.Player.ItemCheck_UseMiningTools().

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