diff --git a/Items/SwapPickaxe.cs b/Items/SwapPickaxe.cs new file mode 100644 index 0000000..5ad0d90 --- /dev/null +++ b/Items/SwapPickaxe.cs @@ -0,0 +1,139 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using VipixToolBox; +using VipixToolBox.Items; + +namespace VipixToolBox.Items +{ + public class SwapPickaxe : ModItem + { + public int baseRange = 12; + public int toolRange; + public bool operationAllowed; + public List validBlocks; + public List validItems; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Swap Pickaxe"); + Tooltip.SetDefault("Nothing is lost, nothing is created\n100% equivalent pickaxe power"); + } + public override void SetDefaults() + { + Item moltenPickaxe = new Item(); //defaults on copper pickaxe + moltenPickaxe.CloneDefaults(ItemID.MoltenPickaxe); + item.damage = moltenPickaxe.damage; + item.knockBack = moltenPickaxe.knockBack; + item.useStyle = 1; + item.useAnimation = 16; + item.useTime = 16; + item.width = 32; + item.height = 32; + item.rare = moltenPickaxe.rare + +1; + item.UseSound = SoundID.Item1; + item.value = Item.buyPrice(0, 5, 0, 0); + item.autoReuse = true; + validBlocks = new List{ + 0,1,6,7,8,9,38,39,40,45,46,47,53,54,57,59,75,76,188,112,116,118,119,120, + 121,122,123,130,131,137,140,145,146,147,148,150,151,152,153,154,155,156, + 160,161,166,167,168,169,175,176,177,189,193,195,196,194,197,198,202,163, + 164,200,206,224,229,230,137,137,137,137,234,272,248,249,250,170,262,263, + 264,265,266,267,268,273,274,284,311,312,313,315,325,326,327,328,329,336, + 340,341,342,343,344,345,346,347,348,350,351,357,367,368,369,370,371,379, + 385,396,397,398,399,400,401,402,403,404,407,408,409,415,416,417,418, + 30,157,159,208,251,252,253,321,322,2,70,179,180,181,182,183,184 + + };//IDs of blocks that need 1 hit from a pickaxe with >100 power except the grass + + validItems = new List{ + 2,3,11,12,13,14,129,131,133,141,143,145,169,170,172,176,192,214,276,370, + 408,412,413,414,415,416,424,511,512,539,577,586,591,593,594,604,607,609, + 611,612,613,614,662,664,699,700,701,702,717,718,719,751,762,763,765,766, + 767,775,824,833,834,835,883,1103,1125,1127,1146,1147,1148,1149,1246,1344, + 1589,1591,1593,1872,1970,1971,1972,1973,1974,1975,1976,2119,2120,2173, + 2260,2261,2262,2435,2692,2693,2694,2695,2697,2701,2751,2752,2753,2754, + 2755,2787,2792,2793,2794,2860,2868,3066,3081,3086,3087,3100,3113,3214, + 3234,3271,3272,3274,3275,3276,3277,3338,3339,3347,3380,3460,3461,3573, + 3574,3575,3576, + 9,619,621,911,1725,1727,1729,2503,2504,2,176,1,1,1,1,1,1 + };//IDs of corresponding items + } + + public override bool AltFunctionUse(Player player) + { + return false; + } + public override void HoldItem(Player player) + { + //this method determines if the pointed block is buildable and in range of the player + //it shows the item icon if true + //and it allows the actions in CanUseItem + VipixToolBoxPlayer myPlayer = player.GetModPlayer(mod); + toolRange = Math.Max(baseRange, myPlayer.fargoRange);//blocks + + if (Vector2.Distance(player.position,myPlayer.pointerCoord) < toolRange*16 && + myPlayer.pointedTile.active() && + Main.tileSolid[myPlayer.pointedTile.type]) + { + operationAllowed = true; + player.showItemIcon = true; + } + else + { + operationAllowed = false; + player.showItemIcon = false; + } + } + + public override bool CanUseItem(Player player) + { + VipixToolBoxPlayer myPlayer = player.GetModPlayer(mod); + + return true; + } + public override bool UseItem(Player player) + { + VipixToolBoxPlayer myPlayer = player.GetModPlayer(mod); + if (operationAllowed && validBlocks.Contains(myPlayer.pointedTile.type)) + { + int index = -1; + int iindex = -1; + for (int i = 0; i < player.inventory.Length; i++) + { + if (validItems.Contains(player.inventory[i].type)) + { + iindex = i; + index = validItems.FindIndex(a => a == player.inventory[i].type); + break; + } + } + //need to check for resource first + //player.inventory[boneIndex].stack--; + if (index != -1) + { + bool halfBrick = myPlayer.pointedTile.halfBrick(); + byte slope = myPlayer.pointedTile.slope(); + bool actuator = myPlayer.pointedTile.actuator(); + byte color = myPlayer.pointedTile.color(); + + WorldGen.KillTile(myPlayer.pointedTileX, myPlayer.pointedTileY); + WorldGen.PlaceTile(myPlayer.pointedTileX, myPlayer.pointedTileY, validBlocks[index]); + player.inventory[iindex].stack--; + + myPlayer.pointedTile.halfBrick(halfBrick); + myPlayer.pointedTile.slope(slope); + myPlayer.pointedTile.actuator(actuator); + myPlayer.pointedTile.color(color); + + if (Main.netMode == 1) NetMessage.SendTileSquare(-1, myPlayer.pointedTileX, myPlayer.pointedTileY, 1);//player, X, Y, square "diameter". -1 as the player equals all ? + Main.PlaySound(SoundID.Dig); + } + } + return true; + } + } +} diff --git a/Items/SwapPickaxe.png b/Items/SwapPickaxe.png new file mode 100644 index 0000000..b1f162a Binary files /dev/null and b/Items/SwapPickaxe.png differ diff --git a/NPCs/Shops.cs b/NPCs/Shops.cs index 582714d..e90abc3 100644 --- a/NPCs/Shops.cs +++ b/NPCs/Shops.cs @@ -37,6 +37,11 @@ public override void SetupShop(int type, Chest shop, ref int nextSlot) shop.item[nextSlot].SetDefaults(mod.ItemType()); nextSlot++; } + if (type == NPCID.Mechanic) + { + shop.item[nextSlot].SetDefaults(mod.ItemType()); + nextSlot++; + } } } } diff --git a/UI/Color/ColorUI.cs b/UI/Color/ColorUI.cs index dc1ee56..463d8ab 100644 --- a/UI/Color/ColorUI.cs +++ b/UI/Color/ColorUI.cs @@ -51,7 +51,13 @@ public override void OnInitialize() toolList = new List(); Texture2D buttonTexture; //color buttons - for (int i = 0; i < 31; i++) + buttonTexture = ModLoader.GetMod("VipixToolBox").GetTexture("UI/Color/null"); + colorList.Add(new UIImageButton(buttonTexture)); + disabledList.Add(new UIImageButton(ModLoader.GetMod("VipixToolBox").GetTexture("UI/Color/no"))); + colorList[0].Left.Set(0f,0f); + colorList[0].Top.Set(0f,0f); + + for (int i = 1; i < 31; i++) { buttonTexture = ModLoader.GetMod("VipixToolBox").GetTexture("UI/Color/" + i.ToString()); colorList.Add(new UIImageButton(buttonTexture)); diff --git a/UI/Color/0.png b/UI/Color/null.png similarity index 89% rename from UI/Color/0.png rename to UI/Color/null.png index 76979b2..1c1287d 100644 Binary files a/UI/Color/0.png and b/UI/Color/null.png differ diff --git a/build.txt b/build.txt index d83260c..f41cf57 100644 --- a/build.txt +++ b/build.txt @@ -1,5 +1,5 @@ author = vipix -version = 1.3.2 +version = 1.4.0 displayName = VipixToolbox buildIgnore = *.psd, *.template, *.csproj, *.csproj.user, *.zip, *.user, obj\*, bin\*, .vs\*, *.txt, archive\*, .git\, *.gitignore includePDB = true diff --git a/description.txt b/description.txt index d2300bd..0f006fa 100644 --- a/description.txt +++ b/description.txt @@ -10,11 +10,14 @@ New items: - Greater Wand (bloc wand interface) - Wall Hammer - Unstable Staff +- Swap Pickaxe Modified items: - Staff of regrowth (moss color interface) ------------ +v1.4.0 +- New tool: Swap Pickaxe. Swaps blocks with the ones in your inventory but keeps all other characteristics v1.3.2 - Fixed an icon - Mod icon introduced