Use the console block's material again - IT WORKS

It shows up in the inventory but crashes when selected
This commit is contained in:
Norbi Peti 2020-12-12 16:59:52 +01:00
parent 432d6bcf96
commit 5dfb01ef0b

View file

@ -100,7 +100,9 @@ namespace GamecraftModdingAPI.Blocks
} }
}*/ }*/
public static void Prefix(ref Dictionary<string, BaseData> blocks) private static Material[] materials;
public static void Prefix(List<PrefabData> prefabData, IList<GameObject> prefabs)
{ {
/*foreach (var block in blocks.Values.Cast<CubeListData>()) /*foreach (var block in blocks.Values.Cast<CubeListData>())
{ {
@ -109,11 +111,25 @@ namespace GamecraftModdingAPI.Blocks
/*var res = Addressables.LoadContentCatalogAsync("customCatalog.json"); /*var res = Addressables.LoadContentCatalogAsync("customCatalog.json");
while (!res.IsDone) yield return Yield.It;*/ 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<MeshRenderer>()[0].sharedMaterials = materials;
break;
case "CTR_CommandBlock":
materials = gameObject.GetComponentsInChildren<MeshRenderer>()[0].sharedMaterials;
break;
}
}
} }
public static MethodBase TargetMethod() public static MethodBase TargetMethod()
{ //General block registration { //General block registration
return AccessTools.Method("RobocraftX.Blocks.BlocksCompositionRoot:RegisterPartPrefabs"); //return AccessTools.Method("RobocraftX.Blocks.BlocksCompositionRoot:RegisterPartPrefabs");
return AccessTools.Method("RobocraftX.Rendering.ECSGPUIResourceManager:InitPreRegisteredPrefabs");
} }
} }