Decompiled source of MineCompany v0.5.0

plugins/MineCompany/nazarii.MineCompany.dll

Decompiled 11 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using MineCompany.Armor;
using MineCompany.Effects;
using MineCompany.Items;
using MineCompany.Mobs;
using MineCompany.World;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Audio;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.UI;
using nazarii.MineCompany.NetcodePatcher;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("nazarii.MineCompany")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.5.0.0")]
[assembly: AssemblyInformationalVersion("0.5.0+1366e67834ade7af5ee785d25fc0842166ef3d02")]
[assembly: AssemblyProduct("MineCompany")]
[assembly: AssemblyTitle("nazarii.MineCompany")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.5.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MineCompany
{
	internal static class Combat
	{
		internal const int HitMask = 1084754248;

		private static readonly Dictionary<EnemyAI, float> Carry = new Dictionary<EnemyAI, float>();

		internal static bool IsUndead(EnemyAI e)
		{
			return NameMatches(e, McConfig.UndeadEnemies.Value);
		}

		internal static bool IsArthropod(EnemyAI e)
		{
			return NameMatches(e, McConfig.ArthropodEnemies.Value);
		}

		private static bool NameMatches(EnemyAI e, string list)
		{
			string name = e.enemyType?.enemyName?.ToLowerInvariant() ?? "";
			return (from s in list.Split(',')
				select s.Trim().ToLowerInvariant()).Any((string s) => s.Length > 0 && name.Contains(s));
		}

		internal static float EnchantBonus(EnchSet ench, EnemyAI? enemy)
		{
			float num = 0f;
			int num2 = ench.Level(Ench.Sharpness);
			if (num2 > 0)
			{
				num += 0.5f * (float)num2 + 0.5f;
			}
			if ((Object)(object)enemy != (Object)null)
			{
				int num3 = ench.Level(Ench.Smite);
				if (num3 > 0 && IsUndead(enemy))
				{
					num += 2.5f * (float)num3;
				}
				int num4 = ench.Level(Ench.BaneOfArthropods);
				if (num4 > 0 && IsArthropod(enemy))
				{
					num += 2.5f * (float)num4;
				}
			}
			return num;
		}

		internal static int HitEnemy(EnemyAICollisionDetect target, float mcDamage, Vector3 dir, PlayerControllerB attacker, bool playSfx = true, bool projectile = false, bool magic = false)
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			EnemyAI mainScript = target.mainScript;
			if ((Object)(object)mainScript == (Object)null || mainScript.isEnemyDead)
			{
				return 0;
			}
			if (mainScript is McMob mcMob)
			{
				mcMob.HitMc(mcDamage, dir, attacker, projectile, magic);
				return Mathf.CeilToInt(mcDamage / Mathf.Max(0.01f, McConfig.McDamagePerEnemyHp.Value));
			}
			Carry.TryGetValue(mainScript, out var value);
			float num = value + mcDamage / Mathf.Max(0.01f, McConfig.McDamagePerEnemyHp.Value);
			int num2 = Mathf.FloorToInt(num + 0.0001f);
			Carry[mainScript] = num - (float)num2;
			((IHittable)target).Hit(num2, dir, attacker, playSfx, 1);
			if (Carry.Count > 64)
			{
				foreach (EnemyAI item in Carry.Keys.Where((EnemyAI k) => (Object)(object)k == (Object)null || k.isEnemyDead).ToList())
				{
					Carry.Remove(item);
				}
			}
			return num2;
		}

		internal static void HitPlayer(PlayerControllerB victim, float mcDamage, Vector3 dir, PlayerControllerB attacker)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)victim == (Object)(object)attacker) && !victim.isPlayerDead && McConfig.FriendlyFire.Value)
			{
				int num = Mathf.Max(1, Mathf.RoundToInt(mcDamage * McConfig.PlayerHpPerMcDamage.Value));
				victim.DamagePlayerFromOtherClientServerRpc(num, dir, (int)attacker.playerClientId);
			}
		}

		internal static IEnumerator PushEnemy(EnemyAI enemy, Vector3 push)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			float t = 0f;
			push.y = 0f;
			if (enemy is McMob mcMob)
			{
				push *= 1f - Mathf.Clamp01(mcMob.Def.KnockbackResistance);
			}
			while (t < 0.25f && (Object)(object)enemy != (Object)null && !enemy.isEnemyDead && (Object)(object)enemy.agent != (Object)null && enemy.agent.isOnNavMesh)
			{
				enemy.agent.Move(push * (Time.deltaTime / 0.25f));
				t += Time.deltaTime;
				yield return null;
			}
		}

		internal static IEnumerator Burn(EnemyAICollisionDetect target, float seconds, PlayerControllerB attacker)
		{
			float end = Time.time + seconds;
			while (Time.time < end && (Object)(object)target != (Object)null && (Object)(object)target.mainScript != (Object)null && !target.mainScript.isEnemyDead)
			{
				yield return (object)new WaitForSeconds(1f);
				HitEnemy(target, 1f, Vector3.up, attacker, playSfx: false);
			}
		}

		internal static bool IsCritical(PlayerControllerB p)
		{
			if (!p.thisController.isGrounded && p.fallValue < -0.5f && !p.isClimbingLadder)
			{
				return !p.isUnderwater;
			}
			return false;
		}

		internal static float BlocksToUnits(float blocks)
		{
			return blocks * McConfig.BlockSize.Value;
		}

		internal static bool IsFinite(Vector3 v)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (!float.IsNaN(v.x) && !float.IsNaN(v.y) && !float.IsNaN(v.z) && !float.IsInfinity(v.x) && !float.IsInfinity(v.y))
			{
				return !float.IsInfinity(v.z);
			}
			return false;
		}
	}
	internal enum Ench
	{
		Sharpness,
		Smite,
		BaneOfArthropods,
		Knockback,
		FireAspect,
		SweepingEdge,
		Efficiency,
		Fortune,
		SilkTouch,
		Power,
		Punch,
		Flame,
		Infinity,
		QuickCharge,
		Multishot,
		Piercing,
		Unbreaking,
		Protection,
		FireProtection,
		BlastProtection,
		ProjectileProtection,
		FeatherFalling
	}
	internal readonly struct EnchSet
	{
		private readonly int _packed;

		private readonly McKind _kind;

		internal int Packed => _packed;

		internal bool Any => _packed != 0;

		internal EnchSet(McKind kind, int packed)
		{
			_kind = kind;
			_packed = packed;
		}

		internal int Level(Ench e)
		{
			int num = 0;
			(Ench, int)[] array = Enchantments.Slots(_kind);
			for (int i = 0; i < array.Length; i++)
			{
				(Ench, int) tuple = array[i];
				Ench item = tuple.Item1;
				int item2 = tuple.Item2;
				int num2 = Enchantments.Bits(item2);
				if (item == e)
				{
					return (_packed >> num) & ((1 << num2) - 1);
				}
				num += num2;
			}
			return 0;
		}

		internal static EnchSet From(McKind kind, IDictionary<Ench, int> levels)
		{
			int num = 0;
			int num2 = 0;
			(Ench, int)[] array = Enchantments.Slots(kind);
			for (int i = 0; i < array.Length; i++)
			{
				(Ench, int) tuple = array[i];
				Ench item = tuple.Item1;
				int item2 = tuple.Item2;
				int num3 = Enchantments.Bits(item2);
				if (levels.TryGetValue(item, out var value))
				{
					num |= Math.Min(value, item2) << num2;
				}
				num2 += num3;
			}
			return new EnchSet(kind, num);
		}

		internal IEnumerable<(Ench ench, int level)> All()
		{
			EnchSet self = this;
			return (from s in Enchantments.Slots(_kind)
				select (ench: s.ench, self.Level(s.ench)) into x
				where x.Item2 > 0
				select x).ToList();
		}

		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			foreach (var (e, level) in All())
			{
				if (stringBuilder.Length > 0)
				{
					stringBuilder.Append(", ");
				}
				stringBuilder.Append(Enchantments.Display(e, level));
			}
			return stringBuilder.ToString();
		}
	}
	internal static class Enchantments
	{
		private static readonly (Ench ench, int max)[] Melee = new(Ench, int)[7]
		{
			(Ench.Sharpness, 5),
			(Ench.Smite, 5),
			(Ench.BaneOfArthropods, 5),
			(Ench.Knockback, 2),
			(Ench.FireAspect, 2),
			(Ench.SweepingEdge, 3),
			(Ench.Unbreaking, 3)
		};

		private static readonly (Ench ench, int max)[] Axe = new(Ench, int)[5]
		{
			(Ench.Sharpness, 5),
			(Ench.Smite, 5),
			(Ench.BaneOfArthropods, 5),
			(Ench.Efficiency, 5),
			(Ench.Unbreaking, 3)
		};

		private static readonly (Ench ench, int max)[] Pickaxe = new(Ench, int)[4]
		{
			(Ench.Efficiency, 5),
			(Ench.Fortune, 3),
			(Ench.SilkTouch, 1),
			(Ench.Unbreaking, 3)
		};

		private static readonly (Ench ench, int max)[] Bow = new(Ench, int)[5]
		{
			(Ench.Power, 5),
			(Ench.Punch, 2),
			(Ench.Flame, 1),
			(Ench.Infinity, 1),
			(Ench.Unbreaking, 3)
		};

		private static readonly (Ench ench, int max)[] Crossbow = new(Ench, int)[4]
		{
			(Ench.QuickCharge, 3),
			(Ench.Multishot, 1),
			(Ench.Piercing, 4),
			(Ench.Unbreaking, 3)
		};

		private static readonly (Ench ench, int max)[] Armor = new(Ench, int)[5]
		{
			(Ench.Protection, 4),
			(Ench.FireProtection, 4),
			(Ench.BlastProtection, 4),
			(Ench.ProjectileProtection, 4),
			(Ench.Unbreaking, 3)
		};

		private static readonly (Ench ench, int max)[] Boots = new(Ench, int)[6]
		{
			(Ench.Protection, 4),
			(Ench.FireProtection, 4),
			(Ench.BlastProtection, 4),
			(Ench.ProjectileProtection, 4),
			(Ench.FeatherFalling, 4),
			(Ench.Unbreaking, 3)
		};

		private static readonly (Ench ench, int max)[] None = Array.Empty<(Ench, int)>();

		private static readonly Ench[][] Exclusive = new Ench[4][]
		{
			new Ench[3]
			{
				Ench.Sharpness,
				Ench.Smite,
				Ench.BaneOfArthropods
			},
			new Ench[2]
			{
				Ench.Fortune,
				Ench.SilkTouch
			},
			new Ench[2]
			{
				Ench.Multishot,
				Ench.Piercing
			},
			new Ench[4]
			{
				Ench.Protection,
				Ench.FireProtection,
				Ench.BlastProtection,
				Ench.ProjectileProtection
			}
		};

		internal static (Ench ench, int max)[] Slots(McKind kind)
		{
			switch (kind)
			{
			case McKind.Sword:
				return Melee;
			case McKind.Axe:
				return Axe;
			case McKind.Pickaxe:
				return Pickaxe;
			case McKind.Bow:
				return Bow;
			case McKind.Crossbow:
				return Crossbow;
			case McKind.Helmet:
			case McKind.Chestplate:
			case McKind.Leggings:
				return Armor;
			case McKind.Boots:
				return Boots;
			default:
				return None;
			}
		}

		internal static int Bits(int max)
		{
			if (max > 1)
			{
				if (max > 3)
				{
					return 3;
				}
				return 2;
			}
			return 1;
		}

		internal static int TotalBits(McKind kind)
		{
			return Slots(kind).Sum(((Ench ench, int max) s) => Bits(s.max));
		}

		internal static string Display(Ench e, int level)
		{
			string text = e switch
			{
				Ench.BaneOfArthropods => "Bane of Arthropods", 
				Ench.FireAspect => "Fire Aspect", 
				Ench.SweepingEdge => "Sweeping Edge", 
				Ench.SilkTouch => "Silk Touch", 
				Ench.QuickCharge => "Quick Charge", 
				Ench.FireProtection => "Fire Protection", 
				Ench.BlastProtection => "Blast Protection", 
				Ench.ProjectileProtection => "Projectile Protection", 
				Ench.FeatherFalling => "Feather Falling", 
				_ => e.ToString(), 
			};
			int num = (from s in Slots(McKind.Sword).Concat(Bow).Concat(Crossbow).Concat(Pickaxe)
					.Concat(Axe)
					.Concat(Boots)
				where s.ench == e
				select s.max).DefaultIfEmpty(1).Max();
			if (num != 1)
			{
				return text + " " + Roman(level);
			}
			return text;
		}

		private static string Roman(int n)
		{
			return n switch
			{
				1 => "I", 
				2 => "II", 
				3 => "III", 
				4 => "IV", 
				5 => "V", 
				_ => n.ToString(), 
			};
		}

		internal static EnchSet Roll(McKind kind, McTier tier, Random rng)
		{
			(Ench, int)[] array = Slots(kind);
			if (array.Length == 0)
			{
				return new EnchSet(kind, 0);
			}
			Dictionary<Ench, int> levels = new Dictionary<Ench, int>();
			double num = rng.NextDouble();
			int num2 = ((num < 0.6) ? 1 : ((num < 0.9) ? 2 : 3));
			double num3;
			switch (tier)
			{
			case McTier.Gold:
				num3 = 1.0;
				break;
			case McTier.Wood:
				num3 = 0.75;
				break;
			case McTier.Diamond:
			case McTier.Netherite:
				num3 = 0.65;
				break;
			default:
				num3 = 0.55;
				break;
			}
			double num4 = num3;
			for (int i = 0; i < num2; i++)
			{
				(Ench, int)[] array2 = array.Where(((Ench ench, int max) s) => !levels.ContainsKey(s.ench) && !Exclusive.Any((Ench[] g) => g.Contains(s.ench) && g.Any(levels.ContainsKey))).ToArray();
				if (array2.Length == 0)
				{
					break;
				}
				(Ench, int) tuple = array2[rng.Next(array2.Length)];
				Ench item = tuple.Item1;
				int item2 = tuple.Item2;
				double num5 = Math.Pow(rng.NextDouble(), 1.6 - num4);
				levels[item] = Math.Max(1, Math.Min(item2, 1 + (int)(num5 * (double)item2)));
			}
			return EnchSet.From(kind, levels);
		}
	}
	internal static class McAssets
	{
		internal static string Root = "";

		private static readonly Dictionary<string, Texture2D?> Textures = new Dictionary<string, Texture2D>();

		private static readonly Dictionary<string, Sprite?> Sprites = new Dictionary<string, Sprite>();

		private static readonly Dictionary<string, AudioClip?> Clips = new Dictionary<string, AudioClip>();

		private static readonly Dictionary<string, AudioClip[]> ClipGroups = new Dictionary<string, AudioClip[]>();

		internal static void Init(string pluginDir)
		{
			Root = Path.Combine(pluginDir, "assets");
			if (!Directory.Exists(Root))
			{
				MineCompany.Logger.LogError((object)("Minecraft assets folder is missing: " + Root));
			}
		}

		internal static Texture2D? Texture(string key)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			if (Textures.TryGetValue(key, out Texture2D value))
			{
				return value;
			}
			Texture2D val = null;
			string text = Path.Combine(Root, "textures", key + ".png");
			if (key.StartsWith("gen/"))
			{
				val = Generate(key);
			}
			else if (File.Exists(text))
			{
				val = new Texture2D(2, 2, (TextureFormat)4, false);
				ImageConversion.LoadImage(val, File.ReadAllBytes(text));
				((Texture)val).filterMode = (FilterMode)0;
				((Texture)val).wrapMode = (TextureWrapMode)1;
				((Object)val).name = "mc_" + key.Replace('/', '_');
			}
			else
			{
				MineCompany.Logger.LogWarning((object)("Missing texture " + text));
			}
			Textures[key] = val;
			return val;
		}

		private static Texture2D? Generate(string key)
		{
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Expected O, but got Unknown
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			if (key.StartsWith("gen/face/"))
			{
				return Face(key.Substring("gen/face/".Length), key);
			}
			if (key == "gen/ominous_banner")
			{
				return OminousBanner(key);
			}
			if (key.StartsWith("gen/frame/"))
			{
				return Frame(key);
			}
			string[] array = key.Split('/');
			Color val = default(Color);
			if (array.Length != 3 || !ColorUtility.TryParseHtmlString("#" + array[2], ref val))
			{
				return null;
			}
			Texture2D val2 = Texture("item/" + array[1]);
			Texture2D val3 = Texture("item/potion_overlay");
			if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || ((Texture)val2).width != ((Texture)val3).width || ((Texture)val2).height != ((Texture)val3).height)
			{
				return val2;
			}
			Color[] pixels = val2.GetPixels();
			Color[] pixels2 = val3.GetPixels();
			Color[] array2 = (Color[])(object)new Color[pixels.Length];
			Color val4 = default(Color);
			for (int i = 0; i < array2.Length; i++)
			{
				((Color)(ref val4))..ctor(pixels2[i].r * val.r, pixels2[i].g * val.g, pixels2[i].b * val.b, pixels2[i].a);
				float num = pixels[i].a + val4.a * (1f - pixels[i].a);
				array2[i] = (Color)((num <= 0f) ? Color.clear : new Color((pixels[i].r * pixels[i].a + val4.r * val4.a * (1f - pixels[i].a)) / num, (pixels[i].g * pixels[i].a + val4.g * val4.a * (1f - pixels[i].a)) / num, (pixels[i].b * pixels[i].a + val4.b * val4.a * (1f - pixels[i].a)) / num, num));
			}
			Texture2D val5 = new Texture2D(((Texture)val2).width, ((Texture)val2).height, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0,
				wrapMode = (TextureWrapMode)1,
				name = "mc_" + key.Replace('/', '_')
			};
			val5.SetPixels(array2);
			val5.Apply();
			return val5;
		}

		private static Texture2D? Face(string entityTexture, string key)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = Texture(entityTexture);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			int num = ((Texture)val).width / 64;
			Texture2D val2 = new Texture2D(16, 16, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0,
				wrapMode = (TextureWrapMode)1,
				name = "mc_" + key.Replace('/', '_')
			};
			for (int i = 0; i < 16; i++)
			{
				for (int j = 0; j < 16; j++)
				{
					int num2 = (8 + j / 2) * num;
					int num3 = ((Texture)val).height - 1 - (8 + (15 - i) / 2) * num;
					val2.SetPixel(j, i, val.GetPixel(num2, num3));
				}
			}
			val2.Apply();
			return val2;
		}

		private static Texture2D? OminousBanner(string key)
		{
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Expected O, but got Unknown
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = Texture("entity/banner_base");
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Color[] pixels = val.GetPixels();
			(string, int)[] array = new(string, int)[9]
			{
				("base", 16383998),
				("rhombus", 1481884),
				("stripe_bottom", 10329495),
				("stripe_center", 4673362),
				("border", 10329495),
				("stripe_middle", 1908001),
				("half_horizontal", 10329495),
				("circle", 10329495),
				("border", 1908001)
			};
			(string, int)[] array2 = array;
			Color val3 = default(Color);
			Color val4 = default(Color);
			for (int i = 0; i < array2.Length; i++)
			{
				(string, int) tuple = array2[i];
				string item = tuple.Item1;
				int item2 = tuple.Item2;
				Texture2D val2 = Texture("entity/banner/" + item);
				if ((Object)(object)val2 == (Object)null || ((Texture)val2).width != ((Texture)val).width || ((Texture)val2).height != ((Texture)val).height)
				{
					continue;
				}
				Color[] pixels2 = val2.GetPixels();
				((Color)(ref val3))..ctor((float)((item2 >> 16) & 0xFF) / 255f, (float)((item2 >> 8) & 0xFF) / 255f, (float)(item2 & 0xFF) / 255f);
				for (int j = 0; j < pixels.Length; j++)
				{
					float a = pixels2[j].a;
					if (!(a <= 0f))
					{
						((Color)(ref val4))..ctor(pixels2[j].r * val3.r, pixels2[j].g * val3.g, pixels2[j].b * val3.b);
						pixels[j] = new Color(Mathf.Lerp(pixels[j].r, val4.r, a), Mathf.Lerp(pixels[j].g, val4.g, a), Mathf.Lerp(pixels[j].b, val4.b, a), Mathf.Max(pixels[j].a, a));
					}
				}
			}
			Texture2D val5 = new Texture2D(((Texture)val).width, ((Texture)val).height, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0,
				wrapMode = (TextureWrapMode)1,
				name = "mc_" + key.Replace('/', '_')
			};
			val5.SetPixels(pixels);
			val5.Apply();
			return val5;
		}

		private static Texture2D? Frame(string key)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			string text = key.Substring("gen/frame/".Length);
			int num = text.LastIndexOf('/');
			if (num < 0 || !int.TryParse(text.Substring(num + 1), out var result))
			{
				return null;
			}
			Texture2D val = Texture(text.Substring(0, num));
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			int width = ((Texture)val).width;
			int num2 = Mathf.Max(1, ((Texture)val).height / width);
			result = (result % num2 + num2) % num2;
			Texture2D val2 = new Texture2D(width, width, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0,
				wrapMode = (TextureWrapMode)1,
				name = "mc_" + key.Replace('/', '_')
			};
			val2.SetPixels(val.GetPixels(0, ((Texture)val).height - (result + 1) * width, width, width));
			val2.Apply();
			return val2;
		}

		internal static Sprite? Sprite(string key)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if (Sprites.TryGetValue(key, out Sprite value))
			{
				return value;
			}
			Texture2D val = Texture(key);
			Sprite val2 = (((Object)(object)val == (Object)null) ? null : Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), (float)((Texture)val).width));
			Sprites[key] = val2;
			return val2;
		}

		internal static AudioClip? Sound(string key)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Invalid comparison between Unknown and I4
			if (Clips.TryGetValue(key, out AudioClip value))
			{
				return value;
			}
			AudioClip val = null;
			string text = Path.Combine(Root, "sounds", key + ".ogg");
			if (File.Exists(text))
			{
				UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("file:///" + text.Replace('\\', '/'), (AudioType)14);
				try
				{
					UnityWebRequestAsyncOperation val2 = audioClip.SendWebRequest();
					while (!((AsyncOperation)val2).isDone)
					{
					}
					if ((int)audioClip.result == 1)
					{
						val = DownloadHandlerAudioClip.GetContent(audioClip);
						((Object)val).name = "mc_" + key.Replace('/', '_');
					}
					else
					{
						MineCompany.Logger.LogWarning((object)("Could not load sound " + text + ": " + audioClip.error));
					}
				}
				finally
				{
					((IDisposable)audioClip)?.Dispose();
				}
			}
			else
			{
				MineCompany.Logger.LogWarning((object)("Missing sound " + text));
			}
			Clips[key] = val;
			return val;
		}

		internal static AudioClip[] Sounds(string key)
		{
			if (ClipGroups.TryGetValue(key, out AudioClip[] value))
			{
				return value;
			}
			List<AudioClip> list = new List<AudioClip>();
			for (int i = 1; i < 16; i++)
			{
				if (!File.Exists(Path.Combine(Root, "sounds", key + i + ".ogg")))
				{
					break;
				}
				AudioClip val = Sound(key + i);
				if ((Object)(object)val != (Object)null)
				{
					list.Add(val);
				}
			}
			if (list.Count == 0 && File.Exists(Path.Combine(Root, "sounds", key + ".ogg")))
			{
				AudioClip val2 = Sound(key);
				if ((Object)(object)val2 != (Object)null)
				{
					list.Add(val2);
				}
			}
			AudioClip[] array = list.ToArray();
			ClipGroups[key] = array;
			return array;
		}

		internal static void Play(AudioSource? src, string key, float volume = 1f)
		{
			if (!((Object)(object)src == (Object)null))
			{
				AudioClip[] array = Sounds(key);
				if (array.Length != 0)
				{
					src.pitch = Random.Range(0.9f, 1.1f);
					src.PlayOneShot(array[Random.Range(0, array.Length)], volume);
				}
			}
		}

		internal static void Preload(IEnumerable<string> soundKeys)
		{
			foreach (string item in soundKeys.Distinct())
			{
				Sounds(item);
			}
		}
	}
	internal static class McConfig
	{
		internal static ConfigEntry<float> McDamagePerEnemyHp;

		internal static ConfigEntry<float> PlayerHpPerMcDamage;

		internal static ConfigEntry<float> LootWeightMultiplier;

		internal static ConfigEntry<float> PriceMultiplier;

		internal static ConfigEntry<float> EnchantedLootChance;

		internal static ConfigEntry<float> BlockSize;

		internal static ConfigEntry<bool> FriendlyFire;

		internal static ConfigEntry<string> UndeadEnemies;

		internal static ConfigEntry<string> ArthropodEnemies;

		internal static ConfigEntry<bool> Crosshair;

		internal static ConfigEntry<float> CrosshairScale;

		internal static ConfigEntry<float> EffectDurationMultiplier;

		internal static ConfigEntry<float> InsideOreMultiplier;

		internal static ConfigEntry<float> SurfaceOreMultiplier;

		internal static ConfigEntry<string> DebrisMoons;

		internal static ConfigEntry<float> FurnaceSecondsPerItem;

		internal static ConfigEntry<float> MaterialValueMultiplier;

		internal static ConfigEntry<string> MobDifficulty;

		internal static ConfigEntry<float> MobSpawnMultiplier;

		internal static ConfigEntry<string> DisabledMobs;

		internal static void Bind(ConfigFile cfg)
		{
			McDamagePerEnemyHp = cfg.Bind<float>("Balance", "McDamagePerEnemyHp", 4f, "How much Minecraft damage removes one HP of a Lethal Company enemy (a shovel hit = 1 HP). Lower = stronger weapons.");
			PlayerHpPerMcDamage = cfg.Bind<float>("Balance", "PlayerHpPerMcDamage", 5f, "Player HP removed per point of Minecraft damage (20 MC health = 100 LC health, so 5).");
			LootWeightMultiplier = cfg.Bind<float>("Balance", "LootWeightMultiplier", 0.5f, "Multiplier for how often Minecraft items appear as scrap. 1 = the table in the mod, 0 = never.");
			PriceMultiplier = cfg.Bind<float>("Balance", "PriceMultiplier", 1f, "Multiplier for all Minecraft store prices.");
			EnchantedLootChance = cfg.Bind<float>("Balance", "EnchantedLootChance", 0.35f, "Chance that a found tool or weapon is enchanted.");
			BlockSize = cfg.Bind<float>("Balance", "BlockSize", 1.39f, "Size of one Minecraft block in game units (player is 2.5 units tall, 1.8 blocks in Minecraft). Scales arrow speed and gravity.");
			FriendlyFire = cfg.Bind<bool>("Balance", "FriendlyFire", true, "Minecraft weapons and arrows can hurt other players (vanilla shovels can).");
			UndeadEnemies = cfg.Bind<string>("Enchantments", "UndeadEnemies", "masked,girl,zombie,skeleton,wither", "Enemy name fragments that Smite deals extra damage to.");
			ArthropodEnemies = cfg.Bind<string>("Enchantments", "ArthropodEnemies", "spider,bug,centipede,bees,locust,hornet", "Enemy name fragments that Bane of Arthropods deals extra damage to.");
			EffectDurationMultiplier = cfg.Bind<float>("Effects", "EffectDurationMultiplier", 0.5f, "Durations of effects lasting a minute or more in Minecraft, relative to Minecraft (its 3-8 minute potions last most of a day here). Shorter effects (regeneration, poison, golden apple healing) and milk's 10 s of invulnerability keep Minecraft's time.");
			InsideOreMultiplier = cfg.Bind<float>("Mining", "InsideOreMultiplier", 1f, "How many ore veins grow in the facility walls (deepslate ores), relative to the mod's table. 0 = none.");
			SurfaceOreMultiplier = cfg.Bind<float>("Mining", "SurfaceOreMultiplier", 1f, "How many small ore veins stick out of the ground outside, relative to the mod's table. 0 = none.");
			DebrisMoons = cfg.Bind<string>("Mining", "DebrisMoons", "Rend,Dine,Titan,Artifice,Embrion", "Moons (name fragments) whose facilities can hold ancient debris, the source of netherite.");
			FurnaceSecondsPerItem = cfg.Bind<float>("Crafting", "FurnaceSecondsPerItem", 10f, "Seconds the ship's furnace takes per item (Minecraft: 10).");
			MaterialValueMultiplier = cfg.Bind<float>("Crafting", "MaterialValueMultiplier", 1f, "Multiplier for the sell value of ores, ingots and diamonds.");
			MobDifficulty = cfg.Bind<string>("Mobs", "Difficulty", "Normal", "Minecraft difficulty for mob damage: Easy (min(d/2+1, d)), Normal, Hard (x1.5), Peaceful (no damage).");
			MobSpawnMultiplier = cfg.Bind<float>("Mobs", "SpawnMultiplier", 1f, "How often Minecraft mobs are picked among a moon's enemies, relative to the mod's table. 0 = they never spawn on their own.");
			DisabledMobs = cfg.Bind<string>("Mobs", "DisabledMobs", "", "Mobs that never spawn on moons on their own (comma-separated ids, e.g. warden,wither). Spawn eggs still work.");
			Crosshair = cfg.Bind<bool>("HUD", "Crosshair", true, "Show Minecraft's crosshair (inverts the colours behind it).");
			CrosshairScale = cfg.Bind<float>("HUD", "CrosshairScale", 1f, "Crosshair size; 1 = Minecraft's GUI scale 4 at 1080p.");
		}
	}
	internal static class McContent
	{
		internal static readonly Dictionary<string, Item> Items = new Dictionary<string, Item>();

		internal const string HoldAnim = "";

		private static AudioMixerGroup? _sfx;

		private static readonly Dictionary<McKind, (Vector3 rot, Vector3 pos, Vector3 rest)> Placement = new Dictionary<McKind, (Vector3, Vector3, Vector3)>
		{
			[McKind.Sword] = (new Vector3(-30f, -35f, 25f), Vector3.zero, new Vector3(90f, 0f, 0f)),
			[McKind.Axe] = (new Vector3(-30f, -35f, 25f), Vector3.zero, new Vector3(90f, 0f, 0f)),
			[McKind.Pickaxe] = (new Vector3(-30f, -35f, 25f), Vector3.zero, new Vector3(90f, 0f, 0f)),
			[McKind.Bow] = (new Vector3(-30f, -35f, 45f), Vector3.zero, new Vector3(90f, 0f, 0f)),
			[McKind.Crossbow] = (new Vector3(-30f, -35f, -20f), Vector3.zero, new Vector3(90f, 0f, 0f)),
			[McKind.Arrows] = (new Vector3(-15f, -35f, 45f), Vector3.zero, new Vector3(90f, 0f, 0f)),
			[McKind.Bolts] = (new Vector3(-15f, -35f, 45f), Vector3.zero, new Vector3(90f, 0f, 0f)),
			[McKind.Potion] = (new Vector3(-30f, -35f, -20f), new Vector3(0f, 0.12f, 0f), new Vector3(90f, 0f, 0f)),
			[McKind.SplashPotion] = (new Vector3(-30f, -35f, -20f), new Vector3(0f, 0.12f, 0f), new Vector3(90f, 0f, 0f)),
			[McKind.Food] = (new Vector3(-30f, -35f, -20f), new Vector3(0f, 0.12f, 0f), new Vector3(90f, 0f, 0f)),
			[McKind.MilkBucket] = (new Vector3(-30f, -35f, -20f), new Vector3(0f, 0.12f, 0f), new Vector3(90f, 0f, 0f)),
			[McKind.Bucket] = (new Vector3(-30f, -35f, -20f), new Vector3(0f, 0.12f, 0f), new Vector3(90f, 0f, 0f)),
			[McKind.Material] = (new Vector3(-30f, -35f, -20f), new Vector3(0f, 0.12f, 0f), new Vector3(90f, 0f, 0f)),
			[McKind.Helmet] = (new Vector3(-30f, -35f, -20f), new Vector3(0f, 0.12f, 0f), new Vector3(90f, 0f, 0f)),
			[McKind.Chestplate] = (new Vector3(-30f, -35f, -20f), new Vector3(0f, 0.12f, 0f), new Vector3(90f, 0f, 0f)),
			[McKind.Leggings] = (new Vector3(-30f, -35f, -20f), new Vector3(0f, 0.12f, 0f), new Vector3(90f, 0f, 0f)),
			[McKind.Boots] = (new Vector3(-30f, -35f, -20f), new Vector3(0f, 0.12f, 0f), new Vector3(90f, 0f, 0f)),
			[McKind.SpawnEgg] = (new Vector3(-30f, -35f, -20f), new Vector3(0f, 0.12f, 0f), new Vector3(90f, 0f, 0f)),
			[McKind.FishingRod] = (new Vector3(-30f, -35f, 25f), Vector3.zero, new Vector3(90f, 0f, 0f))
		};

		internal static void RegisterAll()
		{
			float num = Mathf.Max(0f, McConfig.LootWeightMultiplier.Value);
			float num2 = Mathf.Max(0f, McConfig.PriceMultiplier.Value);
			foreach (McItemDef item in McItemDefs.All)
			{
				Item val = Create(item);
				Items[item.Id] = val;
				bool flag = false;
				if (item.Price >= 0)
				{
					Items.RegisterShopItem(val, Mathf.RoundToInt((float)item.Price * num2));
					flag = true;
				}
				int num3 = Mathf.RoundToInt((float)item.Rarity * num);
				if (num3 > 0)
				{
					Items.RegisterScrap(val, num3, (LevelTypes)(-1));
					flag = true;
				}
				if (!flag)
				{
					Items.RegisterItem(val);
				}
			}
			McOreSpawner.RegisterPrefab();
			McStations.RegisterPrefabs();
			McMobs.RegisterAll();
			MineCompany.Logger.LogInfo((object)$"Registered {McItemDefs.All.Count} Minecraft items");
		}

		private static Item Create(McItemDef def)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0731: Unknown result type (might be due to invalid IL or missing references)
			//IL_0736: Unknown result type (might be due to invalid IL or missing references)
			//IL_0739: Unknown result type (might be due to invalid IL or missing references)
			//IL_073e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0740: Unknown result type (might be due to invalid IL or missing references)
			//IL_0745: Unknown result type (might be due to invalid IL or missing references)
			//IL_0749: Unknown result type (might be due to invalid IL or missing references)
			//IL_074b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0752: Unknown result type (might be due to invalid IL or missing references)
			//IL_0754: Unknown result type (might be due to invalid IL or missing references)
			//IL_075b: Unknown result type (might be due to invalid IL or missing references)
			//IL_075d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = NetworkPrefabs.CreateNetworkPrefab("MC_" + def.Id);
			NetworkObject component = val.GetComponent<NetworkObject>();
			component.AutoObjectParentSync = false;
			component.DontDestroyWithOwner = true;
			val.layer = 6;
			val.tag = "PhysicsProp";
			GameObject val2 = new GameObject("Model")
			{
				layer = 6
			};
			val2.transform.SetParent(val.transform, false);
			MeshFilter val3 = val2.AddComponent<MeshFilter>();
			val3.sharedMesh = McModels.MeshFor(def.Texture);
			MeshRenderer val4 = val2.AddComponent<MeshRenderer>();
			Vector2 val5 = (Vector2)((def.IsMelee || def.Kind == McKind.FishingRod) ? new Vector2(5.5f, 5.5f) : Vector2.zero);
			if (def.Kind == McKind.FishingRod)
			{
				Transform transform = val2.transform;
				Vector3 val6 = new Vector3(1f, 1f, 0f);
				transform.localRotation = Quaternion.AngleAxis(180f, ((Vector3)(ref val6)).normalized);
			}
			val2.transform.localPosition = new Vector3(val5.x, val5.y, 0f) * 0.04f;
			float num = ((def.Kind >= McKind.Potion && def.Kind != McKind.FishingRod) ? 0.55f : 1f);
			val2.transform.localScale = Vector3.one * num;
			Bounds bounds = (Bounds)(((Object)(object)val3.sharedMesh != (Object)null) ? val3.sharedMesh.bounds : new Bounds(Vector3.zero, Vector3.one * 0.6f));
			((Bounds)(ref bounds))..ctor(((Bounds)(ref bounds)).center * num + val2.transform.localPosition, ((Bounds)(ref bounds)).size * num);
			BoxCollider val7 = val.AddComponent<BoxCollider>();
			val7.center = ((Bounds)(ref bounds)).center;
			val7.size = Vector3.Max(((Bounds)(ref bounds)).size, new Vector3(0.3f, 0.3f, 0.3f));
			((Collider)val7).isTrigger = true;
			AudioSource val8 = val.AddComponent<AudioSource>();
			val8.playOnAwake = false;
			val8.spatialBlend = 1f;
			val8.rolloffMode = (AudioRolloffMode)1;
			val8.minDistance = 2f;
			val8.maxDistance = 35f;
			AddScanNode(val, def.Name, bounds);
			McItemBase mcItemBase;
			switch (def.Kind)
			{
			case McKind.Sword:
			case McKind.Axe:
			case McKind.Pickaxe:
				mcItemBase = val.AddComponent<McMeleeWeapon>();
				break;
			case McKind.Bow:
			case McKind.Crossbow:
				mcItemBase = val.AddComponent<McRangedWeapon>();
				break;
			case McKind.Arrows:
			case McKind.Bolts:
				mcItemBase = val.AddComponent<McAmmo>();
				break;
			case McKind.Material:
				mcItemBase = val.AddComponent<McStack>();
				break;
			case McKind.Helmet:
			case McKind.Chestplate:
			case McKind.Leggings:
			case McKind.Boots:
				mcItemBase = val.AddComponent<McArmorItem>();
				break;
			case McKind.SpawnEgg:
				mcItemBase = val.AddComponent<McSpawnEgg>();
				break;
			case McKind.FishingRod:
				mcItemBase = val.AddComponent<McFishingRod>();
				break;
			default:
				mcItemBase = val.AddComponent<McConsumable>();
				break;
			}
			McItemBase mcItemBase2 = mcItemBase;
			mcItemBase2.mcId = def.Id;
			mcItemBase2.modelFilter = val3;
			mcItemBase2.modelRenderer = val4;
			mcItemBase2.audioSource = val8;
			((GrabbableObject)mcItemBase2).mainObjectRenderer = val4;
			((GrabbableObject)mcItemBase2).grabbable = true;
			((GrabbableObject)mcItemBase2).grabbableToEnemies = true;
			((GrabbableObject)mcItemBase2).isInFactory = true;
			Item val9 = ScriptableObject.CreateInstance<Item>();
			((Object)val9).name = "MC_" + def.Id;
			val9.itemName = def.Name;
			val9.spawnPrefab = val;
			val9.itemIcon = McAssets.Sprite(def.Texture);
			val9.spawnPositionTypes = new List<ItemGroup>();
			val9.weight = def.Weight;
			val9.isConductiveMetal = def.IsMetal;
			val9.isScrap = def.IsMaterial;
			val9.creditsWorth = def.Price;
			val9.highestSalePercentage = 80;
			val9.minValue = Mathf.RoundToInt((float)def.MinValue / 0.4f);
			val9.maxValue = Mathf.RoundToInt((float)def.MaxValue / 0.4f);
			val9.itemSpawnsOnGround = true;
			val9.canBeGrabbedBeforeGameStart = true;
			val9.saveItemVariable = true;
			val9.requiresBattery = false;
			val9.automaticallySetUsingPower = false;
			val9.canBeInspected = false;
			McKind kind = def.Kind;
			bool flag = ((kind == McKind.Potion || (uint)(kind - 9) <= 1u) ? true : false);
			bool flag2 = flag || def.Nutrition > 0;
			val9.syncUseFunction = def.IsMelee || def.IsRanged || flag2 || def.Kind == McKind.SplashPotion;
			val9.syncInteractLRFunction = false;
			val9.isDefensiveWeapon = def.IsMelee || def.IsRanged;
			val9.holdButtonUse = def.IsRanged || flag2 || def.Kind == McKind.Pickaxe;
			val9.twoHanded = false;
			switch (def.Kind)
			{
			case McKind.Sword:
			case McKind.Axe:
			case McKind.Pickaxe:
				val9.grabAnim = "";
				val9.toolTips = ((def.Kind != McKind.Pickaxe) ? new string[1] { "Attack : [RMB]" } : new string[1] { "Attack, mine ore : [RMB]" });
				break;
			case McKind.Material:
				val9.grabAnim = "";
				val9.toolTips = ((def.Nutrition <= 0) ? ((!(def.Id == "ender_pearl")) ? new string[0] : new string[1] { "Throw : [RMB]" }) : new string[1] { "Eat : hold [RMB]" });
				break;
			case McKind.SpawnEgg:
				val9.grabAnim = "";
				val9.toolTips = new string[1] { "Spawn on the floor : [RMB]" };
				break;
			case McKind.Helmet:
			case McKind.Chestplate:
			case McKind.Leggings:
			case McKind.Boots:
				val9.grabAnim = "";
				val9.toolTips = new string[1] { "Put on : [RMB]" };
				break;
			case McKind.Bow:
				val9.grabAnim = "";
				val9.toolTips = new string[1] { "Draw and shoot : hold [RMB]" };
				break;
			case McKind.Crossbow:
				val9.grabAnim = "";
				val9.toolTips = new string[2] { "Load : hold [RMB]", "Fire : [RMB]" };
				break;
			case McKind.Potion:
			case McKind.MilkBucket:
				val9.grabAnim = "";
				val9.toolTips = new string[1] { "Drink : hold [RMB]" };
				break;
			case McKind.Food:
				val9.grabAnim = "";
				val9.toolTips = new string[1] { "Eat : hold [RMB]" };
				break;
			case McKind.SplashPotion:
				val9.grabAnim = "";
				val9.toolTips = new string[1] { "Throw : [RMB]" };
				break;
			case McKind.FishingRod:
				val9.grabAnim = "";
				val9.toolTips = new string[1] { "Cast / reel in : [RMB]" };
				break;
			case McKind.Bucket:
				val9.grabAnim = "";
				val9.toolTips = new string[0];
				break;
			default:
				val9.toolTips = new string[1] { "Keep in the inventory to shoot a bow or crossbow" };
				break;
			}
			(Vector3 rot, Vector3 pos, Vector3 rest) tuple = Placement[def.Kind];
			Vector3 item = tuple.rot;
			Vector3 item2 = tuple.pos;
			Vector3 item3 = tuple.rest;
			val9.rotationOffset = item;
			val9.positionOffset = item2;
			val9.restingRotation = item3;
			val9.verticalOffset = 0.05f;
			val9.floorYOffset = 0;
			val9.meshVariants = (Mesh[])(object)new Mesh[0];
			val9.materialVariants = (Material[])(object)new Material[0];
			val9.grabSFX = McAssets.Sound("random/pop");
			kind = def.Kind;
			flag = (uint)(kind - 7) <= 1u;
			bool flag3 = flag;
			val9.dropSFX = McAssets.Sound(flag3 ? "random/glass1" : ((def.IsMetal || def.IsMaterial) ? "step/stone1" : "step/wood1"));
			val9.pocketSFX = McAssets.Sound("random/pop");
			((GrabbableObject)mcItemBase2).itemProperties = val9;
			return val9;
		}

		private static void AddScanNode(GameObject prefab, string header, Bounds bounds)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ScanNode")
			{
				layer = 22
			};
			val.transform.SetParent(prefab.transform, false);
			val.transform.localPosition = ((Bounds)(ref bounds)).center;
			BoxCollider val2 = val.AddComponent<BoxCollider>();
			((Collider)val2).isTrigger = true;
			val2.size = Vector3.one * 0.5f;
			ScanNodeProperties val3 = val.AddComponent<ScanNodeProperties>();
			val3.headerText = header;
			val3.subText = "";
			val3.minRange = 1;
			val3.maxRange = 13;
			val3.requiresLineOfSight = true;
			val3.creatureScanID = -1;
			val3.nodeType = 2;
		}

		internal static AudioMixerGroup? SfxMixer()
		{
			if ((Object)(object)_sfx != (Object)null)
			{
				return _sfx;
			}
			_sfx = (StartOfRound.Instance?.allItemsList?.itemsList)?.Where(delegate(Item i)
			{
				switch (i.itemName)
				{
				case "Shotgun":
				case "Spray paint":
				case "Jetpack":
					return true;
				default:
					return false;
				}
			}).Select((Func<Item, AudioMixerGroup>)delegate(Item i)
			{
				GameObject spawnPrefab = i.spawnPrefab;
				if (spawnPrefab == null)
				{
					return (AudioMixerGroup)null;
				}
				AudioSource componentInChildren = spawnPrefab.GetComponentInChildren<AudioSource>();
				return (componentInChildren == null) ? null : componentInChildren.outputAudioMixerGroup;
			}).FirstOrDefault((Func<AudioMixerGroup, bool>)((AudioMixerGroup g) => (Object)(object)g != (Object)null));
			return _sfx;
		}

		internal static IEnumerable<string> SoundsToPreload()
		{
			return new string[46]
			{
				"random/pop", "random/break", "random/bow", "random/bowhit", "step/stone", "step/wood", "dig/stone", "entity/player/attack/weak", "entity/player/attack/strong", "entity/player/attack/sweep",
				"entity/player/attack/crit", "entity/player/attack/knockback", "item/crossbow/loading_start", "item/crossbow/loading_middle", "item/crossbow/loading_end", "item/crossbow/shoot", "entity/bobber/castfast", "entity/bobber/retrieve1", "entity/bobber/retrieve2", "random/drink",
				"random/eat", "random/burp", "random/glass", "step/stone", "block/deepslate/step", "block/deepslate/break", "block/ancient_debris/break", "block/furnace/fire_crackle", "random/wood_click", "random/click",
				"block/smithing_table/smithing_table", "item/armor/equip_chain", "item/armor/equip_copper", "item/armor/equip_iron", "item/armor/equip_gold", "item/armor/equip_diamond", "item/armor/equip_netherite", "item/armor/equip_generic", "mob/zombie/say", "mob/zombie/hurt",
				"mob/zombie/death", "mob/zombie/step", "mob/skeleton/say", "mob/skeleton/hurt", "mob/skeleton/death", "mob/skeleton/step"
			};
		}
	}
	internal class McCrosshair : MonoBehaviour
	{
		private class CrossGraphic : Graphic
		{
			internal readonly Color32[] Colors = (Color32[])(object)new Color32[Cells.Length];

			private float _cell = 2f;

			internal void SetCellSize(float px)
			{
				if (!Mathf.Approximately(px, _cell))
				{
					_cell = px;
					((Graphic)this).SetVerticesDirty();
				}
			}

			protected override void OnPopulateMesh(VertexHelper vh)
			{
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				vh.Clear();
				float cell = _cell;
				for (int i = 0; i < Cells.Length; i++)
				{
					float num = ((float)((Vector2Int)(ref Cells[i])).x - 0.5f) * cell;
					float num2 = ((float)((Vector2Int)(ref Cells[i])).y - 0.5f) * cell;
					int currentVertCount = vh.currentVertCount;
					Color32 val = Colors[i];
					vh.AddVert(new Vector3(num, num2), val, Vector4.op_Implicit(Vector2.zero));
					vh.AddVert(new Vector3(num, num2 + cell), val, Vector4.op_Implicit(Vector2.zero));
					vh.AddVert(new Vector3(num + cell, num2 + cell), val, Vector4.op_Implicit(Vector2.zero));
					vh.AddVert(new Vector3(num + cell, num2), val, Vector4.op_Implicit(Vector2.zero));
					vh.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2);
					vh.AddTriangle(currentVertCount, currentVertCount + 2, currentVertCount + 3);
				}
			}
		}

		[HarmonyPatch(typeof(HUDManager), "Start")]
		private static class AddToHud
		{
			private static void Postfix(HUDManager __instance)
			{
				Create(__instance);
			}
		}

		private static readonly Vector2Int[] Cells = BuildCells();

		internal static Color32 LastCentre;

		private CrossGraphic _graphic;

		private RawImage _screen;

		private bool _pending;

		private AsyncGPUReadbackRequest _request;

		private int _cx;

		private int _cy;

		private int _x0;

		private int _y0;

		private int _w;

		private int _h;

		private float _cellTexels;

		private static Vector2Int[] BuildCells()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			List<Vector2Int> list = new List<Vector2Int>();
			for (int i = -4; i <= 4; i++)
			{
				list.Add(new Vector2Int(i, 0));
			}
			for (int j = -4; j <= 4; j++)
			{
				if (j != 0)
				{
					list.Add(new Vector2Int(0, j));
				}
			}
			return list.ToArray();
		}

		internal static void Create(HUDManager hud)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			if (McConfig.Crosshair.Value && !((Object)(object)hud.playerScreenTexture == (Object)null) && SystemInfo.supportsAsyncGPUReadback)
			{
				GameObject val = new GameObject("McCrosshair");
				Canvas val2 = val.AddComponent<Canvas>();
				val2.renderMode = (RenderMode)0;
				val2.sortingOrder = 50;
				McCrosshair mcCrosshair = val.AddComponent<McCrosshair>();
				mcCrosshair._screen = hud.playerScreenTexture;
				GameObject val3 = new GameObject("Cross", new Type[1] { typeof(RectTransform) });
				val3.transform.SetParent(val.transform, false);
				mcCrosshair._graphic = val3.AddComponent<CrossGraphic>();
				((Graphic)mcCrosshair._graphic).raycastTarget = false;
				RectTransform val4 = (RectTransform)val3.transform;
				Vector2 val5 = default(Vector2);
				((Vector2)(ref val5))..ctor(0.5f, 0.5f);
				val4.pivot = val5;
				Vector2 anchorMin = (val4.anchorMax = val5);
				val4.anchorMin = anchorMin;
				val4.anchoredPosition = Vector2.zero;
			}
		}

		private void LateUpdate()
		{
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
			bool flag = (Object)(object)val != (Object)null && !val.isPlayerDead && !val.inTerminalMenu && !val.isTypingChat && ((Object)(object)val.quickMenuManager == (Object)null || !val.quickMenuManager.isMenuOpen);
			((Graphic)_graphic).canvasRenderer.cull = !flag;
			if (!flag)
			{
				return;
			}
			float num = McConfig.CrosshairScale.Value / 270f;
			_graphic.SetCellSize(Mathf.Max(1f, Mathf.Round((float)Screen.height * num)));
			if (_pending)
			{
				((AsyncGPUReadbackRequest)(ref _request)).Update();
				if (!((AsyncGPUReadbackRequest)(ref _request)).done)
				{
					return;
				}
				_pending = false;
				if (!((AsyncGPUReadbackRequest)(ref _request)).hasError)
				{
					Apply(((AsyncGPUReadbackRequest)(ref _request)).GetData<Color32>(0));
				}
			}
			Texture texture = _screen.texture;
			RenderTexture val2 = (RenderTexture)(object)((texture is RenderTexture) ? texture : null);
			if (val2 != null)
			{
				_cellTexels = Mathf.Max(1f, (float)((Texture)val2).height * num);
				int num2 = Mathf.CeilToInt(4.5f * _cellTexels) + 1;
				_cx = ((Texture)val2).width / 2;
				_cy = ((Texture)val2).height / 2;
				_x0 = Mathf.Max(0, _cx - num2);
				_y0 = Mathf.Max(0, _cy - num2);
				_w = Mathf.Min(((Texture)val2).width - _x0, 2 * num2);
				_h = Mathf.Min(((Texture)val2).height - _y0, 2 * num2);
				_request = AsyncGPUReadback.Request((Texture)(object)val2, 0, _x0, _w, _y0, _h, 0, 1, (TextureFormat)4, (Action<AsyncGPUReadbackRequest>)null);
				_pending = true;
			}
		}

		private void Apply(NativeArray<Color32> data)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < Cells.Length; i++)
			{
				int num = Mathf.Clamp(Mathf.FloorToInt((float)_cx + (float)((Vector2Int)(ref Cells[i])).x * _cellTexels) - _x0, 0, _w - 1);
				int num2 = Mathf.Clamp(Mathf.FloorToInt((float)_cy + (float)((Vector2Int)(ref Cells[i])).y * _cellTexels) - _y0, 0, _h - 1);
				Color32 val = data[num2 * _w + num];
				if (i == 4)
				{
					LastCentre = val;
				}
				_graphic.Colors[i] = new Color32((byte)(255 - val.r), (byte)(255 - val.g), (byte)(255 - val.b), byte.MaxValue);
			}
			((Graphic)_graphic).SetVerticesDirty();
		}
	}
	internal enum McKind
	{
		Sword,
		Axe,
		Pickaxe,
		Bow,
		Crossbow,
		Arrows,
		Bolts,
		Potion,
		SplashPotion,
		Food,
		MilkBucket,
		Bucket,
		Material,
		Helmet,
		Chestplate,
		Leggings,
		Boots,
		SpawnEgg,
		FishingRod
	}
	internal enum McTier
	{
		None,
		Wood,
		Stone,
		Copper,
		Iron,
		Gold,
		Diamond,
		Netherite,
		Chainmail
	}
	internal sealed class McItemDef
	{
		internal string Id = "";

		internal string Name = "";

		internal McKind Kind;

		internal McTier Tier;

		internal string Texture = "";

		internal float McDamage;

		internal float AttackSpeed;

		internal int Durability;

		internal int Price;

		internal int Rarity;

		internal int MinValue;

		internal int MaxValue;

		internal float Weight = 1.05f;

		internal int AmmoCount;

		internal string PotionId = "";

		internal int UnitValue;

		internal string SmeltsTo = "";

		internal bool Metal;

		internal int Armor;

		internal float Toughness;

		internal float KnockbackResistance;

		internal string Equipment = "";

		internal int Nutrition;

		internal string MobId = "";

		internal bool IsMelee
		{
			get
			{
				McKind kind = Kind;
				if ((uint)kind <= 2u)
				{
					return true;
				}
				return false;
			}
		}

		internal bool IsRanged
		{
			get
			{
				McKind kind = Kind;
				if ((uint)(kind - 3) <= 1u)
				{
					return true;
				}
				return false;
			}
		}

		internal bool IsAmmo
		{
			get
			{
				McKind kind = Kind;
				if ((uint)(kind - 5) <= 1u)
				{
					return true;
				}
				return false;
			}
		}

		internal bool IsConsumable
		{
			get
			{
				McKind kind = Kind;
				if (kind == McKind.Potion || (uint)(kind - 9) <= 2u)
				{
					return true;
				}
				return false;
			}
		}

		internal bool IsMaterial => Kind == McKind.Material;

		internal bool IsArmor
		{
			get
			{
				McKind kind = Kind;
				if ((uint)(kind - 13) <= 3u)
				{
					return true;
				}
				return false;
			}
		}

		internal int ArmorSlot => (int)(Kind - 13);

		internal McPotionType? Potion
		{
			get
			{
				if (PotionId.Length <= 0)
				{
					return null;
				}
				return McPotions.ById[PotionId];
			}
		}

		internal bool IsMetal
		{
			get
			{
				bool metal = Metal;
				bool flag = metal;
				if (!flag)
				{
					McTier tier = Tier;
					bool flag2 = (((uint)(tier - 3) <= 2u || (uint)(tier - 7) <= 1u) ? true : false);
					flag = flag2;
				}
				bool flag3 = flag;
				if (!flag3)
				{
					McKind kind = Kind;
					bool flag2 = ((kind == McKind.Crossbow || (uint)(kind - 10) <= 1u) ? true : false);
					flag3 = flag2;
				}
				return flag3;
			}
		}
	}
	internal static class McItemDefs
	{
		internal static readonly List<McItemDef> All;

		internal static readonly Dictionary<string, McItemDef> ById;

		private static readonly (McTier tier, string prefix, string display, int durability)[] Tiers;

		private static readonly Dictionary<McTier, (float, float)> SwordStats;

		private static readonly Dictionary<McTier, (float, float)> AxeStats;

		private static readonly Dictionary<McTier, (float, float)> PickaxeStats;

		private static readonly Dictionary<McTier, int> BasePrice;

		private static readonly Dictionary<McTier, int> BaseRarity;

		private static readonly Dictionary<McTier, (int, int)> BaseValue;

		private static readonly Dictionary<string, int> PotionPrices;

		private static readonly HashSet<string> CombatSplash;

		private static readonly (string id, string name, string texture, int value, float weight, string smelts, bool metal)[] MaterialTable;

		private static readonly Dictionary<string, int> Nutritions;

		private static readonly (string mob, string name, int price, int rarity)[] SpawnEggs;

		internal static readonly List<McItemDef> Materials;

		private static readonly (McTier tier, string prefix, string display, string texture, int durability, int[] armor, float toughness, float knockback)[] ArmorTiers;

		private static readonly (McKind kind, string noun, int baseDurability, float weight, int chainmailRarity)[] ArmorSlots;

		static McItemDefs()
		{
			All = new List<McItemDef>();
			ById = new Dictionary<string, McItemDef>();
			Tiers = new(McTier, string, string, int)[7]
			{
				(McTier.Wood, "wooden", "Wooden", 59),
				(McTier.Stone, "stone", "Stone", 131),
				(McTier.Copper, "copper", "Copper", 190),
				(McTier.Iron, "iron", "Iron", 250),
				(McTier.Gold, "golden", "Golden", 32),
				(McTier.Diamond, "diamond", "Diamond", 1561),
				(McTier.Netherite, "netherite", "Netherite", 2031)
			};
			SwordStats = new Dictionary<McTier, (float, float)>
			{
				[McTier.Wood] = (4f, 1.6f),
				[McTier.Stone] = (5f, 1.6f),
				[McTier.Copper] = (5f, 1.6f),
				[McTier.Iron] = (6f, 1.6f),
				[McTier.Gold] = (4f, 1.6f),
				[McTier.Diamond] = (7f, 1.6f),
				[McTier.Netherite] = (8f, 1.6f)
			};
			AxeStats = new Dictionary<McTier, (float, float)>
			{
				[McTier.Wood] = (7f, 0.8f),
				[McTier.Stone] = (9f, 0.8f),
				[McTier.Copper] = (9f, 0.8f),
				[McTier.Iron] = (9f, 0.9f),
				[McTier.Gold] = (7f, 1f),
				[McTier.Diamond] = (9f, 1f),
				[McTier.Netherite] = (10f, 1f)
			};
			PickaxeStats = new Dictionary<McTier, (float, float)>
			{
				[McTier.Wood] = (2f, 1.2f),
				[McTier.Stone] = (3f, 1.2f),
				[McTier.Copper] = (3f, 1.2f),
				[McTier.Iron] = (4f, 1.2f),
				[McTier.Gold] = (2f, 1.2f),
				[McTier.Diamond] = (5f, 1.2f),
				[McTier.Netherite] = (6f, 1.2f)
			};
			BasePrice = new Dictionary<McTier, int>
			{
				[McTier.Wood] = 15,
				[McTier.Stone] = 25,
				[McTier.Copper] = 35,
				[McTier.Iron] = 60,
				[McTier.Gold] = 50,
				[McTier.Diamond] = 200,
				[McTier.Netherite] = -1
			};
			BaseRarity = new Dictionary<McTier, int>
			{
				[McTier.Wood] = 18,
				[McTier.Stone] = 16,
				[McTier.Copper] = 14,
				[McTier.Iron] = 12,
				[McTier.Gold] = 9,
				[McTier.Diamond] = 5,
				[McTier.Netherite] = 2
			};
			BaseValue = new Dictionary<McTier, (int, int)>
			{
				[McTier.Wood] = (8, 20),
				[McTier.Stone] = (12, 28),
				[McTier.Copper] = (18, 40),
				[McTier.Iron] = (30, 60),
				[McTier.Gold] = (45, 90),
				[McTier.Diamond] = (90, 170),
				[McTier.Netherite] = (160, 280)
			};
			PotionPrices = new Dictionary<string, int>
			{
				["healing"] = 35,
				["swiftness"] = 40,
				["fire_resistance"] = 30,
				["night_vision"] = 45,
				["leaping"] = 30
			};
			CombatSplash = new HashSet<string> { "harming", "poison", "slowness", "healing" };
			MaterialTable = new(string, string, string, int, float, string, bool)[32]
			{
				("coal", "Coal", "item/coal", 3, 1.01f, "", false),
				("raw_copper", "Raw Copper", "item/raw_copper", 1, 1.02f, "copper_ingot", true),
				("raw_iron", "Raw Iron", "item/raw_iron", 4, 1.02f, "iron_ingot", true),
				("raw_gold", "Raw Gold", "item/raw_gold", 6, 1.02f, "gold_ingot", true),
				("diamond", "Diamond", "item/diamond", 30, 1.01f, "", false),
				("ancient_debris", "Ancient Debris", "block/ancient_debris_side", 40, 1.04f, "netherite_scrap", false),
				("netherite_scrap", "Netherite Scrap", "item/netherite_scrap", 55, 1.02f, "", true),
				("copper_ingot", "Copper Ingot", "item/copper_ingot", 2, 1.02f, "", true),
				("iron_ingot", "Iron Ingot", "item/iron_ingot", 7, 1.02f, "", true),
				("gold_ingot", "Gold Ingot", "item/gold_ingot", 11, 1.02f, "", true),
				("netherite_ingot", "Netherite Ingot", "item/netherite_ingot", 270, 1.03f, "", true),
				("rotten_flesh", "Rotten Flesh", "item/rotten_flesh", 1, 1.01f, "", false),
				("bone", "Bone", "item/bone", 2, 1.01f, "", false),
				("string", "String", "item/string", 2, 1f, "", false),
				("spider_eye", "Spider Eye", "item/spider_eye", 3, 1f, "", false),
				("gunpowder", "Gunpowder", "item/gunpowder", 4, 1f, "", false),
				("leather", "Leather", "item/leather", 3, 1.01f, "", false),
				("beef", "Raw Beef", "item/beef", 2, 1.02f, "cooked_beef", false),
				("cooked_beef", "Steak", "item/cooked_beef", 5, 1.02f, "", false),
				("carrot", "Carrot", "item/carrot", 2, 1.01f, "", false),
				("potato", "Potato", "item/potato", 2, 1.01f, "baked_potato", false),
				("baked_potato", "Baked Potato", "item/baked_potato", 3, 1.01f, "", false),
				("glass_bottle", "Glass Bottle", "item/glass_bottle", 1, 1.01f, "", false),
				("glowstone_dust", "Glowstone Dust", "item/glowstone_dust", 4, 1f, "", false),
				("redstone", "Redstone Dust", "item/redstone", 3, 1f, "", false),
				("sugar", "Sugar", "item/sugar", 1, 1f, "", false),
				("stick", "Stick", "item/stick", 1, 1f, "", false),
				("ender_pearl", "Ender Pearl", "item/ender_pearl", 15, 1.01f, "", false),
				("wither_skeleton_skull", "Wither Skeleton Skull", "gen/face/entity/skeleton/wither_skeleton", 120, 1.04f, "", false),
				("sculk_catalyst", "Sculk Catalyst", "block/sculk_catalyst_side", 150, 1.06f, "", false),
				("nether_star", "Nether Star", "item/nether_star", 400, 1.02f, "", false),
				("ominous_bottle", "Ominous Bottle", "item/ominous_bottle", 30, 1.02f, "", false)
			};
			Nutritions = new Dictionary<string, int>
			{
				["rotten_flesh"] = 4,
				["spider_eye"] = 2,
				["beef"] = 3,
				["cooked_beef"] = 8,
				["carrot"] = 3,
				["potato"] = 1,
				["baked_potato"] = 5
			};
			SpawnEggs = new(string, string, int, int)[11]
			{
				("cow", "Cow", 30, 3),
				("zombie", "Zombie", 50, 3),
				("skeleton", "Skeleton", 60, 3),
				("spider", "Spider", 60, 3),
				("creeper", "Creeper", 80, 2),
				("witch", "Witch", 120, 2),
				("enderman", "Enderman", 150, 2),
				("wither_skeleton", "Wither Skeleton", 150, 2),
				("pillager", "Pillager", 120, 2),
				("warden", "Warden", 500, 1),
				("wither", "Wither", 700, 1)
			};
			Materials = new List<McItemDef>();
			ArmorTiers = new(McTier, string, string, string, int, int[], float, float)[6]
			{
				(McTier.Chainmail, "chainmail", "Chainmail", "chainmail", 15, new int[4] { 2, 5, 4, 1 }, 0f, 0f),
				(McTier.Copper, "copper", "Copper", "copper", 11, new int[4] { 2, 4, 3, 1 }, 0f, 0f),
				(McTier.Iron, "iron", "Iron", "iron", 15, new int[4] { 2, 6, 5, 2 }, 0f, 0f),
				(McTier.Gold, "golden", "Golden", "gold", 7, new int[4] { 2, 5, 3, 1 }, 0f, 0f),
				(McTier.Diamond, "diamond", "Diamond", "diamond", 33, new int[4] { 3, 8, 6, 3 }, 2f, 0f),
				(McTier.Netherite, "netherite", "Netherite", "netherite", 37, new int[4] { 3, 8, 6, 3 }, 3f, 0.1f)
			};
			ArmorSlots = new(McKind, string, int, float, int)[4]
			{
				(McKind.Helmet, "Helmet", 11, 1.03f, 4),
				(McKind.Chestplate, "Chestplate", 16, 1.08f, 3),
				(McKind.Leggings, "Leggings", 15, 1.06f, 3),
				(McKind.Boots, "Boots", 13, 1.03f, 4)
			};
			(McTier, string, string, int)[] tiers = Tiers;
			for (int i = 0; i < tiers.Length; i++)
			{
				var (mcTier, prefix, display, durability) = tiers[i];
				Add(Tool(McKind.Sword, mcTier, prefix, display, "Sword", SwordStats[mcTier], durability, 0, 1.05f));
				Add(Tool(McKind.Axe, mcTier, prefix, display, "Axe", AxeStats[mcTier], durability, 10, 1.08f));
				Add(Tool(McKind.Pickaxe, mcTier, prefix, display, "Pickaxe", PickaxeStats[mcTier], durability, 5, 1.08f));
			}
			Add(new McItemDef
			{
				Id = "bow",
				Name = "Bow",
				Kind = McKind.Bow,
				Texture = "item/bow",
				McDamage = 2f,
				Durability = 384,
				Price = 60,
				Rarity = 8,
				MinValue = 40,
				MaxValue = 80,
				Weight = 1.05f
			});
			Add(new McItemDef
			{
				Id = "crossbow",
				Name = "Crossbow",
				Kind = McKind.Crossbow,
				Texture = "item/crossbow_standby",
				McDamage = 2f,
				Durability = 465,
				Price = 110,
				Rarity = 6,
				MinValue = 60,
				MaxValue = 110,
				Weight = 1.1f
			});
			Add(new McItemDef
			{
				Id = "arrows",
				Name = "Arrows",
				Kind = McKind.Arrows,
				Texture = "item/arrow",
				Price = 40,
				Rarity = 10,
				MinValue = 8,
				MaxValue = 24,
				Weight = 1f,
				AmmoCount = 64
			});
			Add(new McItemDef
			{
				Id = "bolts",
				Name = "Crossbow Bolts",
				Kind = McKind.Bolts,
				Texture = "item/tipped_arrow_base",
				Price = 20,
				Rarity = 8,
				MinValue = 5,
				MaxValue = 14,
				Weight = 1f,
				AmmoCount = 10
			});
			AddPhase2();
			AddPhase3();
			Add(new McItemDef
			{
				Id = "fishing_rod",
				Name = "Fishing Rod",
				Kind = McKind.FishingRod,
				Texture = "item/fishing_rod",
				Durability = 128,
				Price = 45,
				Rarity = 0,
				MinValue = 10,
				MaxValue = 20,
				Weight = 1.02f
			});
		}

		private static void AddPhase2()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			foreach (McPotionType item in McPotions.All)
			{
				string text = ColorUtilityHex(item.Color);
				Add(new McItemDef
				{
					Id = "potion_" + item.Id,
					Name = "Potion of " + item.Title,
					Kind = McKind.Potion,
					PotionId = item.Id,
					Texture = "gen/potion/" + text,
					Price = (PotionPrices.TryGetValue(item.Id, out var value) ? value : (-1)),
					Rarity = 3,
					MinValue = 10,
					MaxValue = 30,
					Weight = 1.02f
				});
				Add(new McItemDef
				{
					Id = "splash_potion_" + item.Id,
					Name = "Splash Potion of " + item.Title,
					Kind = McKind.SplashPotion,
					PotionId = item.Id,
					Texture = "gen/splash_potion/" + text,
					Price = -1,
					Rarity = (CombatSplash.Contains(item.Id) ? 3 : 2),
					MinValue = 12,
					MaxValue = 35,
					Weight = 1.02f
				});
			}
			Add(new McItemDef
			{
				Id = "golden_apple",
				Name = "Golden Apple",
				Kind = McKind.Food,
				Texture = "item/golden_apple",
				Price = 60,
				Rarity = 5,
				MinValue = 30,
				MaxValue = 60,
				Weight = 1.01f
			});
			Add(new McItemDef
			{
				Id = "enchanted_golden_apple",
				Name = "Enchanted Golden Apple",
				Kind = McKind.Food,
				Texture = "item/golden_apple",
				Price = -1,
				Rarity = 1,
				MinValue = 150,
				MaxValue = 250,
				Weight = 1.01f
			});
			Add(new McItemDef
			{
				Id = "milk_bucket",
				Name = "Milk Bucket",
				Kind = McKind.MilkBucket,
				Texture = "item/milk_bucket",
				Price = 40,
				Rarity = 3,
				MinValue = 10,
				MaxValue = 25,
				Weight = 1.08f
			});
			Add(new McItemDef
			{
				Id = "bucket",
				Name = "Bucket",
				Kind = McKind.Bucket,
				Texture = "item/bucket",
				Price = -1,
				Rarity = 0,
				MinValue = 5,
				MaxValue = 12,
				Weight = 1.04f
			});
		}

		private static void AddPhase3()
		{
			(string, string, string, int, float, string, bool)[] materialTable = MaterialTable;
			for (int i = 0; i < materialTable.Length; i++)
			{
				(string, string, string, int, float, string, bool) tuple = materialTable[i];
				string item = tuple.Item1;
				string item2 = tuple.Item2;
				string item3 = tuple.Item3;
				int item4 = tuple.Item4;
				float item5 = tuple.Item5;
				string item6 = tuple.Item6;
				bool item7 = tuple.Item7;
				int value;
				McItemDef mcItemDef = new McItemDef
				{
					Id = item,
					Name = item2,
					Kind = McKind.Material,
					Texture = item3,
					UnitValue = item4,
					Weight = item5,
					SmeltsTo = item6,
					Metal = item7,
					Price = -1,
					Rarity = 0,
					Nutrition = (Nutritions.TryGetValue(item, out value) ? value : 0)
				};
				Add(mcItemDef);
				Materials.Add(mcItemDef);
			}
			(string, string, int, int)[] spawnEggs = SpawnEggs;
			for (int j = 0; j < spawnEggs.Length; j++)
			{
				var (text, text2, num, rarity) = spawnEggs[j];
				Add(new McItemDef
				{
					Id = text + "_spawn_egg",
					Name = text2 + " Spawn Egg",
					Kind = McKind.SpawnEgg,
					Texture = "item/" + text + "_spawn_egg",
					MobId = text,
					Price = num,
					Rarity = rarity,
					MinValue = num / 3,
					MaxValue = num / 2,
					Weight = 1.01f
				});
			}
			(McTier, string, string, string, int, int[], float, float)[] armorTiers = ArmorTiers;
			for (int k = 0; k < armorTiers.Length; k++)
			{
				(McTier, string, string, string, int, int[], float, float) tuple3 = armorTiers[k];
				(McKind, string, int, float, int)[] armorSlots = ArmorSlots;
				for (int l = 0; l < armorSlots.Length; l++)
				{
					(McKind, string, int, float, int) tuple4 = armorSlots[l];
					McKind item8 = tuple4.Item1;
					string item9 = tuple4.Item2;
					int item10 = tuple4.Item3;
					float item11 = tuple4.Item4;
					int item12 = tuple4.Item5;
					int num2 = (int)(item8 - 13);
					Add(new McItemDef
					{
						Id = tuple3.Item2 + "_" + item9.ToLowerInvariant(),
						Name = tuple3.Item3 + " " + item9,
						Kind = item8,
						Tier = tuple3.Item1,
						Texture = "item/" + tuple3.Item2 + "_" + item9.ToLowerInvariant(),
						Durability = item10 * tuple3.Item5,
						Armor = tuple3.Item6[num2],
						Toughness = tuple3.Item7,
						KnockbackResistance = tuple3.Rest.Item1,
						Equipment = tuple3.Item4,
						Price = -1,
						Rarity = ((tuple3.Item1 == McTier.Chainmail) ? item12 : 0),
						MinValue = 20,
						MaxValue = 45,
						Weight = item11
					});
				}
			}
		}

		internal static int MaterialIndex(string id)
		{
			return Materials.FindIndex((McItemDef m) => m.Id == id);
		}

		private static string ColorUtilityHex(Color c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return ColorUtility.ToHtmlStringRGB(c);
		}

		private static McItemDef Tool(McKind kind, McTier tier, string prefix, string display, string noun, (float dmg, float speed) stats, int durability, int priceExtra, float weight)
		{
			var (minValue, maxValue) = BaseValue[tier];
			return new McItemDef
			{
				Id = prefix + "_" + noun.ToLowerInvariant(),
				Name = display + " " + noun,
				Kind = kind,
				Tier = tier,
				Texture = "item/" + prefix + "_" + noun.ToLowerInvariant(),
				McDamage = stats.dmg,
				AttackSpeed = stats.speed,
				Durability = durability,
				Price = ((BasePrice[tier] < 0) ? (-1) : (BasePrice[tier] + priceExtra)),
				Rarity = BaseRarity[tier],
				MinValue = minValue,
				MaxValue = maxValue,
				Weight = weight
			};
		}

		private static void Add(McItemDef d)
		{
			All.Add(d);
			ById[d.Id] = d;
		}

		internal static IEnumerable<string> AllTextures()
		{
			return All.Select((McItemDef d) => d.Texture).Concat(new string[9] { "item/bow_pulling_0", "item/bow_pulling_1", "item/bow_pulling_2", "item/crossbow_pulling_0", "item/crossbow_pulling_1", "item/crossbow_pulling_2", "item/crossbow_arrow", "item/fishing_rod_cast", "entity/fishing_hook" });
		}
	}
	internal static class McModels
	{
		internal const float PixelSize = 0.04f;

		private static readonly Dictionary<string, Mesh> Meshes = new Dictionary<string, Mesh>();

		private static readonly Dictionary<string, Material> Materials = new Dictionary<string, Material>();

		private static Material? _template;

		internal const float ArrowPixel = 0.05f;

		internal static Mesh? MeshFor(string textureKey)
		{
			if (Meshes.TryGetValue(textureKey, out Mesh value))
			{
				return value;
			}
			Texture2D val = McAssets.Texture(textureKey);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Mesh val2 = Extrude(val, 0.04f);
			((Object)val2).name = "mc_mesh_" + textureKey;
			Meshes[textureKey] = val2;
			return val2;
		}

		private static Mesh Extrude(Texture2D tex, float s)
		{
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			int w = ((Texture)tex).width;
			int h = ((Texture)tex).height;
			Color32[] px = tex.GetPixels32();
			List<Vector3> verts = new List<Vector3>();
			List<Vector3> norms = new List<Vector3>();
			List<Vector2> uvs = new List<Vector2>();
			List<int> tris = new List<int>();
			float num = s * 0.5f;
			float num2 = (float)w * s * 0.5f;
			float num3 = (float)h * s * 0.5f;
			Vector2 uv = default(Vector2);
			for (int i = 0; i < h; i++)
			{
				for (int j = 0; j < w; j++)
				{
					if (Solid(j, i))
					{
						((Vector2)(ref uv))..ctor(((float)j + 0.5f) / (float)w, ((float)i + 0.5f) / (float)h);
						float num4 = (float)j * s - num2;
						float num5 = num4 + s;
						float num6 = (float)i * s - num3;
						float num7 = num6 + s;
						Quad(new Vector3(num4, num6, 0f - num), new Vector3(num4, num7, 0f - num), new Vector3(num5, num7, 0f - num), new Vector3(num5, num6, 0f - num), Vector3.back, uv);
						Quad(new Vector3(num5, num6, num), new Vector3(num5, num7, num), new Vector3(num4, num7, num), new Vector3(num4, num6, num), Vector3.forward, uv);
						if (!Solid(j - 1, i))
						{
							Quad(new Vector3(num4, num6, num), new Vector3(num4, num7, num), new Vector3(num4, num7, 0f - num), new Vector3(num4, num6, 0f - num), Vector3.left, uv);
						}
						if (!Solid(j + 1, i))
						{
							Quad(new Vector3(num5, num6, 0f - num), new Vector3(num5, num7, 0f - num), new Vector3(num5, num7, num), new Vector3(num5, num6, num), Vector3.right, uv);
						}
						if (!Solid(j, i - 1))
						{
							Quad(new Vector3(num4, num6, num), new Vector3(num4, num6, 0f - num), new Vector3(num5, num6, 0f - num), new Vector3(num5, num6, num), Vector3.down, uv);
						}
						if (!Solid(j, i + 1))
						{
							Quad(new Vector3(num4, num7, 0f - num), new Vector3(num4, num7, num), new Vector3(num5, num7, num), new Vector3(num5, num7, 0f - num), Vector3.up, uv);
						}
					}
				}
			}
			Mesh val = new Mesh();
			if (verts.Count > 65000)
			{
				val.indexFormat = (IndexFormat)1;
			}
			val.SetVertices(verts);
			val.SetNormals(norms);
			val.SetUVs(0, uvs);
			val.SetTriangles(tris, 0);
			val.RecalculateBounds();
			val.RecalculateTangents();
			return val;
			void Quad(Vector3 a, Vector3 b, Vector3 c, Vector3 d, Vector3 n, Vector2 item)
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				int count = verts.Count;
				verts.Add(a);
				verts.Add(b);
				verts.Add(c);
				verts.Add(d);
				for (int k = 0; k < 4; k++)
				{
					norms.Add(n);
					uvs.Add(item);
				}
				tris.Add(count);
				tris.Add(count + 1);
				tris.Add(count + 2);
				tris.Add(count);
				tris.Add(count + 2);
				tris.Add(count + 3);
			}
			bool Solid(int x, int y)
			{
				if (x >= 0 && y >= 0 && x < w && y < h)
				{
					return px[y * w + x].a > 25;
				}
				return false;
			}
		}

		internal static Mesh? ArrowMeshFor(string textureKey)
		{
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			string text = "arrow:" + textureKey;
			if (Meshes.TryGetValue(text, out Mesh value))
			{
				return value;
			}
			Texture2D val = McAssets.Texture(textureKey);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			int w = ((Texture)val).width;
			int h = ((Texture)val).height;
			Color32[] px = val.GetPixels32();
			int u = w / 32;
			List<Vector3> verts = new List<Vector3>();
			List<Vector3> norms = new List<Vector3>();
			List<Vector2> uvs = new List<Vector2>();
			List<int> tris = new List<int>();
			float num = 0.05f;
			float num2 = 0.040000003f;
			float[] array = new float[2] { 45f, 135f };
			foreach (float num3 in array)
			{
				Quaternion rot = Quaternion.AngleAxis(num3, Vector3.forward);
				for (int j = 0; j < 5; j++)
				{
					for (int k = 0; k < 16; k++)
					{
						if (Solid(k, j))
						{
							TwoSided(rot, new Vector3(0f, (float)(2 - j) * num2, ((float)k - 7.5f) * num), new Vector3(0f, 0f, num * 0.5f), new Vector3(0f, num2 * 0.5f, 0f), Uv(k, j));
						}
					}
				}
			}
			Quaternion rot2 = Quaternion.AngleAxis(45f, Vector3.forward);
			float num4 = num * 0.8f;
			for (int l = 0; l < 5; l++)
			{
				for (int m = 0; m < 5; m++)
				{
					if (Solid(m, 5 + l))
					{
						TwoSided(rot2, new Vector3((float)(m - 2) * num4, (float)(2 - l) * num4, -7.5f * num), new Vector3(num4 * 0.5f, 0f, 0f), new Vector3(0f, num4 * 0.5f, 0f), Uv(m, 5 + l));
					}
				}
			}
			Mesh val2 = new Mesh
			{
				name = "mc_mesh_" + text
			};
			val2.SetVertices(verts);
			val2.SetNormals(norms);
			val2.SetUVs(0, uvs);
			val2.SetTriangles(tris, 0);
			val2.RecalculateBounds();
			val2.RecalculateTangents();
			Meshes[text] = val2;
			return val2;
			bool Solid(int x, int row)
			{
				return px[(h - 1 - row * u) * w + x * u].a > 25;
			}
			void TwoSided(Quaternion val3, Vector3 center, Vector3 halfA, Vector3 halfB, Vector2 uv)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_0101: Unknown result type (might be due to invalid IL or missing references)
				//IL_010f: Unknown result type (might be due to invalid IL or missing references)
				Vector3 item = val3 * (center - halfA - halfB);
				Vector3 item2 = val3 * (center - halfA + halfB);
				Vector3 item3 = val3 * (center + halfA + halfB);
				Vector3 item4 = val3 * (center + halfA - halfB);
				Vector3 val4 = Vector3.Cross(halfA, halfB);
				Vector3 val5 = val3 * ((Vector3)(ref val4)).normalized;
				(bool, Vector3)[] array2 = new(bool, Vector3)[2]
				{
					(false, val5),
					(true, -val5)
				};
				for (int n = 0; n < array2.Length; n++)
				{
					(bool, Vector3) tuple = array2[n];
					bool item5 = tuple.Item1;
					Vector3 item6 = tuple.Item2;
					int count = verts.Count;
					verts.Add(item);
					verts.Add(item2);
					verts.Add(item3);
					verts.Add(item4);
					for (int num5 = 0; num5 < 4; num5++)
					{
						norms.Add(item6);
						uvs.Add(uv);
					}
					if (item5)
					{
						tris.Add(count);
						tris.Add(count + 2);
						tris.Add(count + 1);
						tris.Add(count);
						tris.Add(count + 3);
						tris.Add(count + 2);
					}
					else
					{
						tris.Add(count);
						tris.Add(count + 1);
						tris.Add(count + 2);
						tris.Add(count);
						tris.Add(count + 2);
						tris.Add(count + 3);
					}
				}
			}
			Vector2 Uv(int x, int row)
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				return new Vector2(((float)(x * u) + 0.5f) / (float)w, ((float)(h - 1 - row * u) + 0.5f) / (float)h);
			}
		}

		internal static Material? MaterialFor(string textureKey)
		{
			Texture2D val = McAssets.Texture(textureKey);
			if (!((Object)(object)val == (Object)null))
			{
				return MaterialForTexture(val, textureKey);
			}
			return null;
		}

		internal static Material? MaterialForTexture(Texture2D tex, string cacheKey)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			if (Materials.TryGetValue(cacheKey, out Material value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Material val = Template();
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Material val2 = new Material(val)
			{
				name = "mc_mat_" + cacheKey
			};
			string[] array = new string[6] { "_NormalMap", "_MaskMap", "_EmissiveColorMap", "_DetailMap", "_BentNormalMap", "_SpecularColorMap" };
			foreach (string text in array)
			{
				if (val2.HasProperty(text))
				{
					val2.SetTexture(text, (Texture)null);
				}
			}
			val2.SetTexture("_BaseColorMap", (Texture)(object)tex);
			val2.SetColor("_BaseColor", Color.white);
			if (val2.HasProperty("_Metallic"))
			{
				val2.SetFloat("_Metallic", 0f);
			}
			if (val2.HasProperty("_Smoothness"))
			{
				val2.SetFloat("_Smoothness", 0.15f);
			}
			if (val2.HasProperty("_EmissiveColor"))
			{
				val2.SetColor("_EmissiveColor", Color.black);
			}
			val2.DisableKeyword("_NORMALMAP");
			val2.DisableKeyword("_MASKMAP");
			val2.DisableKeyword("_EMISSIVE_COLOR_MAP");
			Materials[cacheKey] = val2;
			return val2;
		}

		internal static Material? SolidMaterial(Color color)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			string text = "solid_" + ColorUtility.ToHtmlStringRGBA(color);
			if (Materials.TryGetValue(text, out Material value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Material val = Template();
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Material val2 = new Material(val)
			{
				name = "mc_mat_" + text
			};
			string[] array = new string[7] { "_BaseColorMap", "_NormalMap", "_MaskMap", "_EmissiveColorMap", "_DetailMap", "_BentNormalMap", "_SpecularColorMap" };
			foreach (string text2 in array)
			{
				if (val2.HasProperty(text2))
				{
					val2.SetTexture(text2, (Texture)null);
				}
			}
			val2.SetColor("_BaseColor", color);
			if (val2.HasProperty("_Metallic"))
			{
				val2.SetFloat("_Metallic", 0f);
			}
			if (val2.HasProperty("_Smoothness"))
			{
				val2.SetFloat("_Smoothness", 0f);
			}
			if (val2.HasProperty("_EmissiveColor"))
			{
				val2.SetColor("_EmissiveColor", Color.black);
			}
			val2.DisableKeyword("_NORMALMAP");
			val2.DisableKeyword("_MASKMAP");
			val2.DisableKeyword("_EMISSIVE_COLOR_MAP");
			Materials[text] = val2;
			return val2;
		}

		private static Material? Template()
		{
			if ((Object)(object)_template != (Object)null)
			{
				return _template;
			}
			List<Item> list = StartOfRound.Instance?.allItemsList?.itemsList;
			if (list == null)
			{
				return null;
			}
			string[] array = new string[3] { "Key", "Shovel", "Stun grenade" };
			foreach (string name in array)
			{
				Item? obj = ((IEnumerable<Item>)list).FirstOrDefault((Func<Item, bool>)((Item val2) => val2.itemName == name));
				object obj2;
				if (obj == null)
				{
					obj2 = null;
				}
				else
				{
					GameObject spawnPrefab = obj.spawnPrefab;
					obj2 = ((spawnPrefab != null) ? spawnPrefab.GetComponentInChildren<MeshRenderer>() : null);
				}
				MeshRenderer val = (MeshRenderer)obj2;
				if ((Object)(object)val != (Object)null && (Object)(object)((Renderer)val).sharedMaterial != (Object)null && ((Object)((Renderer)val).sharedMaterial.shader).name == "HDRP/Lit")
				{
					_template = ((Renderer)val).sharedMaterial;
					break;
				}
			}
			if ((Object)(object)_template == (Object)null)
			{
				MineCompany.Logger.LogError((object)"No vanilla HDRP/Lit material found for Minecraft items");
			}
			return _template;
		}
	}
	[BepInPlugin("nazarii.MineCompany", "MineCompany", "0.5.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class MineCompany : BaseUnityPlugin
	{
		public static MineCompany Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<int>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<int>();
			NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
			McConfig.Bind(((BaseUnityPlugin)this).Config);
			McAssets.Init(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location));
			McAssets.Preload(McContent.SoundsToPreload());
			McContent.RegisterAll();
			if (Harmony == null)
			{
				Harmony = new Harmony("nazarii.MineCompany");
			}
			Harmony.PatchAll();
			Logger.LogInfo((object)"nazarii.MineCompany v0.5.0 has loaded!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "nazarii.MineCompany";

		public const string PLUGIN_NAME = "MineCompany";

		public const string PLUGIN_VERSION = "0.5.0";
	}
}
namespace MineCompany.World
{
	internal static class McBlocks
	{
		internal readonly struct Faces
		{
			internal readonly string Front;

			internal readonly string Side;

			internal readonly string Top;

			internal readonly string Bottom;

			internal string Key => Front + "|" + Side + "|" + Top + "|" + Bottom;

			internal Faces(string front, string side, string top, string bottom)
			{
				Front = front;
				Side = side;
				Top = top;
				Bottom = bottom;
			}

			internal Faces(string all)
				: this(all, all, all, all)
			{
			}
		}

		private static Mesh? _cube;

		private static readonly Dictionary<string, Material?> Materials = new Dictionary<string, Material>();

		private static readonly Dictionary<string, Texture2D?> Atlases = new Dictionary<string, Texture2D>();

		internal static Mesh Cube => _cube ?? (_cube = BuildCube());

		private static Mesh BuildCube()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown resul