From 535d7308a2da61d53e03f75a65796bd4fd938d53 Mon Sep 17 00:00:00 2001 From: Kirtle Date: Wed, 10 Jun 2020 03:00:19 +0100 Subject: [PATCH] Added an Item that enables Infinite Placement --- Buffs/InfinitePlacementBuff.cs | 19 +++++ Buffs/InfinitePlacementBuff.png | Bin 0 -> 2926 bytes Items/InfinitePlacement.cs | 122 ++++++++++++++++++++++++++++++++ Items/InfinitePlacement.png | Bin 0 -> 960 bytes Items/InfinitePlacement2.png | Bin 0 -> 739 bytes UI/BasePanel.cs | 3 + build.txt | 2 +- description.txt | 7 +- 8 files changed, 148 insertions(+), 5 deletions(-) create mode 100644 Buffs/InfinitePlacementBuff.cs create mode 100644 Buffs/InfinitePlacementBuff.png create mode 100644 Items/InfinitePlacement.cs create mode 100644 Items/InfinitePlacement.png create mode 100644 Items/InfinitePlacement2.png diff --git a/Buffs/InfinitePlacementBuff.cs b/Buffs/InfinitePlacementBuff.cs new file mode 100644 index 0000000..85e864b --- /dev/null +++ b/Buffs/InfinitePlacementBuff.cs @@ -0,0 +1,19 @@ +using Terraria; +using Terraria.ModLoader; + +namespace BuilderEssentials.Buffs +{ + class InfinitePlacementBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Infinite Placement"); + Description.SetDefault("Where are all these materials coming from?"); + Main.debuff[Type] = true; + Main.buffNoSave[Type] = true; + Main.buffNoTimeDisplay[Type] = true; + Main.buffAlpha[Type] = 0; + canBeCleared = false; + } + } +} diff --git a/Buffs/InfinitePlacementBuff.png b/Buffs/InfinitePlacementBuff.png new file mode 100644 index 0000000000000000000000000000000000000000..0d9b462c7d2722719e68c168950b9828bec9e1fd GIT binary patch literal 2926 zcmV-!3z77RP)uJ@VVD_U zC<6{NG_fI~0ue<-1QkJoA_k0xBC#Thg@9ne9*`iQ#9$OrQF$}6R&?d%y_c8YA7_1Q zpS|}zXYYO1x&V;8{kgn!SPFnNo`4_X z6{c}T{8k*B#$jdxfFg<9uYy1K45IaYvHg`_dOZM)Sy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qQ$Q8{ zO!WzMg`0(=S&msXS#Pt$vrpzo=kRj+a`kh!z=6$;cwT88(J6|n-WB%w`m$h~4 zpmp)YIh_3ETV2tjiAU!0h1dxU-n=E9e!)6|Z;4?!H=SSy{V>ut&IOq{_dlbFb#!9eY1iCsp6Bajj|H zr?hX|zPbJE{X++w546-O*Ot`2Kgd0Jx6Z4syTu9enWavU5N9)I?I-1m1* z_?_rJ$vD~agVqoG+9++s?NEDe`%Fht$4F;X=in*dQ{7$mU2Q)a|9JSc+Uc4zvS-T9 z63!N$T{xF_ZuWe}`RNOZ7sk3{yB}PPym+f8xTpV;-=!;;JuhGEb?H5K#o@~7t9DmU zU1MD9xNd#Dz0azz?I)|B+WM{g+Xrk0I&awC=o(x)cy`EX=)z6+o0o6-+`4{y+3mqQ z%kSJBju{@g%f35#FZJHb`&swrA8dGtepviS>QUumrN{L@>;2q1Vm)$Z)P1z?N$8UY zW2~{~zhwUMVZ87u`Dx{Z>O|9|`Q+&->FRy-Sjp7DHsy69KwU-!MxeeuI@&cF4| zM9z%AW~4!5Wr?AHgRIrk>mhE znql(9s>24bmW2OIEf}86n~b6mIVkZNh)*4|97!ditgS0fgUC^b3TJtXU(G8lEhr~?Mv0gOoOk=Z*2 Y00ePuitGY;xBvhE07*qoM6N<$f}eb#DF6Tf literal 0 HcmV?d00001 diff --git a/Items/InfinitePlacement.cs b/Items/InfinitePlacement.cs new file mode 100644 index 0000000..6740fc2 --- /dev/null +++ b/Items/InfinitePlacement.cs @@ -0,0 +1,122 @@ + +using Microsoft.Xna.Framework; +using System.Collections.Generic; +using System.Security.Cryptography.X509Certificates; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace BuilderEssentials.Items +{ + class InfinitePlacement : ModItem + { + public override void SetStaticDefaults() + { + Tooltip.SetDefault("Allows infinite placement"); + } + + public override void SetDefaults() + { + item.accessory = true; + item.vanity = false; + item.width = 48; + item.height = 48; + item.value = Item.sellPrice(0, 10, 0, 0); + item.rare = ItemRarityID.Red; + } + + protected (int index, Item accessory) FindDifferentEquippedExclusiveAccessory() + { + int maxAccessoryIndex = 5 + Main.LocalPlayer.extraAccessorySlots; + for (int i = 3; i < 3 + maxAccessoryIndex; i++) + { + Item otherAccessory = Main.LocalPlayer.armor[i]; + if (!otherAccessory.IsAir && + !item.IsTheSameAs(otherAccessory) && + otherAccessory.modItem is InfinitePlacement) + { + return (i, otherAccessory); + } + } + return (-1, null); + } + + public override bool CanEquipAccessory(Player player, int slot) + { + if (slot < 10) + { + int index = FindDifferentEquippedExclusiveAccessory().index; + if (index != -1) + return slot == index; + } + return base.CanEquipAccessory(player, slot); + } + + public override bool CanRightClick() + { + int maxAccessoryIndex = 5 + Main.LocalPlayer.extraAccessorySlots; + for (int i = 13; i < 13 + maxAccessoryIndex; i++) + { + if (Main.LocalPlayer.armor[i].type == item.type) + return false; + } + + if (FindDifferentEquippedExclusiveAccessory().accessory != null) + return true; + + return base.CanRightClick(); + } + + public override void RightClick(Player player) + { + var (index, accessory) = FindDifferentEquippedExclusiveAccessory(); + if (accessory != null) + { + Main.LocalPlayer.QuickSpawnClonedItem(accessory); + Main.LocalPlayer.armor[index] = item.Clone(); + } + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.AddBuff(mod.BuffType("InfinitePlacementBuff"), 1); + } + + public override void AddRecipes() + { + //Not really worried about balancing at this point + ModRecipe modRecipe = new ModRecipe(mod); + modRecipe.AddIngredient(ItemID.LunarBar, 40); + modRecipe.AddIngredient(ItemID.FragmentNebula, 20); + modRecipe.AddIngredient(ItemID.FragmentSolar, 20); + modRecipe.AddIngredient(ItemID.FragmentStardust, 20); + modRecipe.AddIngredient(ItemID.FragmentVortex, 20); + modRecipe.AddTile(TileID.LunarCraftingStation); + modRecipe.SetResult(this); + modRecipe.AddRecipe(); + } + } + + public partial class InfinitePlacementTile : GlobalTile + { + public override void PlaceInWorld(int i, int j, Item item) + { + if (Main.LocalPlayer.HasBuff(mod.BuffType("InfinitePlacementBuff"))) { + item.stack += 1; + base.PlaceInWorld(i, j, item); + } + } + } + + public partial class InfinitePlacementWall : GlobalWall + { + public override void PlaceInWorld(int i, int j, int type, Item item) + { + if (Main.LocalPlayer.HasBuff(mod.BuffType("InfinitePlacementBuff"))) + { + item.stack += 1; + base.PlaceInWorld(i, j, type, item); + } + } + } +} diff --git a/Items/InfinitePlacement.png b/Items/InfinitePlacement.png new file mode 100644 index 0000000000000000000000000000000000000000..a18dbeec2728be5812bb8d2ed705d91bca8da57c GIT binary patch literal 960 zcmV;x13&zUP)Px&dPzhr43l?Ku~)NGO0XJzwY^b{+HN|`;#iU_St=Ycdze#?_7@^YCIkTaC>_T z5S!Pu)?S@w)N0hVlu|LkVzB^VHk$$UOzg~nK#Q)ft}@rB(FFr|qtVFOPDUWP2LP>guHBP{P*ZrVwI}c*+r*QE&}1^%2)@p< zI}f4BWRe~SK~M+|_tR@yYqZuVrDFM! zYn_LX@B5W)!Z386-`m?uj|Ez0C;5FR(`XT}ydQUWck%uGJwV#?@Ca|3=-j|+wc`5v z8i3_;S=v?%0Ib*Rc)ec7HoQo(cIO5LgFzZbWiPNuOh}T0@}$;j9#Bd#7z_Z2q9`7X zMwwoQ;&2jGO}CwmfJ}o?6s0qf4ZAHo;B}G*%sJfk5`r7PPKeFtb9t^e9*^4}fg<=< z2XFcOLm5TYU%0;7y&Mon(NTz)P}|Qlm8kb>T%~!UYLgQ$_I5l7TY#SSfBU zFVgF;KYqeXY8sabm&`K5F7mcEP}TE)e*WO#+jqQQ56SH2@`5+-Kcx4ZpPewBPSYL_ z!!VuyMUntr73x;AP}8t+Nv1?Id|Vm3sJ!0TK$EZmh~G`H_3!WR6i%|W1At9)V56#*BL#UY;98Q3@_9gNKF&n!;Cw zjs3h$R6B&q$^$#Y7EPUP!$VC2b!wZkG6CA}c~PZ-I`E<*6J5bWg@Gnjr6eNTM3?a3 zFi^CeQKuxfO>_+pmVs^HAzOeI?eVk;55|hj+JhLL2&1SuXhs3~Qv2ez^m@wZDbI~mys$n3G^wH$pfZ|qU}C=gUQU~yHHw<)-h4EJGM*N<#g_!F3h?J`qT3w i*McTjjf(mP5AYv3B$hs{nYYaV0000Px%ok>JNR9J=Wn6Gc!KorM6j;g5W<`_jvR}~DD7)A=26f&u>u&^2*4=gMnp9%&7 z_6KAdi8K-^&~%{6YU*}}qDY-b_OABTcJ8va>!y53oV$1L`<~wY`d$!*Apmh4lOzd1 zPBjASf301?7l9A}^m;wgH2oujUauFVX?i!PK#&8RpPvIT91Z~(32wOf zXf!I>w`!t&FziH8M3!ZyK_d4>)wn2%Xk}T3QflJ}>!6e(%QAL=Tx-qI(b3vLolb|_ z+gr5OwKn2sGMVJyQG-sW!}awwT5GS2cjV*r^t968eWmCrDXEK=pPce(u z85|!UmwtWmbQxS+TmW!(c2+VtI5+^{^768>-G=xPJV^$DQp(I*fy{=wNClFaL@u*O zDHUj~X?45Z#)Y#fwAOUH-ST#=ltOEr7b72!$E8RG(l6^o`XzFKslh{KB9RNs9$(C) z-EOm5txEfS9pt=dx7)#LwKDBDH#gM;ySuwAmrMA4puE_7)kyH;>YE9+FxC*5bs!DJ zOnk9iE{z|7*E(1va~8>*pZ&plV_$+rGG{;Tvmf`l`taVF#EC$h3tql{<4p4CTZI$B ze%xn~%*n%$JPi5%^$UA%-_e>kPhoI44{Q>^**R>B?0|p2$j$`f7;tv(P2l6$jPV}f ziM1Jg{`9f2zaUUHBM`XWi)=iPb+9Ga68z@`W+lsw&Q|_Dh@!}R%MI^d2Ae8>QT8^f z_9AEH5BHTl)~n2;*Pu!txCTWOmf)(); diff --git a/build.txt b/build.txt index a590afb..275c648 100644 --- a/build.txt +++ b/build.txt @@ -1,4 +1,4 @@ displayName = Builder Essentials author = Kirtle -version = 0.1.2 +version = 0.1.3 buildIgnore = *.csproj, *.user, obj\*, bin\*, .vs\* \ No newline at end of file diff --git a/description.txt b/description.txt index 8d2dc0d..f740456 100644 --- a/description.txt +++ b/description.txt @@ -1,11 +1,10 @@ Builder Essentials is a mod designed to help and improve building in survival. -It features a toggleable secondary accessories system so you can always have your building accessories ready to be used, without filling your inventory! +It features a toggleable secondary accessories system so you can always have your building accessories ready to be used (requires you to add your own accessories), without filling your inventory! In the future, I hope to implement more helpful features to complement this mod. Happy Building! Kirtle -Changelog: - - Added Vanity Accessories and Clothes to the "Build Mode" - - Added Multiplayer support \ No newline at end of file +Latest Changelog: + - Added an Infinite Placement Accessory (Post MoonLord) \ No newline at end of file