package com.edicatad.emvi.handlers;

import net.minecraftforge.event.world.ChunkWatchEvent.UnWatch;
import net.minecraftforge.event.world.ChunkWatchEvent.Watch;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.WorldTickEvent;

@Mod.EventBusSubscriber
public class TickHandler {
	@SubscribeEvent(priority=EventPriority.NORMAL)
	public static void chunkWatched(Watch event){
		FMLLog.getLogger().info("[EMVI]  Chunk watched at coords %d, %d", event.getChunk().chunkXPos, event.getChunk().chunkZPos);
	}
	
	@SubscribeEvent(priority=EventPriority.NORMAL)
	public static void chunkUnwatched(UnWatch event){
		FMLLog.getLogger().info("[EMVI]  Chunk unwatched at coords %d, %d", event.getChunk().chunkXPos, event.getChunk().chunkZPos);
	}
	
	@SubscribeEvent
	public static void worldTick(WorldTickEvent event){
		switch(event.phase){
		case END:
			break;
		case START:
			/*
			 * TODO 
			 * use getWorldTime to only run spawn checker code at dawn or something
			 * spawn villagers based on random chance
			 */
			//event.world.getWorldTime();
			// this is a switch in case I want to provide mod support to other mods or add villagers to the nether or something
			switch(event.world.provider.getDimension()){
			case 0:
				// We're ticking the overworld dimension!
				// maybe info has trouble with non-local parameter passes, try storing the world time as an int
				FMLLog.getLogger().info("Tick %d", event.world.getWorldTime());
				break;
			default:
				break;
			}
			break;
		default:
			break;
		}
	}
}

@@ -41,168 +41,197 @@
 ort 
-net.minecraftforge.event.world.ChunkWatchEvent.UnWatch;%0Aimport net.minecraftforge.event.world.ChunkWatchEvent.Watch;%0Aimport net.minecraftforge.fml.common.FMLLog
+java.util.logging.Level;%0Aimport java.util.logging.Logger;%0A%0Aimport net.minecraft.entity.EnumCreatureType;%0Aimport net.minecraft.entity.passive.EntityVillager;%0Aimport net.minecraft.init.Biomes
 ;%0Aim
@@ -320,29 +320,30 @@
 handler.
-EventPriority
+SubscribeEvent
 ;%0Aimport
@@ -373,38 +373,45 @@
 .common.
+game
 event
-handler.Subscribe
+.TickEvent.WorldTick
 Event;%0Ai
@@ -450,42 +450,31 @@
 mon.
-gameevent.TickEvent.WorldTickEvent
+registry.EntityRegistry
 ;%0A%0A@
@@ -528,532 +528,639 @@
  %7B%0A%09
-@SubscribeEvent(priority=EventPriority.NORMAL)%0A%09public static void chunkWatched(Watch event)%7B%0A%09%09FMLLog.getLogger().info(%22%5BEMVI%5D  Chunk watched at coords %25d, %25d%22, event.getChunk().chunkXPos, event.getChunk().chunkZPos);%0A%09%7D%0A%09%0A%09@SubscribeEvent(priority=EventPriority.NORMAL)%0A%09public static void chunkUnwatched(UnWatch event)%7B%0A%09%09FMLLog.getLogger().info(%22%5BEMVI%5D  Chunk unwatched at coords %25d, %25d%22, event.getChunk().chunkXPos, event.getChunk().chunkZPos);%0A%09%7D%0A%09%0A%09@SubscribeEvent%0A%09public static void worldTick(WorldTickEvent event)%7B
+private static long worldTime;%0A%09public static void test()%7B%0A%09%09/*%0A%09%09 * I'm not sure this achieves what I want;  it adds the villager to the spawn list in some fashion%0A%09%09 * but I'm not sure when these are actually spawned, nor do I have any control over their proximity %0A%09%09 * to the player.  I suspect a custom spawn handler may be the way to go here%0A%09%09 */%0A%09%09EntityRegistry.addSpawn(EntityVillager.class, 10, 0, 10, EnumCreatureType.CREATURE, Biomes.DEFAULT);%0A%09%7D%0A%09%0A%09@SubscribeEvent%0A%09public static void worldTick(WorldTickEvent event)%7B%0A%09%09worldTime = event.world.getWorldTime();%0A%09%09if(Math.floorMod(worldTime, 100)!=0)%7B%0A%09%09%09return;%0A%09%09%7D%0A%09%09
 %0A%09%09s
@@ -1364,41 +1364,8 @@
  */%0A
-%09%09%09//event.world.getWorldTime();%0A
 %09%09%09/
@@ -1595,164 +1595,221 @@
 %09// 
-maybe info has trouble with non-local parameter passes, try storing the 
+using a bed sticks you at a multiple of 24000%0A%09%09%09%09worldTime = event.world.getWorldTime();%0A%09%09%09%09if(Math.floorMod(
 world
- time as an int%0A%09%09%09%09FMLLog.getLogger().info(%22Tick %25d%22, event.world.getW
+Time, 10)==0)%7B%0A%09%09%09%09%09Logger.getLogger(%22EMVI%22).log(Level.INFO,String.format(%22TESTING %25d%22, w
 orldTime
 ());
@@ -1808,13 +1808,18 @@
 Time
-(
 ));%0A
+%09%09%09%09%7D%0A
 %09%09%09%09

Add method to enter villagers into spawn registry