From 5574e630afe44e581a37953129cb14dd4b564c08 Mon Sep 17 00:00:00 2001 From: Aesen Vismea Date: Sun, 28 Jun 2015 18:39:09 -0400 Subject: [PATCH] Fix FindBugs warnings --- src/main/java/com/unascribed/farrago/FarragoMod.java | 12 ++++++------ src/main/java/com/unascribed/farrago/Masses.java | 10 +++++----- .../com/unascribed/farrago/block/BlockLightPipe.java | 2 +- .../client/render/LightPipeBlockRenderer.java | 2 +- .../com/unascribed/farrago/item/gun/ItemKahur.java | 3 --- .../com/unascribed/farrago/selector/OreSelector.java | 1 + .../tileentity/TileEntityMachineFurnaceLike.java | 1 - 7 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/unascribed/farrago/FarragoMod.java b/src/main/java/com/unascribed/farrago/FarragoMod.java index 9cfacfb..2ee2a25 100644 --- a/src/main/java/com/unascribed/farrago/FarragoMod.java +++ b/src/main/java/com/unascribed/farrago/FarragoMod.java @@ -175,13 +175,13 @@ public class FarragoMod { public static SimpleNetworkWrapper CHANNEL; - public static Map> recipes = new HashMap>(); + public static final Map> recipes = new HashMap>(); public static String brand = null; public static boolean showBrand = true; public static boolean copperlessEnvironment; - public static CreativeTabs creativeTab = new CreativeTabs("farrago") { + public static final CreativeTabs creativeTab = new CreativeTabs("farrago") { private ItemStack iconItemStack; @Override public ItemStack getIconItemStack() { @@ -199,11 +199,11 @@ public Item getTabIconItem() { public static int scopeTicks; private YttriumGenerator yttrGen; private XenotimeGenerator xenoGen; - public static Map disabled = Maps.newHashMap(); + public static final Map disabled = Maps.newHashMap(); public static Config config; public static int lightPipeRenderType; - public static List materials = Lists.newArrayList(); - public static Map monikerLookup = Maps.newHashMap(); + public static final List materials = Lists.newArrayList(); + public static final Map monikerLookup = Maps.newHashMap(); @EventHandler public void onPreInit(FMLPreInitializationEvent e) { @@ -1023,7 +1023,7 @@ public static long hashItemStack(ItemStack toHash) { hash |= (toHash.getItemDamage() & Short.MAX_VALUE) << Short.SIZE; hash |= (Item.getIdFromItem(toHash.getItem()) & Short.MAX_VALUE); if (toHash.hasTagCompound()) { - hash |= (toHash.getTagCompound().hashCode() << 32); + hash |= ((long)toHash.getTagCompound().hashCode() << 32); } return hash; } diff --git a/src/main/java/com/unascribed/farrago/Masses.java b/src/main/java/com/unascribed/farrago/Masses.java index 4d3bb80..94a314d 100644 --- a/src/main/java/com/unascribed/farrago/Masses.java +++ b/src/main/java/com/unascribed/farrago/Masses.java @@ -27,8 +27,8 @@ import cpw.mods.fml.relauncher.ReflectionHelper; public class Masses { - public static Map> mass = Maps.newHashMap(); - public static Map bakedMass = Maps.newHashMap(); + public static final Map> mass = Maps.newHashMap(); + public static final Map bakedMass = Maps.newHashMap(); static boolean baked = false; public static void calculateMass(Item i, int depth, int durability) { if (!FarragoMod.config.getBoolean("kahur.calculateMasses")) { @@ -145,7 +145,7 @@ static void updateMass(ItemStack is, float newMass) { if (Float.isInfinite(newMass) || Float.isNaN(newMass) || newMass <= 0) { newMass = 0; } - List list = mass.get(is); + List list = mass.get(FarragoMod.hashItemStack(is)); if (list == null) { list = Lists.newArrayList(); mass.put(FarragoMod.hashItemStack(is), list); @@ -249,7 +249,7 @@ private static float average(float[] array) { total += f; } float avg = total / array.length; - return avg == Float.NaN || avg == Float.NEGATIVE_INFINITY || avg == Float.POSITIVE_INFINITY ? 0f : avg; + return Float.isNaN(avg) || avg == Float.NEGATIVE_INFINITY || avg == Float.POSITIVE_INFINITY ? 0f : avg; } private static float average(List list) { @@ -258,7 +258,7 @@ private static float average(List list) { total += f; } float avg = total / list.size(); - return avg == Float.NaN || avg == Float.NEGATIVE_INFINITY || avg == Float.POSITIVE_INFINITY ? 0f : avg; + return Float.isNaN(avg) || avg == Float.NEGATIVE_INFINITY || avg == Float.POSITIVE_INFINITY ? 0f : avg; } diff --git a/src/main/java/com/unascribed/farrago/block/BlockLightPipe.java b/src/main/java/com/unascribed/farrago/block/BlockLightPipe.java index 77dfe5b..266f919 100644 --- a/src/main/java/com/unascribed/farrago/block/BlockLightPipe.java +++ b/src/main/java/com/unascribed/farrago/block/BlockLightPipe.java @@ -121,7 +121,7 @@ public void updateTick(World world, int x, int y, int z, Random rand) { if (mMeta != 0) { mType = ((int) Math.ceil(mMeta/3f))-1; mBase = mType*3; - mCount = (mMeta == 0 ? 0 : mMeta-mBase); + mCount = mMeta-mBase; } else { mType = type; mBase = base; diff --git a/src/main/java/com/unascribed/farrago/client/render/LightPipeBlockRenderer.java b/src/main/java/com/unascribed/farrago/client/render/LightPipeBlockRenderer.java index 22ca328..9dfdddb 100644 --- a/src/main/java/com/unascribed/farrago/client/render/LightPipeBlockRenderer.java +++ b/src/main/java/com/unascribed/farrago/client/render/LightPipeBlockRenderer.java @@ -54,7 +54,7 @@ public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block b if (meta != 0) { type = ((int) Math.ceil(meta/3f))-1; int base = type*3; - count = (meta == 0 ? 0 : meta-base); + count = meta-base; } if (junction) { diff --git a/src/main/java/com/unascribed/farrago/item/gun/ItemKahur.java b/src/main/java/com/unascribed/farrago/item/gun/ItemKahur.java index 3020e9d..b9adb18 100644 --- a/src/main/java/com/unascribed/farrago/item/gun/ItemKahur.java +++ b/src/main/java/com/unascribed/farrago/item/gun/ItemKahur.java @@ -284,9 +284,6 @@ public ItemStack onItemRightClick(final ItemStack gun, final World world, final ent.motionX *= (double)1.5f; ent.motionY *= (double)1.5f; ent.motionZ *= (double)1.5f; - ent.motionX = ent.motionX; - ent.motionY = ent.motionY; - ent.motionZ = ent.motionZ; float f3 = MathHelper.sqrt_double(ent.motionX * ent.motionX + ent.motionZ * ent.motionZ); ent.prevRotationYaw = ent.rotationYaw = (float)(Math.atan2(ent.motionX, ent.motionZ) * 180.0D / Math.PI); ent.prevRotationPitch = ent.rotationPitch = (float)(Math.atan2(ent.motionY, (double)f3) * 180.0D / Math.PI); diff --git a/src/main/java/com/unascribed/farrago/selector/OreSelector.java b/src/main/java/com/unascribed/farrago/selector/OreSelector.java index 6584aa1..eb6d6be 100644 --- a/src/main/java/com/unascribed/farrago/selector/OreSelector.java +++ b/src/main/java/com/unascribed/farrago/selector/OreSelector.java @@ -67,6 +67,7 @@ public boolean isOrePresent() { } else { oresPresent = true; oreRepresentation = ores.get(0); + oreId = OreDictionary.getOreID(ore); } oresChecked = true; return oresPresent; diff --git a/src/main/java/com/unascribed/farrago/tileentity/TileEntityMachineFurnaceLike.java b/src/main/java/com/unascribed/farrago/tileentity/TileEntityMachineFurnaceLike.java index 8047aad..3a68883 100644 --- a/src/main/java/com/unascribed/farrago/tileentity/TileEntityMachineFurnaceLike.java +++ b/src/main/java/com/unascribed/farrago/tileentity/TileEntityMachineFurnaceLike.java @@ -8,7 +8,6 @@ public abstract class TileEntityMachineFurnaceLike extends TileEntityMachine { protected static final int[] slotsTop = new int[] { 0 }; protected static final int[] slotsBottom = new int[] { 2, 1 }; protected static final int[] slotsSides = new int[] { 1 }; - protected String customName; public int burnTime; public int currentItemBurnTime; public int cookTime;