Decompiled source of Minecraft Creative Mode v1.0.0

MinecraftBuild.dll

Decompiled 2 days ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Photon.Pun;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ConsoleApp1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConsoleApp1")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9ad3797c-2c9b-4654-a108-ef0cd930f4ff")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MichBuilder;

[BepInPlugin("com.Mich.Builder", "Mich Minecraft Builder v5", "5.0.0")]
public class BuilderPlugin : BaseUnityPlugin
{
	public static GameObject prefabMadera;

	public static GameObject prefabPiedra;

	public static GameObject prefabMetal;

	public static AudioClip sonidoConstruir;

	public static AudioClip sonidoDestruir;

	public static ConfigEntry<KeyCode> teclaConstruir;

	public static ConfigEntry<KeyCode> teclaDestruir;

	private void Awake()
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)"SadTocinoMods");
		teclaConstruir = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controles", "PonerBloque", (KeyCode)98, "Tecla para construir");
		teclaDestruir = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controles", "QuitarBloque", (KeyCode)118, "Tecla para destruir");
		CargarAssetBundle();
	}

	private void CargarAssetBundle()
	{
		string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "mich_bloques.bundle");
		if (File.Exists(text))
		{
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val != (Object)null)
			{
				prefabMadera = val.LoadAsset<GameObject>("Minecraft Grass");
				prefabPiedra = val.LoadAsset<GameObject>("Minecraft Stone");
				prefabMetal = val.LoadAsset<GameObject>("Minecraft Planks");
				sonidoConstruir = val.LoadAsset<AudioClip>("placeblock");
				sonidoDestruir = val.LoadAsset<AudioClip>("placeblock");
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Cargó bien");
			}
		}
	}

	private void Update()
	{
		PlayerController[] array = Object.FindObjectsOfType<PlayerController>();
		foreach (PlayerController val in array)
		{
			PhotonView component = ((Component)val).GetComponent<PhotonView>();
			if ((!PhotonNetwork.IsConnected || ((Object)(object)component != (Object)null && component.IsMine)) && (Object)(object)((Component)val).GetComponent<MichPlayerBuilder>() == (Object)null)
			{
				((Component)val).gameObject.AddComponent<MichPlayerBuilder>();
			}
		}
	}
}
public class MichPlayerBuilder : MonoBehaviourPun
{
	public static Dictionary<Vector3, GameObject> mundoBloques = new Dictionary<Vector3, GameObject>();

	private float distanciaConstruccion = 5f;

	private int bloqueSeleccionado = 0;

	private void Update()
	{
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		if (!PhotonNetwork.IsConnected || ((MonoBehaviourPun)this).photonView.IsMine)
		{
			if (Input.GetKeyDown((KeyCode)49) || Input.GetKeyDown((KeyCode)257))
			{
				bloqueSeleccionado = 0;
			}
			if (Input.GetKeyDown((KeyCode)50) || Input.GetKeyDown((KeyCode)258))
			{
				bloqueSeleccionado = 1;
			}
			if (Input.GetKeyDown((KeyCode)51) || Input.GetKeyDown((KeyCode)259))
			{
				bloqueSeleccionado = 2;
			}
			if (Input.GetKeyDown(BuilderPlugin.teclaConstruir.Value))
			{
				IntentarConstruir();
			}
			if (Input.GetKeyDown(BuilderPlugin.teclaDestruir.Value))
			{
				IntentarDestruir();
			}
		}
	}

	private void IntentarConstruir()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: 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_0073: 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_0083: 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_00a5: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
		Camera val = Camera.main;
		if ((Object)(object)val == (Object)null)
		{
			val = ((Component)this).GetComponentInChildren<Camera>();
		}
		RaycastHit val2 = default(RaycastHit);
		if ((Object)(object)val == (Object)null || !Physics.Raycast(((Component)val).transform.position, ((Component)val).transform.forward, ref val2, distanciaConstruccion))
		{
			return;
		}
		Vector3 val3 = ((RaycastHit)(ref val2)).point + ((RaycastHit)(ref val2)).normal * 0.5f;
		Vector3 val4 = default(Vector3);
		((Vector3)(ref val4))..ctor(Mathf.Round(val3.x), Mathf.Round(val3.y), Mathf.Round(val3.z));
		if (!mundoBloques.ContainsKey(val4))
		{
			if (PhotonNetwork.IsConnected && PhotonNetwork.InRoom)
			{
				((MonoBehaviourPun)this).photonView.RPC("CrearBloqueRPC", (RpcTarget)3, new object[2] { val4, bloqueSeleccionado });
			}
			else
			{
				CrearBloqueRPC(val4, bloqueSeleccionado);
			}
		}
	}

	private void IntentarDestruir()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
		Camera val = Camera.main;
		if ((Object)(object)val == (Object)null)
		{
			val = ((Component)this).GetComponentInChildren<Camera>();
		}
		RaycastHit val2 = default(RaycastHit);
		if (!((Object)(object)val == (Object)null) && Physics.Raycast(((Component)val).transform.position, ((Component)val).transform.forward, ref val2, distanciaConstruccion) && ((Object)((RaycastHit)(ref val2)).collider).name.StartsWith("MichBloque"))
		{
			if (PhotonNetwork.IsConnected && PhotonNetwork.InRoom)
			{
				((MonoBehaviourPun)this).photonView.RPC("DestruirBloqueRPC", (RpcTarget)3, new object[1] { ((Component)((RaycastHit)(ref val2)).collider).transform.position });
			}
			else
			{
				DestruirBloqueRPC(((Component)((RaycastHit)(ref val2)).collider).transform.position);
			}
		}
	}

	[PunRPC]
	public void CrearBloqueRPC(Vector3 pos, int tipoBloque)
	{
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: 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_00c2: 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)
		GameObject val = null;
		switch (tipoBloque)
		{
		case 0:
			val = BuilderPlugin.prefabMadera;
			break;
		case 1:
			val = BuilderPlugin.prefabPiedra;
			break;
		case 2:
			val = BuilderPlugin.prefabMetal;
			break;
		}
		GameObject val2;
		if ((Object)(object)val != (Object)null)
		{
			val2 = Object.Instantiate<GameObject>(val);
		}
		else
		{
			val2 = GameObject.CreatePrimitive((PrimitiveType)3);
			val2.GetComponent<Renderer>().material.color = (Color)(tipoBloque switch
			{
				1 => Color.gray, 
				0 => Color.green, 
				_ => Color.blue, 
			});
		}
		if ((Object)(object)val2.GetComponent<BoxCollider>() == (Object)null)
		{
			val2.AddComponent<BoxCollider>();
		}
		((Object)val2).name = "MichBloque_" + tipoBloque;
		val2.transform.position = pos;
		mundoBloques[pos] = val2;
		if ((Object)(object)BuilderPlugin.sonidoConstruir != (Object)null)
		{
			AudioSource.PlayClipAtPoint(BuilderPlugin.sonidoConstruir, pos, 1f);
		}
	}

	[PunRPC]
	public void DestruirBloqueRPC(Vector3 pos)
	{
		//IL_0006: 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_0027: 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)
		if (mundoBloques.ContainsKey(pos))
		{
			Object.Destroy((Object)(object)mundoBloques[pos]);
			mundoBloques.Remove(pos);
			if ((Object)(object)BuilderPlugin.sonidoDestruir != (Object)null)
			{
				AudioSource.PlayClipAtPoint(BuilderPlugin.sonidoDestruir, pos, 1f);
			}
		}
	}
}