Minor Cleanup

Fix up some null checks

Clean up redundant array creation to varargs parameter

Remove redundant type casts

Simplify arithmetic

Use foreach loops

Remove unused code

Minor cleanup
This commit is contained in:
mezz committed 2014-11-29 23:49:47 -08:00
1 parent 05a7ac6d93
commit 3884fecf77
222 files changed
+695 -1079

No files matched your search

@@ -153,7 +153,7 @@ public class PluginArboriculture extends ForestryPlugin {
public static int modelIdPods;
public static ITreeRoot treeInterface;
public static MachineDefinition definitionChest;
public static List<Block> validFences = new ArrayList<Block>();
public static final List<Block> validFences = new ArrayList<Block>();
private static final EnumSet<ForestryBlock> logs = EnumSet.of(
ForestryBlock.log1,
ForestryBlock.log2,
@@ -474,12 +474,11 @@ public class PluginArboriculture extends ForestryPlugin {
Proxies.common.addRecipe(ForestryBlock.fences2.getItemStack(4, i), "###", "# #", '#', ForestryBlock.planks2.getItemStack(1, i));
// Treealyzer
RecipeManagers.carpenterManager.addRecipe(100, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 2000), null, ForestryItem.treealyzer.getItemStack(), new Object[]{
"X#X", "X#X", "RDR",
'#', Blocks.glass_pane,
'X', "ingotCopper",
'R', Items.redstone,
'D', Items.diamond});
RecipeManagers.carpenterManager.addRecipe(100, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 2000), null, ForestryItem.treealyzer.getItemStack(), "X#X", "X#X", "RDR",
'#', Blocks.glass_pane,
'X', "ingotCopper",
'R', Items.redstone,
'D', Items.diamond);
// SQUEEZER RECIPES
RecipeManagers.squeezerManager.addRecipe(20, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.CHERRY.ordinal())}, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, 5 * GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed")), ForestryItem.mulch.getItemStack(), 5);
@@ -78,7 +78,7 @@ public class PluginCore extends ForestryPlugin {
public static MachineDefinition definitionEscritoire;
// ICrashCallable for highlighting certain mods during crashes.
public static ForestryModEnvWarningCallable crashCallable;
public static RootCommand rootCommand = new RootCommand();
public static final RootCommand rootCommand = new RootCommand();
@Override
public void preInit() {
@@ -374,15 +374,15 @@ public class PluginFactory extends ForestryPlugin {
// / CHIPSETS
RecipeManagers.carpenterManager.addRecipe(20, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 0),
new Object[]{"R R", "R#R", "R R", '#', "ingotTin", 'R', Items.redstone});
"R R", "R#R", "R R", '#', "ingotTin", 'R', Items.redstone);
RecipeManagers.carpenterManager.addRecipe(40, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 1),
new Object[]{"R#R", "R#R", "R#R", '#', "ingotBronze", 'R', Items.redstone});
"R#R", "R#R", "R#R", '#', "ingotBronze", 'R', Items.redstone);
RecipeManagers.carpenterManager.addRecipe(80, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 2),
new Object[]{"R#R", "R#R", "R#R", '#', Items.iron_ingot, 'R', Items.redstone});
"R#R", "R#R", "R#R", '#', Items.iron_ingot, 'R', Items.redstone);
RecipeManagers.carpenterManager.addRecipe(80, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 3),
new Object[]{"R#R", "R#R", "R#R", '#', Items.gold_ingot, 'R', Items.redstone});
"R#R", "R#R", "R#R", '#', Items.gold_ingot, 'R', Items.redstone);
RecipeManagers.carpenterManager.addRecipe(40, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.solderingIron.getItemStack(),
new Object[]{" # ", "# #", " B", '#', Items.iron_ingot, 'B', "ingotBronze"});
" # ", "# #", " B", '#', Items.iron_ingot, 'B', "ingotBronze");
// ForestryCore.oreHandler.registerCarpenterRecipe(solderingIron);
// RAIN SUBSTRATES
@@ -408,17 +408,17 @@ public class PluginFactory extends ForestryPlugin {
}
// Ender pearl
RecipeManagers.carpenterManager.addRecipe(100, null, new ItemStack(Items.ender_pearl, 1), new Object[]{" # ", "###", " # ", '#',
ForestryItem.craftingMaterial.getItemStack(1, 1)});
RecipeManagers.carpenterManager.addRecipe(100, null, new ItemStack(Items.ender_pearl, 1), " # ", "###", " # ", '#',
ForestryItem.craftingMaterial.getItemStack(1, 1));
// Woven Silk
RecipeManagers.carpenterManager.addRecipe(10, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 500), null, ForestryItem.craftingMaterial.getItemStack(1, 3),
new Object[]{"###", "###", "###", '#', ForestryItem.craftingMaterial.getItemStack(1, 2)});
"###", "###", "###", '#', ForestryItem.craftingMaterial.getItemStack(1, 2));
// Boxes
RecipeManagers.carpenterManager.addRecipe(5, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.carton.getItemStack(2),
new Object[]{" # ", "# #", " # ", '#', "pulpWood"});
" # ", "# #", " # ", '#', "pulpWood");
RecipeManagers.carpenterManager.addRecipe(20, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.crate.getItemStack(24),
new Object[]{" # ", "# #", " # ", '#', "logWood"});
" # ", "# #", " # ", '#', "logWood");
// Assembly Kits
RecipeManagers.carpenterManager.addRecipe(20, null, ForestryItem.carton.getItemStack(), ForestryItem.kitPickaxe.getItemStack(), new Object[]{
@@ -433,8 +433,8 @@ public class PluginFactory extends ForestryPlugin {
// Reclamation
RecipeManagers.carpenterManager.addRecipe(null, ForestryItem.ingotBronze.getItemStack(2, ForestryItem.ingotBronze.item().getMaxDamage()),
new Object[]{"#", '#', ForestryItem.brokenBronzePickaxe});
RecipeManagers.carpenterManager.addRecipe(null, ForestryItem.ingotBronze.getItemStack(), new Object[]{"#", '#', ForestryItem.brokenBronzeShovel});
"#", '#', ForestryItem.brokenBronzePickaxe);
RecipeManagers.carpenterManager.addRecipe(null, ForestryItem.ingotBronze.getItemStack(), "#", '#', ForestryItem.brokenBronzeShovel);
// Crating and uncrating condensed
if (PluginManager.Module.STORAGE.isEnabled()) {
@@ -36,16 +36,16 @@ public class PluginFarmCraftory extends ForestryPlugin {
public static Method methodGrowthSingle;
public static Method methodGrowthMulti;
public static HashMap<String, ItemStack> vegetableSeeds = new HashMap<String, ItemStack>();
public static final HashMap<String, ItemStack> vegetableSeeds = new HashMap<String, ItemStack>();
public static final String[] seedIdentifiers = new String[]{"turnipSeedBag", "cabbageSeedBag", "onionSeedBag", "spinachSeedBag", "leekSeedBag",
"cucumberSeedBag", "tomatoSeedBag", "eggplantSeedBag", "greenPepperSeedBag", "yamSeedBag", "strawberrySeedBag", "pineappleSeedBag"};
public static HashMap<String, ItemStack> vegetableItems = new HashMap<String, ItemStack>();
public static final HashMap<String, ItemStack> vegetableItems = new HashMap<String, ItemStack>();
public static final String[] vegetableIdentifiers = new String[]{"turnipItem", "cabbageItem", "onionItem", "spinachItem", "leekItem", "cucumberItem",
"tomatoItem", "eggplantItem", "greenPepperItem", "yamItem", "strawberryItem", "pineappleItem"};
public static HashMap<String, ItemStack> cerealSeeds = new HashMap<String, ItemStack>();
public static final HashMap<String, ItemStack> cerealSeeds = new HashMap<String, ItemStack>();
public static final String[] cseedIdentifiers = new String[]{"cornSeedBag"};
public static HashMap<String, ItemStack> cerealItems = new HashMap<String, ItemStack>();
public static final HashMap<String, ItemStack> cerealItems = new HashMap<String, ItemStack>();
public static final String[] cerealIdentifiers = new String[]{"cornItem"};
@Override
@@ -149,8 +149,8 @@ public class PluginLepidopterology extends ForestryPlugin {
CraftingManager.getInstance().getRecipeList().add(new MatingRecipe());
RecipeManagers.carpenterManager.addRecipe(100, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 2000), null, ForestryItem.flutterlyzer.getItemStack(),
new Object[]{"X#X", "X#X", "RDR", Character.valueOf('#'), Blocks.glass_pane, Character.valueOf('X'), "ingotBronze", Character.valueOf('R'),
Items.redstone, Character.valueOf('D'), Items.diamond});
"X#X", "X#X", "RDR", Character.valueOf('#'), Blocks.glass_pane, Character.valueOf('X'), "ingotBronze", Character.valueOf('R'),
Items.redstone, Character.valueOf('D'), Items.diamond);
}
private void createAlleles() {
@@ -46,12 +46,12 @@ public class PluginManager {
public static final String MODULE_CONFIG_FILE_NAME = "modules.cfg";
public static final String CATEGORY_MODULES = "modules";
public static ArrayList<IGuiHandler> guiHandlers = Lists.newArrayList();
public static ArrayList<IPacketHandler> packetHandlers = Lists.newArrayList();
public static ArrayList<IPickupHandler> pickupHandlers = Lists.newArrayList();
public static ArrayList<ISaveEventHandler> saveEventHandlers = Lists.newArrayList();
public static ArrayList<IResupplyHandler> resupplyHandlers = Lists.newArrayList();
public static ArrayList<IOreDictionaryHandler> dictionaryHandlers = Lists.newArrayList();
public static final ArrayList<IGuiHandler> guiHandlers = Lists.newArrayList();
public static final ArrayList<IPacketHandler> packetHandlers = Lists.newArrayList();
public static final ArrayList<IPickupHandler> pickupHandlers = Lists.newArrayList();
public static final ArrayList<ISaveEventHandler> saveEventHandlers = Lists.newArrayList();
public static final ArrayList<IResupplyHandler> resupplyHandlers = Lists.newArrayList();
public static final ArrayList<IOreDictionaryHandler> dictionaryHandlers = Lists.newArrayList();
private static final Set<Module> loadedModules = EnumSet.noneOf(Module.class);
private static final Set<Module> unloadedModules = EnumSet.allOf(Module.class);
@@ -284,8 +284,7 @@ public class PluginManager {
private static boolean isEnabled(Configuration config, Module m) {
Plugin info = m.instance().getClass().getAnnotation(Plugin.class);
boolean defaultValue = true;
Property prop = config.get(CATEGORY_MODULES, m.toString().toLowerCase(Locale.ENGLISH).replace('_', '.'), defaultValue);
Property prop = config.get(CATEGORY_MODULES, m.toString().toLowerCase(Locale.ENGLISH).replace('_', '.'), true);
prop.comment = StatCollector.translateToLocal(info.unlocalizedDescription());
return prop.getBoolean(true);
}
@@ -84,8 +84,8 @@ public class PluginNatura extends ForestryPlugin {
seedList.add(seedCotton);
int amount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed");
for (int i = 0; i < seedList.size(); ++i)
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{seedList.get(i)},
for (ItemStack aSeedList : seedList)
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{aSeedList},
LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, amount));
ItemStack berryBlight = GameRegistry.findItemStack(NATURA, "berryBlight", 1);
@@ -117,8 +117,8 @@ public class PluginNatura extends ForestryPlugin {
amount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") / 25;
amount = (amount > 1) ? amount : 1; // Produce at least 1 mb of juice.
for (int i = 0; i < berries.size(); ++i)
RecipeManagers.squeezerManager.addRecipe(3, new ItemStack[]{berries.get(i)},
for (ItemStack berry : berries)
RecipeManagers.squeezerManager.addRecipe(3, new ItemStack[]{berry},
LiquidHelper.getLiquid(Defaults.LIQUID_JUICE, amount));
}
@@ -85,7 +85,7 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl
private final ArrayList<ItemStack> hunterItems = new ArrayList<ItemStack>();
private final ArrayList<ItemStack> adventurerItems = new ArrayList<ItemStack>();
private final ArrayList<ItemStack> builderItems = new ArrayList<ItemStack>();
static String CONFIG_CATEGORY = "backpacks";
private final static String CONFIG_CATEGORY = "backpacks";
Configuration config;
@Override
@@ -482,46 +482,46 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl
// Miner's Backpack
Proxies.common.addRecipe(ForestryItem.minerBackpack.getItemStack(),
new Object[]{"X#X", "VYV", "X#X", '#', Blocks.wool, 'X', Items.string, 'V',
Items.iron_ingot, 'Y', Blocks.chest});
"X#X", "VYV", "X#X", '#', Blocks.wool, 'X', Items.string, 'V',
Items.iron_ingot, 'Y', Blocks.chest);
// Digger's Backpack
Proxies.common.addRecipe(ForestryItem.diggerBackpack.getItemStack(),
new Object[]{"X#X", "VYV", "X#X", '#', Blocks.wool, 'X', Items.string, 'V',
Blocks.stone, 'Y', Blocks.chest});
"X#X", "VYV", "X#X", '#', Blocks.wool, 'X', Items.string, 'V',
Blocks.stone, 'Y', Blocks.chest);
// Forester's Backpack
Proxies.common.addRecipe(ForestryItem.foresterBackpack.getItemStack(), new Object[]{"X#X", "VYV", "X#X", '#', Blocks.wool,
'X', Items.string, 'V', "logWood", 'Y', Blocks.chest});
Proxies.common.addRecipe(ForestryItem.foresterBackpack.getItemStack(), "X#X", "VYV", "X#X", '#', Blocks.wool,
'X', Items.string, 'V', "logWood", 'Y', Blocks.chest);
// Hunter's Backpack
Proxies.common.addRecipe(ForestryItem.hunterBackpack.getItemStack(),
new Object[]{"X#X", "VYV", "X#X", '#', Blocks.wool, 'X', Items.string, 'V',
Items.feather, 'Y', Blocks.chest});
"X#X", "VYV", "X#X", '#', Blocks.wool, 'X', Items.string, 'V',
Items.feather, 'Y', Blocks.chest);
// Adventurer's Backpack
Proxies.common.addRecipe(ForestryItem.adventurerBackpack.getItemStack(), new Object[]{"X#X", "VYV", "X#X", '#', Blocks.wool,
'X', Items.string, 'V', Items.bone, 'Y', Blocks.chest});
Proxies.common.addRecipe(ForestryItem.adventurerBackpack.getItemStack(), "X#X", "VYV", "X#X", '#', Blocks.wool,
'X', Items.string, 'V', Items.bone, 'Y', Blocks.chest);
// Builder's Backpack
Proxies.common.addRecipe(ForestryItem.builderBackpack.getItemStack(), new Object[]{"X#X", "VYV", "X#X", '#', Blocks.wool,
'X', Items.string, 'V', Items.clay_ball, 'Y', Blocks.chest});
Proxies.common.addRecipe(ForestryItem.builderBackpack.getItemStack(), "X#X", "VYV", "X#X", '#', Blocks.wool,
'X', Items.string, 'V', Items.clay_ball, 'Y', Blocks.chest);
// / CARPENTER
// / BACKPACKS T2
RecipeManagers.carpenterManager.addRecipe(200, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.minerBackpackT2.getItemStack(),
new Object[]{"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.minerBackpack});
"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.minerBackpack);
RecipeManagers.carpenterManager.addRecipe(200, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.diggerBackpackT2.getItemStack(),
new Object[]{"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.diggerBackpack});
"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.diggerBackpack);
RecipeManagers.carpenterManager.addRecipe(200, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.foresterBackpackT2.getItemStack(),
new Object[]{"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.foresterBackpack});
"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.foresterBackpack);
RecipeManagers.carpenterManager.addRecipe(200, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.hunterBackpackT2.getItemStack(),
new Object[]{"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.hunterBackpack});
"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.hunterBackpack);
RecipeManagers.carpenterManager.addRecipe(200, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.adventurerBackpackT2.getItemStack(),
new Object[]{"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.adventurerBackpack});
"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.adventurerBackpack);
RecipeManagers.carpenterManager.addRecipe(200, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.builderBackpackT2.getItemStack(),
new Object[]{"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.builderBackpack});
"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.builderBackpack);
}