11package gtexpert .common .metatileentities ;
22
33import gregtech .api .GTValues ;
4+ import gregtech .api .metatileentity .MetaTileEntity ;
45import gregtech .api .metatileentity .SimpleMachineMetaTileEntity ;
56import gregtech .api .util .GTUtility ;
67import gtexpert .api .GTEValues ;
1213import net .minecraftforge .fml .common .Loader ;
1314import org .jetbrains .annotations .NotNull ;
1415
16+ import java .util .function .BiFunction ;
17+
1518import static gregtech .api .GTValues .*;
1619import static gregtech .common .metatileentities .MetaTileEntities .*;
1720
@@ -22,6 +25,7 @@ public class GTEMetaTileEntities {
2225 public static SimpleMachineMetaTileEntity [] VIAL_EXTRACTOR = new SimpleMachineMetaTileEntity [GTValues .V .length - 1 ];
2326 public static SimpleMachineMetaTileEntity [] SLICE_N_SPLICE = new SimpleMachineMetaTileEntity [GTValues .V .length - 1 ];
2427 public static SimpleMachineMetaTileEntity [] SOUL_BINDER = new SimpleMachineMetaTileEntity [GTValues .V .length - 1 ];
28+ public static MetaTileEntityElectricSpawner [] ELECTRIC_SPAWNER = new MetaTileEntityElectricSpawner [GTValues .V .length - 1 ];
2529 public static MetaTileEntityVoidOreMiner VOIDOREMINER ;
2630 public static MetaTileEntityDraconiumFusion DRACONIUM_FUSION ;
2731 public static MetaTileEntityDraconiumFusion AWAKENED_DRACONIUM_FUSION ;
@@ -67,6 +71,13 @@ public static void init() {
6771 // SOUL_BINDER 11036~11048
6872 registerSimpleMetaTileEntity (SOUL_BINDER , 11036 , "soul_binder" , GTERecipeMaps .SOUL_BINDER_RECIPES , GTETextures .SOUL_BINDER_OVERLAY , true , GTEMetaTileEntities ::gteId , GTUtility .defaultTankSizeFunction );
6973
74+ // ELECTRIC_SPAWNER 11049~11061
75+ registerMetaTileEntities (
76+ ELECTRIC_SPAWNER ,
77+ 11049 ,
78+ "electric_spawner" ,
79+ (tier , voltageName ) -> new MetaTileEntityElectricSpawner (gteId (String .format ("%s.%s" , "electric_spawner" , voltageName )), GTETextures .SPAWNER_OVERLAY , tier ));
80+
7081 // multiblocks :12000~
7182 SAWMILL = registerMetaTileEntity (12001 , new MetaTileEntitySawmill (gteId ("sawmill" )));
7283 // = registerMetaTileEntity(12002, new MetaTileEntityVoidOreMiner(gteId("####")));
@@ -82,4 +93,23 @@ public static void init() {
8293 private static ResourceLocation gteId (@ NotNull String name ) {
8394 return new ResourceLocation (GTEValues .MODID , name );
8495 }
96+
97+ // TODO: This method will be included in the next update of CEu
98+ /**
99+ * @param mteCreator Takes tier and voltage name for the machine and outputs MTE to register
100+ */
101+ private static <T extends MetaTileEntity > void registerMetaTileEntities (
102+ T [] machines ,
103+ int startId ,
104+ String name ,
105+ BiFunction <Integer , String , T > mteCreator ) {
106+ for (int i = 0 ; i < machines .length - 1 ; i ++) {
107+ if (i > 4 && !getMidTier (name )) continue ;
108+ if (i > 7 && !getHighTier (name )) break ;
109+
110+ String voltageName = GTValues .VN [i + 1 ].toLowerCase ();
111+ machines [i + 1 ] = registerMetaTileEntity (startId + i ,
112+ mteCreator .apply (i + 1 , voltageName ));
113+ }
114+ }
85115}
0 commit comments