1010import gregtech .api .items .metaitem .MetaItem ;
1111import gregtech .api .items .metaitem .MetaItem .MetaValueItem ;
1212import gregtech .api .unification .OreDictUnifier ;
13+ import gregtech .api .unification .material .type .Material ;
14+ import gregtech .api .unification .ore .OrePrefix ;
15+ import gregtech .api .util .GTLog ;
16+ import gregtech .common .blocks .MetaBlocks ;
17+ import gregtech .common .pipelike .cable .BlockCable ;
1318import net .minecraft .item .ItemStack ;
1419import stanhebben .zenscript .compiler .IEnvironmentGlobal ;
1520import stanhebben .zenscript .expression .ExpressionCallStatic ;
@@ -37,8 +42,8 @@ public MetaItemBracketHandler() {
3742 public static void rebuildComponentRegistry () {
3843 metaItemNames .clear ();
3944 for (MetaItem <?> item : MetaItem .getMetaItems ()) {
40- if (item instanceof MaterialMetaItem ) {
41- for (ItemStack entry : (( MaterialMetaItem ) item ) .getEntries ()) {
45+ if (item instanceof MaterialMetaItem m ) {
46+ for (ItemStack entry : m .getEntries ()) {
4247 metaItemNames .put (OreDictUnifier .getPrefix (entry ).name () + OreDictUnifier .getMaterial (entry ).material .toCamelCaseString (), entry );
4348 }
4449 }
@@ -48,13 +53,26 @@ public static void rebuildComponentRegistry() {
4853 }
4954 }
5055 }
56+
57+ final var prefixes = new OrePrefix [] {
58+ OrePrefix .wireGtSingle , OrePrefix .wireGtDouble , OrePrefix .wireGtQuadruple , OrePrefix .wireGtOctal , OrePrefix .wireGtHex ,
59+ OrePrefix .cableGtSingle , OrePrefix .cableGtDouble , OrePrefix .cableGtQuadruple , OrePrefix .cableGtOctal , OrePrefix .cableGtHex
60+ };
61+
62+ for (Material material : MetaBlocks .CABLE .getEnabledMaterials ()) {
63+ for (OrePrefix prefix : prefixes ) {
64+ String name = prefix .name () + material .toCamelCaseString ();
65+ metaItemNames .put (name , OreDictUnifier .get (name ));
66+ }
67+ }
5168 }
5269
5370 public static IItemStack getMetaItem (String name ) {
5471 ItemStack item = metaItemNames .get (name );
5572 if (item != null ) {
5673 return new MCItemStack (item );
5774 } else {
75+ GTLog .logger .error ("No such metaitem: {}" , name );
5876 return null ;
5977 }
6078 }
0 commit comments