Cache frequent Enum#values() calls (#86)

This commit is contained in:
Alexdoru authored and GitHub committed 2026-03-04 16:15:04 +01:00
1 parent 84d462d8d5
commit a48f59e0ed
64 files changed
+202 -121

No files matched your search

@@ -109,7 +109,7 @@ public class ModuleGardening implements IInitializable {
for (boolean manual : new boolean[] { true, false }) {
for (boolean fertilised : new boolean[] { true, false }) {
for (EnumMoisture moist : EnumMoisture.values()) {
for (EnumMoisture moist : EnumMoisture.VALUES) {
ItemStack icon = (moist == EnumMoisture.DRY) ? yellow
: ((moist == EnumMoisture.NORMAL) ? red : blue);
int insulate = 2 - moist.ordinal();
@@ -258,7 +258,7 @@ public class ModuleGardening implements IInitializable {
GameRegistry
.addRecipe(BotanyItems.Mortar.get(6), " c ", "cgc", " c ", 'c', Items.clay_ball, 'g', Blocks.gravel);
for (EnumFlowerColor c : EnumFlowerColor.values()) {
for (EnumFlowerColor c : EnumFlowerColor.VALUES) {
ItemStack clay = new ItemStack(Botany.clay, 1, c.ordinal());
ItemStack pigment = new ItemStack(Botany.pigment, 1, c.ordinal());
GameRegistry.addShapelessRecipe(clay, Items.clay_ball, Items.clay_ball, Items.clay_ball, pigment);
@@ -276,9 +276,9 @@ public class ModuleGardening implements IInitializable {
return null;
}
return new ItemStack(
Gardening.getSoilBlock(EnumSoilType.values()[type]),
Gardening.getSoilBlock(EnumSoilType.VALUES[type]),
1,
BlockSoil.getMeta(EnumAcidity.values()[pH], EnumMoisture.values()[moisture]));
BlockSoil.getMeta(EnumAcidity.VALUES[pH], EnumMoisture.VALUES[moisture]));
}
private void addAcidFertiliser(ItemStack stack, int strengthMax) {