Clean up Utils.getTile to not use try/catch

This commit is contained in:
mezz committed 2015-08-09 21:02:46 -07:00
1 parent 9f1b1cc474
commit e28ad8424c
1 file changed
+6 -7
+6 -7
View File
@@ -206,14 +206,13 @@ public class Utils {
}
public static <T extends TileEntity> T getTile(IBlockAccess world, int x, int y, int z, Class<T> 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) {