mirror of
https://github.com/GTNewHorizons/Hardcore-Ender-Expansion.git
synced 2026-10-25 20:22:31 +00:00
Cache enum .values() (#46)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
83b88f6347
commit
4e8c432cef
11 files changed
+21
-17
No files matched your search
@@ -95,7 +95,7 @@ public class BlockEssenceAltar extends BlockContainer {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||
for (EssenceType essenceType : EssenceType.values()) list.add(new ItemStack(item, 1, essenceType.id));
|
||||
for (EssenceType essenceType : EssenceType.VALUES) list.add(new ItemStack(item, 1, essenceType.id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,7 +110,7 @@ public class BlockEssenceAltar extends BlockContainer {
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
String s = getTextureName() + "_";
|
||||
|
||||
iconTop = new IIcon[EssenceType.values().length];
|
||||
iconTop = new IIcon[EssenceType.VALUES.length];
|
||||
iconSide = new IIcon[iconTop.length];
|
||||
iconBottom = new IIcon[iconTop.length];
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ItemCharm extends Item {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list) {
|
||||
for (CharmType charmType : CharmType.values()) {
|
||||
for (CharmType charmType : CharmType.VALUES) {
|
||||
for (CharmRecipe charmRecipe : charmType.recipes) list.add(new ItemStack(item, 1, charmRecipe.id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ public class ItemCurse extends Item {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs tabs, List list) {
|
||||
for (CurseType type : CurseType.values()) {
|
||||
for (CurseType type : CurseType.VALUES) {
|
||||
list.add(new ItemStack(item, 1, type.damage));
|
||||
list.add(new ItemStack(item, 1, type.damage | 0b100000000));
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ItemEssence extends Item {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list) {
|
||||
for (EssenceType essenceType : EssenceType.values()) {
|
||||
for (EssenceType essenceType : EssenceType.VALUES) {
|
||||
if (essenceType == EssenceType.INVALID) continue;
|
||||
list.add(new ItemStack(item, 1, essenceType.id - 1));
|
||||
}
|
||||
@@ -62,10 +62,10 @@ public class ItemEssence extends Item {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
iconArray = new IIcon[EssenceType.values().length - 1];
|
||||
iconArray = new IIcon[EssenceType.VALUES.length - 1];
|
||||
int index = -1;
|
||||
|
||||
for (EssenceType essenceType : EssenceType.values()) {
|
||||
for (EssenceType essenceType : EssenceType.VALUES) {
|
||||
if (essenceType == EssenceType.INVALID) continue;
|
||||
iconArray[++index] = iconRegister.registerIcon("hardcoreenderexpansion:essence_" + essenceType.id);
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ public final class RecipeList {
|
||||
ItemList.spectral_tear,
|
||||
ItemList.instability_orb);
|
||||
|
||||
for (CurseType curse : CurseType.values()) {
|
||||
for (CurseType curse : CurseType.VALUES) {
|
||||
GameRegistry.addShapedRecipe(
|
||||
new ItemStack(ItemList.curse, 8, curse.damage),
|
||||
"PAP",
|
||||
|
||||
@@ -193,9 +193,10 @@ public enum CharmType {
|
||||
new String[] { "int,lastresortblocks", "int,lastresortcooldown" });
|
||||
|
||||
// last used id: 79
|
||||
public static final CharmType[] VALUES = values();
|
||||
|
||||
public static Pair<CharmType, CharmRecipe> getFromDamage(int damage) {
|
||||
for (CharmType type : values()) {
|
||||
for (CharmType type : VALUES) {
|
||||
for (CharmRecipe recipe : type.recipes) {
|
||||
if (recipe.id == damage) return Pair.of(type, recipe);
|
||||
}
|
||||
@@ -207,7 +208,7 @@ public enum CharmType {
|
||||
public static Pair<CharmType, CharmRecipe> findRecipe(RuneType[] runes) {
|
||||
if (runes.length < 3 || runes.length > 5) return null;
|
||||
|
||||
for (CharmType type : values()) {
|
||||
for (CharmType type : VALUES) {
|
||||
for (CharmRecipe recipe : type.recipes) {
|
||||
if (recipe.checkRunes(runes)) return Pair.of(type, recipe);
|
||||
}
|
||||
@@ -217,7 +218,7 @@ public enum CharmType {
|
||||
}
|
||||
|
||||
public static String getTooltip(int damage) {
|
||||
for (CharmType type : values()) {
|
||||
for (CharmType type : VALUES) {
|
||||
for (CharmRecipe recipe : type.recipes) {
|
||||
if (recipe.id == damage) {
|
||||
String tooltip = StatCollector.translateToLocal(
|
||||
|
||||
@@ -65,7 +65,7 @@ public final class KnowledgeUtils {
|
||||
List<KnowledgeFragment> fragments = new ArrayList<>();
|
||||
int a = 0;
|
||||
|
||||
for (CharmType type : CharmType.values()) {
|
||||
for (CharmType type : CharmType.VALUES) {
|
||||
for (CharmRecipe recipe : type.recipes) {
|
||||
fragments.add(
|
||||
new KnowledgeFragmentCharm(startID + (a++)).setRecipe(recipe).setPrice(2)
|
||||
@@ -80,7 +80,7 @@ public final class KnowledgeUtils {
|
||||
List<KnowledgeFragment> fragments = new ArrayList<>();
|
||||
int a = 0;
|
||||
|
||||
for (CurseType type : CurseType.values()) {
|
||||
for (CurseType type : CurseType.VALUES) {
|
||||
fragments.add(
|
||||
new KnowledgeFragmentCrafting(startID + (a++))
|
||||
.setRecipe(new ItemStack(ItemList.curse, 8, type.damage)).setPrice(3)
|
||||
|
||||
@@ -519,10 +519,12 @@ public enum CurseType {
|
||||
.setUses(EnumCurseUse.PLAYER, 8, 11).setColor1h(300).setColor2g(50);
|
||||
}
|
||||
|
||||
public static final CurseType[] VALUES = values();
|
||||
|
||||
public static CurseType getFromDamage(int damage) {
|
||||
damage = damage & 0b11111111;
|
||||
|
||||
for (CurseType type : values()) {
|
||||
for (CurseType type : VALUES) {
|
||||
if (damage == type.damage) return type;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ public enum EssenceType {
|
||||
new RuneItem(Items.egg, "mob.chicken.plop") },
|
||||
new float[] { 0.1875F, 0.1641F, 0.5273F });
|
||||
|
||||
public static final EssenceType[] VALUES = values();
|
||||
public final byte id;
|
||||
public final String essenceName;
|
||||
public final String essenceNameLowercase;
|
||||
@@ -73,7 +74,7 @@ public enum EssenceType {
|
||||
}
|
||||
|
||||
public static EssenceType getById(int id) {
|
||||
for (EssenceType type : values()) {
|
||||
for (EssenceType type : VALUES) {
|
||||
if (type.id == id) return type;
|
||||
}
|
||||
return INVALID;
|
||||
|
||||
@@ -18,7 +18,7 @@ public class CharmTests {
|
||||
public void testRecipeConflicts() {
|
||||
TIntIntHashMap hashes = new TIntIntHashMap(80, 0.75F, -1, -1);
|
||||
|
||||
for (CharmType type : CharmType.values()) {
|
||||
for (CharmType type : CharmType.VALUES) {
|
||||
for (CharmRecipe recipe : type.recipes) {
|
||||
Map<RuneType, Byte> data = recipe.getRunes();
|
||||
int hash = 0, prevHash;
|
||||
|
||||
+1
-1
@@ -139,7 +139,7 @@ public final class RavagedDungeonLoot {
|
||||
@Override
|
||||
public ItemStack processItem(ItemStack is, Random rand) {
|
||||
if (is.getItem() == ItemList.charm) {
|
||||
CharmType[] types = CharmType.values();
|
||||
CharmType[] types = CharmType.VALUES;
|
||||
CharmType type = types[rand.nextInt(types.length)];
|
||||
is.setItemDamage(type.recipes[rand.nextInt(type.recipes.length)].id);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user