Remove redundant casts, unnecessary object creation, and string ==

This commit is contained in:
mezz committed 2016-10-21 00:32:06 -07:00
1 parent 100784b51b
commit a4cd13282a
57 files changed
+180 -156

No files matched your search

@@ -5,6 +5,7 @@ import binnie.extratrees.alcohol.drink.DrinkManager;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
public enum Cocktail {
Bellini("Bellini", Glassware.Flute, 15974764),
@@ -58,7 +59,7 @@ public enum Cocktail {
for (final Cocktail cocktail : values()) {
boolean is = true;
for (final Map.Entry<ICocktailIngredient, Integer> entry : ingredients.entrySet()) {
if (cocktail.ingredients.get(entry.getKey()) != entry.getValue()) {
if (!Objects.equals(cocktail.ingredients.get(entry.getKey()), entry.getValue())) {
is = false;
}
}
@@ -21,6 +21,7 @@ import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class ModuleAlcohol implements IInitializable {
public static int drinkRendererID;
@@ -69,13 +70,13 @@ public class ModuleAlcohol implements IInitializable {
for (final ItemStack stack : ores) {
for (final ISqueezerRecipe entry : RecipeManagers.squeezerManager.recipes()) {
try {
final ItemStack input = (ItemStack) entry.getResources()[0];
final ItemStack input = entry.getResources()[0];
final FluidStack output = entry.getFluidOutput();
if (!ItemStack.areItemStacksEqual(stack, input) && !OreDictionary.itemMatches(input, stack, true)) {
continue;
}
int amount = output.amount;
if (output.getFluid().getName() == "seedoil") {
if (Objects.equals(output.getFluid().getName(), "seedoil")) {
amount *= 2;
}
Press.addRecipe(stack, juice.get(amount));
@@ -132,9 +132,9 @@ public class ModuleBlocks implements IInitializable {
final ItemStack slabs = TileEntityMetadata.getItemStack(ExtraTrees.blockSlab, plank.ordinal());
final ItemStack stairs = TileEntityMetadata.getItemStack(ExtraTrees.blockStairs, plank.ordinal());
stairs.stackSize = 4;
GameRegistry.addRecipe(stairs.copy(), new Object[]{"# ", "## ", "###", '#', planks.copy()});
GameRegistry.addRecipe(stairs.copy(), "# ", "## ", "###", '#', planks.copy());
slabs.stackSize = 6;
CraftingManager.getInstance().getRecipeList().add(0, new ShapedOreRecipe(slabs.copy(), new Object[]{"###", '#', planks.copy()}));
CraftingManager.getInstance().getRecipeList().add(0, new ShapedOreRecipe(slabs.copy(), "###", '#', planks.copy()));
}
GameRegistry.addRecipe(new MultiFenceRecipeSize());
GameRegistry.addRecipe(new MultiFenceRecipeEmbedded());
@@ -152,13 +152,13 @@ public class ModuleBlocks implements IInitializable {
continue;
}
gate.stackSize = 1;
GameRegistry.addRecipe(gate.copy(), new Object[]{"fpf", 'f', fenceNormal.copy(), 'p', planks2.copy()});
GameRegistry.addRecipe(gate.copy(), "fpf", 'f', fenceNormal.copy(), 'p', planks2.copy());
fenceNormal.stackSize = 4;
GameRegistry.addRecipe(fenceNormal.copy(), new Object[]{"###", "# #", '#', planks2.copy()});
GameRegistry.addRecipe(doorSolid.copy(), new Object[]{"###", "###", "###", '#', planks2.copy()});
GameRegistry.addRecipe(doorStandard.copy(), new Object[]{"# #", "###", "###", '#', planks2.copy()});
GameRegistry.addRecipe(doorSplit.copy(), new Object[]{"# #", "###", "# #", '#', planks2.copy()});
GameRegistry.addRecipe(doorFull.copy(), new Object[]{"# #", "# #", "# #", '#', planks2.copy()});
GameRegistry.addRecipe(fenceNormal.copy(), "###", "# #", '#', planks2.copy());
GameRegistry.addRecipe(doorSolid.copy(), "###", "###", "###", '#', planks2.copy());
GameRegistry.addRecipe(doorStandard.copy(), "# #", "###", "###", '#', planks2.copy());
GameRegistry.addRecipe(doorSplit.copy(), "# #", "###", "# #", '#', planks2.copy());
GameRegistry.addRecipe(doorFull.copy(), "# #", "# #", "# #", '#', planks2.copy());
}
}
this.addSqueezer(EnumVanillaWoodType.SPRUCE, ExtraTreeLiquid.Resin, 50);
@@ -259,8 +259,13 @@ public class PlankType {
public ItemStack getStack() {
try {
final Class clss = Class.forName("extrabiomes.api.Stuff");
final Block block = (Block) ((Optional) clss.getField("planks").get(null)).get();
return new ItemStack(block, 1, this.ordinal());
Optional planks = (Optional) clss.getField("planks").get(null);
if (planks.isPresent()) {
final Block block = (Block) planks.get();
return new ItemStack(block, 1, this.ordinal());
} else {
return null;
}
} catch (Exception e) {
return null;
}
@@ -8,16 +8,19 @@ import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.HashMap;
public class NBTShapedRecipe implements IRecipe {
public final int recipeWidth;
public final int recipeHeight;
public final ItemStack[] recipeItems;
@Nonnull
private ItemStack recipeOutput;
private boolean field_92101_f;
private static final String __OBFID = "CL_00000093";
@Nonnull
@Override
public ItemStack getRecipeOutput() {
return this.recipeOutput;
@@ -84,7 +87,7 @@ public class NBTShapedRecipe implements IRecipe {
for (int i = 0; i < p_77572_1_.getSizeInventory(); ++i) {
final ItemStack itemstack2 = p_77572_1_.getStackInSlot(i);
if (itemstack2 != null && itemstack2.hasTagCompound()) {
itemstack.setTagCompound((NBTTagCompound) itemstack2.getTagCompound().copy());
itemstack.setTagCompound(itemstack2.getTagCompound().copy());
}
}
}
@@ -96,7 +99,7 @@ public class NBTShapedRecipe implements IRecipe {
return this.recipeWidth * this.recipeHeight;
}
public NBTShapedRecipe(final ItemStack p_92103_1_, final Object... p_92103_2_) {
public NBTShapedRecipe(@Nonnull final ItemStack recipeOutput, final Object... p_92103_2_) {
String s = "";
int i = 0;
int j = 0;
@@ -142,7 +145,7 @@ public class NBTShapedRecipe implements IRecipe {
this.recipeWidth = j;
this.recipeHeight = k;
this.recipeItems = aitemstack;
this.recipeOutput = p_92103_1_;
this.recipeOutput = recipeOutput;
NBTShapedRecipes.addRecipe(this);
}
}
@@ -119,7 +119,7 @@ public class ModuleCore implements IInitializable {
if (wood4 == null) {
outputDesigns.println("<td></td>");
} else {
final String texture = ((EnumPattern) wood4.getTopPattern().getPattern()).toString().toLowerCase();
final String texture = wood4.getTopPattern().getPattern().toString().toLowerCase();
final String img2 = "<img alt=\"" + texture + "\" src=\"images/pattern/" + texture + ".png\">";
outputDesigns.println("<td>" + img2 + " " + wood4.getName() + "</td>");
}
@@ -545,9 +545,9 @@ public class ExtraTreeSpecies implements IAlleleTreeSpecies//, IIconProvider, IG
try {
final Class elements = Class.forName("extrabiomes.lib.Element");
final Method getElementMethod = elements.getMethod("valueOf", String.class);
final Method getItemStack = elements.getMethod("get", new Class[0]);
final Method getItemStack = elements.getMethod("get");
final Object element = getElementMethod.invoke(null, "SAPLING_AUTUMN_YELLOW");
return (ItemStack) getItemStack.invoke(element, new Object[0]);
return (ItemStack) getItemStack.invoke(element);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -107,36 +107,36 @@ public class ModuleItems implements IInitializable {
@Override
public void postInit() {
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(ExtraTrees.itemDurableHammer, 1, 0), new Object[]{"wiw", " s ", " s ", 'w', Blocks.OBSIDIAN, 'i', Items.GOLD_INGOT, 's', Items.STICK}));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(ExtraTrees.itemHammer, 1, 0), new Object[]{"wiw", " s ", " s ", 'w', "plankWood", 'i', Items.IRON_INGOT, 's', Items.STICK}));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(ExtraTreeItems.Yeast.get(8), new Object[]{" m ", "mbm", 'b', Items.BREAD, 'm', Blocks.BROWN_MUSHROOM}));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(ExtraTreeItems.LagerYeast.get(8), new Object[]{"mbm", " m ", 'b', Items.BREAD, 'm', Blocks.BROWN_MUSHROOM}));
GameRegistry.addRecipe(ExtraTreeItems.GrainWheat.get(5), new Object[]{" s ", "sss", " s ", 's', Items.WHEAT_SEEDS});
GameRegistry.addRecipe(ExtraTreeItems.GrainBarley.get(3), new Object[]{" s ", "s ", " s ", 's', ExtraTreeItems.GrainWheat.get(1)});
GameRegistry.addRecipe(ExtraTreeItems.GrainCorn.get(3), new Object[]{" s ", " s", " s ", 's', ExtraTreeItems.GrainWheat.get(1)});
GameRegistry.addRecipe(ExtraTreeItems.GrainRye.get(3), new Object[]{" ", "s s", " s ", 's', ExtraTreeItems.GrainWheat.get(1)});
GameRegistry.addRecipe(ExtraTreeItems.Hops.get(3), new Object[]{" s ", "sps", " s ", 's', Items.WHEAT_SEEDS, 'p', Items.APPLE});
GameRegistry.addRecipe(ExtraTreeItems.ProvenGear.get(1), new Object[]{" s ", "s s", " s ", 's', Mods.Forestry.stack("oakStick")});
GameRegistry.addRecipe(ExtraTreeItems.GlassFitting.get(6), new Object[]{"s s", " i ", "s s", 'i', Items.IRON_INGOT, 's', Items.STICK});
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(ExtraTrees.itemDurableHammer, 1, 0), "wiw", " s ", " s ", 'w', Blocks.OBSIDIAN, 'i', Items.GOLD_INGOT, 's', Items.STICK));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(ExtraTrees.itemHammer, 1, 0), "wiw", " s ", " s ", 'w', "plankWood", 'i', Items.IRON_INGOT, 's', Items.STICK));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(ExtraTreeItems.Yeast.get(8), " m ", "mbm", 'b', Items.BREAD, 'm', Blocks.BROWN_MUSHROOM));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(ExtraTreeItems.LagerYeast.get(8), "mbm", " m ", 'b', Items.BREAD, 'm', Blocks.BROWN_MUSHROOM));
GameRegistry.addRecipe(ExtraTreeItems.GrainWheat.get(5), " s ", "sss", " s ", 's', Items.WHEAT_SEEDS);
GameRegistry.addRecipe(ExtraTreeItems.GrainBarley.get(3), " s ", "s ", " s ", 's', ExtraTreeItems.GrainWheat.get(1));
GameRegistry.addRecipe(ExtraTreeItems.GrainCorn.get(3), " s ", " s", " s ", 's', ExtraTreeItems.GrainWheat.get(1));
GameRegistry.addRecipe(ExtraTreeItems.GrainRye.get(3), " ", "s s", " s ", 's', ExtraTreeItems.GrainWheat.get(1));
GameRegistry.addRecipe(ExtraTreeItems.Hops.get(3), " s ", "sps", " s ", 's', Items.WHEAT_SEEDS, 'p', Items.APPLE);
GameRegistry.addRecipe(ExtraTreeItems.ProvenGear.get(1), " s ", "s s", " s ", 's', Mods.Forestry.stack("oakStick"));
GameRegistry.addRecipe(ExtraTreeItems.GlassFitting.get(6), "s s", " i ", "s s", 'i', Items.IRON_INGOT, 's', Items.STICK);
GameRegistry.addSmelting(ExtraTreeItems.GrainWheat.get(1), ExtraTreeItems.GrainRoasted.get(1), 0.0f);
GameRegistry.addSmelting(ExtraTreeItems.GrainRye.get(1), ExtraTreeItems.GrainRoasted.get(1), 0.0f);
GameRegistry.addSmelting(ExtraTreeItems.GrainCorn.get(1), ExtraTreeItems.GrainRoasted.get(1), 0.0f);
GameRegistry.addSmelting(ExtraTreeItems.GrainBarley.get(1), ExtraTreeItems.GrainRoasted.get(1), 0.0f);
try {
final Item minium = (Item) Class.forName("com.pahimar.ee3.lib.ItemIds").getField("miniumShard").get(null);
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(Food.Papayimar.get(1), new Object[]{minium, "cropPapaya"}));
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(Food.Papayimar.get(1), minium, "cropPapaya"));
} catch (Exception ex) {
}
RecipeManagers.carpenterManager.addRecipe(100, Binnie.Liquid.getLiquidStack("water", 2000), (ItemStack) null, new ItemStack(ExtraTrees.itemDictionary), new Object[]{"X#X", "YEY", "RDR", '#', Blocks.GLASS_PANE, 'X', Items.GOLD_INGOT, 'Y', "ingotCopper", 'R', Items.REDSTONE, 'D', Items.DIAMOND, 'E', Items.EMERALD});
RecipeManagers.carpenterManager.addRecipe(100, Binnie.Liquid.getLiquidStack("water", 2000), (ItemStack) null, new ItemStack(ExtraTrees.itemDictionaryLepi), new Object[]{"X#X", "YEY", "RDR", '#', Blocks.GLASS_PANE, 'X', Items.GOLD_INGOT, 'Y', "ingotBronze", 'R', Items.REDSTONE, 'D', Items.DIAMOND, 'E', Items.EMERALD});
RecipeManagers.carpenterManager.addRecipe(100, Binnie.Liquid.getLiquidStack("water", 2000), null, new ItemStack(ExtraTrees.itemDictionary), "X#X", "YEY", "RDR", '#', Blocks.GLASS_PANE, 'X', Items.GOLD_INGOT, 'Y', "ingotCopper", 'R', Items.REDSTONE, 'D', Items.DIAMOND, 'E', Items.EMERALD);
RecipeManagers.carpenterManager.addRecipe(100, Binnie.Liquid.getLiquidStack("water", 2000), null, new ItemStack(ExtraTrees.itemDictionaryLepi), "X#X", "YEY", "RDR", '#', Blocks.GLASS_PANE, 'X', Items.GOLD_INGOT, 'Y', "ingotBronze", 'R', Items.REDSTONE, 'D', Items.DIAMOND, 'E', Items.EMERALD);
RecipeManagers.stillManager.addRecipe(25, ExtraTreeLiquid.Resin.get(5), ExtraTreeLiquid.Turpentine.get(3));
RecipeManagers.carpenterManager.addRecipe(25, ExtraTreeLiquid.Turpentine.get(50), (ItemStack) null, ((ItemMisc) ExtraTrees.itemMisc).getStack(ExtraTreeItems.WoodWax, 4), new Object[]{"x", 'x', Mods.Forestry.stack("beeswax")});
RecipeManagers.carpenterManager.addRecipe(25, ExtraTreeLiquid.Turpentine.get(50), null, ((ItemMisc) ExtraTrees.itemMisc).getStack(ExtraTreeItems.WoodWax, 4), "x", 'x', Mods.Forestry.stack("beeswax"));
if (Binnie.Liquid.getLiquidStack("Creosote Oil", 100) != null) {
RecipeManagers.carpenterManager.addRecipe(25, Binnie.Liquid.getLiquidStack("Creosote Oil", 50), (ItemStack) null, ((ItemMisc) ExtraTrees.itemMisc).getStack(ExtraTreeItems.WoodWax, 1), new Object[]{"x", 'x', Mods.Forestry.stack("beeswax")});
RecipeManagers.carpenterManager.addRecipe(25, Binnie.Liquid.getLiquidStack("Creosote Oil", 50), null, ((ItemMisc) ExtraTrees.itemMisc).getStack(ExtraTreeItems.WoodWax, 1), "x", 'x', Mods.Forestry.stack("beeswax"));
}
for (final FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
if (data.fluid.isFluidEqual(Binnie.Liquid.getLiquidStack("water", 0)) && data.fluid.amount == 1000) {
CraftingManager.getInstance().addRecipe(Mods.Forestry.stack("mulch"), new Object[]{" b ", "bwb", " b ", 'b', ExtraTreeItems.Bark.get(1), 'w', data.filledContainer.copy()});
CraftingManager.getInstance().addRecipe(Mods.Forestry.stack("mulch"), " b ", "bwb", " b ", 'b', ExtraTreeItems.Bark.get(1), 'w', data.filledContainer.copy());
}
}
FuelManager.bronzeEngineFuel.put(ExtraTreeLiquid.Sap.get(1).getFluid(), new EngineBronzeFuel(ExtraTreeLiquid.Sap.get(1).getFluid(), 20, 10000, 1));
@@ -12,8 +12,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
public enum KitchenMachine implements IMachineType {
Worktop((Class<? extends MachinePackage>) null),
Cupboard((Class<? extends MachinePackage>) null),
Worktop(null),
Cupboard(null),
BottleRack(BottleRack.PackageBottleRack.class);
Class<? extends MachinePackage> clss;
@@ -28,13 +28,13 @@ public class ModuleMachine implements IInitializable {
@Override
public void postInit() {
GameRegistry.addRecipe(new ShapedOreRecipe(ExtraTreeMachine.Lumbermill.get(1), new Object[]{"gAg", "GsG", "gPg", 'G', Blocks.GLASS, 'g', ExtraTreeItems.ProvenGear.get(1), 'A', Items.IRON_AXE, 's', Mods.Forestry.stack("sturdyMachine"), 'P', "gearBronze"}));
GameRegistry.addRecipe(new ShapedOreRecipe(ExtraTreeMachine.Press.get(1), new Object[]{"iGi", "tSt", "tPt", 'i', "ingotIron", 'G', Blocks.GLASS, 't', "ingotTin", 'S', Mods.Forestry.stack("sturdyMachine"), 'P', "gearBronze"}));
GameRegistry.addRecipe(new ShapedOreRecipe(ExtraTreeMachine.Brewery.get(1), new Object[]{"bGb", "iSi", "bPb", 'i', "ingotIron", 'G', Blocks.GLASS, 'b', "gearBronze", 'S', Mods.Forestry.stack("sturdyMachine"), 'P', "gearBronze"}));
GameRegistry.addRecipe(new ShapedOreRecipe(ExtraTreeMachine.Distillery.get(1), new Object[]{"rGr", "iSi", "rPr", 'i', "ingotIron", 'G', Blocks.GLASS, 'r', "dustRedstone", 'S', Mods.Forestry.stack("sturdyMachine"), 'P', "gearBronze"}));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(ExtraTreeMachine.Woodworker.get(1), new Object[]{"wGw", "GsG", "ggg", 'G', Blocks.GLASS, 'g', ExtraTreeItems.ProvenGear.get(1), 'w', Blocks.PLANKS, 's', Mods.Forestry.stack("impregnatedCasing")}));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(ExtraTreeMachine.Panelworker.get(1), new Object[]{"wGw", "GsG", "ggg", 'G', Blocks.GLASS, 'g', ExtraTreeItems.ProvenGear.get(1), 'w', Blocks.WOODEN_SLAB, 's', Mods.Forestry.stack("impregnatedCasing")}));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(ExtraTreeMachine.Glassworker.get(1), new Object[]{"wGw", "GsG", "ggg", 'G', Blocks.GLASS, 'g', ExtraTreeItems.ProvenGear.get(1), 'w', Blocks.GLASS, 's', Mods.Forestry.stack("impregnatedCasing")}));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(ExtraTreeMachine.Tileworker.get(1), new Object[]{"wGw", "GsG", "ggg", 'G', Blocks.GLASS, 'g', ExtraTreeItems.ProvenGear.get(1), 'w', Items.CLAY_BALL, 's', Mods.Forestry.stack("impregnatedCasing")}));
GameRegistry.addRecipe(new ShapedOreRecipe(ExtraTreeMachine.Lumbermill.get(1), "gAg", "GsG", "gPg", 'G', Blocks.GLASS, 'g', ExtraTreeItems.ProvenGear.get(1), 'A', Items.IRON_AXE, 's', Mods.Forestry.stack("sturdyMachine"), 'P', "gearBronze"));
GameRegistry.addRecipe(new ShapedOreRecipe(ExtraTreeMachine.Press.get(1), "iGi", "tSt", "tPt", 'i', "ingotIron", 'G', Blocks.GLASS, 't', "ingotTin", 'S', Mods.Forestry.stack("sturdyMachine"), 'P', "gearBronze"));
GameRegistry.addRecipe(new ShapedOreRecipe(ExtraTreeMachine.Brewery.get(1), "bGb", "iSi", "bPb", 'i', "ingotIron", 'G', Blocks.GLASS, 'b', "gearBronze", 'S', Mods.Forestry.stack("sturdyMachine"), 'P', "gearBronze"));
GameRegistry.addRecipe(new ShapedOreRecipe(ExtraTreeMachine.Distillery.get(1), "rGr", "iSi", "rPr", 'i', "ingotIron", 'G', Blocks.GLASS, 'r', "dustRedstone", 'S', Mods.Forestry.stack("sturdyMachine"), 'P', "gearBronze"));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(ExtraTreeMachine.Woodworker.get(1), "wGw", "GsG", "ggg", 'G', Blocks.GLASS, 'g', ExtraTreeItems.ProvenGear.get(1), 'w', Blocks.PLANKS, 's', Mods.Forestry.stack("impregnatedCasing")));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(ExtraTreeMachine.Panelworker.get(1), "wGw", "GsG", "ggg", 'G', Blocks.GLASS, 'g', ExtraTreeItems.ProvenGear.get(1), 'w', Blocks.WOODEN_SLAB, 's', Mods.Forestry.stack("impregnatedCasing")));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(ExtraTreeMachine.Glassworker.get(1), "wGw", "GsG", "ggg", 'G', Blocks.GLASS, 'g', ExtraTreeItems.ProvenGear.get(1), 'w', Blocks.GLASS, 's', Mods.Forestry.stack("impregnatedCasing")));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(ExtraTreeMachine.Tileworker.get(1), "wGw", "GsG", "ggg", 'G', Blocks.GLASS, 'g', ExtraTreeItems.ProvenGear.get(1), 'w', Items.CLAY_BALL, 's', Mods.Forestry.stack("impregnatedCasing")));
}
}
@@ -13,6 +13,6 @@ public class BlockTypeLeaf extends BlockType {
@Override
public void setBlock(final World world, final ITreeGenData tree, final BlockPos pos) {
tree.setLeaves(world, (GameProfile) null, pos);
tree.setLeaves(world, null, pos);
}
}