From e28ad8424c136820a3d64181d9b56622a9dbef2e Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 9 Aug 2015 21:02:46 -0700 Subject: [PATCH] Clean up Utils.getTile to not use try/catch --- src/main/java/forestry/core/utils/Utils.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/forestry/core/utils/Utils.java b/src/main/java/forestry/core/utils/Utils.java index ae865734b..f02933c13 100755 --- a/src/main/java/forestry/core/utils/Utils.java +++ b/src/main/java/forestry/core/utils/Utils.java @@ -206,14 +206,13 @@ public class Utils { } public static T getTile(IBlockAccess world, int x, int y, int z, Class tileClass) { - T tileEntity = null; - try { - tileEntity = tileClass.cast(world.getTileEntity(x, y, z)); - } catch (ClassCastException ex) { - Proxies.log.warning("Failed to cast a tile entity to a " + tileClass.getName() + " at " + x + '/' + y + '/' + z); + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileClass.isInstance(tileEntity)) { + return tileClass.cast(tileEntity); + } else { + Proxies.log.warning("Failed to cast a tile entity {" + tileEntity + "} to a {" + tileClass.getName() + "} at " + x + '/' + y + '/' + z); + return null; } - - return tileEntity; } public static int addRGBComponents(int colour, int r, int g, int b) {