I have no idea why this doesn't work

This commit is contained in:
2022-12-03 09:56:51 +01:00
parent 9b77966335
commit 18e0bd6a13
3 changed files with 61 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Chat;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using YHTMod.Items;
namespace YHTMod.Changes;
public class TheKeyBehavior : GlobalTile {
public override void RightClick(int i, int j, int type) {
if (type != TileID.Containers) {
base.RightClick(i, j, type);
return;
}
bool foundKey = false;
foreach (Item item in Main.LocalPlayer.inventory) {
if (item.type.Equals(ModContent.ItemType<TheKey>())) {
foundKey = true;
break;
}
}
ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(foundKey.ToString()), Color.White);
if (!foundKey) {
return;
}
ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral("Found key!"), Color.White);
if (!Chest.IsLocked(i, j)) {
base.RightClick(i, j, type);
return;
}
Chest.Unlock(i, j);
if (Main.netMode == NetmodeID.MultiplayerClient)
NetMessage.SendData(MessageID.Unlock, number: 1, number2: 1f, number3: i, number4: j);
}
}
+14
View File
@@ -0,0 +1,14 @@
using Terraria.GameContent.Creative;
using Terraria.ModLoader;
namespace YHTMod.Items;
public class TheKey : ModItem {
public override void SetStaticDefaults() {
DisplayName.SetDefault("The Key");
Tooltip.SetDefault("Opens all locks.");
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1;
}
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB