//Rartrin:
	//Player
		//Make sure "22" replaced with "MaxBuffs" in 'for' and CountBuffs() == and !=.
		//Ensure all blockLists are cleared everywhere that they need to be.

	//Need reimplementing:
		

	//TileLoader
		//Multiply item.axe by 1.2f before adding into the damage.

	//WorldGen
		//Add TileLoader.IsClosedDoor into WorldGen.IsLockedDoor check.

	//Needs checking:
		//WaterStyleLoader.WaterStyleCount
	
	//Main
		//Add IsAValidEquipmentSlotForIteration to VanillaUpdateAccessory check.

//Mirsario:
	//WorldGen:
		//Test drops.
		
		//Test modded grasses' behavior.
		
	//TileDrawing:
		//Reimplement cactus drawing. Search for modCactus in Main.cs 1.3.5.3 tML diffs.
		
		//Reimplement tree drawing. Search for modTree in Main.cs 1.3.5.3 tML diffs.
			
	//Item:
		//In Item.GetDrawHitbox, return the following size if it's not null.
			itemAnimations[item[i].type]?.GetFrame(itemTexture[item[i].type])
			
	//LegacySoundPlayer
		//Re-add clamps for volume and pitch, 0.0..1.0 and -1.0..1.0 respectively?
			
		//Put this in somewhere:
			if (waveBank == null) //Supress extra exceptions from the audio engine failing to load
				return null;
		
	//LegacyPlayerRenderer:
		//Reimplement ItemLoader.DrawHair hook.
		
		//Reimplement these calls from Main.DrawPlayer:
			ItemLoader.DrawHands(drawPlayer, ref flag, ref flag2);
			
			ItemLoader.DrawHair(drawPlayer, ref flag4, ref flag5);
			
			ItemLoader.DrawArmorColor(EquipType.Head, drawPlayer.head, drawPlayer, shadow, ref color11, ref num12, ref newColor);
			ItemLoader.DrawArmorColor(EquipType.Body, drawPlayer.body, drawPlayer, shadow, ref color12, ref num13, ref newColor2);
			ItemLoader.ArmorArmGlowMask(drawPlayer.body, drawPlayer, shadow, ref num14, ref newColor3);
			ItemLoader.DrawArmorColor(EquipType.Legs, drawPlayer.legs, drawPlayer, shadow, ref color14, ref num15, ref newColor4);
			
			ItemLoader.DrawHands(drawPlayer, ref flag, ref flag2);
			
			ProjectileLoader.DrawHeldProjInFrontOfHeldItemAndArms(projectile[drawPlayer.heldProj], ref flag3); //(multiple of these)
			
			ItemLoader.DrawBody(drawPlayer) // ('if' check)

// {
+						Vector2 holdoutOrigin = Vector2.Zero;
+						ItemLoader.HoldoutOrigin(drawPlayer, ref holdoutOrigin);
-						value = new DrawData(itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type], new Vector2((int)(value2.X - screenPosition.X + origin5.X + (float)num103), (int)(value2.Y - screenPosition.Y + (float)num104)), new Microsoft.Xna.Framework.Rectangle(0, 0, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Width, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Height), drawPlayer.inventory[drawPlayer.selectedItem].GetAlpha(currentColor), num102, origin5, drawPlayer.inventory[drawPlayer.selectedItem].scale, spriteEffects2, 0);
+						value = new DrawData(itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type], new Vector2((int)(value2.X - screenPosition.X + origin5.X + (float)num103), (int)(value2.Y - screenPosition.Y + (float)num104)), new Microsoft.Xna.Framework.Rectangle(0, 0, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Width, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Height), drawPlayer.inventory[drawPlayer.selectedItem].GetAlpha(currentColor), num102, origin5 + holdoutOrigin, drawPlayer.inventory[drawPlayer.selectedItem].scale, spriteEffects2, 0);
// }
		
	//Main:
		//Add this to the end of Initialize():
			#if SERVER
			this.OpenSettings();
			#endif
			
		//Put this somewhere it fits. Was in Main.LoadTextures():
			UICommon.LoadTextures();
		
		//Define and pass modMusic and modPriority to UpdateAudio_DecideOnTOWMusic and UpdateAudio_DecideOnNewMusic methods...
			int modMusic = -1;
			MusicPriority modPriority = MusicPriority.None;
			
		//...And put this after the calls.
			ModHooks.UpdateMusic(ref modMusic, ref modPriority);
			
		//Redo all the checks like that in both UpdateAudio_DecideOnTOWMusic and UpdateAudio_DecideOnNewMusic:
			if (modPriority >= MusicPriority.Event) {
				newMusic = modMusic;
			}
			
		//Put this somewhere high in DoUpdateInWorld:
			if (netMode == 1 && Netplay.syncingWorld) // skip updating entities while world is loading in multiplayer #340
				goto skipEntityUpdates;
				
		//In DrawWaters, replace '13' in for check with
			WaterStyleLoader.WaterStyleCount'
			
		//Add this to the middle of DrawBG() after definition of the used variable.
			SurfaceBgStyleLoader.ChooseStyle(ref preferredBGStyleForPlayer);
			
		//Add this to the end of DrawSurfaceBG_BackMountainsStep2:
			SurfaceBgStyleLoader.DrawMiddleTexture();
			
		//Add this near the end of DrawSurfaceBG(), after SkyManager.Instance.DrawToDepth(spriteBatch, 1f); call:
			FinishDrawCloseBackground:
			SurfaceBgStyleLoader.DrawCloseBackground(num21);
		//...Then make sure that all returns/continues before it are replaced with gotos to that statement.
			
		//Find where the logo is rendered, and lower the position a bit.
			
		//If still needed - replace Utils.WordwrapString call in Main.TextDisplayCache.PrepareCache with Utils.WordwrapStringSmart.
		//Use old diffs in Main.GUIChatDrawInner
			
		//Reimplement the entire ModifyTooltips hook call with all the tooltipNames filling, based on diffs of 1.3.5.3. See MouseText_DrawItemTooltip.
		
		//Reimplement PreDrawExtras and PostDraw:
		//In DrawProj, jump over drawing of all extras with a goto:
			if (!ProjectileLoader.PreDrawExtras(projectile, spriteBatch)) {
				goto DrawExtrasEnd;
			}
			
			ProjectileLoader.PostDraw(projectile, spriteBatch, color25);
			
		//Projectile drawing hooks need more thought because of early returns
			
		//Reimplement broken patches:
// {
if (nPC.aiStyle == 7)
	DrawNPCExtras(n3, beforeDraw: false, num65, num64, color9, vector10, spriteEffects);

+NPCLoader.PostDraw(npc[iNPCIndex], spriteBatch, color9);
// }

// {
@@ -6674,41 +5292,48 @@
 			}
 
 			if (autoJoin) {
+				ModLoader.ModLoader.OnSuccessfulLoad += () => {
-				LoadPlayers();
+					LoadPlayers();
-				menuMode = 1;
+					menuMode = 1;
-				menuMultiplayer = true;
+					menuMultiplayer = true;
+				};
 			}
 
 			fpsTimer.Start();
 		}
 
 		protected override void LoadContent() {
+			HiDefGraphicsIssues.OnLoadContent();
 			Configuration.Load();
+			ModLoader.ModLoader.MigrateSettings();
 			Configuration.Get("UseExperimentalFeatures", ref UseExperimentalFeatures);
 			if (UseExperimentalFeatures)
 				TexturePackSupport.Enabled = true;
 
 			Configuration.Get("Support4K", ref Support4K);
 			bool flag = Support4K && base.GraphicsDevice.Adapter.IsProfileSupported(GraphicsProfile.HiDef);
-			if (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width <= 1920 && GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height <= 1200)
-				flag = false;
-
+			// (resolution check removed) tModLoader will attempt to use HiDef even if the computer resolution doesn't need it to support newer shaders.
 			if (Support4K && flag)
-				SetGraphicsProfile(GraphicsProfile.HiDef);
+				if (SetGraphicsProfile(GraphicsProfile.HiDef))
+					return; // changing the graphics profile triggers a device recreation and XNA will call `LoadContent` again
 
-			TexturePackSupport.FindTexturePack();
+			TexturePackSupport.FindTexturePacks();
 			TextureManager.Initialize();
 			mapSectionTexture = new RenderTarget2D(base.GraphicsDevice, 200, 150);
-			ShaderContentManager = new ContentManager(base.Content.ServiceProvider, base.Content.RootDirectory);
+			ShaderContentManager = new TMLContentManager(base.Content.ServiceProvider, base.Content.RootDirectory, AlternateContentManager);
 			PixelShaderRef.Value = ShaderContentManager.Load<Effect>("PixelShader");
 			TileShaderRef.Value = ShaderContentManager.Load<Effect>("TileShader");
 			ScreenShaderRef.Value = ShaderContentManager.Load<Effect>("ScreenShader");
// }

// {
@@ -16295,7 +16647,9 @@
 				}
 
 				try {
+					Texture2D modTopTextures;
 					if (type4 == 5 && frameY >= 198 && frameX >= 22) {
+						//frame
 						int num316 = 0;
 						switch (frameX) {
 							case 22: {
// }

// {
@@ -16309,11 +16663,22 @@
 									}
 
 									int num320 = 0;
+									//frame width
 									int num321 = 80;
+									//frame height
 									int num322 = 80;
+									//x offset left
 									int num323 = 32;
+									//y offset
 									int num324 = 0;
+									modTopTextures = null;
 									for (int num325 = num301; num325 < num301 + 100; num325++) {
+										modTopTextures = TileLoader.GetTreeTopTextures(tile[num300, num325].type,
+											num300, num325, ref num316, ref num321, ref num322, ref num323, ref num324);
+
+										if (modTopTextures != null)
+											break;
+
 										if (Main.tile[num300, num325].type == 2) {
 											num320 = GetTreeStyle(num300);
 											break;
// }

// {
@@ -16152,6 +16503,7 @@
 						int num298 = 0;
 						spriteBatch.Draw(texture2D2, new Vector2((float)(j * 16 - (int)screenPosition.X) - ((float)num9 - 16f) / 2f + (float)num297, i * 16 - (int)screenPosition.Y + num12 + num298) + value, empty, color6, 0f, default(Vector2), 1f, effects, 0f);
 					}
+					TileLoader.PostDraw(j, i, type, spriteBatch);
 				}
 			}
// }

// {
 @@ -16380,10 +16745,12 @@
 										Lighting.AddLight(num300, num301, 0.1f, 0.2f + num326 / 2f, 0.7f + num326);
 									}
 
-									if (tile6.color() > 0)
+									if (modTopTextures == null && tile6.color() > 0)
 										checkTreeAlt[num320, tile6.color()] = true;
 
+									if (modTopTextures != null)
+										spriteBatch.Draw(modTopTextures, new Vector2(num300 * 16 - (int)screenPosition.X - num323, num301 * 16 - (int)screenPosition.Y - num322 + 16 + num324) + value, new Microsoft.Xna.Framework.Rectangle(num316 * (num321 + 2), 0, num321, num322), Lighting.GetColor(num300, num301), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
-									if (tile6.color() > 0 && treeAltTextureDrawn[num320, tile6.color()])
+									else if (tile6.color() > 0 && treeAltTextureDrawn[num320, tile6.color()])
 										spriteBatch.Draw(treeTopAltTexture[num320, tile6.color()], new Vector2(num300 * 16 - (int)screenPosition.X - num323, num301 * 16 - (int)screenPosition.Y - num322 + 16 + num324) + value, new Microsoft.Xna.Framework.Rectangle(num316 * (num321 + 2), 0, num321, num322), Lighting.GetColor(num300, num301), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
 									else
 										spriteBatch.Draw(treeTopTexture[num320], new Vector2(num300 * 16 - (int)screenPosition.X - num323, num301 * 16 - (int)screenPosition.Y - num322 + 16 + num324) + value, new Microsoft.Xna.Framework.Rectangle(num316 * (num321 + 2), 0, num321, num322), Lighting.GetColor(num300, num301), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
// }

// {
@@ -16401,7 +16768,13 @@
 									}
 
 									int num327 = 0;
+									Texture2D modBranchTextures = null;
 									for (int num328 = num301; num328 < num301 + 100; num328++) {
+										modBranchTextures = TileLoader.GetTreeBranchTextures(tile[num300 + 1, num328].type, num300, num328, 1, ref num316);
+
+										if (modBranchTextures != null)
+											break;
+
 										if (Main.tile[num300 + 1, num328].type == 2) {
 											num327 = GetTreeStyle(num300 + 1);
 											break;
// }

// {
@@ -16455,10 +16828,12 @@
 										Lighting.AddLight(num300, num301, 0.1f, 0.2f + num329 / 2f, 0.7f + num329);
 									}
 
-									if (tile6.color() > 0)
+									if (modBranchTextures == null && tile6.color() > 0)
 										checkTreeAlt[num327, tile6.color()] = true;
 
+									if (modBranchTextures != null)
+										spriteBatch.Draw(modBranchTextures, new Vector2(num300 * 16 - (int)screenPosition.X - 24, num301 * 16 - (int)screenPosition.Y - 12) + value, new Microsoft.Xna.Framework.Rectangle(0, num316 * 42, 40, 40), Lighting.GetColor(num300, num301), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
-									if (tile6.color() > 0 && treeAltTextureDrawn[num327, tile6.color()])
+									else if (tile6.color() > 0 && treeAltTextureDrawn[num327, tile6.color()])
 										spriteBatch.Draw(treeBranchAltTexture[num327, tile6.color()], new Vector2(num300 * 16 - (int)screenPosition.X - 24, num301 * 16 - (int)screenPosition.Y - 12) + value, new Microsoft.Xna.Framework.Rectangle(0, num316 * 42, 40, 40), Lighting.GetColor(num300, num301), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
 									else
 										spriteBatch.Draw(treeBranchTexture[num327], new Vector2(num300 * 16 - (int)screenPosition.X - 24, num301 * 16 - (int)screenPosition.Y - 12) + value, new Microsoft.Xna.Framework.Rectangle(0, num316 * 42, 40, 40), Lighting.GetColor(num300, num301), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
// }

// {
@@ -16476,7 +16851,13 @@
 									}
 
 									int num317 = 0;
+									Texture2D modBranchTextures = null;
 									for (int num318 = num301; num318 < num301 + 100; num318++) {
+										modBranchTextures = TileLoader.GetTreeBranchTextures(tile[num300 - 1, num318].type, num300, num318, -1, ref num316);
+
+										if (modBranchTextures != null)
+											break;
+
 										if (Main.tile[num300 - 1, num318].type == 2) {
 											num317 = GetTreeStyle(num300 - 1);
 											break;
// }

// {
@@ -16530,10 +16911,12 @@
 										Lighting.AddLight(num300, num301, 0.1f, 0.2f + num319 / 2f, 0.7f + num319);
 									}
 
-									if (tile6.color() > 0)
+									if (modBranchTextures == null && tile6.color() > 0)
 										checkTreeAlt[num317, tile6.color()] = true;
 
+									if (modBranchTextures != null)
+										spriteBatch.Draw(modBranchTextures, new Vector2(num300 * 16 - (int)screenPosition.X, num301 * 16 - (int)screenPosition.Y - 12) + value, new Microsoft.Xna.Framework.Rectangle(42, num316 * 42, 40, 40), Lighting.GetColor(num300, num301), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
-									if (tile6.color() > 0 && treeAltTextureDrawn[num317, tile6.color()])
+									else if (tile6.color() > 0 && treeAltTextureDrawn[num317, tile6.color()])
 										spriteBatch.Draw(treeBranchAltTexture[num317, tile6.color()], new Vector2(num300 * 16 - (int)screenPosition.X, num301 * 16 - (int)screenPosition.Y - 12) + value, new Microsoft.Xna.Framework.Rectangle(42, num316 * 42, 40, 40), Lighting.GetColor(num300, num301), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
 									else
 										spriteBatch.Draw(treeBranchTexture[num317], new Vector2(num300 * 16 - (int)screenPosition.X, num301 * 16 - (int)screenPosition.Y - 12) + value, new Microsoft.Xna.Framework.Rectangle(42, num316 * 42, 40, 40), Lighting.GetColor(num300, num301), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
// }

// {
@@ -16544,7 +16927,7 @@
 					}
 
 					if (type4 != 323 || frameX < 88 || frameX > 132)
-						continue;
+						goto SpecialDraw;
 
 					int num330 = 0;
 					switch (frameX) {
// }

// {
@@ -16562,7 +16945,12 @@
 					int num334 = 80;
 					int num335 = 32;
 					int num336 = 0;
+					modTopTextures = null;
 					for (int num337 = num301; num337 < num301 + 100; num337++) {
+						modTopTextures = TileLoader.GetPalmTreeTopTextures(tile[num300, num337].type);
+						if (modTopTextures != null)
+							break;
+
 						if (Main.tile[num300, num337].type == 53) {
 							num332 = 0;
 							break;
// }

// {
@@ -16586,16 +16974,22 @@
 
 					int frameY3 = Main.tile[num300, num301].frameY;
 					int y3 = num332 * 82;
-					if (tile6.color() > 0)
+					if (modTopTextures == null && tile6.color() > 0)
 						checkTreeAlt[num331, tile6.color()] = true;
 
+					if (modTopTextures != null)
+						spriteBatch.Draw(modTopTextures, new Vector2(num300 * 16 - (int)screenPosition.X - num335 + frameY3, num301 * 16 - (int)screenPosition.Y - num334 + 16 + num336) + value, new Microsoft.Xna.Framework.Rectangle(num330 * (num333 + 2), y3, num333, num334), Lighting.GetColor(num300, num301), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
-					if (tile6.color() > 0 && treeAltTextureDrawn[num331, tile6.color()])
+					else if (tile6.color() > 0 && treeAltTextureDrawn[num331, tile6.color()])
 						spriteBatch.Draw(treeTopAltTexture[num331, tile6.color()], new Vector2(num300 * 16 - (int)screenPosition.X - num335 + frameY3, num301 * 16 - (int)screenPosition.Y - num334 + 16 + num336) + value, new Microsoft.Xna.Framework.Rectangle(num330 * (num333 + 2), y3, num333, num334), Lighting.GetColor(num300, num301), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
 					else
 						spriteBatch.Draw(treeTopTexture[num331], new Vector2(num300 * 16 - (int)screenPosition.X - num335 + frameY3, num301 * 16 - (int)screenPosition.Y - num334 + 16 + num336) + value, new Microsoft.Xna.Framework.Rectangle(num330 * (num333 + 2), y3, num333, num334), Lighting.GetColor(num300, num301), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
 				}
 				catch {
 				}
+
+				SpecialDraw:
+
+				TileLoader.SpecialDraw(type4, num300, num301, spriteBatch);
 			}
 
 			if (TileObject.objectPreview.Active && player[myPlayer].showItemIcon && placementPreview && !CaptureManager.Instance.Active) {
// }

// {
@@ -12580,18 +12880,30 @@
 					else if (array2[l]) {
 						black = (array3[l] ? new Microsoft.Xna.Framework.Color((byte)(190f * num18), (byte)(120f * num18), (byte)(120f * num18), a) : new Microsoft.Xna.Framework.Color((byte)(120f * num18), (byte)(190f * num18), (byte)(120f * num18), a));
 					}
-					else if (l == currentLine - 1) {
+					else if (drawableLines[l].mod.Equals("Terraria") && drawableLines[l].Name.Equals("Price")) {
 						black = color;
 					}
 
-					ChatManager.DrawColorCodedStringWithShadow(spriteBatch, fontMouseText, array[l], new Vector2(X, Y + num25), black, 0f, Vector2.Zero, Vector2.One);
+					drawableLines[l].color = black;
+					drawColor = black;
+					if (overrideColor[l].HasValue) {
+						drawColor = overrideColor[l].Value * num18;
+						drawableLines[l].overrideColor = drawColor;
+					}
+
+					if (ItemLoader.PreDrawTooltipLine(HoverItem, drawableLines[l], ref yOffset) && globalCanDraw)
+						ChatManager.DrawColorCodedStringWithShadow(spriteBatch, drawableLines[l].font, drawableLines[l].text, new Vector2((float)drawableLines[l].X, (float)drawableLines[l].Y), drawColor, drawableLines[l].rotation, drawableLines[l].origin, drawableLines[l].baseScale, drawableLines[l].maxWidth, drawableLines[l].spread);
+
+					ItemLoader.PostDrawTooltipLine(HoverItem, drawableLines[l]);
 				}
 
-				num25 += (int)(fontMouseText.MeasureString(array[l]).Y + (float)num24);
+				Y += (int)(fontMouseText.MeasureString(array[l]).Y + yOffset);
 			}
+
+			ItemLoader.PostDrawTooltip(HoverItem, drawableLines.AsReadOnly());
 		}
 
-		private void MouseText_DrawBuffString(ref int X, ref int Y) {
+		private void MouseText_DrawBuffString(ref int X, ref int Y, int buffNameHeight) {
 			Microsoft.Xna.Framework.Point p = new Microsoft.Xna.Framework.Point(X, Y);
 			int num = 220;
 			int num2 = -1;