// Path: src/net/zhuoweizhang/pocketinveditor/io/EntityDataConverter.java
// public final class EntityDataConverter {
// 	public static final byte[] header = {0x45, 0x4e, 0x54, 0x00, 0x01, 0x00, 0x00, 0x00};
// 
// 	public static class EntityData {
// 		public List<Entity> entities;
// 		public List<TileEntity> tileEntities;
// 		public EntityData(List<Entity> entities, List<TileEntity> tileEntities) {
// 			this.entities = entities;
// 			this.tileEntities = tileEntities;
// 		}
// 	}
// 
// 	public static EntityData read(File file) throws IOException {
// 		FileInputStream fis = new FileInputStream(file);
// 		BufferedInputStream is = new BufferedInputStream(fis);
// 		is.skip(12);
// 		EntityData eDat = NBTConverter.readEntities((CompoundTag) new NBTInputStream(is, false, true).readTag());
// 		is.close();
// 		return eDat;
// 	}
// 
// 	public static void write(List<Entity> entitiesList, List<TileEntity> tileEntitiesList, File file) throws IOException {
// 		ByteArrayOutputStream bos = new ByteArrayOutputStream();
// 		new NBTOutputStream(bos, false, true).writeTag(NBTConverter.writeEntities(entitiesList, tileEntitiesList));
// 
// 		FileOutputStream os = new FileOutputStream(file);
// 		DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(os));
// 
// 		int length = bos.size();
// 		dos.write(header);
// 		dos.writeInt(Integer.reverseBytes(length));
// 		bos.writeTo(dos);
// 		dos.close();
// 	}
// 
// 	public static void main(String[] args) throws Exception {
// 		EntityData entities = read(new File(args[0]));
// 		System.out.println(entities);
// 		write(entities.entities, entities.tileEntities, new File(args[1]));
// 	}
// 
// }
// 
// Path: src/net/zhuoweizhang/pocketinveditor/util/Vector3f.java
// public class Vector3f {
// 	
// 	public float x, y, z;
// 
// 	public Vector3f() {
// 		this(0f, 0f, 0f);
// 	}
// 	
// 	public Vector3f(float x, float y, float z) {
// 		this.x = x;
// 		this.y = y;
// 		this.z = z;
// 	}
// 
// 	public float getX() {
// 		return x;
// 	}
// 
// 	public Vector3f setX(float x) {
// 		this.x = x;
// 		return this;
// 	}
// 
// 	public float getY() {
// 		return y;
// 	}
// 
// 	public Vector3f setY(float y) {
// 		this.y = y;
// 		return this;
// 	}
// 
// 	public float getZ() {
// 		return z;
// 	}
// 
// 	public Vector3f setZ(float z) {
// 		this.z = z;
// 		return this;
// 	}
// 
// 	public int getBlockX() {
// 		return (int) x;
// 	}
// 
// 	public int getBlockY() {
// 		return (int) y;
// 	}
// 
// 	public int getBlockZ() {
// 		return (int) z;
// 	}
// 
// 	public double distSquared(Vector3f other) {
// 		return Math.pow(other.x - (double) this.x, 2) + Math.pow(other.y - (double) this.y, 2) + Math.pow(other.z - (double) this.z, 2);
// 	}
// 
// }


import java.io.File;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import net.zhuoweizhang.pocketinveditor.entity.*;
import net.zhuoweizhang.pocketinveditor.io.EntityDataConverter;
import net.zhuoweizhang.pocketinveditor.tileentity.*;
import net.zhuoweizhang.pocketinveditor.util.Vector3f;
		String entityCountString = buildEntityCountString(countMap);
		if (entityCountString.length() == 0) {
			entityCountString = this.getResources().getText(R.string.entities_none).toString();
		}
		entityCountText.setText(entityCountString);
	}

	private String buildEntityCountString(Map<EntityType, Integer> countMap) {
		StringBuilder builder = new StringBuilder();
		for (Map.Entry<EntityType, Integer> entry: countMap.entrySet()) {
			Integer resId = EntityTypeLocalization.namesMap.get(entry.getKey());
			if (resId == null) resId = new Integer(R.string.entity_unknown);
			builder.append(this.getResources().getText(resId));
			builder.append(':');
			builder.append(entry.getValue());
			builder.append('\n');
		}
		return builder.toString();
	}

	public void apoCowlypse() {
		List<Entity> list = EditorActivity.level.getEntities();
		Vector3f playerLoc = EditorActivity.level.getPlayer().getLocation();
		int beginX = (int) playerLoc.getX() - 16;
		int endX = (int) playerLoc.getX() + 16;
		int beginZ = (int) playerLoc.getZ() - 16;
		int endZ = (int) playerLoc.getZ() + 16;
		for (int x = beginX; x < endX; x += 2) {
			for (int z = beginZ; z < endZ; z += 2) {
				Cow cow = new Cow();
// Path: src/net/zhuoweizhang/pocketinveditor/io/EntityDataConverter.java
// public final class EntityDataConverter {
// 	public static final byte[] header = {0x45, 0x4e, 0x54, 0x00, 0x01, 0x00, 0x00, 0x00};
// 
// 	public static class EntityData {
// 		public List<Entity> entities;
// 		public List<TileEntity> tileEntities;
// 		public EntityData(List<Entity> entities, List<TileEntity> tileEntities) {
// 			this.entities = entities;
// 			this.tileEntities = tileEntities;
// 		}
// 	}
// 
// 	public static EntityData read(File file) throws IOException {
// 		FileInputStream fis = new FileInputStream(file);
// 		BufferedInputStream is = new BufferedInputStream(fis);
// 		is.skip(12);
// 		EntityData eDat = NBTConverter.readEntities((CompoundTag) new NBTInputStream(is, false, true).readTag());
// 		is.close();
// 		return eDat;
// 	}
// 
// 	public static void write(List<Entity> entitiesList, List<TileEntity> tileEntitiesList, File file) throws IOException {
// 		ByteArrayOutputStream bos = new ByteArrayOutputStream();
// 		new NBTOutputStream(bos, false, true).writeTag(NBTConverter.writeEntities(entitiesList, tileEntitiesList));
// 
// 		FileOutputStream os = new FileOutputStream(file);
// 		DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(os));
// 
// 		int length = bos.size();
// 		dos.write(header);
// 		dos.writeInt(Integer.reverseBytes(length));
// 		bos.writeTo(dos);
// 		dos.close();
// 	}
// 
// 	public static void main(String[] args) throws Exception {
// 		EntityData entities = read(new File(args[0]));
// 		System.out.println(entities);
// 		write(entities.entities, entities.tileEntities, new File(args[1]));
// 	}
// 
// }
// 
// Path: src/net/zhuoweizhang/pocketinveditor/util/Vector3f.java
// public class Vector3f {
// 	
// 	public float x, y, z;
// 
// 	public Vector3f() {
// 		this(0f, 0f, 0f);
// 	}
// 	
// 	public Vector3f(float x, float y, float z) {
// 		this.x = x;
// 		this.y = y;
// 		this.z = z;
// 	}
// 
// 	public float getX() {
// 		return x;
// 	}
// 
// 	public Vector3f setX(float x) {
// 		this.x = x;
// 		return this;
// 	}
// 
// 	public float getY() {
// 		return y;
// 	}
// 
// 	public Vector3f setY(float y) {
// 		this.y = y;
// 		return this;
// 	}
// 
// 	public float getZ() {
// 		return z;
// 	}
// 
// 	public Vector3f setZ(float z) {
// 		this.z = z;
// 		return this;
// 	}
// 
// 	public int getBlockX() {
// 		return (int) x;
// 	}
// 
// 	public int getBlockY() {
// 		return (int) y;
// 	}
// 
// 	public int getBlockZ() {
// 		return (int) z;
// 	}
// 
// 	public double distSquared(Vector3f other) {
// 		return Math.pow(other.x - (double) this.x, 2) + Math.pow(other.y - (double) this.y, 2) + Math.pow(other.z - (double) this.z, 2);
// 	}
// 
// }


// Path: src/net/zhuoweizhang/pocketinveditor/EntitiesInfoActivity.java
import java.io.File;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import net.zhuoweizhang.pocketinveditor.entity.*;
import net.zhuoweizhang.pocketinveditor.io.EntityDataConverter;
import net.zhuoweizhang.pocketinveditor.tileentity.*;
import net.zhuoweizhang.pocketinveditor.util.Vector3f;

		String entityCountString = buildEntityCountString(countMap);
		if (entityCountString.length() == 0) {
			entityCountString = this.getResources().getText(R.string.entities_none).toString();
		}
		entityCountText.setText(entityCountString);
	}

	private String buildEntityCountString(Map<EntityType, Integer> countMap) {
		StringBuilder builder = new StringBuilder();
		for (Map.Entry<EntityType, Integer> entry: countMap.entrySet()) {
			Integer resId = EntityTypeLocalization.namesMap.get(entry.getKey());
			if (resId == null) resId = new Integer(R.string.entity_unknown);
			builder.append(this.getResources().getText(resId));
			builder.append(':');
			builder.append(entry.getValue());
			builder.append('\n');
		}
		return builder.toString();
	}

	public void apoCowlypse() {
		List<Entity> list = EditorActivity.level.getEntities();
		Vector3f playerLoc = EditorActivity.level.getPlayer().getLocation();
		int beginX = (int) playerLoc.getX() - 16;
		int endX = (int) playerLoc.getX() + 16;
		int beginZ = (int) playerLoc.getZ() - 16;
		int endZ = (int) playerLoc.getZ() + 16;
		for (int x = beginX; x < endX; x += 2) {
			for (int z = beginZ; z < endZ; z += 2) {
				Cow cow = new Cow();
				cow.setLocation(new Vector3f(x, 128, z));