package org.cyclops.cyclopscore.helper;

import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;

/**
 * Contains helper methods for various tile entity specific things.
 * @author rubensworks
 */
public final class TileHelpers {

    /**
     * Safely cast a tile entity.
     * @param world The world.
     * @param pos The position of the block providing the tile entity.
     * @param targetClazz The class to cast to.
     * @param <T> The type of tile to cast at.
     * @return The tile entity or null.
     */
    public static <T> T getSafeTile(IBlockAccess world, BlockPos pos, Class<T> targetClazz) {
        TileEntity tile = world.getTileEntity(pos);
        try {
            return targetClazz.cast(tile);
        } catch (ClassCastException e) {
            return null;
        }
    }

}

@@ -154,16 +154,69 @@
 kAccess;
+%0Aimport org.cyclops.cyclopscore.datastructure.DimPos;
 %0A%0A/**%0A *
@@ -342,16 +342,451 @@
 pers %7B%0A%0A
+    /**%0A     * Safely cast a tile entity.%0A     * @param dimPos The dimensional position of the block providing the tile entity.%0A     * @param targetClazz The class to cast to.%0A     * @param %3CT%3E The type of tile to cast at.%0A     * @return The tile entity or null.%0A     */%0A    public static %3CT%3E T getSafeTile(DimPos dimPos, Class%3CT%3E targetClazz) %7B%0A        return getSafeTile(dimPos.getWorld(), dimPos.getBlockPos(), targetClazz);%0A    %7D%0A%0A
     /**%0A

Add convenience getSafeTile method