Decompiled source of HerobrineNotRemoved v1.0.6
plugins/HerobrineNotRemoved.dll
Decompiled 6 hours ago
The result has been truncated due to the large size, download it to view full contents!
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 System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("ManTrinket")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ManTrinket")] [assembly: AssemblyTitle("ManTrinket")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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; } } [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace HerobrineNotRemoved { internal sealed class Achievement { internal string id; internal string name; internal string about; internal string reward; internal string character; internal bool challenge; internal bool secret; } internal static class Achievements { [HarmonyPatch(typeof(CL_GameManager), "InitializeCommands")] private static class Command { private static void Postfix() { try { CommandConsole.AddCommand("hnr-giftlight", (Action<string[]>)delegate(string[] args) { CultureInfo invariantCulture = CultureInfo.InvariantCulture; if (args.Length != 0 && float.TryParse(args[0], NumberStyles.Float, invariantCulture, out var result)) { EndDimension.GiftLight = result; } if (args.Length > 1 && float.TryParse(args[1], NumberStyles.Float, invariantCulture, out var result2)) { EndDimension.GiftLightRange = result2; if ((Object)(object)EndDimension.GiftLamp != (Object)null) { EndDimension.GiftLamp.range = (EndDimension.GiftLamp.curRange = result2); } } CommandConsole.Log(string.Format("The trident's light: intensity {0}, range {1} ({2})", EndDimension.GiftLight, EndDimension.GiftLightRange, ((Object)(object)EndDimension.GiftLamp != (Object)null) ? "lit" : "not here")); }, true); CommandConsole.AddCommand("hnr_unlock_all", (Action<string[]>)delegate { foreach (Achievement item in All) { Grant(item.id, quiet: true); } CommandConsole.Log("Every achievement made, every character unlocked."); }, true); CommandConsole.AddCommand("hnr-forget", (Action<string[]>)delegate(string[] args) { string id = ((args != null && args.Length != 0) ? args[0] : ""); if (All.Find((Achievement a) => a.id == id) == null) { CommandConsole.Log("Achievements: " + string.Join(", ", All.ConvertAll((Achievement a) => a.id))); } else { CommandConsole.Log(HNRCharacters.ForgetAchievement(id) ? ("\"" + All.Find((Achievement a) => a.id == id).name + "\" unmade.") : "Not made yet."); } }, true); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[achievements] console: " + ex.Message)); } } } internal const string SeaGift = "sea_gift"; internal const string WhiteEyesBane = "white_eyes_bane"; internal const string AbyssAlex = "abyss_alex"; internal const string AbyssSteve = "abyss_steve"; internal const string Audience = "audience"; internal const string BazaarThief = "bazaar_thief"; internal static readonly List<Achievement> All = new List<Achievement> { new Achievement { id = "abyss_steve", name = "Never Gave Up", challenge = false, secret = false, reward = "jesse", about = "Reach the Abyss as Steve" }, new Achievement { id = "abyss_alex", name = "Sword First", challenge = false, secret = false, reward = "knight", about = "Reach the Abyss as Alex" }, new Achievement { id = "white_eyes_bane", name = "White Eyes Bane", challenge = true, secret = false, reward = "admin", about = "Bring down Herobrine in the Void's arena" }, Win("steve", "Home, at Last"), Win("alex", "No Regrets"), Win("knight", "Village Kept"), Win("jesse", "Hero Twice Over"), Win("derek", "Looked Away", secret: true), Win("popbob", "Duped Out", secret: true), Win("drowned", "Surfaced", secret: true), Win("admin", "Removal Complete"), new Achievement { id = "bazaar_thief", name = "Five Finger Discount", challenge = false, secret = true, reward = "popbob", about = "Leave the Bazaar with something you never paid for" }, new Achievement { id = "audience", name = "An Audience", challenge = true, secret = true, reward = "derek", about = "Be seen by the King in Yellow" }, new Achievement { id = "sea_gift", name = "Beneath It All", challenge = true, secret = true, reward = "drowned", about = "Pull the trident from the very bottom of the Void's island" } }; private static AudioClip chime; private static bool loading; internal static string Section(Achievement a) { if (a.character == null) { if (!a.secret) { return "MAIN"; } return "SECRET"; } return "ESCAPE"; } private static Achievement Win(string who, string name, bool secret = false) { HNRCharacters.Character character = HNRCharacters.All.Find((HNRCharacters.Character x) => x.id == who); return new Achievement { id = "win_" + who, name = name, challenge = true, secret = secret, character = who, about = "Go home as " + ((character != null) ? (character.callName ?? character.name) : who) }; } internal static Achievement WinOf(string who) { return All.Find((Achievement a) => a.character == who); } internal static bool Has(string id) { return HNRCharacters.HasAchievement(id); } private static IEnumerator LoadChime() { string text = Path.Combine(HNRMenu.Dir, "challenge_complete.ogg"); if (!File.Exists(text)) { yield break; } UnityWebRequest r = UnityWebRequestMultimedia.GetAudioClip("file://" + text, (AudioType)14); try { yield return r.SendWebRequest(); if ((int)r.result == 1) { chime = DownloadHandlerAudioClip.GetContent(r); } } finally { ((IDisposable)r)?.Dispose(); } } internal static void Preload() { if (!loading && (Object)(object)Plugin.Instance != (Object)null) { loading = true; ((MonoBehaviour)Plugin.Instance).StartCoroutine(LoadChime()); } } internal static void Grant(string id, bool quiet = false, float after = 0f) { Achievement achievement = All.Find((Achievement x) => x.id == id); if (achievement == null || Has(id)) { return; } HNRCharacters.AddAchievement(id, achievement.reward); Plugin.Log.LogInfo((object)("[achievements] made: " + achievement.name)); if (!quiet) { Preload(); if (after > 0f && (Object)(object)Plugin.Instance != (Object)null) { ((MonoBehaviour)Plugin.Instance).StartCoroutine(TellLater(achievement, after)); } else { Tell(achievement); } } } private static IEnumerator TellLater(Achievement a, float after) { yield return (object)new WaitForSeconds(after); Tell(a); } private static void Tell(Achievement a) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) ENT_Player pl = ENT_Player.playerObject; string text = "Steve"; HNRCharacters.Character character = HNRCharacters.All.Find((HNRCharacters.Character x) => x.id == HNRCharacters.IdOf(pl)); if (character != null) { text = character.callName ?? character.name; } MCChat.Add(a.challenge ? (text + " has completed the challenge §5[" + a.name + "]") : (text + " has reached the goal §a[" + a.name + "]"), Color.white); HNRCharacters.Character character2 = HNRCharacters.All.Find((HNRCharacters.Character x) => x.id == a.reward); if (character2 != null) { MCChat.Add("§eUnlocked: " + character2.name, Color.white); } if ((Object)(object)chime != (Object)null) { HerobrineFX.Play2D((AudioClip[])(object)new AudioClip[1] { chime }, 0.6f); } else if ((Object)(object)Plugin.Instance != (Object)null) { ((MonoBehaviour)Plugin.Instance).StartCoroutine(ChimeWhenLoaded()); } } private static IEnumerator ChimeWhenLoaded() { for (int i = 0; i < 60; i++) { if (!((Object)(object)chime == (Object)null)) { break; } yield return null; } if ((Object)(object)chime != (Object)null) { HerobrineFX.Play2D((AudioClip[])(object)new AudioClip[1] { chime }, 0.6f); } } internal static void ResetAll() { HNRCharacters.ResetProgress(); Plugin.Log.LogInfo((object)"[achievements] all reset"); } } public class SeaGift : MonoBehaviour { private const int Frames = 24; private const float Pulse = 2.6f; internal static readonly Color Violet = new Color(0.62f, 0.3f, 1f); internal CL_Lamp lamp; private static Texture2D[] glow; private static Sprite[] omen; private Material mat; private float nextOmen; private void Start() { //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Expected O, but got Unknown Transform val = ((Component)this).transform.Find("SpearVoxels"); Renderer val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Renderer>() : null); if ((Object)(object)val2 != (Object)null && (Object)(object)Trident.Model != (Object)null && (Object)(object)MCItems.WorldMat != (Object)null) { if (glow == null) { glow = (Texture2D[])(object)new Texture2D[24]; Color32[] pixels = Trident.Model.GetPixels32(); for (int i = 0; i < 24; i++) { float num = 0.35f + 0.45f * (0.5f + 0.5f * Mathf.Sin((float)i / 24f * MathF.PI * 2f)); Color32[] array = (Color32[])(object)new Color32[pixels.Length]; for (int j = 0; j < pixels.Length; j++) { Color val3 = Color32.op_Implicit(pixels[j]); float num2 = (val3.r + val3.g + val3.b) / 3f; Color val4 = Color.Lerp(val3 * 0.4f, Violet * (0.4f + 0.8f * num2), 0.75f) * num; array[j] = Color32.op_Implicit(new Color(val4.r, val4.g, val4.b, val3.a)); } glow[i] = new Texture2D(((Texture)Trident.Model).width, ((Texture)Trident.Model).height, (TextureFormat)4, false) { filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)1 }; glow[i].SetPixels32(array); glow[i].Apply(false); } } mat = new Material(MCItems.WorldMat) { name = "sea_gift", mainTexture = (Texture)(object)Trident.Model }; val2.sharedMaterial = mat; } if (omen == null) { Texture2D val5 = MinerPickaxe.Load(Path.Combine(Plugin.AssetDir, "miner", "trident", "omen.png")); omen = (Sprite[])(object)((!((Object)(object)val5 != (Object)null)) ? new Sprite[0] : new Sprite[1] { Sprite.Create(val5, new Rect(0f, 0f, (float)((Texture)val5).width, (float)((Texture)val5).height), new Vector2(0.5f, 0.5f), (float)((Texture)val5).width) }); } } private void Update() { //IL_00ae: 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_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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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) //IL_0137: 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_014c: Unknown result type (might be due to invalid IL or missing references) int num = (int)(Time.time / 2.6f * 24f) % 24; if ((Object)(object)mat != (Object)null && glow != null && mat.HasProperty("_Emission")) { mat.SetTexture("_Emission", (Texture)(object)glow[num]); } if ((Object)(object)lamp != (Object)null) { lamp.intensity = EndDimension.GiftLight; } if (omen.Length != 0 && Time.time >= nextOmen) { nextOmen = Time.time + Random.Range(0.25f, 0.6f); Vector3 at = ((Component)this).transform.position - ((Component)this).transform.forward * Random.Range(0.3f, 2.2f) + Random.insideUnitSphere * 0.3f; MCParticles.Sprite(omen, at, (Random.insideUnitSphere * 0.01f - Vector3.up * 0.01f) * 1.25f, -0.01f, 0.96f, Random.Range(20, 40), 0.08f, Color.Lerp(Violet, Color.white, Random.value * 0.3f)); } } private void OnDestroy() { if (!((Object)(object)lamp == (Object)null)) { GiftLightFade component = ((Component)lamp).GetComponent<GiftLightFade>(); if ((Object)(object)component != (Object)null) { component.Begin(); } } } } public class GiftLightFade : MonoBehaviour { private const float Time3 = 3f; private CL_Lamp lamp; private float from; private float t = -1f; internal void Begin() { lamp = ((Component)this).GetComponent<CL_Lamp>(); if (!((Object)(object)lamp == (Object)null) && !(t >= 0f)) { from = lamp.intensity; t = 0f; } } private void Update() { if (t < 0f || (Object)(object)lamp == (Object)null) { return; } t += Time.deltaTime; float num = Mathf.Clamp01(t / 3f); lamp.intensity = from * (1f - Mathf.SmoothStep(0f, 1f, num)); if (!(num < 1f)) { EndDimension.Lamps.Remove(lamp); if ((Object)(object)EndDimension.GiftLamp == (Object)(object)lamp) { EndDimension.GiftLamp = null; } Object.Destroy((Object)(object)((Component)this).gameObject); } } } public class AbyssWatch : MonoBehaviour { private float next; internal static void Ensure(GameObject host) { if ((Object)(object)host.GetComponent<AbyssWatch>() == (Object)null) { host.AddComponent<AbyssWatch>(); } } private void Update() { if (Time.unscaledTime < next) { return; } next = Time.unscaledTime + 1f; M_Region currentRegion = CL_EventManager.currentRegion; ENT_Player playerObject = ENT_Player.playerObject; if (!((Object)(object)currentRegion == (Object)null) && !((Object)(object)playerObject == (Object)null) && !((GameEntity)playerObject).dead && ((Object)currentRegion).name.IndexOf("Abyss", StringComparison.OrdinalIgnoreCase) >= 0) { string text = HNRCharacters.IdOf(playerObject); if (text == "alex") { Achievements.Grant("abyss_alex"); } else if (text == "steve") { Achievements.Grant("abyss_steve"); } } } } internal static class AdminHands { [HarmonyPatch(typeof(CL_CosmeticManager), "GetCosmeticInHand")] private static class ChoicePatch { private static void Postfix(ref Cosmetic_HandItem __result) { try { if ((Object)(object)__result != (Object)null && ((Cosmetic_Base)__result).cosmeticInfo != null && Locked.Contains(((Cosmetic_Base)__result).cosmeticInfo.id)) { __result = null; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[hands] choice: " + ex.Message)); } } } internal const string RightId = "admin_hands"; internal const string LeftId = "admin_hands_left"; private static readonly HashSet<string> Locked = new HashSet<string> { "admin_hands", "admin_hands_left", "miner_steve", "alex_hands", "oxide_hands", "oxide_hands_left", "jesse_hands", "jesse_hands_left", "drowned_hands", "drowned_hands_left", "derek_hands", "derek_hands_left", "popbob_hands" }; private static readonly FieldRef<Dictionary<string, Cosmetic_HandItem>> Dict = AccessTools.StaticFieldRefAccess<Dictionary<string, Cosmetic_HandItem>>(AccessTools.Field(typeof(CL_CosmeticManager), "cosmeticHandDict")); private static Cosmetic_HandItem Find(string id) { Dictionary<string, Cosmetic_HandItem> dictionary = Dict.Invoke(); if (dictionary == null || !dictionary.TryGetValue(id, out var value)) { return null; } return value; } internal static void HideOurs() { try { int num = 0; foreach (string item in Locked) { Cosmetic_HandItem val = Find(item); if ((Object)(object)val != (Object)null) { ((Cosmetic_Base)val).showInCosmeticsWindow = false; num++; } } Plugin.Log.LogInfo((object)$"[hands] {num} of the characters' hands kept out of the cosmetics window (of {Locked.Count})"); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[hands] hide: " + ex.Message)); } } } internal static class BobHearts { [HarmonyPatch(typeof(ENT_Player), "Damage")] [HarmonyPriority(200)] private static class ShieldPatch { private static bool Prefix(ENT_Player __instance, DamageInfo info, bool __runOriginal) { if (!__runOriginal) { return false; } if (info == null || info.amount <= 0f || ((GameEntity)__instance).dead || ((GameEntity)__instance).maxHealth <= 0f || !Is(__instance)) { return true; } float num = info.amount * 20f / ((GameEntity)__instance).maxHealth; float num2 = 0f; int num3 = 4; while (num3 >= 0 && num > 0f) { float num4 = Mathf.Min(value[num3], num); if (!(num4 <= 0f)) { value[num3] -= num4; num -= num4; num2 += num4; glitchUntil[num3] = Time.time + 0.35f; } num3--; } if (num2 > 0f) { Plugin.Log.LogInfo((object)$"[bob] the trollfaces took {num2:0.#} of it, {num:0.#} left for him"); } if (num <= 0.0001f) { return false; } info.amount = num * ((GameEntity)__instance).maxHealth / 10f; return true; } } [HarmonyPatch(typeof(ENT_Player), "Heal")] private static class HealPatch { private static void Prefix(ENT_Player __instance, ref float amount) { if (amount > 0f && Is(__instance)) { amount *= 2f; } } } private const int Count = 5; private const float JumpMin = 4f; private const float JumpMax = 6f; private const float GlitchTime = 0.35f; private static readonly float[] value = new float[5]; private static readonly float[] nextJump = new float[5]; private static readonly float[] glitchUntil = new float[5]; private static Texture2D full; private static Texture2D half; private static Texture2D container; private static Texture2D glitch; internal const float Points = 10f; internal static bool Is(ENT_Player pl) { if ((Object)(object)pl != (Object)null && (Object)(object)pl == (Object)(object)ENT_Player.playerObject) { return HNRCharacters.IdOf(pl) == "popbob"; } return false; } internal static void Tick(ENT_Player pl) { float time = Time.time; for (int i = 0; i < 5; i++) { if (time >= nextJump[i]) { nextJump[i] = time + Random.Range(4f, 6f); value[i] = Random.Range(0, 3); glitchUntil[i] = time + 0.35f; } } } internal static void Draw(int slot, float x, float y) { if ((Object)(object)full == (Object)null) { string path = Path.Combine(HNRMenu.Dir, "characters", "popbob"); full = MinerPickaxe.Load(Path.Combine(path, "heart_troll_full.png")); half = MinerPickaxe.Load(Path.Combine(path, "heart_troll_half.png")); container = MinerPickaxe.Load(Path.Combine(path, "heart_troll_container.png")); glitch = MinerPickaxe.Load(Path.Combine(path, "heart_troll_glitch.png")); } int num; if (!(Time.time < glitchUntil[slot])) { num = ((Random.value < 0.006f) ? 1 : 0); if (num == 0) { goto IL_00ac; } } else { num = 1; } x += (float)Random.Range(-1, 2); y += (float)Random.Range(-1, 2); goto IL_00ac; IL_00ac: MCAssets.Blit(container, x, y, 9f, 9f); if (num != 0 && Random.value < 0.5f) { MCAssets.Blit((Random.value < 0.5f) ? glitch : ((Random.value < 0.5f) ? full : half), x, y, 9f, 9f); return; } int num2 = Mathf.CeilToInt(value[slot] - 0.001f); if (num2 >= 2) { MCAssets.Blit(full, x, y, 9f, 9f); } else if (num2 == 1) { MCAssets.Blit(half, x, y, 9f, 9f); } } } internal static class BobPortrait { private const int Cols = 16; private const int Rows = 20; private const int Cells = 320; private static Texture2D troll; private static int[] src; private static Vector2[] slip; private static bool[] trollBlock; private static float nextTick; private static float nextTroll; private static float trollUntil; private static bool trollWhole; internal static void Draw(Rect r, Texture2D picture) { //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)picture == (Object)null) { return; } if (src == null) { src = new int[320]; slip = (Vector2[])(object)new Vector2[320]; trollBlock = new bool[320]; for (int i = 0; i < 320; i++) { src[i] = i; } troll = MinerPickaxe.Load(Path.Combine(HNRMenu.Dir, "characters", "popbob", "trollface.png")); nextTroll = Time.unscaledTime + Random.Range(2f, 5f); } float unscaledTime = Time.unscaledTime; if (unscaledTime >= nextTick) { nextTick = unscaledTime + Random.Range(0.04f, 0.12f); Break(); } if (unscaledTime >= nextTroll) { nextTroll = unscaledTime + Random.Range(2.5f, 7f); trollUntil = unscaledTime + Random.Range(0.1f, 0.45f); trollWhole = Random.value < 0.45f; int num = Random.Range(0, 16); int num2 = Random.Range(0, 20); int num3 = Random.Range(2, 6); for (int j = 0; j < 320; j++) { trollBlock[j] = Mathf.Abs(j % 16 - num) + Mathf.Abs(j / 16 - num2) <= num3 || Random.value < 0.04f; } } bool flag = (Object)(object)troll != (Object)null && unscaledTime < trollUntil; if (flag && trollWhole) { GUI.DrawTexture(r, (Texture)(object)troll, (ScaleMode)2); return; } float num4 = ((Rect)(ref r)).width / 16f; float num5 = ((Rect)(ref r)).height / 20f; Rect val = default(Rect); for (int k = 0; k < 320; k++) { if (src[k] >= 0) { int num6 = k % 16; int num7 = k / 16; ((Rect)(ref val))..ctor(((Rect)(ref r)).x + (float)num6 * num4, ((Rect)(ref r)).y + (float)num7 * num5, num4 + 0.6f, num5 + 0.6f); if (flag && trollBlock[k]) { GUI.DrawTextureWithTexCoords(val, (Texture)(object)troll, new Rect((float)num6 / 16f, 1f - (float)(num7 + 1) / 20f, 0.0625f, 0.05f)); continue; } float num8 = (float)(src[k] % 16) + slip[k].x; float num9 = (float)(src[k] / 16) + slip[k].y; GUI.DrawTextureWithTexCoords(val, (Texture)(object)picture, new Rect(num8 / 16f, 1f - (num9 + 1f) / 20f, 0.0625f, 0.05f)); } } } private static void Break() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 10; i++) { int num = Random.Range(0, 320); src[num] = num; slip[num] = Vector2.zero; } for (int num2 = Random.Range(0, 4); num2 > 0; num2--) { int num3 = Random.Range(0, 320); int num4 = ((Random.value < 0.6f) ? Mathf.Clamp(num3 + Random.Range(-2, 3) + 16 * Random.Range(-2, 3), 0, 319) : Random.Range(0, 320)); ref int reference = ref src[num3]; ref int reference2 = ref src[num4]; int num5 = src[num4]; int num6 = src[num3]; reference = num5; reference2 = num6; } for (int num7 = Random.Range(0, 4); num7 > 0; num7--) { src[Random.Range(0, 320)] = -1; } for (int num8 = Random.Range(0, 5); num8 > 0; num8--) { slip[Random.Range(0, 320)] = new Vector2(Random.Range(-0.5f, 0.5f), Random.Range(-0.3f, 0.3f)); } if (!(Random.value < 0.12f)) { return; } int num9 = Random.Range(0, 20); int num10 = Random.Range(1, 4); int num11 = Random.Range(-3, 4); for (int j = num9; j < Mathf.Min(20, num9 + num10); j++) { for (int k = 0; k < 16; k++) { int num12 = j * 16 + k; int num13 = j * 16 + ((k + num11) % 16 + 16) % 16; src[num12] = num13; } } } } internal static class BrianKiller { internal const string Prefab = "brian_killer"; internal const string PhaseEnder = "phase_ender"; private static readonly Color PhaseColour = new Color(0.42f, 0.08f, 0.7f); private static Material Tint(Material from, string prefab, Color colour) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_001b: 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_0023: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_00be: 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_00b7: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); Color32 val2 = Color32.op_Implicit(colour); val.SetPixels32((Color32[])(object)new Color32[4] { val2, val2, val2, val2 }); val.Apply(false); Material val3 = (((Object)(object)from != (Object)null) ? new Material(from) : new Material(Shader.Find("Standard"))); ((Object)val3).name = prefab + "_tint"; val3.mainTexture = (Texture)(object)val; if (val3.HasProperty("_Color")) { val3.color = colour; } if (val3.HasProperty("_EmissionColor")) { val3.SetColor("_EmissionColor", (colour == Color.black) ? Color.black : (colour * 0.4f)); } return val3; } private static void Blacken(GameObject go, string prefab, Color colour) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) MeshRenderer[] componentsInChildren = go.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val in componentsInChildren) { Material[] sharedMaterials = ((Renderer)val).sharedMaterials; for (int j = 0; j < sharedMaterials.Length; j++) { sharedMaterials[j] = Tint(sharedMaterials[j], prefab, colour); } ((Renderer)val).sharedMaterials = sharedMaterials; } } internal static void Register(List<WKDatabaseHolder> holders, WKDatabaseHolder target, Transform container) { //IL_0008: 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) Make(holders, target, container, "brian_killer", Color.black); Make(holders, target, container, "phase_ender", PhaseColour); } private static void Make(List<WKDatabaseHolder> holders, WKDatabaseHolder target, Transform container, string Prefab, Color colour) { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) GameObject val = MinerPickaxe.FindItem(holders, "Item_Rebar"); HandItem_Shoot val2 = (HandItem_Shoot)(((Object)(object)val != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogWarning((object)"[brian_killer] no rebar donor"); return; } GameObject val3 = Object.Instantiate<GameObject>(val, container); ((Object)val3).name = Prefab; Item_Object component = val3.GetComponent<Item_Object>(); Item itemData = component.itemData; itemData.prefabName = Prefab; itemData.itemName = Prefab; itemData.itemAsset = component; itemData.allowCosmetics = false; itemData.itemTags = new List<string>(itemData.itemTags ?? new List<string>()) { "debug" }; CL_Prop component2 = val3.GetComponent<CL_Prop>(); if ((Object)(object)component2 != (Object)null) { ((GameEntity)component2).entityPrefabID = Prefab; } Blacken(val3, Prefab, colour); GameObject val4 = null; if ((Object)(object)val2.projectile != (Object)null) { val4 = Object.Instantiate<GameObject>(val2.projectile, container); ((Object)val4).name = "Projectile_" + Prefab; Blacken(val4, Prefab, colour); Projectile component3 = val4.GetComponent<Projectile>(); if ((Object)(object)component3 != (Object)null && (Object)(object)component3.hitEffect != (Object)null) { GameObject val5 = Object.Instantiate<GameObject>(component3.hitEffect, container); ((Object)val5).name = Prefab + "_stuck"; Blacken(val5, Prefab, colour); component3.hitEffect = val5; } } GameObject val6 = Object.Instantiate<GameObject>(((Component)val2).gameObject, container); ((Object)val6).name = "Item_Hands_" + Prefab; SpriteRenderer[] componentsInChildren = val6.GetComponentsInChildren<SpriteRenderer>(true); foreach (SpriteRenderer val7 in componentsInChildren) { if ((Object)(object)val7.sprite != (Object)null && ((Object)val7.sprite).name.StartsWith("Item_Hands_Rebar")) { val7.color = colour; } } HandItem_Shoot component4 = val6.GetComponent<HandItem_Shoot>(); if ((Object)(object)val4 != (Object)null) { component4.projectile = val4; } itemData.handItemAsset = (HandItem)(object)component4; target.database.itemPrefabs.Add(val3); target.RefreshDictionary(); Plugin.Log.LogInfo((object)("[" + Prefab + "] registered: spawnitem " + Prefab)); } } internal static class CombatFatigue { [HarmonyPatch(typeof(HandItem_Melee), "StartUse")] private static class GameSwing { private static void Prefix(HandItem_Melee __instance) { if (!(__instance is MCToolMelee) && MinerInv.Active) { factor[__instance] = Swing(__instance); } } } [HarmonyPatch(typeof(HandItem_Melee), "Hit")] private static class GameBlow { private static void Prefix(HandItem_Melee __instance, out (float damage, float charged)? __state) { __state = null; if (!(__instance is MCToolMelee) && factor.TryGetValue(__instance, out var value) && !(value >= 1f)) { __state = (__instance.damage, __instance.chargeAttackDamage); __instance.damage *= value; __instance.chargeAttackDamage *= value; factor.Remove(__instance); } } private static void Finalizer(HandItem_Melee __instance, (float damage, float charged)? __state) { if (__state.HasValue) { __instance.damage = __state.Value.damage; __instance.chargeAttackDamage = __state.Value.charged; } } } private static readonly FieldRef<HandItem_Melee, bool> Charging = AccessTools.FieldRefAccess<HandItem_Melee, bool>("isCharging"); private static readonly float[] since = new float[2] { 99f, 99f }; private static readonly HandItem[] holding = (HandItem[])(object)new HandItem[2]; private static ENT_Player player; private static Texture2D barBack; private static Texture2D barFill; private const float GameMeleeSpeed = 1.6f; private const float RapierSpeed = 1.2f; private const float Gap = 30f; private static readonly Dictionary<HandItem_Melee, float> factor = new Dictionary<HandItem_Melee, float>(); internal static readonly Dictionary<string, (float damage, float charged)> GameMelee = new Dictionary<string, (float, float)>(); internal static float Speed(MinerPickaxe.Tier t) { if (t == null) { return 4f; } string text = t.stats ?? t.material; switch (t.kind) { case MinerPickaxe.Kind.Sword: return 1.6f; case MinerPickaxe.Kind.Pickaxe: return 1.2f; case MinerPickaxe.Kind.Shovel: return 1f; case MinerPickaxe.Kind.Axe: switch (text) { default: return 0.8f; case "golden": case "diamond": case "netherite": return 1f; case "iron": return 0.9f; } case MinerPickaxe.Kind.Hoe: switch (text) { default: return 4f; case "iron": return 3f; case "stone": case "copper": return 2f; case "wooden": case "golden": return 1f; } default: return 1.1f; } } private static int HandIndex(HandItem hi) { ENT_Player playerObject = ENT_Player.playerObject; if (playerObject?.hands == null || (Object)(object)hi == (Object)null) { return -1; } for (int i = 0; i < playerObject.hands.Length && i < 2; i++) { if (playerObject.hands[i] == ((Hand_Base)hi).hand) { return i; } } return -1; } internal static float Speed(HandItem_Melee m) { if (m is MCToolMelee mCToolMelee) { return Speed(MinerPickaxe.TierByKey(mCToolMelee.tierKey)); } if (m is HandItem_Melee_Rapier) { return 1.2f; } string text = ((HandItem)m).item?.prefabName; float num; if (text != null && GameMelee.TryGetValue(text, out (float, float) value)) { (num, _) = value; } else { num = m.damage; } float num2 = num; return Mathf.Clamp(1.6f / Mathf.Max(0.1f, num2), 0.5f, 2.5f); } private static float Strength(int h, HandItem_Melee m) { float num = 1f / Mathf.Max(0.1f, Speed(m)); return Mathf.Clamp01((since[h] + 0.025f) / num); } internal static void Tick() { ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject != (Object)(object)player) { player = playerObject; since[0] = (since[1] = 99f); holding[0] = (holding[1] = null); } if (playerObject?.hands == null) { return; } for (int i = 0; i < 2 && i < playerObject.hands.Length; i++) { HandItem val = null; try { Hand obj = playerObject.hands[i]; val = ((obj != null) ? obj.GetHandItem() : null); } catch { } if ((Object)(object)val != (Object)(object)holding[i]) { holding[i] = val; since[i] = 0f; } HandItem_Melee val2 = (HandItem_Melee)(object)((val is HandItem_Melee) ? val : null); if (val2 == null || !Charging.Invoke(val2)) { since[i] = Mathf.Min(since[i] + Time.deltaTime, 99f); } } } internal static float Swing(HandItem_Melee m) { if (!MinerInv.Active) { return 1f; } int num = HandIndex((HandItem)(object)m); if (num < 0) { return 1f; } float num2 = Strength(num, m); since[num] = 0f; return 0.2f + 0.8f * num2 * num2; } internal static void DrawHud(float w, float hgt) { ENT_Player playerObject = ENT_Player.playerObject; if (playerObject?.hands == null || ((GameEntity)playerObject).dead || !MinerInv.Active) { return; } if ((Object)(object)barBack == (Object)null) { barBack = MCAssets.Load("crosshair_attack_indicator_background.png"); barFill = MCAssets.Load("crosshair_attack_indicator_progress.png"); } if ((Object)(object)barBack == (Object)null || (Object)(object)barFill == (Object)null) { return; } float num = Mathf.Floor(w / 2f); float num2 = Mathf.Floor(hgt / 2f); for (int i = 0; i < 2 && i < playerObject.hands.Length; i++) { HandItem obj = holding[i]; HandItem_Melee val = (HandItem_Melee)(object)((obj is HandItem_Melee) ? obj : null); if (val == null) { continue; } float num3 = Strength(i, val); if (!(num3 >= 1f)) { float x = ((i == 0) ? (num - 30f - 16f) : (num + 30f)); float y = num2 - 2f; MCAssets.Blit(barBack, x, y, 16f, 4f); int num4 = Mathf.Min(16, (int)(num3 * 17f)); if (num4 > 0) { MCAssets.Blit(barFill, x, y, 0f, 0f, num4, 4f); } } } } internal static void Survey(List<WKDatabaseHolder> holders) { try { foreach (WKDatabaseHolder holder in holders) { if (holder?.database?.itemPrefabs == null) { continue; } foreach (GameObject itemPrefab in holder.database.itemPrefabs) { HandItem obj = ((!((Object)(object)itemPrefab != (Object)null)) ? null : itemPrefab.GetComponent<Item_Object>()?.itemData)?.handItemAsset; HandItem_Melee val = (HandItem_Melee)(object)((obj is HandItem_Melee) ? obj : null); if (val != null && !(val is MCToolMelee) && !GameMelee.ContainsKey(((Object)itemPrefab).name)) { GameMelee[((Object)itemPrefab).name] = (val.damage, val.chargeAttackDamage); } } } Plugin.Log.LogInfo((object)($"[fatigue] {GameMelee.Count} of the game's melee items: " + string.Join(", ", GameMelee.Select((KeyValuePair<string, (float damage, float charged)> kv) => $"{kv.Key} {kv.Value.damage}")))); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[fatigue] survey: " + ex.Message)); } } } internal static class CommandBlock { internal const string Prefab = "Item_CommandBlock"; internal const string HeldId = "cmd:command_block"; internal static Item_Object Obj; private static Texture2D atlas; private static Texture2D stone; private static Mesh cube; internal static AudioClip[] Dig = (AudioClip[])(object)new AudioClip[0]; internal static AudioClip[] Click = (AudioClip[])(object)new AudioClip[0]; internal static AudioClip[] Orb = (AudioClip[])(object)new AudioClip[0]; private static Sprite[] heart; private static AudioSource flat; internal static string Dir => Path.Combine(Plugin.AssetDir, "miner", "command_block"); internal static Texture2D Stone { get { if (!((Object)(object)stone != (Object)null)) { return stone = MinerPickaxe.Load(Path.Combine(Dir, "stone.png")); } return stone; } } internal static Mesh Cube(int frontTile = 0, int backTile = 1, int sideTile = 2, int tiles = 3) { //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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_00db: Expected O, but got Unknown List<Vector3> v = new List<Vector3>(); List<Vector2> uv = new List<Vector2>(); List<int> t = new List<int>(); Face(Vector3.forward, Vector3.up, frontTile); Face(Vector3.back, Vector3.up, backTile); Face(Vector3.right, Vector3.up, sideTile); Face(Vector3.left, Vector3.up, sideTile); Face(Vector3.up, Vector3.forward, sideTile); Face(Vector3.down, Vector3.back, sideTile); Mesh val = new Mesh { name = "mc_cube" }; val.SetVertices(v); val.SetUVs(0, uv); val.SetTriangles(t, 0); val.RecalculateNormals(); val.RecalculateBounds(); return val; void Face(Vector3 n, Vector3 up, int tile) { //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_0007: 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_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_0026: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00ab: 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_00b6: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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) Vector3 val2 = Vector3.Cross(n, up); Vector3 val3 = n * 0.5f; int count = v.Count; v.Add(val3 - val2 * 0.5f - up * 0.5f); v.Add(val3 + val2 * 0.5f - up * 0.5f); v.Add(val3 + val2 * 0.5f + up * 0.5f); v.Add(val3 - val2 * 0.5f + up * 0.5f); float num = (float)tile / (float)tiles; float num2 = (float)(tile + 1) / (float)tiles; uv.Add(new Vector2(num, 0f)); uv.Add(new Vector2(num2, 0f)); uv.Add(new Vector2(num2, 1f)); uv.Add(new Vector2(num, 1f)); t.AddRange(new int[6] { count, count + 2, count + 1, count, count + 3, count + 2 }); } } internal static GameObject Body(float size) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown if ((Object)(object)atlas == (Object)null) { atlas = MinerPickaxe.Load(Path.Combine(Dir, "atlas.png")); } if ((Object)(object)cube == (Object)null) { cube = Cube(); } GameObject val = new GameObject("CommandBlockBody"); val.AddComponent<MeshFilter>().sharedMesh = cube; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = MCItems.TexturedMat(atlas, cutout: false); val.transform.localScale = Vector3.one * size; return val; } internal static void Register(List<WKDatabaseHolder> holders, WKDatabaseHolder target, Transform container) { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) GameObject val = MinerPickaxe.FindItem(holders, "Item_Hammer"); if ((Object)(object)val == (Object)null) { return; } MCItems.CustomBodies["cmd:command_block"] = () => Body(0.32f); GameObject val2 = Object.Instantiate<GameObject>(val, container); ((Object)val2).name = "Item_CommandBlock"; Item_Object component = val2.GetComponent<Item_Object>(); Item itemData = component.itemData; itemData.prefabName = "Item_CommandBlock"; itemData.itemAsset = component; itemData.allowCosmetics = false; itemData.itemName = "Command Block"; itemData.itemTags = new List<string> { "commandblock" }; itemData.data = new List<string>(); itemData.upDirection = Vector3.forward; Texture2D val3 = MinerPickaxe.Load(Path.Combine(Dir, "icon.png")); if ((Object)(object)val3 != (Object)null) { itemData.normalSprite = Sprite.Create(val3, new Rect(0f, 0f, (float)((Texture)val3).width, (float)((Texture)val3).height), new Vector2(0.5f, 0.5f), (float)((Texture)val3).width * 4f); } Renderer[] componentsInChildren = val2.GetComponentsInChildren<Renderer>(true); for (int num = 0; num < componentsInChildren.Length; num++) { componentsInChildren[num].enabled = false; } Collider[] componentsInChildren2 = val2.GetComponentsInChildren<Collider>(true); for (int num = 0; num < componentsInChildren2.Length; num++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[num]); } GameObject obj = Body(0.32f); obj.transform.SetParent(val2.transform, false); obj.layer = val2.layer; val2.AddComponent<BoxCollider>().size = Vector3.one * 0.32f; HandItem val4 = MCItems.BuddyHandFor("cmd:command_block", "CommandBlock", container); if ((Object)(object)val4 != (Object)null) { itemData.handItemAsset = val4; } target.database.itemPrefabs.Add(val2); target.RefreshDictionary(); Obj = component; if ((Object)(object)Plugin.Instance != (Object)null) { string dir = Path.Combine(Plugin.AssetDir, "miner", "herobrine"); ((MonoBehaviour)Plugin.Instance).StartCoroutine(LoadSet(dir, "dig_stone", 4, delegate(AudioClip[] c) { Dig = c; })); ((MonoBehaviour)Plugin.Instance).StartCoroutine(LoadSet(Dir, "click", 1, delegate(AudioClip[] c) { Click = c; })); ((MonoBehaviour)Plugin.Instance).StartCoroutine(LoadSet(Dir, "orb", 1, delegate(AudioClip[] c) { Orb = c; })); } Plugin.Log.LogInfo((object)"[cmd] command block registered"); } private static IEnumerator LoadSet(string dir, string name, int n, Action<AudioClip[]> done) { List<AudioClip> l = new List<AudioClip>(); for (int i = 1; i <= n; i++) { string text = Path.Combine(dir, $"{name}{i}.ogg"); if (!File.Exists(text)) { continue; } UnityWebRequest r = UnityWebRequestMultimedia.GetAudioClip("file://" + text, (AudioType)14); try { yield return r.SendWebRequest(); if ((int)r.result == 1) { l.Add(DownloadHandlerAudioClip.GetContent(r)); } } finally { ((IDisposable)r)?.Dispose(); } } done(l.ToArray()); } internal static void Play2D(AudioClip[] set, float vol, float pitch = 1f) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown if (set != null && set.Length != 0 && !((Object)(object)Plugin.Instance == (Object)null)) { if ((Object)(object)flat == (Object)null) { GameObject val = new GameObject("CommandBlockSound"); Object.DontDestroyOnLoad((Object)val); flat = val.AddComponent<AudioSource>(); flat.playOnAwake = false; flat.spatialBlend = 0f; flat.ignoreListenerPause = true; } if ((Object)(object)flat.outputAudioMixerGroup == (Object)null && (Object)(object)AudioManager.instance != (Object)null) { flat.outputAudioMixerGroup = AudioManager.instance.gameMixer; } flat.pitch = pitch; SafeAudio.OneShot(flat, set[Random.Range(0, set.Length)], vol); } } internal static void Fail() { Play2D(Click, 0.6f, 1.2f); } internal static void Hearts(ENT_Player pl) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_0062: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: 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_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //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_01d2: 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_01ed: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)pl.cCon == (Object)null) { return; } if (heart == null) { Texture2D val = MinerPickaxe.Load(Path.Combine(MCEffects.Dir, "heart.png")); heart = (Sprite[])(object)((!((Object)(object)val != (Object)null)) ? new Sprite[0] : new Sprite[1] { 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) }); } if (heart.Length == 0) { return; } Bounds bounds = ((Collider)pl.cCon).bounds; float cell = 1.25f; float x = ((Bounds)(ref bounds)).extents.x; for (int i = 0; i < 9; i++) { One(new Vector3(((Bounds)(ref bounds)).center.x + (Random.value * 2f - 1f) * x * 1.6f, ((Bounds)(ref bounds)).min.y + 0.5f * cell * 0.6f + Random.value * ((Bounds)(ref bounds)).size.y, ((Bounds)(ref bounds)).center.z + (Random.value * 2f - 1f) * x * 1.6f)); } Transform val2 = (((Object)(object)pl.cam != (Object)null) ? ((Component)pl.cam).transform : null); if ((Object)(object)val2 != (Object)null) { for (int j = 0; j < 4; j++) { One(val2.position + val2.forward * (0.9f + Random.value * 0.4f) + val2.right * (Random.value - 0.5f) * 1.1f + Vector3.up * (Random.value * 0.4f - 0.6f)); } } void One(Vector3 at) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) MCSpriteParticle.Spawn(heart, at, (Random.insideUnitSphere * 0.0002f + Vector3.up * 0.1f) * cell, 0f, 0.86f, 16, 0.1f * (Random.value * 0.5f + 0.5f) * 2f * 1.5f, Color.white); } } internal static void Grant(ENT_Player pl) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Obj == (Object)null)) { MinerPickaxe.GrantInstead(Obj.itemData.GetClone((Item)null, false), "command block"); MinerPickaxe.Tier tier = MinerPickaxe.TierByMcId("iron_pickaxe"); if ((Object)(object)tier?.obj != (Object)null && (Object)(object)Inventory.instance != (Object)null) { Item clone = tier.obj.itemData.GetClone((Item)null, false); MinerPickaxe.SetUses(clone, tier.maxUses, tier); Inventory.instance.AddItemToInventoryScreen(new Vector3(0f, 0f, 1f), clone, true, false, true); } } } internal static bool Is(Item it) { if (it != null) { return it.prefabName == "Item_CommandBlock"; } return false; } } internal static class ItemCooldowns { private static readonly Dictionary<string, (float start, float end)> cooldowns; static ItemCooldowns() { cooldowns = new Dictionary<string, (float, float)>(); SceneManager.activeSceneChanged += delegate { Clear(); }; } internal static void Set(string prefab, float seconds) { cooldowns[prefab] = (Time.time, Time.time + seconds); } internal static float Fraction(Item it) { if (it == null || it.prefabName == null || !cooldowns.TryGetValue(it.prefabName, out (float, float) value)) { return 0f; } if (Time.time >= value.Item2 || Time.time < value.Item1) { return 0f; } return Mathf.Clamp01((value.Item2 - Time.time) / Mathf.Max(0.01f, value.Item2 - value.Item1)); } internal static bool Cooling(Item it) { return Fraction(it) > 0f; } internal static void Draw(Item it, float x, float y) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) float num = Fraction(it); if (!(num <= 0f)) { float num2 = y + Mathf.Floor(16f * (1f - num)); MCAssets.Fill(x, num2, 16f, y + 16f - num2, new Color(1f, 1f, 1f, 0.5f)); } } internal static void Clear() { cooldowns.Clear(); } } internal static class AdminCommands { internal sealed class Command { internal string name; internal string full; internal string usage; internal float cooldown; internal Func<ENT_Player, (bool ok, string output)> run; } internal static readonly List<Command> All = new List<Command> { new Command { name = "effect", full = "/effect give @s minecraft:instant_health 1 1", usage = "give <targets> <effect> [<seconds>] [<amplifier>]", cooldown = 45f, run = Heal }, new Command { name = "fill", full = "/fill ~-1 ~-1 ~-1 ~1 ~-1 ~1 minecraft:stone", usage = "<from> <to> <block>", cooldown = 15f, run = Fill }, new Command { name = "op", full = "/op Romeo", usage = "<targets>", cooldown = 0f, run = Op }, new Command { name = "tp", full = "/tp @s ^ ^ ^10", usage = "<location>", cooldown = 19f, run = Teleport } }; internal const float TpRange = 10f; private static int Solid => HerobrineManager.SolidForClimber(); private static (bool, string) Teleport(ENT_Player pl) { //IL_0030: 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_003c: 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) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_00bd: 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_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_00d4: 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) //IL_00fd: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_0141: 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_0152: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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_017b: 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_0185: 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_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: 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_01d4: 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_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: 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_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0205: 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) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: 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_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) Camera cam = pl.cam; if ((Object)(object)cam == (Object)null || (Object)(object)pl.cCon == (Object)null) { return (false, "Invalid position for teleport"); } Vector3 position = ((Component)cam).transform.position; Vector3 forward = ((Component)cam).transform.forward; RaycastHit val = default(RaycastHit); bool flag = false; RaycastHit[] array = Physics.RaycastAll(position, forward, 12.5f, Solid, (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val2 = array[i]; if ((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<ENT_Player>() == (Object)null && (!flag || ((RaycastHit)(ref val2)).distance < ((RaycastHit)(ref val)).distance)) { val = val2; flag = true; } } Bounds bounds = ((Collider)pl.cCon).bounds; Vector3 val3 = ((Bounds)(ref bounds)).center - ((Component)pl).transform.position; float num = position.y - ((Bounds)(ref bounds)).center.y; float r = pl.cCon.radius; float y = ((Bounds)(ref bounds)).extents.y; float half = Mathf.Max(0f, y - r); Vector3 normal = ((RaycastHit)(ref val)).normal; Vector3 val4; if (!flag) { val4 = position + forward * 12.5f - Vector3.up * num; } else if (normal.y > 0.5f) { val4 = ((RaycastHit)(ref val)).point + Vector3.up * (y + 0.05f); } else if (normal.y < -0.5f) { val4 = ((RaycastHit)(ref val)).point - Vector3.up * (y + 0.05f); } else { Vector3 val5 = new Vector3(normal.x, 0f, normal.z); Vector3 normalized = ((Vector3)(ref val5)).normalized; val4 = ((RaycastHit)(ref val)).point + normalized * (r + 0.1f) - Vector3.up * num; } Vector3 val6 = -forward; bool flag2 = false; float[] array2 = new float[4] { 0f, 0.25f, 0.5f, 0.8f }; foreach (float num2 in array2) { float[] array3 = new float[3] { 0f, 0.3f, 0.6f }; foreach (float num3 in array3) { Vector3 val7 = val4 + Vector3.up * num2 + val6 * num3; if (Fits(val7)) { val4 = val7; flag2 = true; break; } } if (flag2) { break; } } if (!flag2 || Physics.OverlapSphere(val4, 25f, Solid, (QueryTriggerInteraction)1).Length == 0) { return (false, "Invalid position for teleport"); } Vector3 val8 = val4 - val3; Vector3 val9 = default(Vector3); ((Vector3)(ref val9))..ctor(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).min.y, ((Bounds)(ref bounds)).center.z); Vector3 val10 = val4 - Vector3.up * y; HerobrineFX.PlayNear(HerobrineFX.EndermanPortal, val9, 1f, 4f); ((GameEntity)pl).Teleport(val8, ((Component)pl).transform.rotation, false); HerobrineFX.PlayNear(HerobrineFX.EndermanPortal, val10 + Vector3.up * y, 1f, 4f); HerobrineFX.Portal(val9, val10, r * 2f, y * 2f); return (true, $"Teleported Romeo to {val8.x / 1.25f:0.0}, {val8.y / 1.25f:0.0}, {val8.z / 1.25f:0.0}"); bool Fits(Vector3 at) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_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) return !Physics.CheckCapsule(at - Vector3.up * half, at + Vector3.up * half, r * 0.95f, Solid, (QueryTriggerInteraction)1); } } private static (bool, string) Fill(ENT_Player pl) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_00a3: 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_00bf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)pl.cCon == (Object)null) { return (false, "No blocks were filled"); } Bounds bounds = ((Collider)pl.cCon).bounds; float num = 1.25f; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).min.y - num * 0.5f - 0.03f, ((Bounds)(ref bounds)).center.z); int num2 = 0; for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { Vector3 val2 = val + new Vector3((float)i * num, 0f, (float)j * num); if (!Physics.CheckBox(val2, Vector3.one * (num * 0.47f), Quaternion.identity, Solid, (QueryTriggerInteraction)1) && !FillBlock.At(val2, num)) { FillBlock.Make(val2, num, (float)(Mathf.Abs(i) + Mathf.Abs(j)) * 0.06f + (float)num2 * 0.012f); num2++; } } } FillBlock.RefreshAround(val, num * 3f); if (num2 != 0) { return (true, $"Successfully filled {num2} block(s)"); } return (false, "No blocks were filled"); } private static (bool, string) Heal(ENT_Player pl) { try { ((GameEntity)pl).Heal(8f * ((GameEntity)pl).maxHealth / 20f); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[cmd] heal: " + ex.Message)); } CommandBlock.Play2D(CommandBlock.Orb, 0.7f, 0.75f); CommandBlock.Hearts(pl); return (true, "Applied effect Instant Health to Romeo"); } private static (bool, string) Op(ENT_Player pl) { return (false, "You do not have permission to use this command"); } } public class FillBlock : MonoBehaviour { private const float Life = 10f; private const float CrackFrom = 7f; private float born; private float nextCheck; private MeshRenderer crack; private int stage = -1; private BoxCollider box; private static Mesh stoneCube; private static Material stoneMat; private static readonly List<FillBlock> live = new List<FillBlock>(); private static readonly Collider[] overlap = (Collider[])(object)new Collider[32]; private Transform visual; private float appearAt; private bool appeared; private readonly List<GameObject> edges = new List<GameObject>(); private static readonly string[] Sides = new string[4] { "north", "east", "south", "west" }; internal static bool At(Vector3 c, float size) { //IL_0024: 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_002f: Unknown result type (might be due to invalid IL or missing references) foreach (FillBlock item in live) { if ((Object)(object)item != (Object)null) { Vector3 val = ((Component)item).transform.position - c; if (((Vector3)(ref val)).sqrMagnitude < size * size * 0.8f) { return true; } } } return false; } private void OnEnable() { live.Add(this); } private void OnDisable() { live.Remove(this); } internal static FillBlock Make(Vector3 at, float size, float delay) { //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_0057: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_0115: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)stoneCube == (Object)null) { stoneCube = CommandBlock.Cube(0, 0, 0, 1); } if ((Object)(object)stoneMat == (Object)null && (Object)(object)CommandBlock.Stone != (Object)null) { stoneMat = MCItems.TexturedMat(CommandBlock.Stone, cutout: false); } GameObject val = new GameObject("FillBlock") { layer = 0 }; val.transform.position = at; val.transform.localScale = Vector3.one * size; FillBlock fillBlock = val.AddComponent<FillBlock>(); fillBlock.box = val.AddComponent<BoxCollider>(); fillBlock.born = Time.time; fillBlock.appearAt = Time.time + delay; GameObject val2 = new GameObject("Visual") { layer = 0 }; val2.transform.SetParent(val.transform, false); val2.transform.localScale = Vector3.zero; val2.AddComponent<MeshFilter>().sharedMesh = stoneCube; ((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = stoneMat; fillBlock.visual = val2.transform; GameObject val3 = new GameObject("Crack") { layer = 0 }; val3.transform.SetParent(val2.transform, false); val3.transform.localScale = Vector3.one * 1.004f; val3.AddComponent<MeshFilter>().sharedMesh = stoneCube; fillBlock.crack = val3.AddComponent<MeshRenderer>(); ((Renderer)fillBlock.crack).enabled = false; ((Renderer)fillBlock.crack).shadowCastingMode = (ShadowCastingMode)0; return fillBlock; } private void RebuildEdges() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //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: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_0154: Unknown result type (might be due to invalid IL or missing references) foreach (GameObject edge in edges) { if ((Object)(object)edge != (Object)null) { Object.Destroy((Object)(object)edge); } } edges.Clear(); float x = ((Component)this).transform.localScale.x; if (At(((Component)this).transform.position + Vector3.up * x, x)) { return; } string[] sides = Sides; Vector3 val2 = default(Vector3); foreach (string text in sides) { Vector3Int val = MCWorld.DirVec(text); ((Vector3)(ref val2))..ctor((float)((Vector3Int)(ref val)).x, 0f, (float)((Vector3Int)(ref val)).z); if (!At(((Component)this).transform.position + val2 * x, x)) { GameObject val3 = new GameObject("FillEdge_" + text); val3.transform.SetParent(((Component)this).transform, false); BoxCollider val4 = val3.AddComponent<BoxCollider>(); val3.transform.localPosition = new Vector3(0f, 0.43f, 0f) + val2 * 0.44f; val4.size = ((((Vector3Int)(ref val)).x != 0) ? new Vector3(0.14f, 0.14f, 1f) : new Vector3(1f, 0.14f, 0.14f)); MCEdges.MakeHandhold(val3, (Collider)(object)val4); edges.Add(val3); } } } internal static void RefreshAround(Vector3 at, float within) { //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_002d: Unknown result type (might be due to invalid IL or missing references) FillBlock[] array = live.ToArray(); foreach (FillBlock fillBlock in array) { if ((Object)(object)fillBlock != (Object)null) { Vector3 val = ((Component)fillBlock).transform.position - at; if (((Vector3)(ref val)).sqrMagnitude <= within * within) { fillBlock.RebuildEdges(); } } } } private void Appear() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) appeared = true; if (CommandBlock.Dig.Length != 0) { HerobrineFX.PlayNear(CommandBlock.Dig, ((Component)this).transform.position, 0.6f, 4f, 0.8f + Random.Range(-0.05f, 0.05f)); } Chips(3, 0.03f); } private void Chips(int perAxis, float speed) { //IL_0016: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00d0: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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) Texture2D stone = CommandBlock.Stone; if ((Object)(object)stone == (Object)null) { return; } float x = ((Component)this).transform.localScale.x; for (int i = 0; i < perAxis; i++) { for (int j = 0; j < perAxis; j++) { for (int k = 0; k < perAxis; k++) { if (perAxis >= 4 || !(Random.value < 0.5f)) { Vector3 val = ((Component)this).transform.position + new Vector3(((float)i + 0.5f) / (float)perAxis - 0.5f, ((float)j + 0.5f) / (float)perAxis - 0.5f, ((float)k + 0.5f) / (float)perAxis - 0.5f) * x; Vector3 val2 = val - ((Component)this).transform.position; Vector3 velocity = ((Vector3)(ref val2)).normalized * speed * 2f * 1.25f + Vector3.up * speed * 1.25f; MCSpriteParticle.Spawn(MCParticles.One(MCParticles.Piece(stone)), val, velocity, 1f, 0.98f, (int)(4f / (Random.value * 0.9f + 0.1f)), 0.1f * (Random.value * 0.5f + 0.5f), new Color(0.6f, 0.6f, 0.6f)); } } } } } private void Update() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) if (!appeared && Time.time >= appearAt) { Appear(); } if ((Object)(object)visual != (Object)null) { float num = Mathf.Clamp01((Time.time - appearAt) / 0.18f); float num2 = ((num <= 0f) ? 0f : (1f + 2.2f * Mathf.Pow(num - 1f, 3f) + 1.2f * Mathf.Pow(num - 1f, 2f))); visual.localScale = Vector3.one * num2; } float num3 = Time.time - born; if (num3 >= 10f) { Break(); return; } if (num3 > 7f) { int num4 = Mathf.Clamp(Mathf.FloorToInt((num3 - 7f) / 3f * 10f), 0, 9); if (num4 != stage) { stage = num4; ((Renderer)crack).enabled = true; ((Renderer)crack).sharedMaterial = MCEdges.CrackMat(num4); } } if (!(Time.time >= nextCheck)) { return; } nextCheck = Time.time + 0.1f; int num5 = Physics.OverlapBoxNonAlloc(((Component)this).transform.position, ((Component)this).transform.localScale * 0.44f, overlap, Quaternion.identity, HerobrineManager.SolidForClimber(), (QueryTriggerInteraction)1); for (int i = 0; i < num5; i++) { Collider val = overlap[i]; if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)box && (Object)(object)((Component)val).GetComponentInParent<FillBlock>() == (Object)null && (Object)(object)((Component)val).GetComponentInParent<ENT_Player>() == (Object)null) { Break(); break; } } } private void Break() { //IL_003e: 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) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_0197: Unknown result type (might be due to invalid IL or missing references) if (CommandBlock.Dig.Length != 0) { HerobrineFX.PlayNear(CommandBlock.Dig, ((Component)this).transform.position, 1f, 4f, 0.8f); } live.Remove(this); RefreshAround(((Component)this).transform.position, ((Component)this).transform.localScale.x * 1.5f); Texture2D stone = CommandBlock.Stone; if ((Object)(object)stone != (Object)null) { float x = ((Component)this).transform.localScale.x; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { for (int k = 0; k < 4; k++) { Vector3 val = ((Component)this).transform.position + new Vector3(((float)i + 0.5f) / 4f - 0.5f, ((float)j + 0.5f) / 4f - 0.5f, ((float)k + 0.5f) / 4f - 0.5f) * x; Vector3 val2 = val - ((Component)this).transform.position; Vector3 velocity = ((Vector3)(ref val2)).normalized * 0.06f * 1.25f + Vector3.up * 0.05f * 1.25f; MCSpriteParticle.Spawn(MCParticles.One(MCParticles.Piece(stone)), val, velocity, 1f, 0.98f, (int)(4f / (Random.value * 0.9f + 0.1f)), 0.1f * (Random.value * 0.5f + 0.5f), new Color(0.6f, 0.6f, 0.6f)); } } } } Object.Destroy((Object)(object)((Component)this).gameObject); } } public class CommandBlockUI : MonoBehaviour { private static CommandBlockUI instance; private bool open; private Item item; private string line = "/"; private string typing; private string output = ""; private bool erasing; private float erasedAt; private static readonly Dictionary<Item, string> written = new Dictionary<Item, string>(); private bool outputBad; private float typedAt; private float openedAt; private int selected; private float scale = 2f; private float W; private float H; private float mx; private float my; private bool camWasLocked; private bool cursorWasShown; private Texture2D button; private Texture2D buttonHover; private Texture2D buttonOff; private static readonly FieldRef<ENT_Player, bool> CamLocked = AccessTools.FieldRefAccess<ENT_Player, bool>("camLocked"); private static readonly Color Grey = new Color(0.63f, 0.63f, 0.63f); private static readonly Color Text = new Color(0.88f, 0.88f, 0.88f); internal static bool Open { get { if ((Object)(object)instance != (Object)null) { return instance.open; } return false; } } internal static void Show(Item it) { //IL_0012: 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_001d: Expected O, but got Unknown if ((Object)(object)instance == (Object)null) { GameObject val = new GameObject("CommandBlockUI"); Object.DontDestroyOnLoad((Object)val); instance = val.AddComponent<CommandBlockUI>(); } instance.OpenFor(it); } internal static void Hide() { if (Open) { instance.Close(); } } private void OpenFor(Item it) { ENT_Player playerObject = ENT_Player.playerObject; if (!((Object)(object)playerObject == (Object)null) && !open && !SceneGuard.Active) { if ((Object)(object)button == (Object)null) { string path = Path.Combine(Plugin.AssetDir, "miner", "hnr"); button = MinerPickaxe.Load(Path.Combine(path, "button.png")); buttonHover = MinerPickaxe.Load(Path.Combine(path, "button_highlighted.png")); buttonOff = MinerPickaxe.Load(Path.Combine(path, "button_disabled.png")); } item = it; open = true; line = (written.TryGetValue(it, out var value) ? value : "/"); typing = null; erasing = false; selected = 0; openedAt = Time.unscaledTime; camWasLocked = CamLocked.Invoke(playerObject); playerObject.LockCamera(); cursorWasShown = CL_GameManager.showCursor; CL_GameManager.showCursor = true; Cursor.lockState = (CursorLockMode)0; } } private void Close() { open = false; if (item != null) { written[item] = (erasing ? "/" : (typing ?? line)); } typing = null; erasing = false; MinerInvUI.NoteClosed(); ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject != (Object)null) { CamLocked.Invoke(playerObject) = camWasLocked; } CL_GameManager.showCursor = cursorWasShown; Cursor.lockState = (CursorLockMode)1; } private void LateUpdate() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (!open) { return; } ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject == (Object)null || ((GameEntity)playerObject).dead || item == null || item.hasBeenDestroyed || MinerInv.HandHolding(item) < 0) { Close(); return; } CL_GameManager.showCursor = true; if ((int)Cursor.lockState != 0) { Cursor.lockState = (CursorLockMode)0; } if (typing != null) { int num = Mathf.Min(typing.Length, Mathf.FloorToInt((Time.unscaledTime - typedAt) * 45f) + 1); line = typing.Substring(0, num); if (num >= typing.Length) { typing = null; } } else if (erasing) { int num2 = Mathf.FloorToInt((Time.unscaledTime - erasedAt) * 70f); if (num2 > 0) { erasedAt += (float)num2 / 70f; line = line.Substring(0, Mathf.Max(1, line.Length - num2)); } if (line.Length <= 1) { line = "/"; erasing = false; } } } private List<AdminCommands.Command> Suggestions() { List<AdminCommands.Command> list = new List<AdminCommands.Command>(); if (typing != null || erasing) { return list; } foreach (AdminCommands.Command item in AdminCommands.All) { if (item.full.StartsWith(line) && item.full != line) { list.Add(item); } } return list; } private static bool CouldBe(string s) { return AdminCommands.All.Exists((AdminCommands.Command c) => c.full.StartsWith(s)); } private AdminCommands.Command Complete() { return AdminCommands.All.Find((AdminCommands.Command c) => c.full == line); } private AdminCommands.Command Matching() { string head = line.TrimStart('/').Split(' ')[0]; return AdminCommands.All.Find((AdminCommands.Command c) => c.name == head); } private void Choose(AdminCommands.Command c) { typing = c.full; typedAt = Time.unscaledTime - (float)line.Length / 45f; } private void Run() { //IL_00f4: 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) ENT_Player playerObject = ENT_Player.playerObject; AdminCommands.Command command = Complete(); string text = DateTime.Now.ToString("[HH:mm:ss] "); if ((Object)(object)playerObject == (Object)null) { return; } if (command == null || line.Trim() == "/") { CommandBlock.Fail(); string text2 = line.Trim(); output = text + ((text2.Length <= 1) ? "Unknown or incomplete command" : "Unknown or incomplete command, see below for error"); outputBad = true; return; } var (flag, text3) = command.run(playerObject); if (!flag) { CommandBlock.Fail(); } output = text + text3; outputBad = !flag; MCChat.Add("[@: " + text3 + "]", flag ? new Color(0.67f, 0.67f, 0.67f) : new Color(1f, 0.33f, 0.33f)); Plugin.Log.LogInfo((object)("[cmd] " + command.full + " -> " + (flag ? "ok" : "failed") + ": " + text3)); if (flag && command.cooldown > 0f) { ItemCooldowns.Set("Item_CommandBlock", command.cooldown); Close(); } } private void OnGUI() { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00dd: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Invalid comparison between Unknown and I4 //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Invalid comparison between Unknown and I4 if (open) { Event current = Event.current; int i; for (i = 1; Screen.width / (i + 1) >= 320 && Screen.height / (i + 1) >= 240; i++) { } scale = Mathf.Max(1, i - 1); W = Mathf.Floor((float)Screen.width / scale); H = Mathf.Floor((float)Screen.height / scale); mx = current.mousePosition.x / scale; my = current.mousePosition.y / scale; bool flag = (int)current.type == 0 && current.button == 0; GUI.depth = -1500; Matrix4x4 matrix = GUI.matrix; GUI.matrix = Matri