Compare commits

...
1 Commits
Author SHA1 Message Date
boubou19 50bed12f66 Cache enum .values() (#112) 2026-08-10 20:58:59 +02:00
5 changed files with 17 additions and 10 deletions

No files matched your search

@@ -38,8 +38,8 @@ public class ItemInsulatedTube extends Item {
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
for (Material mat : Material.values()) {
for (Insulate ins : Insulate.values()) {
for (Material mat : Material.VALUES) {
for (Insulate ins : Insulate.VALUES) {
list.add(new ItemStack(this, 1, mat.ordinal() + ins.ordinal() * 128));
}
}
@@ -97,6 +97,8 @@ public class ItemInsulatedTube extends Item {
Bronze(0xddc276, "bronze"),
Iron(0xd8d8d8, "iron");
public static final Material[] VALUES = values();
private final int color;
private final String name;
@@ -106,7 +108,7 @@ public class ItemInsulatedTube extends Item {
}
public static Material get(int i) {
return values()[i % values().length];
return VALUES[i % VALUES.length];
}
public int getColor() {
@@ -127,6 +129,8 @@ public class ItemInsulatedTube extends Item {
Stone(0x6d6d6d, "smoothStone"),
Sandstone(0xc1b989, "sandstone");
public static final Insulate[] VALUES = values();
private final int color;
private final String name;
@@ -136,7 +140,7 @@ public class ItemInsulatedTube extends Item {
}
public static Insulate get(int i) {
return values()[i / 128 % values().length];
return values()[i / 128 % VALUES.length];
}
public int getColor() {
@@ -48,7 +48,7 @@ public class BlockPlant extends BlockBush {
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
for (Type t : Type.values()) {
for (Type t : Type.VALUES) {
t.icon = Botany.proxy.getIcon(register, t.name().toLowerCase());
}
}
@@ -61,7 +61,7 @@ public class BlockPlant extends BlockBush {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return Type.values()[meta % Type.values().length].icon;
return Type.VALUES[meta % Type.VALUES.length].icon;
}
@Override
@@ -72,7 +72,7 @@ public class BlockPlant extends BlockBush {
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
for (Type type : Type.values()) {
for (Type type : Type.VALUES) {
list.add(type.get());
}
}
@@ -135,6 +135,7 @@ public class BlockPlant extends BlockBush {
DeadFlower("deadFlower"),
DecayingFlower("decayingFlower");
public static final Type[] VALUES = values();
public IIcon icon;
private final String name;
@@ -144,7 +145,7 @@ public class BlockPlant extends BlockBush {
}
public static Type get(int id) {
return values()[id % values().length];
return VALUES[id % VALUES.length];
}
public ItemStack get() {
@@ -18,7 +18,7 @@ public class ItemWeed extends ItemBlock {
@Override
public String getItemStackDisplayName(ItemStack stack) {
return BlockPlant.Type.values()[stack.getItemDamage()].getName();
return BlockPlant.Type.VALUES[stack.getItemDamage()].getName();
}
@Override
@@ -902,7 +902,7 @@ public enum ExtraTreeSpecies implements IAlleleTreeSpecies, IIconProvider, IGerm
@Override
public void registerIcons(IIconRegister register) {
for (SaplingType type : SaplingType.values()) {
for (SaplingType type : SaplingType.VALUES) {
type.icon = new IIcon[2];
type.icon[0] = ExtraTrees.proxy.getIcon(register, "saplings/" + type.toString().toLowerCase() + ".trunk");
type.icon[1] = ExtraTrees.proxy.getIcon(register, "saplings/" + type.toString().toLowerCase() + ".leaves");
@@ -12,5 +12,7 @@ public enum SaplingType {
PALM,
SHRUB;
public static final SaplingType[] VALUES = values();
public IIcon[] icon;
}