package codechicken.lib.world;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.ChunkEvent;

public class TileChunkLoadHook
{
    private static boolean init;
    public static void init() {
        if(init) return;
        init = true;

        MinecraftForge.EVENT_BUS.register(new TileChunkLoadHook());
    }

    @SubscribeEvent
    public void onChunkLoad(ChunkEvent.Load event) {
        for(TileEntity t : ((Iterable<TileEntity>)event.getChunk().chunkTileEntityMap.values()))
            if(t instanceof IChunkLoadTile)
                ((IChunkLoadTile)t).onChunkLoad();
    }
}

@@ -225,16 +225,68 @@
 Event;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.List;%0A%0A
 public c
@@ -582,12 +582,13 @@
     
-for(
+List%3C
 Tile
@@ -597,23 +597,30 @@
 tity
- t : ((Iterable
+%3E list = new ArrayList
 %3CTil
@@ -627,17 +627,17 @@
 eEntity%3E
-)
+(
 event.ge
@@ -673,16 +673,49 @@
 alues())
+;%0A        for(TileEntity t : list
 )%0A      

Fix ConcurrentModificationException in tile chunk load hook