From 5dfb01ef0b10e3e3823031f7ab5dfb22e1968e6b Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 12 Dec 2020 16:59:52 +0100 Subject: [PATCH] Use the console block's material again - IT WORKS It shows up in the inventory but crashes when selected --- GamecraftModdingAPI/Blocks/CustomBlock.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs index 7c5d6db..2cf6b72 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -100,7 +100,9 @@ namespace GamecraftModdingAPI.Blocks } }*/ - public static void Prefix(ref Dictionary blocks) + private static Material[] materials; + + public static void Prefix(List prefabData, IList prefabs) { /*foreach (var block in blocks.Values.Cast()) { @@ -109,11 +111,25 @@ namespace GamecraftModdingAPI.Blocks /*var res = Addressables.LoadContentCatalogAsync("customCatalog.json"); while (!res.IsDone) yield return Yield.It;*/ + for (int i = 0; i < prefabData.Count; i++) + { + var gameObject = prefabs[i]; + switch (gameObject.name) + { + case "Cube": + gameObject.GetComponentsInChildren()[0].sharedMaterials = materials; + break; + case "CTR_CommandBlock": + materials = gameObject.GetComponentsInChildren()[0].sharedMaterials; + break; + } + } } public static MethodBase TargetMethod() { //General block registration - return AccessTools.Method("RobocraftX.Blocks.BlocksCompositionRoot:RegisterPartPrefabs"); + //return AccessTools.Method("RobocraftX.Blocks.BlocksCompositionRoot:RegisterPartPrefabs"); + return AccessTools.Method("RobocraftX.Rendering.ECSGPUIResourceManager:InitPreRegisteredPrefabs"); } }