Browse Source

Use the console block's material again - IT WORKS

It shows up in the inventory but crashes when selected
tags/v1.8.0
NorbiPeti 3 years ago
parent
commit
5dfb01ef0b
1 changed files with 18 additions and 2 deletions
  1. +18
    -2
      GamecraftModdingAPI/Blocks/CustomBlock.cs

+ 18
- 2
GamecraftModdingAPI/Blocks/CustomBlock.cs 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>())
{
@@ -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<MeshRenderer>()[0].sharedMaterials = materials;
break;
case "CTR_CommandBlock":
materials = gameObject.GetComponentsInChildren<MeshRenderer>()[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");
}
}



Loading…
Cancel
Save