package openccsensors.common.sensor;

import java.util.HashMap;

import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.Icon;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import openccsensors.api.IRequiresIconLoading;
import openccsensors.api.ISensor;
import openccsensors.api.ISensorTier;

public class WorldSensor implements ISensor, IRequiresIconLoading {
	
	private Icon icon;
	
	@Override
	public HashMap getDetails(World world, Object obj, ChunkCoordinates sensorLocation, boolean additional) {
		
		Vec3 location = (Vec3) obj;
		
		HashMap response = new HashMap();
		
		int x = (int) location.xCoord;
		int y = (int) location.yCoord;
		int z = (int) location.zCoord;
		
		response.put("Dimension", world.getWorldInfo().getVanillaDimension());
		response.put("Biome", world.getBiomeGenForCoords(x, z).biomeName);
		response.put("LightLevel", world.getBlockLightValue(x, y, z));
		response.put("Raining", world.isRaining());
		response.put("Thundering", world.isThundering());
		response.put("Daytime", world.isDaytime());
		response.put("MoonPhase", world.getCurrentMoonPhaseFactor());
		response.put("CelestialAngle", world.getCelestialAngle(1.0F));
		
		return response;
	}

	@Override
	public HashMap getTargets(World world, ChunkCoordinates location, ISensorTier tier) {
		HashMap targets = new HashMap();
		targets.put("CURRENT", location);
		return targets;
	}

	@Override
	public String[] getCustomMethods(ISensorTier tier) {
		return null;
	}

	@Override
	public Object callCustomMethod(World world, ChunkCoordinates location, int methodID,
			Object[] args, ISensorTier tier) {
		return null;
	}

	@Override
	public String getName() {
		return "worldCard";
	}

	@Override
	public Icon getIcon() {
		return icon;
	}
	
	@Override
	public void loadIcon(IconRegister iconRegistry) {
		icon = iconRegistry.registerIcon("openccsensors:world");
	}

	@Override
	public ItemStack getUniqueRecipeItem() {
		return new ItemStack(Item.enderPearl);
	}

}

@@ -665,41 +665,8 @@
 %0A%09%09%0A
-%09%09Vec3 location = (Vec3) obj;%0A%09%09%0A
 %09%09Ha
@@ -716,25 +716,31 @@
 = (int) 
-l
+sensorL
 ocation.
 xCoord;%0A
@@ -735,14 +735,12 @@
 ion.
-xCoord
+posX
 ;%0A%09%09
@@ -753,25 +753,31 @@
 = (int) 
-l
+sensorL
 ocation.
 yCoord;%0A
@@ -772,14 +772,12 @@
 ion.
-yCoord
+posY
 ;%0A%09%09
@@ -794,17 +794,23 @@
 nt) 
-l
+sensorL
 ocation.
 zCoo
@@ -809,14 +809,12 @@
 ion.
-zCoord
+posZ
 ;%0A%09%09

fix world sensor vec3 issue, fixes #181