package com.corwinjv.mobtotems.blocks;

import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLLog;
import org.apache.logging.log4j.Level;

import java.util.List;
import java.util.Random;

/**
 * Created by CorwinJV on 9/1/14.
 */
public class CreeperTotem extends BaseBlock
{
    public CreeperTotem()
    {
        super();
        setTickRandomly(true);
    }

    public boolean isOpaqueCube()
    {
        return false;
    }

    public boolean isFullCube()
    {
        return false;
    }

    public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
    {
        return false;
    }


    @Override
    public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
    {
        super.updateTick(worldIn, pos, state, rand);
        //FMLLog.log(Level.INFO, "Update tick on block at {%d, %d, %d}", pos.getX(), pos.getY(), pos.getZ());

        // Find all mobs within bounding box that match the type creeper...
        // Set those mobs on fire.
        Class creeperClass = (Class) EntityList.stringToClassMapping.get("Creeper");
        List entitiesWithinAABB = worldIn.getEntitiesWithinAABB(creeperClass,
                AxisAlignedBB.fromBounds(pos.getX() - 16,
                                            pos.getY() - 16,
                                            pos.getZ() - 16,
                                            pos.getX() + 16,
                                            pos.getY() + 16,
                                            pos.getZ() + 16));

        //FMLLog.log(Reference.MOD_NAME, Level.INFO, String.format("Entities found: %d", entitiesWithinAABB.size()));

        for(int i = 0; i < entitiesWithinAABB.size(); i++)
        {
            EntityLivingBase creeperToBurn = (EntityLivingBase)entitiesWithinAABB.get(i);
            if(!creeperToBurn.isBurning())
            {
                creeperToBurn.setFire(3);
            }
        }

        worldIn.scheduleBlockUpdate(pos, this, tickRate(worldIn), 0);
        setTickRandomly(false);
    }

    @Override
    public int tickRate(World world)
    {
        return 20;
    }
}

@@ -281,16 +281,54 @@
 ockPos;%0A
+import net.minecraft.util.EnumFacing;%0A
 import n
@@ -360,16 +360,16 @@
 Access;%0A
-
 import n
@@ -616,16 +616,62 @@
 Block%0A%7B%0A
+    public static final int TMP_BOUNDS = 16;%0A%0A
     publ
@@ -719,32 +719,330 @@
     
+%7D%0A%0A
     
-setTickRandomly(true
+public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)%0A    %7B%0A        worldIn.scheduleBlockUpdate(pos, this, tickRate(worldIn), 0);%0A        return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer
 );%0A 
@@ -1284,17 +1284,16 @@
 %0A    %7D%0A%0A
-%0A
     @Ove
@@ -1667,16 +1667,56 @@
 n fire.%0A
+        int currentRadius = TMP_BOUNDS;%0A
         
@@ -1920,26 +1920,37 @@
 os.getX() - 
-16
+currentRadius
 ,%0A          
@@ -1992,26 +1992,37 @@
 os.getY() - 
-16
+currentRadius
 ,%0A          
@@ -2068,18 +2068,29 @@
 etZ() - 
-16
+currentRadius
 ,%0A      
@@ -2136,26 +2136,37 @@
 os.getX() + 
-16
+currentRadius
 ,%0A          
@@ -2212,18 +2212,29 @@
 etY() + 
-16
+currentRadius
 ,%0A      
@@ -2284,18 +2284,29 @@
 etZ() + 
-16
+currentRadius
 ));%0A%0A   
@@ -2700,24 +2700,24 @@
 %0A        %7D%0A%0A
+
         worl
@@ -2778,40 +2778,8 @@
 0);%0A
-        setTickRandomly(false);%0A
     

Use onBlockPlaced to init CreeperTotem's updateTicks