From 28c3d30bcf1fb5b43e1186d4f268492390d84187 Mon Sep 17 00:00:00 2001 From: Stevie Date: Fri, 9 Oct 2020 22:21:08 -0700 Subject: [PATCH] ModItem. GlobalItem, and ModRecipe --- .../PlayerDrawHeadLayers.cs.patch | 41 + .../DataStructures/PlayerDrawHeadSet.cs.patch | 11 + .../DataStructures/PlayerDrawLayers.cs.patch | 202 +++++ .../ItemDropRules/CommonCode.cs.patch | 35 + .../LootSimulationItemCounter.cs.patch | 19 + .../Tea/Terraria/ID/ContentSamples.cs.patch | 28 + patches/Tea/Terraria/Item.Tea.cs | 9 + patches/Tea/Terraria/Item.cs.patch | 155 ++++ patches/Tea/Terraria/Lang.cs.patch | 35 + patches/Tea/Terraria/Main.cs.patch | 58 ++ patches/Tea/Terraria/MessageBuffer.cs.patch | 19 + patches/Tea/Terraria/NPC.cs.patch | 19 + patches/Tea/Terraria/Player.cs.patch | 444 +++++++++++ patches/Tea/Terraria/Recipe.cs.patch | 51 ++ patches/Tea/Terraria/Tea/GlobalItem.cs | 87 +++ patches/Tea/Terraria/Tea/ItemLoader.cs | 723 ++++++++++++++++++ patches/Tea/Terraria/Tea/Loader.cs | 21 +- patches/Tea/Terraria/Tea/LoaderUtils.cs | 17 + patches/Tea/Terraria/Tea/Mod.cs | 140 +++- patches/Tea/Terraria/Tea/ModItem.cs | 121 +++ patches/Tea/Terraria/Tea/ModRecipe.cs | 79 ++ patches/Tea/Terraria/UI/ItemSlot.cs.patch | 28 + patches/Tea/Terraria/UI/ItemSorting.cs.patch | 19 + 23 files changed, 2352 insertions(+), 9 deletions(-) create mode 100644 patches/Tea/Terraria/DataStructures/PlayerDrawHeadLayers.cs.patch create mode 100644 patches/Tea/Terraria/DataStructures/PlayerDrawHeadSet.cs.patch create mode 100644 patches/Tea/Terraria/DataStructures/PlayerDrawLayers.cs.patch create mode 100644 patches/Tea/Terraria/GameContent/ItemDropRules/CommonCode.cs.patch create mode 100644 patches/Tea/Terraria/GameContent/LootSimulation/LootSimulationItemCounter.cs.patch create mode 100644 patches/Tea/Terraria/ID/ContentSamples.cs.patch create mode 100644 patches/Tea/Terraria/Item.Tea.cs create mode 100644 patches/Tea/Terraria/Item.cs.patch create mode 100644 patches/Tea/Terraria/Lang.cs.patch create mode 100644 patches/Tea/Terraria/MessageBuffer.cs.patch create mode 100644 patches/Tea/Terraria/NPC.cs.patch create mode 100644 patches/Tea/Terraria/Player.cs.patch create mode 100644 patches/Tea/Terraria/Recipe.cs.patch create mode 100644 patches/Tea/Terraria/Tea/GlobalItem.cs create mode 100644 patches/Tea/Terraria/Tea/ItemLoader.cs create mode 100644 patches/Tea/Terraria/Tea/LoaderUtils.cs create mode 100644 patches/Tea/Terraria/Tea/ModItem.cs create mode 100644 patches/Tea/Terraria/Tea/ModRecipe.cs create mode 100644 patches/Tea/Terraria/UI/ItemSlot.cs.patch create mode 100644 patches/Tea/Terraria/UI/ItemSorting.cs.patch diff --git a/patches/Tea/Terraria/DataStructures/PlayerDrawHeadLayers.cs.patch b/patches/Tea/Terraria/DataStructures/PlayerDrawHeadLayers.cs.patch new file mode 100644 index 00000000000..6bfe73a405d --- /dev/null +++ b/patches/Tea/Terraria/DataStructures/PlayerDrawHeadLayers.cs.patch @@ -0,0 +1,41 @@ +--- src/Terraria/Terraria/DataStructures/PlayerDrawHeadLayers.cs ++++ src/Tea/Terraria/DataStructures/PlayerDrawHeadLayers.cs +@@ -5,6 +_,7 @@ + using Terraria.GameContent; + using Terraria.Graphics; + using Terraria.ID; ++using Terraria.Tea; + + namespace Terraria.DataStructures + { +@@ -14,7 +_,7 @@ + } + + public static void DrawPlayer_00_BackHelmet(ref PlayerDrawHeadSet drawinfo) { +- if (drawinfo.drawPlayer.head >= 0 && drawinfo.drawPlayer.head < 266) { ++ if (drawinfo.drawPlayer.head >= 0) { + int num = ArmorIDs.Head.Sets.FrontToBackID[drawinfo.drawPlayer.head]; + if (num >= 0) { + Rectangle hairFrame = drawinfo.HairFrame; +@@ -24,7 +_,9 @@ + } + + public static void DrawPlayer_01_FaceSkin(ref PlayerDrawHeadSet drawinfo) { ++ ItemLoader.DrawHair(drawinfo.drawPlayer, ref drawinfo.fullHair, ref drawinfo.hatHair); ++ +- if (drawinfo.drawPlayer.head != 38 && drawinfo.drawPlayer.head != 135 && !drawinfo.drawPlayer.isHatRackDoll) { ++ if (drawinfo.drawPlayer.head != 38 && drawinfo.drawPlayer.head != 135 && !drawinfo.drawPlayer.isHatRackDoll && ItemLoader.DrawHead(drawinfo.drawPlayer)) { + QuickCDD(drawinfo.DrawData, drawinfo.skinDyePacked, TextureAssets.Players[drawinfo.skinVar, 0].Value, new Vector2(drawinfo.Position.X - Main.screenPosition.X - (float)(drawinfo.bodyFrameMemory.Width / 2) + (float)(drawinfo.drawPlayer.width / 2), drawinfo.Position.Y - Main.screenPosition.Y + (float)drawinfo.drawPlayer.height - (float)drawinfo.bodyFrameMemory.Height + 4f) + drawinfo.drawPlayer.headPosition + drawinfo.headVect, drawinfo.bodyFrameMemory, drawinfo.colorHead, drawinfo.drawPlayer.headRotation, drawinfo.headVect, drawinfo.scale, drawinfo.playerEffect, 0f); + QuickCDD(drawinfo.DrawData, TextureAssets.Players[drawinfo.skinVar, 1].Value, new Vector2(drawinfo.Position.X - Main.screenPosition.X - (float)(drawinfo.bodyFrameMemory.Width / 2) + (float)(drawinfo.drawPlayer.width / 2), drawinfo.Position.Y - Main.screenPosition.Y + (float)drawinfo.drawPlayer.height - (float)drawinfo.bodyFrameMemory.Height + 4f) + drawinfo.drawPlayer.headPosition + drawinfo.headVect, drawinfo.bodyFrameMemory, drawinfo.colorEyeWhites, drawinfo.drawPlayer.headRotation, drawinfo.headVect, drawinfo.scale, drawinfo.playerEffect, 0f); + QuickCDD(drawinfo.DrawData, TextureAssets.Players[drawinfo.skinVar, 2].Value, new Vector2(drawinfo.Position.X - Main.screenPosition.X - (float)(drawinfo.bodyFrameMemory.Width / 2) + (float)(drawinfo.drawPlayer.width / 2), drawinfo.Position.Y - Main.screenPosition.Y + (float)drawinfo.drawPlayer.height - (float)drawinfo.bodyFrameMemory.Height + 4f) + drawinfo.drawPlayer.headPosition + drawinfo.headVect, drawinfo.bodyFrameMemory, drawinfo.colorEyes, drawinfo.drawPlayer.headRotation, drawinfo.headVect, drawinfo.scale, drawinfo.playerEffect, 0f); +@@ -214,7 +_,9 @@ + } + + public static void DrawPlayer_08_FaceAcc(ref PlayerDrawHeadSet drawinfo) { +- if (drawinfo.drawPlayer.face > 0 && drawinfo.drawPlayer.face < 16 && drawinfo.drawPlayer.face != 5) { ++ ItemLoader.DrawHair(drawinfo.drawPlayer, ref drawinfo.fullHair, ref drawinfo.hatHair); ++ ++ if (drawinfo.drawPlayer.face > 0 && drawinfo.drawPlayer.face != 5) { + if (drawinfo.drawPlayer.face == 7) { + new Color(200, 200, 200, 150); + QuickCDD(drawinfo.DrawData, drawinfo.cFace, TextureAssets.AccFace[drawinfo.drawPlayer.face].Value, new Vector2((int)(drawinfo.Position.X - Main.screenPosition.X - (float)(drawinfo.bodyFrameMemory.Width / 2) + (float)(drawinfo.drawPlayer.width / 2)), drawinfo.Position.Y - Main.screenPosition.Y + (float)drawinfo.drawPlayer.height - (float)drawinfo.bodyFrameMemory.Height + 4f) + drawinfo.drawPlayer.headPosition + drawinfo.headVect, drawinfo.bodyFrameMemory, new Color(200, 200, 200, 200), drawinfo.drawPlayer.headRotation, drawinfo.headVect, drawinfo.scale, drawinfo.playerEffect, 0f); diff --git a/patches/Tea/Terraria/DataStructures/PlayerDrawHeadSet.cs.patch b/patches/Tea/Terraria/DataStructures/PlayerDrawHeadSet.cs.patch new file mode 100644 index 00000000000..a22be758d61 --- /dev/null +++ b/patches/Tea/Terraria/DataStructures/PlayerDrawHeadSet.cs.patch @@ -0,0 +1,11 @@ +--- src/Terraria/Terraria/DataStructures/PlayerDrawHeadSet.cs ++++ src/Tea/Terraria/DataStructures/PlayerDrawHeadSet.cs +@@ -100,7 +_,7 @@ + helmetOffset = drawPlayer.GetHelmetDrawOffset(); + drawPlayer.GetHairSettings(out fullHair, out hatHair, out hideHair, out bool _, out helmetIsOverFullHair); + helmetIsTall = (drawPlayer.head == 14 || drawPlayer.head == 56 || drawPlayer.head == 158); +- helmetIsNormal = (!helmetIsTall && !helmetIsOverFullHair && drawPlayer.head > 0 && drawPlayer.head < 266 && drawPlayer.head != 28); ++ helmetIsNormal = (!helmetIsTall && !helmetIsOverFullHair && drawPlayer.head > 0 && drawPlayer.head != 28); + } + } + } diff --git a/patches/Tea/Terraria/DataStructures/PlayerDrawLayers.cs.patch b/patches/Tea/Terraria/DataStructures/PlayerDrawLayers.cs.patch new file mode 100644 index 00000000000..3c98f02f636 --- /dev/null +++ b/patches/Tea/Terraria/DataStructures/PlayerDrawLayers.cs.patch @@ -0,0 +1,202 @@ +--- src/Terraria/Terraria/DataStructures/PlayerDrawLayers.cs ++++ src/Tea/Terraria/DataStructures/PlayerDrawLayers.cs +@@ -7,6 +_,7 @@ + using Terraria.Graphics; + using Terraria.Graphics.Shaders; + using Terraria.ID; ++using Terraria.Tea; + using Terraria.UI; + + namespace Terraria.DataStructures +@@ -223,7 +_,7 @@ + } + + public static void DrawPlayer_01_3_BackHead(ref PlayerDrawSet drawinfo) { +- if (drawinfo.drawPlayer.head >= 0 && drawinfo.drawPlayer.head < 266) { ++ if (drawinfo.drawPlayer.head >= 0) { + int num = ArmorIDs.Head.Sets.FrontToBackID[drawinfo.drawPlayer.head]; + if (num >= 0) { + Vector2 helmetOffset = drawinfo.helmetOffset; +@@ -386,7 +_,7 @@ + } + + public static void DrawPlayer_09_BackAc(ref PlayerDrawSet drawinfo) { +- if (drawinfo.backPack || drawinfo.drawPlayer.back <= 0 || drawinfo.drawPlayer.back >= 30 || drawinfo.drawPlayer.mount.Active) ++ if (drawinfo.backPack || drawinfo.drawPlayer.back <= 0 || drawinfo.drawPlayer.mount.Active) + return; + + if (drawinfo.drawPlayer.front >= 1 && drawinfo.drawPlayer.front <= 4) { +@@ -886,7 +_,7 @@ + float rotation = bodyRotation + drawinfo.compositeBackArmRotation; + bool flag = !drawinfo.drawPlayer.invis; + bool flag2 = !drawinfo.drawPlayer.invis; +- bool flag3 = drawinfo.drawPlayer.body > 0 && drawinfo.drawPlayer.body < 235; ++ bool flag3 = drawinfo.drawPlayer.body > 0; + bool flag4 = !drawinfo.hidesTopSkin; + bool flag5 = false; + DrawData drawData; +@@ -961,7 +_,7 @@ + } + } + +- if (drawinfo.drawPlayer.handoff > 0 && drawinfo.drawPlayer.handoff < 14) { ++ if (drawinfo.drawPlayer.handoff > 0) { + Texture2D value3 = TextureAssets.AccHandsOffComposite[drawinfo.drawPlayer.handoff].Value; + drawData = new DrawData(value3, vector2, drawinfo.compBackArmFrame, drawinfo.colorArmorBody, rotation, bodyVect, 1f, drawinfo.playerEffect, 0) { + shader = drawinfo.cHandOff +@@ -983,7 +_,7 @@ + public static void DrawPlayer_13_Leggings(ref PlayerDrawSet drawinfo) { + DrawData item; + if (drawinfo.isSitting && drawinfo.drawPlayer.legs != 140 && drawinfo.drawPlayer.legs != 217) { +- if (drawinfo.drawPlayer.legs > 0 && drawinfo.drawPlayer.legs < 218 && (!ShouldOverrideLegs_CheckShoes(ref drawinfo) || drawinfo.drawPlayer.wearsRobe)) { ++ if (drawinfo.drawPlayer.legs > 0 && (!ShouldOverrideLegs_CheckShoes(ref drawinfo) || drawinfo.drawPlayer.wearsRobe)) { + if (!drawinfo.drawPlayer.invis) { + DrawSittingLegs(ref drawinfo, TextureAssets.ArmorLeg[drawinfo.drawPlayer.legs].Value, drawinfo.colorArmorLegs, drawinfo.cLegs); + if (drawinfo.legsGlowMask != -1) +@@ -1021,7 +_,7 @@ + drawinfo.DrawDataCache.Add(item); + } + } +- else if (drawinfo.drawPlayer.legs > 0 && drawinfo.drawPlayer.legs < 218 && (!ShouldOverrideLegs_CheckShoes(ref drawinfo) || drawinfo.drawPlayer.wearsRobe)) { ++ else if (drawinfo.drawPlayer.legs > 0 && (!ShouldOverrideLegs_CheckShoes(ref drawinfo) || drawinfo.drawPlayer.wearsRobe)) { + if (drawinfo.drawPlayer.invis) + return; + +@@ -1110,7 +_,7 @@ + } + + public static void DrawPlayer_14_Shoes(ref PlayerDrawSet drawinfo) { +- if (drawinfo.drawPlayer.shoe > 0 && drawinfo.drawPlayer.shoe < 25 && !ShouldOverrideLegs_CheckPants(ref drawinfo)) { ++ if (drawinfo.drawPlayer.shoe > 0 && !ShouldOverrideLegs_CheckPants(ref drawinfo)) { + if (drawinfo.isSitting) { + DrawSittingLegs(ref drawinfo, TextureAssets.AccShoes[drawinfo.drawPlayer.shoe].Value, drawinfo.colorArmorLegs, drawinfo.cShoe); + return; +@@ -1123,7 +_,7 @@ + } + + public static void DrawPlayer_15_SkinLongCoat(ref PlayerDrawSet drawinfo) { +- if ((drawinfo.skinVar == 3 || drawinfo.skinVar == 8 || drawinfo.skinVar == 7) && (drawinfo.drawPlayer.body <= 0 || drawinfo.drawPlayer.body >= 235) && !drawinfo.drawPlayer.invis) { ++ if ((drawinfo.skinVar == 3 || drawinfo.skinVar == 8 || drawinfo.skinVar == 7) && (drawinfo.drawPlayer.body <= 0) && !drawinfo.drawPlayer.invis) { + if (drawinfo.isSitting) { + DrawSittingLegs(ref drawinfo, TextureAssets.Players[drawinfo.skinVar, 14].Value, drawinfo.colorShirt); + return; +@@ -1212,7 +_,7 @@ + if (drawinfo.usesCompositeTorso) { + DrawPlayer_17_TorsoComposite(ref drawinfo); + } +- else if (drawinfo.drawPlayer.body > 0 && drawinfo.drawPlayer.body < 235) { ++ else if (drawinfo.drawPlayer.body > 0) { + Rectangle bodyFrame = drawinfo.drawPlayer.bodyFrame; + int num = drawinfo.armorAdjust; + bodyFrame.X += num; +@@ -1272,7 +_,7 @@ + _ = value2 + compositeOffset_BackArm; + bodyVect += compositeOffset_BackArm; + DrawData drawData; +- if (drawinfo.drawPlayer.body > 0 && drawinfo.drawPlayer.body < 235) { ++ if (drawinfo.drawPlayer.body > 0) { + if (!drawinfo.drawPlayer.invis || IsArmorDrawnWhenInvisible(drawinfo.drawPlayer.body)) { + Texture2D value3 = TextureAssets.ArmorBodyComposite[drawinfo.drawPlayer.body].Value; + drawData = new DrawData(value3, vector, drawinfo.compTorsoFrame, drawinfo.colorArmorBody, bodyRotation, drawinfo.bodyVect, 1f, drawinfo.playerEffect, 0) { +@@ -1300,7 +_,7 @@ + } + + public static void DrawPlayer_18_OffhandAcc(ref PlayerDrawSet drawinfo) { +- if (!drawinfo.usesCompositeBackHandAcc && drawinfo.drawPlayer.handoff > 0 && drawinfo.drawPlayer.handoff < 14) { ++ if (!drawinfo.usesCompositeBackHandAcc && drawinfo.drawPlayer.handoff > 0) { + DrawData item = new DrawData(TextureAssets.AccHandsOff[drawinfo.drawPlayer.handoff].Value, new Vector2((int)(drawinfo.Position.X - Main.screenPosition.X - (float)(drawinfo.drawPlayer.bodyFrame.Width / 2) + (float)(drawinfo.drawPlayer.width / 2)), (int)(drawinfo.Position.Y - Main.screenPosition.Y + (float)drawinfo.drawPlayer.height - (float)drawinfo.drawPlayer.bodyFrame.Height + 4f)) + drawinfo.drawPlayer.bodyPosition + new Vector2(drawinfo.drawPlayer.bodyFrame.Width / 2, drawinfo.drawPlayer.bodyFrame.Height / 2), drawinfo.drawPlayer.bodyFrame, drawinfo.colorArmorBody, drawinfo.drawPlayer.bodyRotation, drawinfo.bodyVect, 1f, drawinfo.playerEffect, 0); + item.shader = drawinfo.cHandOff; + drawinfo.DrawDataCache.Add(item); +@@ -1308,7 +_,7 @@ + } + + public static void DrawPlayer_19_WaistAcc(ref PlayerDrawSet drawinfo) { +- if (drawinfo.drawPlayer.waist > 0 && drawinfo.drawPlayer.waist < 17) { ++ if (drawinfo.drawPlayer.waist > 0) { + Rectangle value = drawinfo.drawPlayer.legFrame; + if (ArmorIDs.Waist.Sets.UsesTorsoFraming[drawinfo.drawPlayer.waist]) + value = drawinfo.drawPlayer.bodyFrame; +@@ -1320,7 +_,7 @@ + } + + public static void DrawPlayer_20_NeckAcc(ref PlayerDrawSet drawinfo) { +- if (drawinfo.drawPlayer.neck > 0 && drawinfo.drawPlayer.neck < 11) { ++ if (drawinfo.drawPlayer.neck > 0) { + DrawData item = new DrawData(TextureAssets.AccNeck[drawinfo.drawPlayer.neck].Value, new Vector2((int)(drawinfo.Position.X - Main.screenPosition.X - (float)(drawinfo.drawPlayer.bodyFrame.Width / 2) + (float)(drawinfo.drawPlayer.width / 2)), (int)(drawinfo.Position.Y - Main.screenPosition.Y + (float)drawinfo.drawPlayer.height - (float)drawinfo.drawPlayer.bodyFrame.Height + 4f)) + drawinfo.drawPlayer.bodyPosition + new Vector2(drawinfo.drawPlayer.bodyFrame.Width / 2, drawinfo.drawPlayer.bodyFrame.Height / 2), drawinfo.drawPlayer.bodyFrame, drawinfo.colorArmorBody, drawinfo.drawPlayer.bodyRotation, drawinfo.bodyVect, 1f, drawinfo.playerEffect, 0); + item.shader = drawinfo.cNeck; + drawinfo.DrawDataCache.Add(item); +@@ -1405,7 +_,7 @@ + drawinfo.DrawDataCache.Add(item); + } + } +- else if (drawinfo.drawPlayer.head > 0 && drawinfo.drawPlayer.head < 266 && !flag2) { ++ else if (drawinfo.drawPlayer.head > 0 && !flag2) { + if (!(drawinfo.drawPlayer.invis && flag3)) { + if (drawinfo.drawPlayer.head == 13) { + int num6 = 0; +@@ -1610,7 +_,10 @@ + + public static void DrawPlayer_22_FaceAcc(ref PlayerDrawSet drawinfo) { + DrawData item; +- if (drawinfo.drawPlayer.face > 0 && drawinfo.drawPlayer.face < 16 && drawinfo.drawPlayer.face != 5) { ++ ++ ItemLoader.DrawHair(drawinfo.drawPlayer, ref drawinfo.fullHair, ref drawinfo.hatHair); ++ ++ if (drawinfo.drawPlayer.face > 0 && drawinfo.drawPlayer.face != 5) { + if (drawinfo.drawPlayer.face == 7) { + item = new DrawData(TextureAssets.AccFace[drawinfo.drawPlayer.face].Value, new Vector2((int)(drawinfo.Position.X - Main.screenPosition.X - (float)(drawinfo.drawPlayer.bodyFrame.Width / 2) + (float)(drawinfo.drawPlayer.width / 2)), (int)(drawinfo.Position.Y - Main.screenPosition.Y + (float)drawinfo.drawPlayer.height - (float)drawinfo.drawPlayer.bodyFrame.Height + 4f)) + drawinfo.drawPlayer.headPosition + drawinfo.headVect, drawinfo.drawPlayer.bodyFrame, new Color(200, 200, 200, 150), drawinfo.drawPlayer.headRotation, drawinfo.headVect, 1f, drawinfo.playerEffect, 0); + item.shader = drawinfo.cFace; +@@ -1766,7 +_,7 @@ + } + + public static void DrawPlayer_25_Shield(ref PlayerDrawSet drawinfo) { +- if (drawinfo.drawPlayer.shield <= 0 || drawinfo.drawPlayer.shield >= 10) ++ if (drawinfo.drawPlayer.shield <= 0) + return; + + Vector2 zero = Vector2.Zero; +@@ -2147,7 +_,7 @@ + if (drawinfo.usesCompositeTorso) { + DrawPlayer_28_ArmOverItemComposite(ref drawinfo); + } +- else if (drawinfo.drawPlayer.body > 0 && drawinfo.drawPlayer.body < 235) { ++ else if (drawinfo.drawPlayer.body > 0) { + Rectangle bodyFrame = drawinfo.drawPlayer.bodyFrame; + int num = drawinfo.armorAdjust; + bodyFrame.X += num; +@@ -2223,7 +_,7 @@ + vector += new Vector2((!drawinfo.playerEffect.HasFlag(SpriteEffects.FlipHorizontally)) ? 1 : (-1), (!drawinfo.playerEffect.HasFlag(SpriteEffects.FlipVertically)) ? 1 : (-1)); + + _ = drawinfo.drawPlayer.invis; +- bool num = drawinfo.drawPlayer.body > 0 && drawinfo.drawPlayer.body < 235; ++ bool num = drawinfo.drawPlayer.body > 0; + int num2 = drawinfo.compShoulderOverFrontArm ? 1 : 0; + int num3 = (!drawinfo.compShoulderOverFrontArm) ? 1 : 0; + int num4 = (!drawinfo.compShoulderOverFrontArm) ? 1 : 0; +@@ -2305,7 +_,7 @@ + } + } + +- if (drawinfo.drawPlayer.handon > 0 && drawinfo.drawPlayer.handon < 22) { ++ if (drawinfo.drawPlayer.handon > 0) { + Texture2D value3 = TextureAssets.AccHandsOnComposite[drawinfo.drawPlayer.handon].Value; + drawData = new DrawData(value3, vector, drawinfo.compFrontArmFrame, drawinfo.colorArmorBody, rotation, bodyVect, 1f, drawinfo.playerEffect, 0) { + shader = drawinfo.cHandOn +@@ -2316,7 +_,7 @@ + } + + public static void DrawPlayer_29_OnhandAcc(ref PlayerDrawSet drawinfo) { +- if (!drawinfo.usesCompositeFrontHandAcc && drawinfo.drawPlayer.handon > 0 && drawinfo.drawPlayer.handon < 22) { ++ if (!drawinfo.usesCompositeFrontHandAcc && drawinfo.drawPlayer.handon > 0) { + DrawData item = new DrawData(TextureAssets.AccHandsOn[drawinfo.drawPlayer.handon].Value, new Vector2((int)(drawinfo.Position.X - Main.screenPosition.X - (float)(drawinfo.drawPlayer.bodyFrame.Width / 2) + (float)(drawinfo.drawPlayer.width / 2)), (int)(drawinfo.Position.Y - Main.screenPosition.Y + (float)drawinfo.drawPlayer.height - (float)drawinfo.drawPlayer.bodyFrame.Height + 4f)) + drawinfo.drawPlayer.bodyPosition + new Vector2(drawinfo.drawPlayer.bodyFrame.Width / 2, drawinfo.drawPlayer.bodyFrame.Height / 2), drawinfo.drawPlayer.bodyFrame, drawinfo.colorArmorBody, drawinfo.drawPlayer.bodyRotation, drawinfo.bodyVect, 1f, drawinfo.playerEffect, 0); + item.shader = drawinfo.cHandOn; + drawinfo.DrawDataCache.Add(item); +@@ -2348,7 +_,7 @@ + } + + public static void DrawPlayer_32_FrontAcc(ref PlayerDrawSet drawinfo) { +- if (!drawinfo.backPack && drawinfo.drawPlayer.front > 0 && drawinfo.drawPlayer.front < 9 && !drawinfo.drawPlayer.mount.Active) { ++ if (!drawinfo.backPack && drawinfo.drawPlayer.front > 0 && !drawinfo.drawPlayer.mount.Active) { + Vector2 zero = Vector2.Zero; + DrawData item = new DrawData(TextureAssets.AccFront[drawinfo.drawPlayer.front].Value, zero + new Vector2((int)(drawinfo.Position.X - Main.screenPosition.X - (float)(drawinfo.drawPlayer.bodyFrame.Width / 2) + (float)(drawinfo.drawPlayer.width / 2)), (int)(drawinfo.Position.Y - Main.screenPosition.Y + (float)drawinfo.drawPlayer.height - (float)drawinfo.drawPlayer.bodyFrame.Height + 4f)) + drawinfo.drawPlayer.bodyPosition + new Vector2(drawinfo.drawPlayer.bodyFrame.Width / 2, drawinfo.drawPlayer.bodyFrame.Height / 2), drawinfo.drawPlayer.bodyFrame, drawinfo.colorArmorBody, drawinfo.drawPlayer.bodyRotation, drawinfo.bodyVect, 1f, drawinfo.playerEffect, 0); + item.shader = drawinfo.cFront; diff --git a/patches/Tea/Terraria/GameContent/ItemDropRules/CommonCode.cs.patch b/patches/Tea/Terraria/GameContent/ItemDropRules/CommonCode.cs.patch new file mode 100644 index 00000000000..c92177110aa --- /dev/null +++ b/patches/Tea/Terraria/GameContent/ItemDropRules/CommonCode.cs.patch @@ -0,0 +1,35 @@ +--- src/Terraria/Terraria/GameContent/ItemDropRules/CommonCode.cs ++++ src/Tea/Terraria/GameContent/ItemDropRules/CommonCode.cs +@@ -1,4 +_,5 @@ + using Microsoft.Xna.Framework; ++using Terraria.Tea; + using Terraria.Utilities; + + namespace Terraria.GameContent.ItemDropRules +@@ -6,7 +_,7 @@ + public static class CommonCode + { + public static void DropItemFromNPC(NPC npc, int itemId, int stack, bool scattered = false) { +- if (itemId > 0 && itemId < 5045) { ++ if (itemId > 0 && itemId < ItemLoader.Count) { + int x = (int)npc.position.X + npc.width / 2; + int y = (int)npc.position.Y + npc.height / 2; + if (scattered) { +@@ -20,7 +_,7 @@ + } + + public static void DropItemLocalPerClientAndSetNPCMoneyTo0(NPC npc, int itemId, int stack, bool interactionRequired = true) { +- if (itemId <= 0 || itemId >= 5045) ++ if (itemId <= 0 || itemId >= ItemLoader.Count) + return; + + if (Main.netMode == 2) { +@@ -41,7 +_,7 @@ + } + + public static void DropItemForEachInteractingPlayerOnThePlayer(NPC npc, int itemId, UnifiedRandom rng, int dropsAtXOutOfY_TheX, int dropsAtXOutOfY_TheY, int stack = 1, bool interactionRequired = true) { +- if (itemId <= 0 || itemId >= 5045) ++ if (itemId <= 0 || itemId >= ItemLoader.Count) + return; + + if (Main.netMode == 2) { diff --git a/patches/Tea/Terraria/GameContent/LootSimulation/LootSimulationItemCounter.cs.patch b/patches/Tea/Terraria/GameContent/LootSimulation/LootSimulationItemCounter.cs.patch new file mode 100644 index 00000000000..3b84ce69777 --- /dev/null +++ b/patches/Tea/Terraria/GameContent/LootSimulation/LootSimulationItemCounter.cs.patch @@ -0,0 +1,19 @@ +--- src/Terraria/Terraria/GameContent/LootSimulation/LootSimulationItemCounter.cs ++++ src/Tea/Terraria/GameContent/LootSimulation/LootSimulationItemCounter.cs +@@ -1,13 +_,14 @@ + using System.Collections.Generic; + using System.Linq; + using Terraria.ID; ++using Terraria.Tea; + + namespace Terraria.GameContent.LootSimulation + { + public class LootSimulationItemCounter + { +- private long[] _itemCountsObtained = new long[5045]; ++ private long[] _itemCountsObtained = new long[ItemLoader.Count]; +- private long[] _itemCountsObtainedExpert = new long[5045]; ++ private long[] _itemCountsObtainedExpert = new long[ItemLoader.Count]; + private long _totalTimesAttempted; + private long _totalTimesAttemptedExpert; + diff --git a/patches/Tea/Terraria/ID/ContentSamples.cs.patch b/patches/Tea/Terraria/ID/ContentSamples.cs.patch new file mode 100644 index 00000000000..adab06f948f --- /dev/null +++ b/patches/Tea/Terraria/ID/ContentSamples.cs.patch @@ -0,0 +1,28 @@ +--- src/Terraria/Terraria/ID/ContentSamples.cs ++++ src/Tea/Terraria/ID/ContentSamples.cs +@@ -2,6 +_,7 @@ + using System.Linq; + using Terraria.GameContent.Bestiary; + using Terraria.Graphics.Shaders; ++using Terraria.Tea; + + namespace Terraria.ID + { +@@ -588,7 +_,7 @@ + + public static void SetCreativeMenuOrder() { + List list = new List(); +- for (int i = 1; i < 5045; i++) { ++ for (int i = 1; i < ItemLoader.Count; i++) { + Item item = new Item(); + item.SetDefaults(i); + list.Add(item); +@@ -699,7 +_,7 @@ + } + + ItemsByType.Clear(); +- for (int k = 0; k < 5045; k++) { ++ for (int k = 0; k < ItemLoader.Count; k++) { + Item item = new Item(); + item.SetDefaults(k); + ItemsByType[k] = item; diff --git a/patches/Tea/Terraria/Item.Tea.cs b/patches/Tea/Terraria/Item.Tea.cs new file mode 100644 index 00000000000..b5d1c91c721 --- /dev/null +++ b/patches/Tea/Terraria/Item.Tea.cs @@ -0,0 +1,9 @@ +using Terraria.Tea; + +namespace Terraria +{ + partial class Item + { + public ModItem modItem { get; internal set; } + } +} diff --git a/patches/Tea/Terraria/Item.cs.patch b/patches/Tea/Terraria/Item.cs.patch new file mode 100644 index 00000000000..9b2f639ed62 --- /dev/null +++ b/patches/Tea/Terraria/Item.cs.patch @@ -0,0 +1,155 @@ +--- src/Terraria/Terraria/Item.cs ++++ src/Tea/Terraria/Item.cs +@@ -8,12 +_,13 @@ + using Terraria.GameContent.UI; + using Terraria.Graphics.Shaders; + using Terraria.ID; ++using Terraria.Tea; + using Terraria.UI; + using Terraria.Utilities; + + namespace Terraria + { +- public class Item : Entity ++ public partial class Item : Entity + { + private string _nameOverride; + public const int luckPotionDuration1 = 10800; +@@ -291,7 +_,7 @@ + num = -1; + + if (num == -1 || num == -2 || num == -3) { +- if (type == 1 || type == 4 || type == 6 || type == 7 || type == 10 || type == 24 || type == 45 || type == 46 || type == 65 || type == 103 || type == 104 || type == 121 || type == 122 || type == 155 || type == 190 || type == 196 || type == 198 || type == 199 || type == 200 || type == 201 || type == 202 || type == 203 || type == 4258 || type == 204 || type == 213 || type == 217 || type == 273 || type == 367 || type == 368 || type == 426 || type == 482 || type == 483 || type == 484 || type == 653 || type == 654 || type == 656 || type == 657 || type == 659 || type == 660 || type == 671 || type == 672 || type == 674 || type == 675 || type == 676 || type == 723 || type == 724 || type == 757 || type == 776 || type == 777 || type == 778 || type == 787 || type == 795 || type == 797 || type == 798 || type == 799 || type == 881 || type == 882 || type == 921 || type == 922 || type == 989 || type == 990 || type == 991 || type == 992 || type == 993 || type == 1123 || type == 1166 || type == 1185 || type == 1188 || type == 1192 || type == 1195 || type == 1199 || type == 1202 || type == 1222 || type == 1223 || type == 1224 || type == 1226 || type == 1227 || type == 1230 || type == 1233 || type == 1234 || type == 1294 || type == 1304 || type == 1305 || type == 1306 || type == 1320 || type == 1327 || type == 1506 || type == 1507 || type == 1786 || type == 1826 || type == 1827 || type == 1909 || type == 1917 || type == 1928 || type == 2176 || type == 2273 || type == 2608 || type == 2341 || type == 2330 || type == 2320 || type == 2516 || type == 2517 || type == 2746 || type == 2745 || type == 3063 || type == 3018 || type == 3211 || type == 3013 || type == 3258 || type == 3106 || type == 3065 || type == 2880 || type == 3481 || type == 3482 || type == 3483 || type == 3484 || type == 3485 || type == 3487 || type == 3488 || type == 3489 || type == 3490 || type == 3491 || type == 3493 || type == 3494 || type == 3495 || type == 3496 || type == 3497 || type == 3499 || type == 3500 || type == 3501 || type == 3502 || type == 3503 || type == 3505 || type == 3506 || type == 3507 || type == 3508 || type == 3509 || type == 3511 || type == 3512 || type == 3513 || type == 3514 || type == 3515 || type == 3517 || type == 3518 || type == 3519 || type == 3520 || type == 3521 || type == 3522 || type == 3523 || type == 3524 || type == 3525 || (type >= 3462 && type <= 3466) || (type >= 2772 && type <= 2786) || type == 3349 || type == 3352 || type == 3351 || (type >= 3764 && type <= 3769) || type == 4259 || type == 3772 || type == 3823 || type == 3827 || type == 186 || type == 946 || type == 4059 || type == 4317 || type == 4463 || type == 486 || type == 4707 || type == 4711 || type == 4956 || type == 4923 || type == 4788 || type == 4790 || type == 4789 || type == 4672 || type == 4913 || type == 4912 || type == 4911 || type == 4678 || type == 4679 || type == 4680 || type == 4914) { ++ if (type == 1 || type == 4 || type == 6 || type == 7 || type == 10 || type == 24 || type == 45 || type == 46 || type == 65 || type == 103 || type == 104 || type == 121 || type == 122 || type == 155 || type == 190 || type == 196 || type == 198 || type == 199 || type == 200 || type == 201 || type == 202 || type == 203 || type == 4258 || type == 204 || type == 213 || type == 217 || type == 273 || type == 367 || type == 368 || type == 426 || type == 482 || type == 483 || type == 484 || type == 653 || type == 654 || type == 656 || type == 657 || type == 659 || type == 660 || type == 671 || type == 672 || type == 674 || type == 675 || type == 676 || type == 723 || type == 724 || type == 757 || type == 776 || type == 777 || type == 778 || type == 787 || type == 795 || type == 797 || type == 798 || type == 799 || type == 881 || type == 882 || type == 921 || type == 922 || type == 989 || type == 990 || type == 991 || type == 992 || type == 993 || type == 1123 || type == 1166 || type == 1185 || type == 1188 || type == 1192 || type == 1195 || type == 1199 || type == 1202 || type == 1222 || type == 1223 || type == 1224 || type == 1226 || type == 1227 || type == 1230 || type == 1233 || type == 1234 || type == 1294 || type == 1304 || type == 1305 || type == 1306 || type == 1320 || type == 1327 || type == 1506 || type == 1507 || type == 1786 || type == 1826 || type == 1827 || type == 1909 || type == 1917 || type == 1928 || type == 2176 || type == 2273 || type == 2608 || type == 2341 || type == 2330 || type == 2320 || type == 2516 || type == 2517 || type == 2746 || type == 2745 || type == 3063 || type == 3018 || type == 3211 || type == 3013 || type == 3258 || type == 3106 || type == 3065 || type == 2880 || type == 3481 || type == 3482 || type == 3483 || type == 3484 || type == 3485 || type == 3487 || type == 3488 || type == 3489 || type == 3490 || type == 3491 || type == 3493 || type == 3494 || type == 3495 || type == 3496 || type == 3497 || type == 3499 || type == 3500 || type == 3501 || type == 3502 || type == 3503 || type == 3505 || type == 3506 || type == 3507 || type == 3508 || type == 3509 || type == 3511 || type == 3512 || type == 3513 || type == 3514 || type == 3515 || type == 3517 || type == 3518 || type == 3519 || type == 3520 || type == 3521 || type == 3522 || type == 3523 || type == 3524 || type == 3525 || (type >= 3462 && type <= 3466) || (type >= 2772 && type <= 2786) || type == 3349 || type == 3352 || type == 3351 || (type >= 3764 && type <= 3769) || type == 4259 || type == 3772 || type == 3823 || type == 3827 || type == 186 || type == 946 || type == 4059 || type == 4317 || type == 4463 || type == 486 || type == 4707 || type == 4711 || type == 4956 || type == 4923 || type == 4788 || type == 4790 || type == 4789 || type == 4672 || type == 4913 || type == 4912 || type == 4911 || type == 4678 || type == 4679 || type == 4680 || type == 4914 || ItemLoader.MeleePrefix(this)) { + int num9 = unifiedRandom.Next(40); + if (num9 == 0) + num = 1; +@@ -413,7 +_,7 @@ + if (num9 == 39) + num = 81; + } +- else if (type == 162 || type == 5011 || type == 5012 || type == 160 || type == 163 || type == 220 || type == 274 || type == 277 || type == 280 || type == 383 || type == 384 || type == 385 || type == 386 || type == 387 || type == 388 || type == 389 || type == 390 || type == 406 || type == 537 || type == 550 || type == 579 || type == 756 || type == 759 || type == 801 || type == 802 || type == 1186 || type == 1189 || type == 1190 || type == 1193 || type == 1196 || type == 1197 || type == 1200 || type == 1203 || type == 1204 || type == 1228 || type == 1231 || type == 1232 || type == 1259 || type == 1262 || type == 1297 || type == 1314 || type == 1325 || type == 1947 || type == 2332 || type == 2331 || type == 2342 || type == 2424 || type == 2611 || type == 2798 || type == 3012 || type == 3473 || type == 3098 || type == 3368 || type == 3835 || type == 3836 || type == 3858 || type == 4061 || type == 4144 || type == 4272 || type == 2774 || type == 2773 || type == 2779 || type == 2778 || type == 2784 || type == 2783 || type == 3464 || type == 3463) { ++ else if (type == 162 || type == 5011 || type == 5012 || type == 160 || type == 163 || type == 220 || type == 274 || type == 277 || type == 280 || type == 383 || type == 384 || type == 385 || type == 386 || type == 387 || type == 388 || type == 389 || type == 390 || type == 406 || type == 537 || type == 550 || type == 579 || type == 756 || type == 759 || type == 801 || type == 802 || type == 1186 || type == 1189 || type == 1190 || type == 1193 || type == 1196 || type == 1197 || type == 1200 || type == 1203 || type == 1204 || type == 1228 || type == 1231 || type == 1232 || type == 1259 || type == 1262 || type == 1297 || type == 1314 || type == 1325 || type == 1947 || type == 2332 || type == 2331 || type == 2342 || type == 2424 || type == 2611 || type == 2798 || type == 3012 || type == 3473 || type == 3098 || type == 3368 || type == 3835 || type == 3836 || type == 3858 || type == 4061 || type == 4144 || type == 4272 || type == 2774 || type == 2773 || type == 2779 || type == 2778 || type == 2784 || type == 2783 || type == 3464 || type == 3463 || ItemLoader.WeaponPrefix(this)) { + int num10 = unifiedRandom.Next(14); + if (num10 == 0) + num = 36; +@@ -457,7 +_,7 @@ + if (num10 == 13) + num = 61; + } +- else if (type == 39 || type == 44 || type == 95 || type == 96 || type == 98 || type == 99 || type == 120 || type == 164 || type == 197 || type == 219 || type == 266 || type == 281 || type == 434 || type == 435 || type == 436 || type == 481 || type == 506 || type == 533 || type == 534 || type == 578 || type == 655 || type == 658 || type == 661 || type == 679 || type == 682 || type == 725 || type == 758 || type == 759 || type == 760 || type == 796 || type == 800 || type == 905 || type == 923 || type == 964 || type == 986 || type == 1156 || type == 1187 || type == 1194 || type == 1201 || type == 1229 || type == 1254 || type == 1255 || type == 1258 || type == 1265 || type == 1319 || type == 1553 || type == 1782 || type == 1784 || type == 1835 || type == 1870 || type == 1910 || type == 1929 || type == 1946 || type == 2223 || type == 2269 || type == 2270 || type == 2624 || type == 2515 || type == 2747 || type == 2796 || type == 2797 || type == 3052 || type == 2888 || type == 3019 || type == 3029 || type == 3007 || type == 3008 || type == 3210 || type == 3107 || type == 3245 || type == 3475 || type == 3540 || type == 3854 || type == 3859 || type == 3821 || type == 3930 || type == 3480 || type == 3486 || type == 3492 || type == 3498 || type == 3504 || type == 3510 || type == 3516 || type == 3350 || type == 3546 || type == 3788 || type == 4058 || type == 4060 || type == 4381 || type == 4703 || type == 4953) { ++ else if (type == 39 || type == 44 || type == 95 || type == 96 || type == 98 || type == 99 || type == 120 || type == 164 || type == 197 || type == 219 || type == 266 || type == 281 || type == 434 || type == 435 || type == 436 || type == 481 || type == 506 || type == 533 || type == 534 || type == 578 || type == 655 || type == 658 || type == 661 || type == 679 || type == 682 || type == 725 || type == 758 || type == 759 || type == 760 || type == 796 || type == 800 || type == 905 || type == 923 || type == 964 || type == 986 || type == 1156 || type == 1187 || type == 1194 || type == 1201 || type == 1229 || type == 1254 || type == 1255 || type == 1258 || type == 1265 || type == 1319 || type == 1553 || type == 1782 || type == 1784 || type == 1835 || type == 1870 || type == 1910 || type == 1929 || type == 1946 || type == 2223 || type == 2269 || type == 2270 || type == 2624 || type == 2515 || type == 2747 || type == 2796 || type == 2797 || type == 3052 || type == 2888 || type == 3019 || type == 3029 || type == 3007 || type == 3008 || type == 3210 || type == 3107 || type == 3245 || type == 3475 || type == 3540 || type == 3854 || type == 3859 || type == 3821 || type == 3930 || type == 3480 || type == 3486 || type == 3492 || type == 3498 || type == 3504 || type == 3510 || type == 3516 || type == 3350 || type == 3546 || type == 3788 || type == 4058 || type == 4060 || type == 4381 || type == 4703 || type == 4953 || ItemLoader.RangedPrefix(this)) { + int num11 = unifiedRandom.Next(35); + if (num11 == 0) + num = 16; +@@ -564,7 +_,7 @@ + if (num11 == 34) + num = 82; + } +- else if (type == 64 || type == 112 || type == 113 || type == 127 || type == 157 || type == 165 || type == 218 || type == 272 || type == 494 || type == 495 || type == 496 || type == 514 || type == 517 || type == 518 || type == 519 || type == 683 || type == 726 || type == 739 || type == 740 || type == 741 || type == 742 || type == 743 || type == 744 || type == 788 || type == 1121 || type == 1155 || type == 1157 || type == 1178 || type == 1244 || type == 1256 || type == 1260 || type == 1264 || type == 1266 || type == 1295 || type == 1296 || type == 1308 || type == 1309 || type == 1313 || type == 1336 || type == 1444 || type == 1445 || type == 1446 || type == 1572 || type == 1801 || type == 1802 || type == 1930 || type == 1931 || type == 2188 || type == 2622 || type == 2621 || type == 2584 || type == 2551 || type == 2366 || type == 2535 || type == 2365 || type == 2364 || type == 2623 || type == 2750 || type == 2795 || type == 3053 || type == 3051 || type == 3209 || type == 3014 || type == 3105 || type == 2882 || type == 3269 || type == 3006 || type == 3377 || type == 3069 || type == 2749 || type == 3249 || type == 3476 || type == 3474 || type == 3531 || type == 3541 || type == 3542 || type == 3569 || type == 3570 || type == 3571 || type == 3779 || type == 3787 || type == 3531 || type == 3852 || type == 3870 || type == 4269 || type == 4273 || type == 4281 || type == 4347 || type == 4348 || type == 4270 || type == 4758 || type == 4715 || type == 4952 || type == 4607 || type == 5005 || type == 3824 || type == 3818 || type == 3829 || type == 3832 || type == 3825 || type == 3819 || type == 3830 || type == 3833 || type == 3826 || type == 3820 || type == 3831 || type == 3834 || type == 4062) { ++ else if (type == 64 || type == 112 || type == 113 || type == 127 || type == 157 || type == 165 || type == 218 || type == 272 || type == 494 || type == 495 || type == 496 || type == 514 || type == 517 || type == 518 || type == 519 || type == 683 || type == 726 || type == 739 || type == 740 || type == 741 || type == 742 || type == 743 || type == 744 || type == 788 || type == 1121 || type == 1155 || type == 1157 || type == 1178 || type == 1244 || type == 1256 || type == 1260 || type == 1264 || type == 1266 || type == 1295 || type == 1296 || type == 1308 || type == 1309 || type == 1313 || type == 1336 || type == 1444 || type == 1445 || type == 1446 || type == 1572 || type == 1801 || type == 1802 || type == 1930 || type == 1931 || type == 2188 || type == 2622 || type == 2621 || type == 2584 || type == 2551 || type == 2366 || type == 2535 || type == 2365 || type == 2364 || type == 2623 || type == 2750 || type == 2795 || type == 3053 || type == 3051 || type == 3209 || type == 3014 || type == 3105 || type == 2882 || type == 3269 || type == 3006 || type == 3377 || type == 3069 || type == 2749 || type == 3249 || type == 3476 || type == 3474 || type == 3531 || type == 3541 || type == 3542 || type == 3569 || type == 3570 || type == 3571 || type == 3779 || type == 3787 || type == 3531 || type == 3852 || type == 3870 || type == 4269 || type == 4273 || type == 4281 || type == 4347 || type == 4348 || type == 4270 || type == 4758 || type == 4715 || type == 4952 || type == 4607 || type == 5005 || type == 3824 || type == 3818 || type == 3829 || type == 3832 || type == 3825 || type == 3819 || type == 3830 || type == 3833 || type == 3826 || type == 3820 || type == 3831 || type == 3834 || type == 4062 || ItemLoader.MagicPrefix(this)) { + int num12 = unifiedRandom.Next(36); + if (num12 == 0) + num = 26; +@@ -674,7 +_,7 @@ + if (num12 == 35) + num = 83; + } +- else if (type == 55 || type == 119 || type == 191 || type == 284 || type == 670 || type == 1122 || type == 1513 || type == 1569 || type == 1571 || type == 1825 || type == 1918 || type == 3054 || type == 3262 || (type >= 3278 && type <= 3292) || (type >= 3315 && type <= 3317) || type == 3389 || type == 3030 || type == 3543 || type == 4764 || type == 4818 || type == 4760) { ++ else if (type == 55 || type == 119 || type == 191 || type == 284 || type == 670 || type == 1122 || type == 1513 || type == 1569 || type == 1571 || type == 1825 || type == 1918 || type == 3054 || type == 3262 || (type >= 3278 && type <= 3292) || (type >= 3315 && type <= 3317) || type == 3389 || type == 3030 || type == 3543 || type == 4764 || type == 4818 || type == 4760 || ItemLoader.WeaponPrefix(this)) { + int num13 = unifiedRandom.Next(14); + if (type == 3389) + num13 = unifiedRandom.Next(15); +@@ -44361,8 +_,6 @@ + playerIndexTheItemIsReservedFor = Main.myPlayer; + + ResetStats(Type); +- if (type >= 5045) +- type = 0; + + if (type == 0) { + netID = 0; +@@ -44536,11 +_,14 @@ + maxStack = 999; + + netID = type; ++ ++ RebuildTooltip(); ++ ItemLoader.SetupItem(this); ++ + if (!noMatCheck) + material = ItemID.Sets.IsAMaterial[type]; + +- RebuildTooltip(); +- if (type > 0 && type < 5045 && ItemID.Sets.Deprecated[type]) { ++ if (type > 0 && type < ItemLoader.Count && ItemID.Sets.Deprecated[type]) { + netID = 0; + type = 0; + stack = 0; +@@ -44548,6 +_,7 @@ + } + + public void ResetStats(int Type) { ++ modItem = null; + tooltipContext = -1; + BestiaryNotes = null; + sentry = false; +@@ -44652,6 +_,12 @@ + } + + public Color GetAlpha(Color newColor) { ++ Color? modColor = ItemLoader.GetAlpha(this, newColor); ++ ++ if (modColor.HasValue) { ++ return modColor.Value; ++ } ++ + switch (type) { + case 3318: + case 3319: +@@ -45062,6 +_,8 @@ + } + + private void MoveInWorld(float gravity, float maxFallSpeed, ref Vector2 wetVelocity) { ++ ItemLoader.Update(this, ref gravity, ref maxFallSpeed); ++ + if (ItemID.Sets.ItemNoGravity[type]) { + base.velocity.X *= 0.95f; + if ((double)base.velocity.X < 0.1 && (double)base.velocity.X > -0.1) +@@ -45777,8 +_,25 @@ + } + } + +- public Item Clone() => (Item)MemberwiseClone(); +- public Item DeepClone() => (Item)MemberwiseClone(); ++ public Item Clone() { ++ Item newItem = (Item)MemberwiseClone(); ++ ++ if (newItem.type >= ItemID.Count) { ++ ItemLoader.GetItem(newItem.type).SetupModItem(newItem); ++ } ++ ++ return newItem; ++ } ++ ++ public Item DeepClone() { ++ Item newItem = (Item)MemberwiseClone(); ++ ++ if (newItem.type >= ItemID.Count) { ++ ItemLoader.GetItem(newItem.type).SetupModItem(newItem); ++ } ++ ++ return newItem; ++ } + + public bool IsTheSameAs(Item compareItem) { + if (netID == compareItem.netID) +@@ -45840,7 +_,7 @@ + Prefix(reader.ReadByte()); + } + +- if (type >= 5045) ++ if (type >= ItemLoader.Count) + TurnToAir(); + } + diff --git a/patches/Tea/Terraria/Lang.cs.patch b/patches/Tea/Terraria/Lang.cs.patch new file mode 100644 index 00000000000..6285666852b --- /dev/null +++ b/patches/Tea/Terraria/Lang.cs.patch @@ -0,0 +1,35 @@ +--- src/Terraria/Terraria/Lang.cs ++++ src/Tea/Terraria/Lang.cs +@@ -8,6 +_,7 @@ + using Terraria.Localization; + #if CLIENT + using Terraria.Map; ++using Terraria.Tea; + #endif + using Terraria.UI; + +@@ -35,13 +_,13 @@ + public static LocalizedText[] chestType2 = new LocalizedText[14]; + public static LocalizedText[] prefix = new LocalizedText[85]; + public static LocalizedText[] _mapLegendCache; +- private static LocalizedText[] _itemNameCache = new LocalizedText[5045]; ++ internal static LocalizedText[] _itemNameCache = new LocalizedText[5045]; + private static LocalizedText[] _projectileNameCache = new LocalizedText[950]; + private static LocalizedText[] _npcNameCache = new LocalizedText[663]; + private static LocalizedText[] _negativeNpcNameCache = new LocalizedText[65]; + private static LocalizedText[] _buffNameCache = new LocalizedText[323]; + private static LocalizedText[] _buffDescriptionCache = new LocalizedText[323]; +- private static ItemTooltip[] _itemTooltipCache = new ItemTooltip[5045]; ++ internal static ItemTooltip[] _itemTooltipCache = new ItemTooltip[5045]; + private static LocalizedText[] _emojiNameCache = new LocalizedText[145]; + + public static string GetMapObjectName(int id) { +@@ -122,7 +_,7 @@ + + public static LocalizedText GetItemName(int id) { + id = ItemID.FromNetId((short)id); +- if (id > 0 && id < 5045 && _itemNameCache[id] != null) ++ if (id > 0 && id < ItemLoader.Count && _itemNameCache[id] != null) + return _itemNameCache[id]; + + return LocalizedText.Empty; diff --git a/patches/Tea/Terraria/Main.cs.patch b/patches/Tea/Terraria/Main.cs.patch index 09a74bd9e18..27be67c5cb7 100644 --- a/patches/Tea/Terraria/Main.cs.patch +++ b/patches/Tea/Terraria/Main.cs.patch @@ -26,6 +26,64 @@ public static bool AnnouncementBoxDisabled; public static int AnnouncementBoxRange = -1; public static string AutogenSeedName; +@@ -5020,7 +_,7 @@ + } + + private static void Initialize_Items() { +- for (int i = 0; i < 5045; i++) { ++ for (int i = 0; i < ItemLoader.Count; i++) { + Item item = new Item(); + item.SetDefaults(i); + if (item.headSlot > 0) +@@ -12295,6 +_,15 @@ + } + + protected override void Update(GameTime gameTime) { ++ try { ++ do_Update(gameTime); ++ } ++ catch (Exception e) { ++ ErrorLogger.LogException(e); ++ } ++ } ++ ++ protected void do_Update(GameTime gameTime) { + if (!IsEnginePreloaded) { + IsEnginePreloaded = true; + if (Main.OnEnginePreload != null) +@@ -27688,6 +_,11 @@ + Microsoft.Xna.Framework.Color color = Lighting.GetColor(item.Center.ToTileCoordinates()); + Microsoft.Xna.Framework.Color currentColor = item.GetAlpha(color); + ItemSlot.GetItemLight(ref currentColor, ref scale, item); ++ ++ if (!ItemLoader.PreDrawInWorld(item, Main.spriteBatch, color, currentColor, ref num, ref scale)) { ++ ItemLoader.PostDrawInWorld(item, Main.spriteBatch, color, currentColor, num, scale); ++ } ++ + int num2 = item.glowMask; + if (!gamePaused && base.IsActive && ((item.type >= 71 && item.type <= 74) || item.type == 58 || item.type == 109) && color.R > 60 && (float)rand.Next(500) - (Math.Abs(item.velocity.X) + Math.Abs(item.velocity.Y)) * 10f < (float)((int)color.R / 50)) { + int num3 = Dust.NewDust(item.position, item.width, item.height, 43, 0f, 0f, 254, Microsoft.Xna.Framework.Color.White, 0.5f); +@@ -27768,6 +_,11 @@ + + if (item.type == 3858) + spriteBatch.Draw(TextureAssets.GlowMask[233].Value, vector2, frame, new Microsoft.Xna.Framework.Color(255, 255, 255, 63) * 0.75f, num, frame.Size() / 2f, scale, SpriteEffects.None, 0f); ++ ++ if (ItemLoader.animations.Contains(item.type)) { ++ ItemLoader.DrawAnimatedItem(item, color, currentColor, num, scale); ++ ItemLoader.PostDrawInWorld(item, spriteBatch, color, currentColor, num, scale); ++ } + } + + public void DrawItems() { +@@ -35924,7 +_,7 @@ + + string[] array9 = new string[maxMenuItems]; + if (menuMode == -1) +- menuMode = 0; ++ menuMode = LoaderMenus.loadModsID; + + if (Program.LoadedEverything) + GamepadMainMenuHandler.CanRun = true; @@ -36391,7 +_,7 @@ netMode = 0; ClearVisualPostProcessEffects(); diff --git a/patches/Tea/Terraria/MessageBuffer.cs.patch b/patches/Tea/Terraria/MessageBuffer.cs.patch new file mode 100644 index 00000000000..48fbf688dce --- /dev/null +++ b/patches/Tea/Terraria/MessageBuffer.cs.patch @@ -0,0 +1,19 @@ +--- src/Terraria/Terraria/MessageBuffer.cs ++++ src/Tea/Terraria/MessageBuffer.cs +@@ -17,6 +_,7 @@ + using Terraria.ID; + using Terraria.Localization; + using Terraria.Net; ++using Terraria.Tea; + using Terraria.Testing; + using Terraria.UI; + +@@ -1141,7 +_,7 @@ + Item item2 = Main.item[num72]; + ItemSyncPersistentStats itemSyncPersistentStats = default(ItemSyncPersistentStats); + itemSyncPersistentStats.CopyFrom(item2); +- bool newAndShiny = (item2.newAndShiny || item2.netID != num71) && ItemSlot.Options.HighlightNewItems && (num71 < 0 || num71 >= 5045 || !ItemID.Sets.NeverAppearsAsNewInInventory[num71]); ++ bool newAndShiny = (item2.newAndShiny || item2.netID != num71) && ItemSlot.Options.HighlightNewItems && (num71 < 0 || num71 >= ItemLoader.Count || !ItemID.Sets.NeverAppearsAsNewInInventory[num71]); + item2.netDefaults(num71); + item2.newAndShiny = newAndShiny; + item2.Prefix(pre2); diff --git a/patches/Tea/Terraria/NPC.cs.patch b/patches/Tea/Terraria/NPC.cs.patch new file mode 100644 index 00000000000..cbc513399bc --- /dev/null +++ b/patches/Tea/Terraria/NPC.cs.patch @@ -0,0 +1,19 @@ +--- src/Terraria/Terraria/NPC.cs ++++ src/Tea/Terraria/NPC.cs +@@ -19,6 +_,7 @@ + using Terraria.Graphics.Effects; + using Terraria.ID; + using Terraria.Localization; ++using Terraria.Tea; + using Terraria.Utilities; + using Terraria.WorldBuilding; + +@@ -56648,7 +_,7 @@ + + if (type == 1 && ai[1] > 0f) { + int num3 = (int)ai[1]; +- if (num3 > 0 && num3 < 5045) { ++ if (num3 > 0 && num3 < ItemLoader.Count) { + int stackForSlimeItemDrop = GetStackForSlimeItemDrop(num3); + Item.NewItem((int)position.X, (int)position.Y, width, height, num3, stackForSlimeItemDrop); + } diff --git a/patches/Tea/Terraria/Player.cs.patch b/patches/Tea/Terraria/Player.cs.patch new file mode 100644 index 00000000000..3192b4ef1ab --- /dev/null +++ b/patches/Tea/Terraria/Player.cs.patch @@ -0,0 +1,444 @@ +--- src/Terraria/Terraria/Player.cs ++++ src/Tea/Terraria/Player.cs +@@ -29,6 +_,7 @@ + using Terraria.Localization; + using Terraria.ObjectData; + using Terraria.Social; ++using Terraria.Tea; + using Terraria.UI; + using Terraria.UI.Chat; + using Terraria.UI.Gamepad; +@@ -6191,37 +_,37 @@ + + private void UpdateItemDye(bool effectiveEquipmentSlot, bool armorHidden, Item armorItem, Item dyeItem) { + if (!armorItem.IsAir && (!(effectiveEquipmentSlot && armorHidden) || armorItem.wingSlot > 0 || armorItem.type == 934 || armorItem.type == 4341 || armorItem.type == 4563)) { +- if (armorItem.handOnSlot > 0 && armorItem.handOnSlot < 22) ++ if (armorItem.handOnSlot > 0) + cHandOn = dyeItem.dye; + +- if (armorItem.handOffSlot > 0 && armorItem.handOffSlot < 14) ++ if (armorItem.handOffSlot > 0) + cHandOff = dyeItem.dye; + +- if (armorItem.backSlot > 0 && armorItem.backSlot < 30) ++ if (armorItem.backSlot > 0) + cBack = dyeItem.dye; + +- if (armorItem.frontSlot > 0 && armorItem.frontSlot < 9) ++ if (armorItem.frontSlot > 0) + cFront = dyeItem.dye; + +- if (armorItem.shoeSlot > 0 && armorItem.shoeSlot < 25) ++ if (armorItem.shoeSlot > 0) + cShoe = dyeItem.dye; + +- if (armorItem.waistSlot > 0 && armorItem.waistSlot < 17) ++ if (armorItem.waistSlot > 0) + cWaist = dyeItem.dye; + +- if (armorItem.shieldSlot > 0 && armorItem.shieldSlot < 10) ++ if (armorItem.shieldSlot > 0) + cShield = dyeItem.dye; + +- if (armorItem.neckSlot > 0 && armorItem.neckSlot < 11) ++ if (armorItem.neckSlot > 0) + cNeck = dyeItem.dye; + +- if (armorItem.faceSlot > 0 && armorItem.faceSlot < 16) ++ if (armorItem.faceSlot > 0) + cFace = dyeItem.dye; + +- if (armorItem.balloonSlot > 0 && armorItem.balloonSlot < 18) ++ if (armorItem.balloonSlot > 0) + cBalloon = dyeItem.dye; + +- if (armorItem.wingSlot > 0 && armorItem.wingSlot < 47) ++ if (armorItem.wingSlot > 0) + cWings = dyeItem.dye; + + if (armorItem.type == 934) +@@ -8127,6 +_,8 @@ + + if (type == 4743) + hasFootball = true; ++ ++ ItemLoader.UpdateInventory(inventory[j], this); + } + + if (inventory[58].type == 4743) +@@ -8990,6 +_,8 @@ + + if (armor[k].prefix == 80) + meleeSpeed += 0.04f; ++ ++ ItemLoader.UpdateEquip(armor[k], this); + } + + equippedAnyWallSpeedAcc = false; +@@ -10229,6 +_,8 @@ + } + + ApplyMusicBox(currentItem); ++ ++ ItemLoader.UpdateAccessory(currentItem, this); + } + + private void ApplyMusicBox(Item currentItem) { +@@ -10939,6 +_,8 @@ + maxTurrets++; + } + ++ ItemLoader.UpdateArmorSet(this, armor[0], armor[1], armor[2]); ++ + ApplyArmorSoundAndDustChanges(); + } + +@@ -14935,6 +_,8 @@ + num = 0.15f; + } + ++ ItemLoader.VerticalWingSpeeds(this, ref num2, ref num5, ref num4, ref num3, ref num); ++ + velocity.Y -= num * gravDir; + if (gravDir == 1f) { + if (velocity.Y > 0f) +@@ -18074,8 +_,10 @@ + UpdateControlHolds(); + } + else if (grappling[0] == -1 && !tongued) { +- if (wingsLogic > 0 && base.velocity.Y != 0f && !merman && !mount.Active) ++ if (wingsLogic > 0 && base.velocity.Y != 0f && !merman && !mount.Active) { +- WingAirLogicTweaks(); ++ WingAirLogicTweaks(); ++ ItemLoader.HorizontalWingSpeeds(this); ++ } + + if (empressBrooch) + runAcceleration *= 2f; +@@ -25041,6 +_,9 @@ + _ = bodyFrame; + reference6.Y = 0; + } ++ else if (ItemLoader.HoldItemFrame(inventory[selectedItem], this)) { ++ return; ++ } + else if (shieldRaised) { + bodyFrame.Y = bodyFrame.Height * 10; + } +@@ -29058,7 +_,7 @@ + if (itemAnimation == 0 && altFunctionUse == 2) + altFunctionUse = 0; + +- bool flag2 = true; ++ bool flag2 = ItemLoader.CanUseItem(item, this); + if (gravDir == -1f && GolfHelper.IsPlayerHoldingClub(this)) + flag2 = false; + +@@ -29204,6 +_,8 @@ + + if (((item.damage >= 0 && item.type > 0 && !item.noMelee) || item.type == 1450 || item.type == 1991 || item.type == 3183 || item.type == 4821 || item.type == 3542 || item.type == 3779) && itemAnimation > 0) { + ItemCheck_GetMeleeHitbox(item, drawHitbox, out bool dontAttack, out Rectangle itemRectangle); ++ ItemLoader.MeleeEffects(item, this, itemRectangle); ++ + if (!dontAttack) { + itemRectangle = ItemCheck_EmitUseVisuals(item, itemRectangle); + if (Main.myPlayer == whoAmI && (item.type == 1991 || item.type == 3183 || item.type == 4821)) +@@ -29238,6 +_,8 @@ + } + + if (ItemTimeIsZero && itemAnimation > 0) { ++ ItemLoader.UseItem(item, this); ++ + if (item.hairDye >= 0) { + ApplyItemTime(item); + if (whoAmI == Main.myPlayer) { +@@ -29578,6 +_,8 @@ + if (flag7.HasValue) + flag6 = flag7.Value; + ++ ItemLoader.ConsumeItem(item, this, ref flag6); ++ + if (flag6) { + if (item.stack > 0) + item.stack--; +@@ -29855,6 +_,7 @@ + if (Main.rand.Next(1, 101) <= 10) + flag = true; + ++ ItemLoader.ModifyHitPvp(sItem, this, Main.player[i], ref damage, ref flag); + int num = Main.DamageVar(damage, luck); + StatusToPlayerPvP(sItem.type, i); + OnHit(player.Center.X, player.Center.Y, player); +@@ -29900,6 +_,8 @@ + if (sItem.type == 1826 && Main.npc[i].value > 0f) + pumpkinSword(i, (int)((double)damage * 1.5), knockBack); + ++ ItemLoader.OnHitPvp(sItem, this, Main.player[i], damage, flag); ++ + if (Main.netMode != 0) + NetMessage.SendPlayerHurt(i, playerDeathReason, num, direction, flag, pvp: true, -1); + +@@ -29925,6 +_,8 @@ + if (Main.rand.Next(1, 101) <= weaponCrit) + flag = true; + ++ ItemLoader.ModifyHitNPC(sItem, this, Main.npc[i], ref num, ref knockBack, ref flag); ++ + int num2 = Item.NPCtoBanner(Main.npc[i].BannerID()); + if (num2 > 0 && HasNPCBannerBuff(num2)) + num = ((!Main.expertMode) ? ((int)((float)num * ItemID.Sets.BannerStrength[Item.BannerToItem(num2)].NormalDamageDealt)) : ((int)((float)num * ItemID.Sets.BannerStrength[Item.BannerToItem(num2)].ExpertDamageDealt))); +@@ -29960,6 +_,7 @@ + + int dmgDone = (int)Main.npc[i].StrikeNPC(num4, knockBack, direction, flag); + ApplyNPCOnHitEffects(sItem, itemRectangle, num, knockBack, i, num4, dmgDone); ++ ItemLoader.OnHitNPC(sItem, this, Main.npc[i], num, knockBack, flag); + int num5 = Item.NPCtoBanner(Main.npc[i].BannerID()); + if (num5 >= 0) + lastCreatureHit = num5; +@@ -30543,6 +_,8 @@ + } + } + ++ ItemLoader.UseItemHitbox(sItem, this, ref itemRectangle, ref dontAttack); ++ + if (sItem.type == 1450 && Main.rand.Next(3) == 0) { + int num = -1; + float x = itemRectangle.X + Main.rand.Next(itemRectangle.Width); +@@ -33146,7 +_,7 @@ + Main.projectile[num180].originalDamage = damage; + UpdateMaxTurrets(); + } +- else { ++ else if (ItemLoader.Shoot(sItem, this, ref vector, ref num2, ref num3, ref projToShoot, ref Damage, ref KnockBack)) { + int num181 = Projectile.NewProjectile(vector.X, vector.Y, num2, num3, projToShoot, Damage, KnockBack, i); + if (sItem.type == 726) + Main.projectile[num181].magic = true; +@@ -33627,6 +_,8 @@ + if (sItem.type != 4952 || pulley) + return; + ++ ItemLoader.HoldItem(sItem, this); ++ + Vector2 pos = itemLocation + new Vector2(8 * direction, -10f * gravDir); + Vector3 rgb = new Vector3(1f, 0.7f, 0.8f) * 1.3f; + Vector2 vector = RotatedRelativePoint(pos); +@@ -33665,6 +_,8 @@ + if (!CanVisuallyHoldItem(sItem)) + return; + ++ ItemLoader.UseStyle(sItem, this); ++ + if (isPettingAnimal) { + int num = miscCounter % 14 / 7; + CompositeArmStretchAmount stretch = CompositeArmStretchAmount.ThreeQuarters; +@@ -33903,6 +_,8 @@ + SetCompositeArmBack(enabled: true, stretch6, (float)Math.PI * -3f / 5f * (float)direction); + FlipItemLocationAndRotationForGravity(); + } ++ ++ ItemLoader.HoldStyle(sItem, this); + } + + private void ItemCheck_ApplyManaRegenDelay(Item sItem) { +@@ -35776,6 +_,10 @@ + if ((projToShoot == 145 || projToShoot == 146 || projToShoot == 147 || projToShoot == 148 || projToShoot == 149) && itemAnimation < itemAnimationMax - 5) + flag2 = true; + ++ if (!ItemLoader.ConsumeAmmo(sItem, item, this)) { ++ flag2 = true; ++ } ++ + if (!flag2 && item.consumable) { + item.stack--; + if (item.stack <= 0) { +@@ -36654,49 +_,49 @@ + binaryWriter.Write(player.shoeColor.G); + binaryWriter.Write(player.shoeColor.B); + for (int k = 0; k < player.armor.Length; k++) { +- binaryWriter.Write(player.armor[k].netID); ++ ItemLoader.WriteID(player.armor[k], binaryWriter); + binaryWriter.Write(player.armor[k].prefix); + } + + for (int l = 0; l < player.dye.Length; l++) { +- binaryWriter.Write(player.dye[l].netID); ++ ItemLoader.WriteID(player.dye[l], binaryWriter); + binaryWriter.Write(player.dye[l].prefix); + } + + for (int m = 0; m < 58; m++) { +- binaryWriter.Write(player.inventory[m].netID); ++ ItemLoader.WriteID(player.inventory[m], binaryWriter); + binaryWriter.Write(player.inventory[m].stack); + binaryWriter.Write(player.inventory[m].prefix); + binaryWriter.Write(player.inventory[m].favorited); + } + + for (int n = 0; n < player.miscEquips.Length; n++) { +- binaryWriter.Write(player.miscEquips[n].netID); ++ ItemLoader.WriteID(player.miscEquips[n], binaryWriter); + binaryWriter.Write(player.miscEquips[n].prefix); +- binaryWriter.Write(player.miscDyes[n].netID); ++ ItemLoader.WriteID(player.miscDyes[n], binaryWriter); + binaryWriter.Write(player.miscDyes[n].prefix); + } + + for (int num = 0; num < 40; num++) { +- binaryWriter.Write(player.bank.item[num].netID); ++ ItemLoader.WriteID(player.bank.item[num], binaryWriter); + binaryWriter.Write(player.bank.item[num].stack); + binaryWriter.Write(player.bank.item[num].prefix); + } + + for (int num2 = 0; num2 < 40; num2++) { +- binaryWriter.Write(player.bank2.item[num2].netID); ++ ItemLoader.WriteID(player.bank2.item[num2], binaryWriter); + binaryWriter.Write(player.bank2.item[num2].stack); + binaryWriter.Write(player.bank2.item[num2].prefix); + } + + for (int num3 = 0; num3 < 40; num3++) { +- binaryWriter.Write(player.bank3.item[num3].netID); ++ ItemLoader.WriteID(player.bank3.item[num3], binaryWriter); + binaryWriter.Write(player.bank3.item[num3].stack); + binaryWriter.Write(player.bank3.item[num3].prefix); + } + + for (int num4 = 0; num4 < 40; num4++) { +- binaryWriter.Write(player.bank4.item[num4].netID); ++ ItemLoader.WriteID(player.bank4.item[num4], binaryWriter); + binaryWriter.Write(player.bank4.item[num4].stack); + binaryWriter.Write(player.bank4.item[num4].prefix); + } +@@ -36959,7 +_,7 @@ + else { + int num4 = 20; + for (int m = 0; m < num4; m++) { +- player.armor[m].netDefaults(binaryReader.ReadInt32()); ++ ItemLoader.ReadID(player.armor[m], binaryReader); + player.armor[m].Prefix(binaryReader.ReadByte()); + } + } +@@ -36974,34 +_,24 @@ + + for (int n = 0; n < num5; n++) { + int num6 = n; +- player.dye[num6].netDefaults(binaryReader.ReadInt32()); ++ ItemLoader.ReadID(player.dye[num6], binaryReader); + player.dye[num6].Prefix(binaryReader.ReadByte()); + } + } + + if (num >= 58) { + for (int num7 = 0; num7 < 58; num7++) { +- int num8 = binaryReader.ReadInt32(); +- if (num8 >= 5045) { +- player.inventory[num7].netDefaults(0); +- binaryReader.ReadInt32(); +- binaryReader.ReadByte(); +- if (num >= 114) +- binaryReader.ReadBoolean(); +- } +- else { +- player.inventory[num7].netDefaults(num8); ++ ItemLoader.ReadID(player.inventory[num7], binaryReader); +- player.inventory[num7].stack = binaryReader.ReadInt32(); ++ player.inventory[num7].stack = binaryReader.ReadInt32(); +- player.inventory[num7].Prefix(binaryReader.ReadByte()); ++ player.inventory[num7].Prefix((int)binaryReader.ReadByte()); +- if (num >= 114) ++ if (num >= 114) +- player.inventory[num7].favorited = binaryReader.ReadBoolean(); ++ player.inventory[num7].favorited = binaryReader.ReadBoolean(); +- } + } + } + else { + for (int num9 = 0; num9 < 48; num9++) { + int num10 = binaryReader.ReadInt32(); +- if (num10 >= 5045) { ++ if (num10 >= ItemLoader.Count) { + player.inventory[num9].netDefaults(0); + binaryReader.ReadInt32(); + binaryReader.ReadByte(); +@@ -37019,7 +_,7 @@ + for (int num11 = 0; num11 < 5; num11++) { + if (num11 != 1) { + int num12 = binaryReader.ReadInt32(); +- if (num12 >= 5045) { ++ if (num12 >= ItemLoader.Count) { + player.miscEquips[num11].netDefaults(0); + binaryReader.ReadByte(); + } +@@ -37029,7 +_,7 @@ + } + + num12 = binaryReader.ReadInt32(); +- if (num12 >= 5045) { ++ if (num12 >= ItemLoader.Count) { + player.miscDyes[num11].netDefaults(0); + binaryReader.ReadByte(); + } +@@ -37042,38 +_,23 @@ + } + else { + for (int num13 = 0; num13 < 5; num13++) { +- int num14 = binaryReader.ReadInt32(); +- if (num14 >= 5045) { +- player.miscEquips[num13].netDefaults(0); +- binaryReader.ReadByte(); +- } +- else { +- player.miscEquips[num13].netDefaults(num14); +- player.miscEquips[num13].Prefix(binaryReader.ReadByte()); +- } +- +- num14 = binaryReader.ReadInt32(); +- if (num14 >= 5045) { +- player.miscDyes[num13].netDefaults(0); +- binaryReader.ReadByte(); +- } +- else { +- player.miscDyes[num13].netDefaults(num14); +- player.miscDyes[num13].Prefix(binaryReader.ReadByte()); +- } ++ ItemLoader.ReadID(player.miscEquips[num13], binaryReader); ++ player.miscEquips[num13].Prefix((int)binaryReader.ReadByte()); ++ ItemLoader.ReadID(player.miscDyes[num13], binaryReader); ++ player.miscDyes[num13].Prefix((int)binaryReader.ReadByte()); + } + } + } + + if (num >= 58) { + for (int num15 = 0; num15 < 40; num15++) { +- player.bank.item[num15].netDefaults(binaryReader.ReadInt32()); ++ ItemLoader.ReadID(player.bank.item[num15], binaryReader); + player.bank.item[num15].stack = binaryReader.ReadInt32(); + player.bank.item[num15].Prefix(binaryReader.ReadByte()); + } + + for (int num16 = 0; num16 < 40; num16++) { +- player.bank2.item[num16].netDefaults(binaryReader.ReadInt32()); ++ ItemLoader.ReadID(player.bank2.item[num16], binaryReader); + player.bank2.item[num16].stack = binaryReader.ReadInt32(); + player.bank2.item[num16].Prefix(binaryReader.ReadByte()); + } +@@ -37094,7 +_,7 @@ + + if (num >= 182) { + for (int num19 = 0; num19 < 40; num19++) { +- player.bank3.item[num19].netDefaults(binaryReader.ReadInt32()); ++ ItemLoader.ReadID(player.bank3.item[num19], binaryReader); + player.bank3.item[num19].stack = binaryReader.ReadInt32(); + player.bank3.item[num19].Prefix(binaryReader.ReadByte()); + } +@@ -37102,7 +_,7 @@ + + if (num >= 198) { + for (int num20 = 0; num20 < 40; num20++) { +- player.bank4.item[num20].netDefaults(binaryReader.ReadInt32()); ++ ItemLoader.ReadID(player.bank4.item[num20], binaryReader); + player.bank4.item[num20].stack = binaryReader.ReadInt32(); + player.bank4.item[num20].Prefix(binaryReader.ReadByte()); + } diff --git a/patches/Tea/Terraria/Recipe.cs.patch b/patches/Tea/Terraria/Recipe.cs.patch new file mode 100644 index 00000000000..5fdaf4a15a6 --- /dev/null +++ b/patches/Tea/Terraria/Recipe.cs.patch @@ -0,0 +1,51 @@ +--- src/Terraria/Terraria/Recipe.cs ++++ src/Tea/Terraria/Recipe.cs +@@ -3,6 +_,7 @@ + using Terraria.GameContent.Achievements; + using Terraria.ID; + using Terraria.Localization; ++using Terraria.Tea; + + namespace Terraria + { +@@ -113,6 +_,13 @@ + break; + + int num = item2.stack; ++ ++ ModRecipe modRecipe = this as ModRecipe; ++ ++ if (modRecipe != null) { ++ num = modRecipe.ConsumeItem(item.type, item.stack); ++ } ++ + if (alchemy && Main.player[Main.myPlayer].alchemyTable) { + if (num > 1) { + int num2 = 0; +@@ -456,6 +_,9 @@ + public static void SetupRecipes() { + int num = 5; + int stack = 2; ++ RecipeGroup.recipeGroups.Clear(); ++ RecipeGroup.recipeGroupIDs.Clear(); ++ RecipeGroup.nextRecipeGroupIndex = 0; + SetupRecipeGroups(); + currentRecipe.createItem.SetDefaults(8); + currentRecipe.createItem.stack = 3; +@@ -13050,6 +_,7 @@ + currentRecipe.requiredItem[0].SetDefaults(73); + currentRecipe.requiredItem[0].stack = 100; + AddRecipe(); ++ Loader.AddRecipes(); + CreateReverseWallRecipes(); + CreateReversePlatformRecipes(); + UpdateWhichItemsAreMaterials(); +@@ -13067,7 +_,7 @@ + } + + public static void UpdateWhichItemsAreMaterials() { +- for (int i = 0; i < 5045; i++) { ++ for (int i = 0; i < ItemLoader.Count; i++) { + Item item = new Item(); + item.SetDefaults(i, noMatCheck: true); + item.checkMat(); diff --git a/patches/Tea/Terraria/Tea/GlobalItem.cs b/patches/Tea/Terraria/Tea/GlobalItem.cs new file mode 100644 index 00000000000..0da5aa006e6 --- /dev/null +++ b/patches/Tea/Terraria/Tea/GlobalItem.cs @@ -0,0 +1,87 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace Terraria.Tea +{ + public class GlobalItem + { + public Mod mod { get; internal set; } + + public string Name { get; internal set; } + + public virtual bool Autoload(ref string name) => true; + + public virtual void SetDefaults(Item item) { } + + public virtual bool CanUseItem(Item item, Player player) => true; + + public virtual void UseStyle(Item item, Player player) { } + + public virtual void HoldStyle(Item item, Player player) { } + + public virtual void HoldItem(Item item, Player player) { } + + public virtual bool ConsumeAmmo(Item item, Player player) => true; + + public virtual bool Shoot(Item item, Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) => true; + + public virtual void UseItemHitbox(Item item, Player player, ref Rectangle hitbox, ref bool noHitbox) { } + + public virtual void MeleeEffects(Item item, Player player, Rectangle hitbox) { } + + public virtual void ModifyHitNPC(Item item, Player player, NPC target, ref int damage, ref float knockBack, ref bool crit) { } + + public virtual void OnHitNPC(Item item, Player player, NPC target, int damage, float knockBack, bool crit) { } + + public virtual void ModifyHitPvp(Item item, Player player, Player target, ref int damage, ref bool crit) { } + + public virtual void OnHitPvp(Item item, Player player, Player target, int damage, bool crit) { } + + public virtual bool UseItem(Item item, Player player) => false; + + public virtual bool ConsumeItem(Item item, Player player) => true; + + public virtual bool UseItemFrame(Item item, Player player) => false; + + public virtual bool HoldItemFrame(Item item, Player player) => false; + + public virtual void UpdateInventory(Item item, Player player) { } + + public virtual void UpdateEquip(Item item, Player player) { } + + public virtual void UpdateAccessory(Item item, Player player) { } + + public virtual string IsArmorSet(Item head, Item body, Item legs) => ""; + + public virtual void UpdateArmorSet(Player player, string set) { } + + public virtual bool CanRightClick(Item item) => false; + + public virtual void RightClick(Item item, Player player) { } + + public virtual void DrawHair(Item item, ref bool drawHair, ref bool drawAltHair) { } + + public virtual bool DrawHead(Item item) => true; + + public virtual void VerticalWingSpeeds(Item item, ref float ascentWhenFalling, ref float ascentWhenRising, + ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) { } + + public virtual void HorizontalWingSpeeds(Item item, ref float speed, ref float acceleration) { } + + public virtual void Update(Item item, ref float gravity, ref float maxFallSpeed) { } + + public virtual Color? GetAlpha(Item item, Color lightColor) => null; + + public virtual bool PreDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale) => true; + + public virtual void PostDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale) { } + + public virtual bool PreDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, + Color drawColor, Color itemColor, Vector2 origin, float scale) => true; + + public virtual void PostDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, + Color drawColor, Color itemColor, Vector2 origin, float scale) { } + + public virtual bool CanEquipAccessory(Item item, Player player, int slot) => true; + } +} diff --git a/patches/Tea/Terraria/Tea/ItemLoader.cs b/patches/Tea/Terraria/Tea/ItemLoader.cs new file mode 100644 index 00000000000..43def3ee7ce --- /dev/null +++ b/patches/Tea/Terraria/Tea/ItemLoader.cs @@ -0,0 +1,723 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.Localization; +using Terraria.UI; + +namespace Terraria.Tea +{ + public static class ItemLoader + { + private static int nextItem = ItemID.Count; + + internal static readonly IDictionary items = new Dictionary(); + internal static readonly IList globalItems = new List(); + internal static readonly IList animations = new List(); + internal static readonly int[] vanillaWings = new int[Main.maxWings]; + + public static int Count = nextItem; + + internal static int ReserveItemID() { + int reserveID = nextItem; + nextItem++; + + return reserveID; + } + + public static ModItem GetItem(int type) { + if (items.ContainsKey(type)) { + return items[type]; + } + else { + return null; + } + } + + internal static void ResizeArrays() { + Array.Resize(ref TextureAssets.Item, nextItem); + Array.Resize(ref TextureAssets.ItemFlame, nextItem); + Array.Resize(ref Main.itemAnimations, nextItem); + Array.Resize(ref Item.cachedItemSpawnsByType, nextItem); + Array.Resize(ref Item.staff, nextItem); + Array.Resize(ref Item.claw, nextItem); + Array.Resize(ref Lang._itemNameCache, nextItem); + Array.Resize(ref Lang._itemTooltipCache, nextItem); + Array.Resize(ref ItemID.Sets.ItemsThatCountAsBombsForDemolitionistToSpawn, nextItem); + Array.Resize(ref ItemID.Sets.NewItemSpawnPriority, nextItem); + Array.Resize(ref ItemID.Sets.CanBeQuickusedOnGamepad, nextItem); + Array.Resize(ref ItemID.Sets.ForcesBreaksSleeping, nextItem); + Array.Resize(ref ItemID.Sets.SkipsInitialUseSound, nextItem); + Array.Resize(ref ItemID.Sets.UsesCursedByPlanteraTooltip, nextItem); + Array.Resize(ref ItemID.Sets.IsAKite, nextItem); + Array.Resize(ref ItemID.Sets.ForceConsumption, nextItem); + Array.Resize(ref ItemID.Sets.HasAProjectileThatHasAUsabilityCheck, nextItem); + Array.Resize(ref ItemID.Sets.CanGetPrefixes, nextItem); + Array.Resize(ref ItemID.Sets.ColorfulDyeValues, nextItem); + Array.Resize(ref ItemID.Sets.flowerPacketInfo, nextItem); + Array.Resize(ref ItemID.Sets.IsAMaterial, nextItem); + Array.Resize(ref ItemID.Sets.IgnoresEncumberingStone, nextItem); + Array.Resize(ref ItemID.Sets.ToolTipDamageMultiplier, nextItem); + Array.Resize(ref ItemID.Sets.IsAPickup, nextItem); + Array.Resize(ref ItemID.Sets.IsDrill, nextItem); + Array.Resize(ref ItemID.Sets.IsChainsaw, nextItem); + Array.Resize(ref ItemID.Sets.IsPaintScraper, nextItem); + Array.Resize(ref ItemID.Sets.IsFood, nextItem); + Array.Resize(ref ItemID.Sets.FoodParticleColors, nextItem); + Array.Resize(ref ItemID.Sets.DrinkParticleColors, nextItem); + Array.Resize(ref ItemID.Sets.BannerStrength, nextItem); + Array.Resize(ref ItemID.Sets.KillsToBanner, nextItem); + Array.Resize(ref ItemID.Sets.CanFishInLava, nextItem); + Array.Resize(ref ItemID.Sets.IsLavaBait, nextItem); + Array.Resize(ref ItemID.Sets.ItemSpawnDecaySpeed, nextItem); + Array.Resize(ref ItemID.Sets.IsFishingCrate, nextItem); + Array.Resize(ref ItemID.Sets.IsFishingCrateHardmode, nextItem); + Array.Resize(ref ItemID.Sets.CanBePlacedOnWeaponRacks, nextItem); + Array.Resize(ref ItemID.Sets.TextureCopyLoad, nextItem); + Array.Resize(ref ItemID.Sets.TrapSigned, nextItem); + Array.Resize(ref ItemID.Sets.Deprecated, nextItem); + Array.Resize(ref ItemID.Sets.CommonCoin, nextItem); + Array.Resize(ref ItemID.Sets.ItemIconPulse, nextItem); + Array.Resize(ref ItemID.Sets.ItemNoGravity, nextItem); + Array.Resize(ref ItemID.Sets.ExtractinatorMode, nextItem); + Array.Resize(ref ItemID.Sets.StaffMinionSlotsRequired, nextItem); + Array.Resize(ref ItemID.Sets.ExoticPlantsForDyeTrade, nextItem); + Array.Resize(ref ItemID.Sets.NebulaPickup, nextItem); + Array.Resize(ref ItemID.Sets.AnimatesAsSoul, nextItem); + Array.Resize(ref ItemID.Sets.gunProj, nextItem); + Array.Resize(ref ItemID.Sets.SortingPriorityBossSpawns, nextItem); + Array.Resize(ref ItemID.Sets.NeverAppearsAsNewInInventory, nextItem); + Array.Resize(ref ItemID.Sets.SortingPriorityWiring, nextItem); + Array.Resize(ref ItemID.Sets.SortingPriorityMaterials, nextItem); + Array.Resize(ref ItemID.Sets.SortingPriorityExtractibles, nextItem); + Array.Resize(ref ItemID.Sets.SortingPriorityRopes, nextItem); + Array.Resize(ref ItemID.Sets.SortingPriorityPainting, nextItem); + Array.Resize(ref ItemID.Sets.SortingPriorityTerraforming, nextItem); + Array.Resize(ref ItemID.Sets.GamepadExtraRange, nextItem); + Array.Resize(ref ItemID.Sets.GamepadWholeScreenUseRange, nextItem); + Array.Resize(ref ItemID.Sets.BonusMeleeSpeedMultiplier, nextItem); + Array.Resize(ref ItemID.Sets.GamepadSmartQuickReach, nextItem); + Array.Resize(ref ItemID.Sets.Yoyo, nextItem); + Array.Resize(ref ItemID.Sets.AlsoABuildingItem, nextItem); + Array.Resize(ref ItemID.Sets.LockOnIgnoresCollision, nextItem); + Array.Resize(ref ItemID.Sets.LockOnAimAbove, nextItem); + Array.Resize(ref ItemID.Sets.LockOnAimCompensation, nextItem); + Array.Resize(ref ItemID.Sets.SingleUseInGamepad, nextItem); + Array.Resize(ref ItemID.Sets.Torches, nextItem); + Array.Resize(ref ItemID.Sets.WaterTorches, nextItem); + Array.Resize(ref ItemID.Sets.Workbenches, nextItem); + + for (int k = ItemID.Count; k < nextItem; k++) { + Lang._itemNameCache[k] = LocalizedText.Empty; + Lang._itemTooltipCache[k] = ItemTooltip.None; + Item.cachedItemSpawnsByType[k] = -1; + } + + Array.Resize(ref Main.anglerQuestItemNetIDs, 41); + + if (vanillaWings[1] != 0) + return; + + Item item = new Item(); + + for (int k = 0; k < ItemID.Count; k++) { + item.SetDefaults(k); + + if (item.wingSlot > 0) { + vanillaWings[item.wingSlot] = k; + } + } + } + + public static bool IsModItem(Item item) => item.type >= ItemID.Count; + + internal static void WriteID(Item item, BinaryWriter writer) { + if (item.netID >= ItemID.Count) { + int writeID = Int32.MaxValue; + byte[] data; + + using (MemoryStream memoryStream = new MemoryStream()) { + using (BinaryWriter customWriter = new BinaryWriter(memoryStream)) { + item.modItem.SaveCustomData(customWriter); + customWriter.Flush(); + data = memoryStream.ToArray(); + } + } + + if (data.Length > 0) { + writeID -= 1; + } + + writer.Write(writeID); + writer.Write(item.modItem.mod.Name); + writer.Write(Lang._itemNameCache[item.type].Value); + + if (data.Length > 0) { + writer.Write((short)data.Length); + writer.Write(data); + } + } + else { + writer.Write(item.netID); + } + } + + internal static void ReadID(Item item, BinaryReader reader) { + int type = reader.ReadInt32(); + + if (type >= int.MaxValue - 1) { + bool hasCustomData = type == int.MaxValue - 1; + string modName = reader.ReadString(); + string itemName = reader.ReadString(); + Mod mod = Loader.GetMod(modName); + + if (mod == null) { + type = 0; + } + else { + type = mod.ItemType(itemName); + } + + item.netDefaults(type); + + if (type != 0 && hasCustomData) { + byte[] data = reader.ReadBytes(reader.ReadInt16()); + + using (MemoryStream memoryStream = new MemoryStream(data)) { + using (BinaryReader customReader = new BinaryReader(memoryStream)) { + item.modItem.LoadCustomData(customReader); + } + } + } + } + else { + item.netDefaults(type); + } + } + + internal static bool MeleePrefix(Item item) { + if (item.modItem == null) { + return false; + } + + return item.damage > 0 && item.melee && !item.noUseGraphic; + } + + internal static bool WeaponPrefix(Item item) { + if (item.modItem == null) { + return false; + } + + return item.damage > 0 && item.melee && item.noUseGraphic; + } + + internal static bool RangedPrefix(Item item) { + if (item.modItem == null) { + return false; + } + + return item.damage > 0 && item.ranged; + } + + internal static bool MagicPrefix(Item item) { + if (item.modItem == null) { + return false; + } + + return item.damage > 0 && (item.magic || item.summon); + } + + internal static void SetupItem(Item item) { + if (IsModItem(item)) { + GetItem(item.type).SetupItem(item); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.SetDefaults(item); + } + } + + internal static void DrawAnimatedItem(Item item, Color color, Color alpha, float rotation, float scale) { + int frameCount = Main.itemAnimations[item.type].FrameCount; + int frameDuration = Main.itemAnimations[item.type].TicksPerFrame; + Main.itemFrameCounter[item.whoAmI]++; + + if (Main.itemFrameCounter[item.whoAmI] >= frameDuration) { + Main.itemFrameCounter[item.whoAmI] = 0; + Main.itemFrame[item.whoAmI]++; + } + + if (Main.itemFrame[item.whoAmI] >= frameCount) { + Main.itemFrame[item.whoAmI] = 0; + } + + Rectangle frame = TextureAssets.Item[item.type].Frame(1, frameCount, 0, Main.itemFrame[item.whoAmI]); + float offX = (item.width / 2 - frame.Width / 2); + float offY = (item.height - frame.Height); + + Main.spriteBatch.Draw(TextureAssets.Item[item.type].Value, new Vector2(item.position.X - Main.screenPosition.X + (frame.Width / 2) + offX, item.position.Y - Main.screenPosition.Y + (frame.Height / 2) + offY), new Rectangle?(frame), alpha, rotation, frame.Size() / 2f, scale, SpriteEffects.None, 0f); + + if (item.color != default) { + Main.spriteBatch.Draw(TextureAssets.Item[item.type].Value, new Vector2(item.position.X - Main.screenPosition.X + (frame.Width / 2) + offX, item.position.Y - Main.screenPosition.Y + (frame.Height / 2) + offY), new Rectangle?(frame), item.GetColor(color), rotation, frame.Size() / 2f, scale, SpriteEffects.None, 0f); + } + } + + internal static bool CanUseItem(Item item, Player player) { + bool flag = true; + + if (IsModItem(item)) { + flag = flag && item.modItem.CanUseItem(player); + } + + foreach (GlobalItem globalItem in globalItems) { + flag = flag && globalItem.CanUseItem(item, player); + } + + return flag; + } + + internal static void UseStyle(Item item, Player player) { + if (IsModItem(item)) { + item.modItem.UseStyle(player); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.UseStyle(item, player); + } + } + + internal static void HoldStyle(Item item, Player player) { + if (!player.pulley && player.itemAnimation <= 0) { + if (IsModItem(item)) { + item.modItem.HoldStyle(player); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.HoldStyle(item, player); + } + } + } + + internal static void HoldItem(Item item, Player player) { + if (IsModItem(item)) { + item.modItem.HoldItem(player); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.HoldItem(item, player); + } + } + + internal static bool ConsumeAmmo(Item item, Item ammo, Player player) { + if (IsModItem(item) && !item.modItem.ConsumeAmmo(player)) { + return false; + } + + if (IsModItem(ammo) && !ammo.modItem.ConsumeAmmo(player)) { + return false; + } + + foreach (GlobalItem globalItem in globalItems) { + if (!globalItem.ConsumeAmmo(item, player) || !globalItem.ConsumeAmmo(ammo, player)) { + return false; + } + } + + return true; + } + + internal static bool Shoot(Item item, Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { + foreach (GlobalItem globalItem in globalItems) { + if (!globalItem.Shoot(item, player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockBack)) { + return false; + } + } + + if (IsModItem(item)) { + if (!item.modItem.Shoot(player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockBack)) { + return false; + } + } + + return true; + } + + internal static void UseItemHitbox(Item item, Player player, ref Rectangle hitbox, ref bool noHitbox) { + if (IsModItem(item)) { + item.modItem.UseItemHitbox(player, ref hitbox, ref noHitbox); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.UseItemHitbox(item, player, ref hitbox, ref noHitbox); + } + } + + internal static void MeleeEffects(Item item, Player player, Rectangle hitbox) { + if (IsModItem(item)) { + item.modItem.MeleeEffects(player, hitbox); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.MeleeEffects(item, player, hitbox); + } + } + + internal static void ModifyHitNPC(Item item, Player player, NPC target, ref int damage, ref float knockBack, ref bool crit) { + if (IsModItem(item)) { + item.modItem.ModifyHitNPC(player, target, ref damage, ref knockBack, ref crit); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.ModifyHitNPC(item, player, target, ref damage, ref knockBack, ref crit); + } + } + + internal static void OnHitNPC(Item item, Player player, NPC target, int damage, float knockBack, bool crit) { + if (IsModItem(item)) { + item.modItem.OnHitNPC(player, target, damage, knockBack, crit); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.OnHitNPC(item, player, target, damage, knockBack, crit); + } + } + + internal static void ModifyHitPvp(Item item, Player player, Player target, ref int damage, ref bool crit) { + if (IsModItem(item)) { + item.modItem.ModifyHitPvp(player, target, ref damage, ref crit); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.ModifyHitPvp(item, player, target, ref damage, ref crit); + } + } + + internal static void OnHitPvp(Item item, Player player, Player target, int damage, bool crit) { + if (IsModItem(item)) { + item.modItem.OnHitPvp(player, target, damage, crit); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.OnHitPvp(item, player, target, damage, crit); + } + } + + internal static void UseItem(Item item, Player player) { + if (IsModItem(item) && item.modItem.UseItem(player)) { + player.itemTime = item.useTime; + } + + foreach (GlobalItem globalItem in globalItems) { + if (globalItem.UseItem(item, player)) { + player.itemTime = item.useTime; + } + } + } + + internal static void ConsumeItem(Item item, Player player, ref bool consume) { + if (IsModItem(item) && !item.modItem.ConsumeItem(player)) { + consume = false; + } + + foreach (GlobalItem globalItem in globalItems) { + if (!globalItem.ConsumeItem(item, player)) { + consume = false; + } + } + } + + internal static bool UseItemFrame(Item item, Player player) { + if (IsModItem(item) && item.modItem.UseItemFrame(player)) { + return true; + } + + foreach (GlobalItem globalItem in globalItems) { + if (globalItem.UseItemFrame(item, player)) { + return true; + } + } + + return false; + } + + internal static bool HoldItemFrame(Item item, Player player) { + if (IsModItem(item) && item.modItem.HoldItemFrame(player)) { + return true; + } + + foreach (GlobalItem globalItem in globalItems) { + if (globalItem.HoldItemFrame(item, player)) { + return true; + } + } + + return false; + } + + internal static void UpdateInventory(Item item, Player player) { + if (IsModItem(item)) { + item.modItem.UpdateInventory(player); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.UpdateInventory(item, player); + } + } + + internal static void UpdateEquip(Item item, Player player) { + if (IsModItem(item)) { + item.modItem.UpdateEquip(player); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.UpdateEquip(item, player); + } + } + + internal static void UpdateAccessory(Item item, Player player) { + if (IsModItem(item)) { + item.modItem.UpdateAccessory(player); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.UpdateAccessory(item, player); + } + } + + internal static void UpdateArmorSet(Player player, Item head, Item body, Item legs) { + if (IsModItem(head) && head.modItem.IsArmorSet(head, body, legs)) { + head.modItem.UpdateArmorSet(player); + } + + if (IsModItem(body) && body.modItem.IsArmorSet(head, body, legs)) { + body.modItem.UpdateArmorSet(player); + } + + if (IsModItem(legs) && legs.modItem.IsArmorSet(head, body, legs)) { + legs.modItem.UpdateArmorSet(player); + } + + foreach (GlobalItem globalItem in globalItems) { + string set = globalItem.IsArmorSet(head, body, legs); + + if (set.Length > 0) { + globalItem.UpdateArmorSet(player, set); + } + } + } + + internal static bool CanRightClick(Item item) { + if (IsModItem(item) && item.modItem.CanRightClick()) { + return Main.mouseRight; + } + + foreach (GlobalItem globalItem in globalItems) { + if (globalItem.CanRightClick(item)) { + return Main.mouseRight; + } + } + + return false; + } + + internal static void RightClick(Item item, Player player) { + if (Main.mouseRightRelease) { + if (IsModItem(item)) { + item.modItem.RightClick(player); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.RightClick(item, player); + } + + item.stack--; + + if (item.stack == 0) { + item.SetDefaults(0, false); + } + + SoundEngine.PlaySound(7, -1, -1, 1); + + Main.stackSplit = 30; + Main.mouseRightRelease = false; + + Recipe.FindRecipes(); + } + } + + internal static void DrawHair(Player player, ref bool drawHair, ref bool drawAltHair) { + Item item = player.armor[10].headSlot >= 0 ? player.armor[10] : player.armor[0]; + + if (IsModItem(item)) { + item.modItem.DrawHair(ref drawHair, ref drawAltHair); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.DrawHair(item, ref drawHair, ref drawAltHair); + } + } + + internal static bool DrawHead(Player player) { + Item item = player.armor[10].headSlot >= 0 ? player.armor[10] : player.armor[0]; + + if (IsModItem(item) && !item.modItem.DrawHead()) { + return false; + } + + foreach (GlobalItem globalItem in globalItems) { + if (!globalItem.DrawHead(item)) { + return false; + } + } + + return true; + } + + private static Item GetWing(Player player) { + Item item = null; + + for (int k = 3; k < 8 + player.extraAccessorySlots; k++) { + if (player.armor[k].wingSlot > 0) { + item = player.armor[k]; + } + } + + return item; + } + + internal static void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, + ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) { + Item item = GetWing(player); + + if (item == null) { + return; + } + + if (IsModItem(item)) { + item.modItem.VerticalWingSpeeds(ref ascentWhenFalling, ref ascentWhenRising, ref maxCanAscendMultiplier, + ref maxAscentMultiplier, ref constantAscend); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.VerticalWingSpeeds(item, ref ascentWhenFalling, ref ascentWhenRising, + ref maxCanAscendMultiplier, ref maxAscentMultiplier, ref constantAscend); + } + } + + internal static void HorizontalWingSpeeds(Player player) { + Item item = GetWing(player); + + if (item == null) { + return; + } + + if (IsModItem(item)) { + item.modItem.HorizontalWingSpeeds(ref player.accRunSpeed, ref player.runAcceleration); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.HorizontalWingSpeeds(item, ref player.accRunSpeed, ref player.runAcceleration); + } + } + + internal static void Update(Item item, ref float gravity, ref float maxFallSpeed) { + if (IsModItem(item)) { + item.modItem.Update(ref gravity, ref maxFallSpeed); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.Update(item, ref gravity, ref maxFallSpeed); + } + } + + internal static Color? GetAlpha(Item item, Color lightColor) { + foreach (GlobalItem globalItem in globalItems) { + Color? color = globalItem.GetAlpha(item, lightColor); + + if (color.HasValue) { + return color; + } + } + + if (IsModItem(item)) { + return item.modItem.GetAlpha(lightColor); + } + + return null; + } + + internal static bool PreDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale) { + bool flag = true; + + if (IsModItem(item) && !item.modItem.PreDrawInWorld(spriteBatch, lightColor, alphaColor, ref rotation, ref scale)) { + flag = false; + } + + foreach (GlobalItem globalItem in globalItems) { + if (!globalItem.PreDrawInWorld(item, spriteBatch, lightColor, alphaColor, ref rotation, ref scale)) { + flag = false; + } + } + + return flag; + } + + internal static void PostDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale) { + if (IsModItem(item)) { + item.modItem.PostDrawInWorld(spriteBatch, lightColor, alphaColor, rotation, scale); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.PostDrawInWorld(item, spriteBatch, lightColor, alphaColor, rotation, scale); + } + } + + internal static bool PreDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, + Color drawColor, Color itemColor, Vector2 origin, float scale) { + bool flag = true; + + foreach (GlobalItem globalItem in globalItems) { + if (!globalItem.PreDrawInInventory(item, spriteBatch, position, frame, drawColor, itemColor, origin, scale)) { + flag = false; + } + } + + if (IsModItem(item) && !item.modItem.PreDrawInInventory(spriteBatch, position, frame, drawColor, itemColor, origin, scale)) { + flag = false; + } + + return flag; + } + + internal static void PostDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, + Color drawColor, Color itemColor, Vector2 origin, float scale) { + if (IsModItem(item)) { + item.modItem.PostDrawInInventory(spriteBatch, position, frame, drawColor, itemColor, origin, scale); + } + + foreach (GlobalItem globalItem in globalItems) { + globalItem.PostDrawInInventory(item, spriteBatch, position, frame, drawColor, itemColor, origin, scale); + } + } + + internal static bool CanEquipAccessory(Item item, int slot) { + Player player = Main.player[Main.myPlayer]; + + if (IsModItem(item) && !item.modItem.CanEquipAccessory(player, slot)) { + return false; + } + + foreach (GlobalItem globalItem in globalItems) { + if (!globalItem.CanEquipAccessory(item, player, slot)) { + return false; + } + } + + return true; + } + } +} \ No newline at end of file diff --git a/patches/Tea/Terraria/Tea/Loader.cs b/patches/Tea/Terraria/Tea/Loader.cs index f09bb735bb3..af42635ccdf 100644 --- a/patches/Tea/Terraria/Tea/Loader.cs +++ b/patches/Tea/Terraria/Tea/Loader.cs @@ -112,7 +112,7 @@ public static void do_Load(object threadContext) { modsLoaded = 0; } - /*LoaderMenus.loadMods.SetProgressRecipes(); + LoaderMenus.loadMods.SetProgressRecipes(); Recipe.numRecipes = 0; @@ -123,13 +123,15 @@ public static void do_Load(object threadContext) { ErrorLogger.LogLoadingError("recipes", e); Main.menuMode = LoaderMenus.errorMessageID; - }*/ + + return; + } Main.menuMode = 0; } private static void ResizeArrays(bool unloading = false) { - + ItemLoader.ResizeArrays(); } internal static string[] FindMods() { @@ -615,7 +617,20 @@ public static Texture2D GetTexture(string name) { } internal static void AddRecipes() { + foreach (Mod mod in mods.Values) { + try { + mod.AddRecipes(); + foreach (ModItem item in mod.items.Values) { + item.AddRecipes(); + } + } + catch { + DisableMod(mod.filePath); + + throw; + } + } } } } diff --git a/patches/Tea/Terraria/Tea/LoaderUtils.cs b/patches/Tea/Terraria/Tea/LoaderUtils.cs new file mode 100644 index 00000000000..791d1d4f6a4 --- /dev/null +++ b/patches/Tea/Terraria/Tea/LoaderUtils.cs @@ -0,0 +1,17 @@ +using System; + +namespace Terraria.Tea +{ + internal class LoaderUtils + { + public static void ResetStaticMembers(Type type, bool recursive) { + type.TypeInitializer?.Invoke(null, null); + + if (recursive) { + foreach (var nestedType in type.GetNestedTypes()) { + ResetStaticMembers(nestedType, recursive); + } + } + } + } +} diff --git a/patches/Tea/Terraria/Tea/Mod.cs b/patches/Tea/Terraria/Tea/Mod.cs index 6f72d484700..bbea2fca412 100644 --- a/patches/Tea/Terraria/Tea/Mod.cs +++ b/patches/Tea/Terraria/Tea/Mod.cs @@ -1,4 +1,6 @@ -using System.Reflection; +using System; +using System.Collections.Generic; +using System.Reflection; namespace Terraria.Tea { @@ -6,6 +8,10 @@ public abstract class Mod { internal string filePath; internal Assembly ModAssembly; + internal readonly List recipes = new List(); + internal readonly IDictionary items = new Dictionary(); + internal readonly IDictionary globalItems = new Dictionary(); + private string name; @@ -19,14 +25,136 @@ internal void Initialize() { public virtual void Load() { } - public virtual void Unload() { } - public virtual void AddRecipes() { } - internal void Autoload() { } + internal void SetupContent() { } - // public void AddItem(string name, ModItem item, string texture) { } + internal void Autoload() { + Type[] classes = ModAssembly.GetTypes(); - internal void SetupContent() { } + foreach (Type type in classes) { + if (type.IsSubclassOf(typeof(ModItem))) { + AutoloadItem(type); + } + + if (type.IsSubclassOf(typeof(GlobalItem))) { + AutoloadGlobalItem(type); + } + } + } + + internal void Unload() { + recipes.Clear(); + items.Clear(); + globalItems.Clear(); + } + + public void AddItem(string name, ModItem item, string texture) { + int id = ItemLoader.ReserveItemID(); + item.item.SetNameOverride(name); + item.item.ResetStats(id); + items[name] = item; + ItemLoader.items[id] = item; + item.texture = texture; + item.mod = this; + } + + public void AddGlobalItem(string name, GlobalItem globalItem) { + globalItem.mod = this; + globalItem.Name = name; + globalItems[name] = globalItem; + + ItemLoader.globalItems.Add(globalItem); + } + + // TODO: AddEquipTexture + /*public int AddEquipTexture(ModItem item, EquipType type, string texture, string armTexture = "", string femaleTexture = "") { + int slot = EquipLoader.ReserveEquipID(type); + EquipLoader.equips[type][texture] = slot; + + ModLoader.GetTexture(texture); + + if (type == EquipType.Body) { + EquipLoader.armTextures[slot] = armTexture; + EquipLoader.femaleTextures[slot] = femaleTexture.Length > 0 ? femaleTexture : texture; + + ModLoader.GetTexture(armTexture); + ModLoader.GetTexture(femaleTexture); + } + + if (type == EquipType.Head || type == EquipType.Body || type == EquipType.Legs) { + EquipLoader.slotToId[type][slot] = item.item.type; + } + + return slot; + }*/ + + private void AutoloadItem(Type type) { + ModItem item = (ModItem)Activator.CreateInstance(type); + + item.mod = this; + string name = type.Name; + string texture = (type.Namespace + "." + type.Name).Replace('.', '/'); + // TODO: IList equips = new List(); + + if (item.Autoload(ref name, ref texture/*, equips*/)) { + + AddItem(name, item, texture); + + /*if (equips.Count > 0) { + EquipLoader.idToSlot[item.item.type] = new Dictionary(); + + foreach (EquipType equip in equips) { + string equipTexture = texture + "_" + equip.ToString(); + string armTexture = texture + "_Arms"; + string femaleTexture = texture + "_FemaleBody"; + + item.AutoloadEquip(equip, ref equipTexture, ref armTexture, ref femaleTexture); + int slot = AddEquipTexture(item, equip, equipTexture, armTexture, femaleTexture); + EquipLoader.idToSlot[item.item.type][equip] = slot; + } + }*/ + } + } + + private void AutoloadGlobalItem(Type type) { + GlobalItem globalItem = (GlobalItem)Activator.CreateInstance(type); + + globalItem.mod = this; + string name = type.Name; + + if (globalItem.Autoload(ref name)) { + AddGlobalItem(name, globalItem); + } + } + + + public ModItem GetItem(string name) { + if (items.ContainsKey(name)) { + return items[name]; + } + else { + return null; + } + } + + public int ItemType(string name) { + ModItem item = GetItem(name); + + if (item == null) { + return 0; + } + + return item.item.type; + } + + public GlobalItem GetGlobalItem(string name) { + if (globalItems.ContainsKey(name)) { + return globalItems[name]; + } + else { + return null; + } + } } } diff --git a/patches/Tea/Terraria/Tea/ModItem.cs b/patches/Tea/Terraria/Tea/ModItem.cs new file mode 100644 index 00000000000..287021eea49 --- /dev/null +++ b/patches/Tea/Terraria/Tea/ModItem.cs @@ -0,0 +1,121 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.IO; +using Terraria.DataStructures; + +namespace Terraria.Tea +{ + public class ModItem + { + public Item item { get; internal set; } + + public Mod mod { get; internal set; } + + internal string texture; + + public ModItem() { + item = new Item(); + item.modItem = this; + } + + public virtual bool Autoload(ref string name, ref string texture /*, TODO: IList equips*/) => true; + + // TODO: public virtual void AutoloadEquip(EquipType equip, ref string texture, ref string armTexture, ref string femaleTexture) { } + + public virtual DrawAnimation GetAnimation() => null; + + public virtual void SetDefaults() { } + + public virtual bool CanUseItem(Player player) => true; + + public virtual void UseStyle(Player player) { } + + public virtual void HoldStyle(Player player) { } + + public virtual void HoldItem(Player player) { } + + public virtual bool ConsumeAmmo(Player player) => true; + + public virtual bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) => true; + + public virtual void UseItemHitbox(Player player, ref Rectangle hitbox, ref bool noHitbox) { } + + public virtual void MeleeEffects(Player player, Rectangle hitbox) { } + + public virtual void ModifyHitNPC(Player player, NPC target, ref int damage, ref float knockBack, ref bool crit) { } + + public virtual void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit) { } + + public virtual void ModifyHitPvp(Player player, Player target, ref int damage, ref bool crit) { } + + public virtual void OnHitPvp(Player player, Player target, int damage, bool crit) { } + + public virtual bool UseItem(Player player) => false; + + public virtual bool ConsumeItem(Player player) => true; + + public virtual bool UseItemFrame(Player player) => false; + + public virtual bool HoldItemFrame(Player player) => false; + + public virtual void UpdateInventory(Player player) { } + + public virtual void UpdateEquip(Player player) { } + + public virtual void UpdateAccessory(Player player) { } + + public virtual bool IsArmorSet(Item head, Item body, Item legs) => false; + + public virtual void UpdateArmorSet(Player player) { } + + public virtual bool CanRightClick() => false; + + public virtual void RightClick(Player player) { } + + public virtual void DrawHair(ref bool drawHair, ref bool drawAltHair) { } + + public virtual bool DrawHead() => true; + + public virtual void VerticalWingSpeeds(ref float ascentWhenFalling, ref float ascentWhenRising, + ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) { } + + public virtual void HorizontalWingSpeeds(ref float speed, ref float acceleration) { } + + public virtual void Update(ref float gravity, ref float maxFallSpeed) { } + + public virtual Color? GetAlpha(Color lightColor) => null; + + public virtual bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale) => true; + + public virtual void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale) { } + + public virtual bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, + Color itemColor, Vector2 origin, float scale) => true; + + public virtual void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, + Color itemColor, Vector2 origin, float scale) { } + + public virtual bool CanEquipAccessory(Player player, int slot) => true; + + internal void SetupItem(Item item) { + SetupModItem(item); + // TODO: EquipLoader.SetSlot(item); + item.modItem.SetDefaults(); + } + + internal void SetupModItem(Item item) { + ModItem newItem = (ModItem)Activator.CreateInstance(GetType()); + newItem.item = item; + item.modItem = newItem; + newItem.mod = mod; + } + + public virtual void SaveCustomData(BinaryWriter writer) { } + + public virtual void LoadCustomData(BinaryReader reader) { } + + public virtual void AddRecipes() { } + } +} \ No newline at end of file diff --git a/patches/Tea/Terraria/Tea/ModRecipe.cs b/patches/Tea/Terraria/Tea/ModRecipe.cs new file mode 100644 index 00000000000..ab6e0630f62 --- /dev/null +++ b/patches/Tea/Terraria/Tea/ModRecipe.cs @@ -0,0 +1,79 @@ +namespace Terraria.Tea +{ + public class ModRecipe : Recipe + { + public readonly Mod mod; + private int numIngredients = 0; + private int numTiles = 0; + + public int RecipeIndex { + get; + private set; + } + + public ModRecipe(Mod mod) => this.mod = mod; + + public void SetResult(int itemID, int stack = 1) { + this.createItem.SetDefaults(itemID, false); + this.createItem.stack = stack; + } + + public void SetResult(Mod mod, string itemName, int stack = 1) { + if (mod == null) { + mod = this.mod; + } + + this.SetResult(mod.ItemType(itemName), stack); + } + + public void SetResult(ModItem item, int stack = 1) => this.SetResult(item.item.type, stack); + + public void AddIngredient(int itemID, int stack = 1) { + this.requiredItem[numIngredients].SetDefaults(itemID, false); + this.requiredItem[numIngredients].stack = stack; + numIngredients++; + } + + public void AddIngredient(Mod mod, string itemName, int stack = 1) { + if (mod == null) { + mod = this.mod; + } + + this.AddIngredient(mod.ItemType(itemName), stack); + } + + public void AddIngredient(ModItem item, int stack = 1) => this.AddIngredient(item.item.type, stack); + + public void AddTile(int tileID) { + this.requiredTile[numTiles] = tileID; + numTiles++; + } + + /*public void AddTile(Mod mod, string tileName) { + if (mod == null) { + mod = this.mod; + } + + this.AddTile(mod.TileType(tileName)); + } + + public void AddTile(ModTile tile) { + this.AddTile(tile.Type); + }*/ + + public virtual int ConsumeItem(int type, int numRequired) => numRequired; + + public void AddRecipe() { + for (int k = 0; k < Recipe.maxRequirements; k++) { + if (this.requiredTile[k] == 13) { + this.alchemy = true; + break; + } + } + Main.recipe[Recipe.numRecipes] = this; + this.RecipeIndex = Recipe.numRecipes; + mod.recipes.Add(this); + Recipe.numRecipes++; + } + } +} diff --git a/patches/Tea/Terraria/UI/ItemSlot.cs.patch b/patches/Tea/Terraria/UI/ItemSlot.cs.patch new file mode 100644 index 00000000000..47392867697 --- /dev/null +++ b/patches/Tea/Terraria/UI/ItemSlot.cs.patch @@ -0,0 +1,28 @@ +--- src/Terraria/Terraria/UI/ItemSlot.cs ++++ src/Tea/Terraria/UI/ItemSlot.cs +@@ -10,6 +_,7 @@ + using Terraria.GameInput; + using Terraria.ID; + using Terraria.Localization; ++using Terraria.Tea; + using Terraria.UI.Chat; + using Terraria.UI.Gamepad; + +@@ -1013,7 +_,7 @@ + Recipe.FindRecipes(); + } + } +- else if (Main.mouseRight && inv[slot].type > 0 && inv[slot].type < 5045 && ItemID.Sets.IsFishingCrate[inv[slot].type]) { ++ else if (Main.mouseRight && inv[slot].type > 0 && inv[slot].type < ItemLoader.Count && ItemID.Sets.IsFishingCrate[inv[slot].type]) { + if (Main.mouseRightRelease) { + player.OpenFishingCrate(inv[slot].type); + inv[slot].stack--; +@@ -2062,7 +_,7 @@ + } + + public static Color GetItemLight(ref Color currentColor, ref float scale, int type, bool outInTheWorld = false) { +- if (type < 0 || type > 5045) ++ if (type < 0 || type > ItemLoader.Count) + return currentColor; + + if (type == 662 || type == 663) { diff --git a/patches/Tea/Terraria/UI/ItemSorting.cs.patch b/patches/Tea/Terraria/UI/ItemSorting.cs.patch new file mode 100644 index 00000000000..8f3d6be09cd --- /dev/null +++ b/patches/Tea/Terraria/UI/ItemSorting.cs.patch @@ -0,0 +1,19 @@ +--- src/Terraria/Terraria/UI/ItemSorting.cs ++++ src/Tea/Terraria/UI/ItemSorting.cs +@@ -2,6 +_,7 @@ + using System.Collections.Generic; + using System.Linq; + using Terraria.ID; ++using Terraria.Tea; + + namespace Terraria.UI + { +@@ -809,7 +_,7 @@ + list.Add(ItemSortingLayers.LastTilesCommon); + list.Add(ItemSortingLayers.LastNotTrash); + list.Add(ItemSortingLayers.LastTrash); +- for (int i = -48; i < 5045; i++) { ++ for (int i = -48; i < ItemLoader.Count; i++) { + Item item = new Item(); + item.netDefaults(i); + list2.Add(item);