Cache more enum .values() (#67)

This commit is contained in:
boubou19 authored and GitHub committed 2026-08-11 02:54:09 +02:00
1 parent 4345981958
commit 53d085d292
2 files changed
+8 -6

No files matched your search

+5 -5
View File
@@ -45,14 +45,14 @@ public class ItemWax extends Item {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int meta) {
return (WaxType.values()[meta].sparkly) ? this.itemIcon : this.secondaryIcon;
return (WaxType.VALUES[meta].sparkly) ? this.itemIcon : this.secondaryIcon;
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "unchecked", "rawtypes" })
public void getSubItems(Item item, CreativeTabs tabs, List list) {
for (WaxType type : WaxType.values()) {
for (WaxType type : WaxType.VALUES) {
list.add(this.getStackForType(type));
}
}
@@ -62,14 +62,14 @@ public class ItemWax extends Item {
public int getColorFromItemStack(ItemStack stack, int pass) {
int colour = 0xffffff;
int meta = stack.getItemDamage();
if (meta >= 0 && meta < WaxType.values().length) {
colour = WaxType.values()[meta].colour;
if (meta >= 0 && meta < WaxType.VALUES.length) {
colour = WaxType.VALUES[meta].colour;
}
return colour;
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
return WaxType.values()[stack.getItemDamage()].getName();
return WaxType.VALUES[stack.getItemDamage()].getName();
}
}
@@ -8,7 +8,9 @@ public enum WaxType {
SOUL("soul", false, 0x967C63),
AMNESIC("amnesic", true, 0x856DFF);
private WaxType(String n, boolean sp, int c) {
public static final WaxType[] VALUES = values();
WaxType(String n, boolean sp, int c) {
this.name = n;
this.sparkly = sp;
this.colour = c;