-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an Item that enables Infinite Placement
- Loading branch information
Kirtle
committed
Jun 10, 2020
1 parent
45f58cb
commit 535d730
Showing
8 changed files
with
148 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
displayName = Builder Essentials | ||
author = Kirtle | ||
version = 0.1.2 | ||
version = 0.1.3 | ||
buildIgnore = *.csproj, *.user, obj\*, bin\*, .vs\* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
Latest Changelog: | ||
- Added an Infinite Placement Accessory (Post MoonLord) |