forked from GregTechCEu/GregTech
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
De-enumify MaterialIconSet + MaterialIconType (GregTechCEu#82)
- Names are converted to the right format in the ctor
- Loading branch information
Showing
5 changed files
with
180 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 50 additions & 31 deletions
81
src/main/java/gregtech/api/unification/material/info/MaterialIconSet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
244 changes: 127 additions & 117 deletions
244
src/main/java/gregtech/api/unification/material/info/MaterialIconType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,135 +1,145 @@ | ||
package gregtech.api.unification.material.info; | ||
|
||
import com.google.common.base.CaseFormat; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.google.common.base.Preconditions; | ||
import gregtech.api.GTValues; | ||
import net.minecraft.util.ResourceLocation; | ||
|
||
public enum MaterialIconType { | ||
|
||
//ITEM TEXTURES | ||
dustTiny, | ||
dustSmall, | ||
dust, | ||
dustImpure, | ||
dustPure, | ||
crushed, | ||
crushedPurified, | ||
crushedCentrifuged, | ||
gem, | ||
nugget, | ||
ingot, | ||
ingotHot, | ||
ingotDouble, | ||
ingotTriple, | ||
ingotQuadruple, | ||
ingotQuintuple, | ||
plate, | ||
plateDouble, | ||
plateTriple, | ||
plateQuadruple, | ||
plateQuintuple, | ||
plateDense, | ||
stick, | ||
lens, | ||
round, | ||
bolt, | ||
screw, | ||
ring, | ||
cell, | ||
cellPlasma, | ||
toolHeadSword, | ||
toolHeadPickaxe, | ||
toolHeadShovel, | ||
toolHeadAxe, | ||
toolHeadHoe, | ||
toolHeadHammer, | ||
toolHeadFile, | ||
toolHeadSaw, | ||
toolHeadBuzzSaw, | ||
toolHeadDrill, | ||
toolHeadChainsaw, | ||
toolHeadSense, | ||
toolHeadArrow, | ||
toolHeadScrewdriver, | ||
toolHeadBuzSaw, | ||
toolHeadSoldering, | ||
toolHeadWrench, | ||
toolHeadUniversalSpade, | ||
wireFine, | ||
gearSmall, | ||
rotor, | ||
stickLong, | ||
springSmall, | ||
spring, | ||
arrow, | ||
gemChipped, | ||
gemFlawed, | ||
gemFlawless, | ||
gemExquisite, | ||
gear, | ||
foil, | ||
crateGtDust, | ||
crateGtIngot, | ||
crateGtGem, | ||
crateGtPlate, | ||
turbineBlade, | ||
handleMallet, | ||
toolHeadMallet, | ||
plateCurved, | ||
coke, | ||
|
||
//BLOCK TEXTURES | ||
block, | ||
fluid, | ||
foilBlock, //todo unused | ||
wire, //todo unused | ||
ore, | ||
frameGt, | ||
pipeSide, //todo unused | ||
pipeTiny, | ||
pipeSmall, | ||
pipeMedium, | ||
pipeLarge, | ||
pipeHuge, | ||
pipeQuadruple, | ||
pipeNonuple, | ||
|
||
//USED FOR GREGIFICATION ADDON | ||
oreChunk, | ||
oreEnderChunk, | ||
oreNetherChunk, | ||
oreSandyChunk, | ||
seed, | ||
crop, | ||
essence; | ||
|
||
public static final ImmutableMap<String, MaterialIconType> values; | ||
|
||
static { | ||
ImmutableMap.Builder<String, MaterialIconType> builder = ImmutableMap.builder(); | ||
for (MaterialIconType value : values()) { | ||
builder.put(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, value.name()), value); | ||
} | ||
values = builder.build(); | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class MaterialIconType { | ||
|
||
public static final Map<String, MaterialIconType> ICON_TYPES = new HashMap<>(); | ||
|
||
static int idCounter = 0; | ||
|
||
public static final MaterialIconType dustTiny = new MaterialIconType("dustTiny"); | ||
public static final MaterialIconType dustSmall = new MaterialIconType("dustSmall"); | ||
public static final MaterialIconType dust = new MaterialIconType("dust"); | ||
public static final MaterialIconType dustImpure = new MaterialIconType("dustImpure"); | ||
public static final MaterialIconType dustPure = new MaterialIconType("dustPure"); | ||
|
||
public static final MaterialIconType crushed = new MaterialIconType("crushed"); | ||
public static final MaterialIconType crushedPurified = new MaterialIconType("crushedPurified"); | ||
public static final MaterialIconType crushedCentrifuged = new MaterialIconType("crushedCentrifuged"); | ||
|
||
public static final MaterialIconType gem = new MaterialIconType("gem"); | ||
public static final MaterialIconType gemChipped = new MaterialIconType("gemChipped"); | ||
public static final MaterialIconType gemFlawed = new MaterialIconType("gemFlawed"); | ||
public static final MaterialIconType gemFlawless = new MaterialIconType("gemFlawless"); | ||
public static final MaterialIconType gemExquisite = new MaterialIconType("gemExquisite"); | ||
|
||
public static final MaterialIconType nugget = new MaterialIconType("nugget"); | ||
|
||
public static final MaterialIconType ingot = new MaterialIconType("ingot"); | ||
public static final MaterialIconType ingotHot = new MaterialIconType("ingotHot"); | ||
public static final MaterialIconType ingotDouble = new MaterialIconType("ingotDouble"); | ||
public static final MaterialIconType ingotTriple = new MaterialIconType("ingotTriple"); | ||
public static final MaterialIconType ingotQuadruple = new MaterialIconType("ingotQuadruple"); | ||
public static final MaterialIconType ingotQuintuple = new MaterialIconType("ingotQuintuple"); | ||
|
||
public static final MaterialIconType plate = new MaterialIconType("plate"); | ||
public static final MaterialIconType plateDouble = new MaterialIconType("plateDouble"); | ||
public static final MaterialIconType plateTriple = new MaterialIconType("plateTriple"); | ||
public static final MaterialIconType plateQuadruple = new MaterialIconType("plateQuadruple"); | ||
public static final MaterialIconType plateQuintuple = new MaterialIconType("plateQuintuple"); | ||
public static final MaterialIconType plateDense = new MaterialIconType("plateDense"); | ||
|
||
public static final MaterialIconType stick = new MaterialIconType("stick"); | ||
public static final MaterialIconType lens = new MaterialIconType("lens"); | ||
public static final MaterialIconType round = new MaterialIconType("round"); | ||
public static final MaterialIconType bolt = new MaterialIconType("bolt"); | ||
public static final MaterialIconType screw = new MaterialIconType("screw"); | ||
public static final MaterialIconType ring = new MaterialIconType("ring"); | ||
public static final MaterialIconType wireFine = new MaterialIconType("wireFine"); | ||
public static final MaterialIconType gearSmall = new MaterialIconType("gearSmall"); | ||
public static final MaterialIconType rotor = new MaterialIconType("rotor"); | ||
public static final MaterialIconType stickLong = new MaterialIconType("stickLong"); | ||
public static final MaterialIconType springSmall = new MaterialIconType("springSmall"); | ||
public static final MaterialIconType spring = new MaterialIconType("spring"); | ||
public static final MaterialIconType arrow = new MaterialIconType("arrow"); | ||
public static final MaterialIconType gear = new MaterialIconType("gear"); | ||
public static final MaterialIconType foil = new MaterialIconType("foil"); | ||
|
||
public static final MaterialIconType cell = new MaterialIconType("cell"); | ||
public static final MaterialIconType cellPlasma = new MaterialIconType("cellPlasma"); | ||
|
||
public static final MaterialIconType toolHeadSword = new MaterialIconType("toolHeadSword"); | ||
public static final MaterialIconType toolHeadPickaxe = new MaterialIconType("toolHeadPickaxe"); | ||
public static final MaterialIconType toolHeadShovel = new MaterialIconType("toolHeadShovel"); | ||
public static final MaterialIconType toolHeadAxe = new MaterialIconType("toolHeadAxe"); | ||
public static final MaterialIconType toolHeadHoe = new MaterialIconType("toolHeadHoe"); | ||
public static final MaterialIconType toolHeadHammer = new MaterialIconType("toolHeadHammer"); | ||
public static final MaterialIconType toolHeadFile = new MaterialIconType("toolHeadFile"); | ||
public static final MaterialIconType toolHeadSaw = new MaterialIconType("toolHeadSaw"); | ||
public static final MaterialIconType toolHeadBuzzSaw = new MaterialIconType("toolHeadBuzzSaw"); | ||
public static final MaterialIconType toolHeadDrill = new MaterialIconType("toolHeadDrill"); | ||
public static final MaterialIconType toolHeadChainsaw = new MaterialIconType("toolHeadChainsaw"); | ||
public static final MaterialIconType toolHeadSense = new MaterialIconType("toolHeadSense"); | ||
public static final MaterialIconType toolHeadArrow = new MaterialIconType("toolHeadArrow"); | ||
public static final MaterialIconType toolHeadScrewdriver = new MaterialIconType("toolHeadScrewdriver"); | ||
public static final MaterialIconType toolHeadSoldering = new MaterialIconType("toolHeadSoldering"); | ||
public static final MaterialIconType toolHeadWrench = new MaterialIconType("toolHeadWrench"); | ||
public static final MaterialIconType toolHeadUniversalSpade = new MaterialIconType("toolHeadUniversalSpade"); | ||
|
||
public static final MaterialIconType crateGtDust = new MaterialIconType("crateGtDust"); | ||
public static final MaterialIconType crateGtIngot = new MaterialIconType("crateGtIngot"); | ||
public static final MaterialIconType crateGtGem = new MaterialIconType("crateGtGem"); | ||
public static final MaterialIconType crateGtPlate = new MaterialIconType("crateGtPlate"); | ||
|
||
public static final MaterialIconType turbineBlade = new MaterialIconType("turbineBlade"); | ||
public static final MaterialIconType handleMallet = new MaterialIconType("handleMallet"); | ||
public static final MaterialIconType toolHeadMallet = new MaterialIconType("toolHeadMallet"); | ||
public static final MaterialIconType plateCurved = new MaterialIconType("plateCurved"); | ||
public static final MaterialIconType coke = new MaterialIconType("coke"); | ||
|
||
// BLOCK TEXTURES | ||
public static final MaterialIconType block = new MaterialIconType("block"); | ||
public static final MaterialIconType fluid = new MaterialIconType("fluid"); | ||
public static final MaterialIconType foilBlock = new MaterialIconType("foilBlock"); | ||
public static final MaterialIconType wire = new MaterialIconType("wire"); // TODO unused | ||
public static final MaterialIconType ore = new MaterialIconType("ore"); | ||
public static final MaterialIconType frameGt = new MaterialIconType("frameGt"); | ||
|
||
public static final MaterialIconType pipeSide = new MaterialIconType("pipeSide"); // TODO unused | ||
public static final MaterialIconType pipeTiny = new MaterialIconType("pipeTiny"); | ||
public static final MaterialIconType pipeSmall = new MaterialIconType("pipeSmall"); | ||
public static final MaterialIconType pipeMedium = new MaterialIconType("pipeMedium"); | ||
public static final MaterialIconType pipeLarge = new MaterialIconType("pipeLarge"); | ||
public static final MaterialIconType pipeHuge = new MaterialIconType("pipeHuge"); | ||
public static final MaterialIconType pipeQuadruple = new MaterialIconType("pipeQuadruple"); | ||
public static final MaterialIconType pipeNonuple = new MaterialIconType("pipeNonuple"); | ||
|
||
// USED FOR GREGIFICATION ADDON | ||
public static final MaterialIconType oreChunk = new MaterialIconType("oreChunk"); | ||
public static final MaterialIconType oreEnderChunk = new MaterialIconType("oreEnderChunk"); | ||
public static final MaterialIconType oreNetherChunk = new MaterialIconType("oreNetherChunk"); | ||
public static final MaterialIconType oreSandyChunk = new MaterialIconType("oreSandyChunk"); | ||
public static final MaterialIconType seed = new MaterialIconType("seed"); | ||
public static final MaterialIconType crop = new MaterialIconType("crop"); | ||
public static final MaterialIconType essence = new MaterialIconType("essence"); | ||
|
||
public final String name; | ||
public final int id; | ||
|
||
public MaterialIconType(String name) { | ||
this.name = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name); | ||
Preconditions.checkArgument(!ICON_TYPES.containsKey(this.name), "MaterialIconType " + this.name + " already registered!"); | ||
this.id = idCounter++; | ||
ICON_TYPES.put(this.name, this); | ||
} | ||
|
||
public ResourceLocation getBlockPath(MaterialIconSet materialIconSet) { | ||
String iconSet = materialIconSet.name().toLowerCase(); | ||
String iconType = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name()); | ||
return new ResourceLocation(GTValues.MODID, "blocks/material_sets/" + iconSet + "/" + iconType); | ||
return new ResourceLocation(GTValues.MODID, "blocks/material_sets/" + materialIconSet.name + "/" + this.name); | ||
} | ||
|
||
public ResourceLocation getItemModelPath(MaterialIconSet materialIconSet) { | ||
String iconSet = materialIconSet.name().toLowerCase(); | ||
String iconType = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name()); | ||
return new ResourceLocation(GTValues.MODID, "material_sets/" + iconSet + "/" + iconType); | ||
return new ResourceLocation(GTValues.MODID, "material_sets/" + materialIconSet.name + "/" + this.name); | ||
} | ||
|
||
public ResourceLocation getItemOverlayPath(MaterialIconSet materialIconSet) { | ||
String iconSet = materialIconSet.name().toLowerCase(); | ||
String iconType = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name()); | ||
return new ResourceLocation(GTValues.MODID, "material_sets/" + iconSet + "/" + iconType + "_overlay"); | ||
return new ResourceLocation(GTValues.MODID, "material_sets/" + materialIconSet.name + "/" + this.name + "_overlay"); | ||
} | ||
|
||
} |