Skip to content

Commit

Permalink
add method for addons to register MTEs easily
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss committed Aug 12, 2021
1 parent f0c75f2 commit 19ce515
Showing 1 changed file with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;

public class MetaTileEntities {

Expand Down Expand Up @@ -623,14 +624,7 @@ private static void registerSimpleMetaTileEntity(SimpleMachineMetaTileEntity[] m
RecipeMap<?> map,
OrientedOverlayRenderer texture,
boolean hasFrontFacing) {
for (int i = 0; i < machines.length - 1; i++) {
if (i > 4 && !getMidTier(name)) continue;
if (i > 7 && !getHighTier(name)) break;

String voltageName = GTValues.VN[i + 1].toLowerCase();
machines[i] = GregTechAPI.registerMetaTileEntity(startId + i,
new SimpleMachineMetaTileEntity(gregtechId(String.format("%s.%s", name, voltageName)), map, texture, i + 1, hasFrontFacing));
}
registerSimpleMetaTileEntity(machines, startId, name, map, texture, hasFrontFacing, MetaTileEntities::gregtechId);
}

private static void registerSimpleMetaTileEntity(SimpleMachineMetaTileEntity[] machines,
Expand All @@ -641,6 +635,23 @@ private static void registerSimpleMetaTileEntity(SimpleMachineMetaTileEntity[] m
registerSimpleMetaTileEntity(machines, startId, name, map, texture, true);
}

public static void registerSimpleMetaTileEntity(SimpleMachineMetaTileEntity[] machines,
int startId,
String name,
RecipeMap<?> map,
OrientedOverlayRenderer texture,
boolean hasFrontFacing,
Function<String, ResourceLocation> resourceId) {
for (int i = 0; i < machines.length - 1; i++) {
if (i > 4 && !getMidTier(name)) continue;
if (i > 7 && !getHighTier(name)) break;

String voltageName = GTValues.VN[i + 1].toLowerCase();
machines[i] = GregTechAPI.registerMetaTileEntity(startId + i,
new SimpleMachineMetaTileEntity(resourceId.apply(String.format("%s.%s", name, voltageName)), map, texture, i + 1, hasFrontFacing));
}
}

private static ResourceLocation gregtechId(String name) {
return new ResourceLocation(GTValues.MODID, name);
}
Expand Down

0 comments on commit 19ce515

Please sign in to comment.