// Path: src/main/java/eureka/api/EurekaAPI.java
// public class EurekaAPI {
// 
// 	public static IEurekAPI API;
// }
// 
// Path: src/main/java/eureka/api/IEurekaInfo.java
// public interface IEurekaInfo {
// 
// 	String getCategory();
// 
// 	int getMaxProgress();
// 
// 	ItemStack getDisplayStack();
// 
// 	String getName();
// 
// 	List<String> getRequiredResearch();
// }
// 
// Path: src/main/java/eureka/networking/MessageResearchFinished.java
// public class MessageResearchFinished implements IMessage, IMessageHandler<MessageResearchFinished, IMessage> {
// 	public String key;
// 
// 	public MessageResearchFinished() {
// 	}
// 
// 	public MessageResearchFinished(String key) {
// 		this.key = key;
// 	}
// 
// 	@Override
// 	public void fromBytes(ByteBuf buf) {
// 		int num = buf.readInt();
// 		key = "";
// 		for (int t = 0; t < num; t++)
// 			key += buf.readChar();
// 		key = key.trim();
// 	}
// 
// 	@Override
// 	public void toBytes(ByteBuf buf) {
// 		buf.writeInt(key.length());
// 		for (char c : key.toCharArray())
// 			buf.writeChar(c);
// 	}
// 
// 	@Override
// 	public IMessage onMessage(MessageResearchFinished message, MessageContext ctx) {
// 		FMLClientHandler.instance().getClient().thePlayer.addChatComponentMessage(new ChatComponentTranslation("EUREKA"));
// 		FMLClientHandler.instance().getClient().thePlayer.addChatComponentMessage(new ChatComponentText("Research finished: " + TextGetter.getTitle(message.key)));
// 		return null;
// 	}
// }
// 
// Path: src/main/java/eureka/networking/PacketHandler.java
// public class PacketHandler {
// 
// 	public static final SimpleNetworkWrapper instance = NetworkRegistry.INSTANCE.newSimpleChannel("eureka");
// 
// 	public static void init() {
// 		instance.registerMessage(MessageResearch.class, MessageResearch.class, 0, Side.CLIENT);
// 		instance.registerMessage(MessageResearchFinished.class, MessageResearchFinished.class, 1, Side.CLIENT);
// 		instance.registerMessage(MessageBookSave.class, MessageBookSave.class, 2, Side.SERVER);
// 	}
// }


import java.util.HashMap;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties;
import eureka.api.EurekaAPI;
import eureka.api.IEurekaInfo;
import eureka.networking.MessageResearchFinished;
import eureka.networking.PacketHandler;

	public void loadOldResearch(NBTTagCompound compound) {
		if (compound.getCompoundTag("ForgeData") != null && compound.getCompoundTag("ForgeData").getCompoundTag("PlayerPersisted") != null) {
			NBTTagCompound tag = compound.getCompoundTag("ForgeData").getCompoundTag("PlayerPersisted");
			for (IEurekaInfo research : EurekaAPI.API.getAllKeys()) {
				progressList.put(research.getName(), tag.getInteger(research.getName() + "Progress"));
				finished.put(research.getName(), tag.getBoolean(research.getName() + "Finished"));
				tag.removeTag(research.getName() + "Progress");
				tag.removeTag(research.getName() + "Finished");
			}
		}
	}

	@Override
	public void init(Entity entity, World world) {
	}

	public void makeProgress(String key) {
		try {
			List<String> keys = EurekaAPI.API.getInfo(key).getRequiredResearch();
			for (String checkKey : keys)
				if (!isFinished(checkKey))
					return;
			if (!progressList.containsKey(key))
				progressList.put(key, 0);
			int progress = progressList.get(key);
			progress++;
			if (progress >= EurekaAPI.API.getMaxProgress(key)) {
				progress = EurekaAPI.API.getMaxProgress(key);
				if (finished != null && key != null && !finished.get(key)) {
// Path: src/main/java/eureka/api/EurekaAPI.java
// public class EurekaAPI {
// 
// 	public static IEurekAPI API;
// }
// 
// Path: src/main/java/eureka/api/IEurekaInfo.java
// public interface IEurekaInfo {
// 
// 	String getCategory();
// 
// 	int getMaxProgress();
// 
// 	ItemStack getDisplayStack();
// 
// 	String getName();
// 
// 	List<String> getRequiredResearch();
// }
// 
// Path: src/main/java/eureka/networking/MessageResearchFinished.java
// public class MessageResearchFinished implements IMessage, IMessageHandler<MessageResearchFinished, IMessage> {
// 	public String key;
// 
// 	public MessageResearchFinished() {
// 	}
// 
// 	public MessageResearchFinished(String key) {
// 		this.key = key;
// 	}
// 
// 	@Override
// 	public void fromBytes(ByteBuf buf) {
// 		int num = buf.readInt();
// 		key = "";
// 		for (int t = 0; t < num; t++)
// 			key += buf.readChar();
// 		key = key.trim();
// 	}
// 
// 	@Override
// 	public void toBytes(ByteBuf buf) {
// 		buf.writeInt(key.length());
// 		for (char c : key.toCharArray())
// 			buf.writeChar(c);
// 	}
// 
// 	@Override
// 	public IMessage onMessage(MessageResearchFinished message, MessageContext ctx) {
// 		FMLClientHandler.instance().getClient().thePlayer.addChatComponentMessage(new ChatComponentTranslation("EUREKA"));
// 		FMLClientHandler.instance().getClient().thePlayer.addChatComponentMessage(new ChatComponentText("Research finished: " + TextGetter.getTitle(message.key)));
// 		return null;
// 	}
// }
// 
// Path: src/main/java/eureka/networking/PacketHandler.java
// public class PacketHandler {
// 
// 	public static final SimpleNetworkWrapper instance = NetworkRegistry.INSTANCE.newSimpleChannel("eureka");
// 
// 	public static void init() {
// 		instance.registerMessage(MessageResearch.class, MessageResearch.class, 0, Side.CLIENT);
// 		instance.registerMessage(MessageResearchFinished.class, MessageResearchFinished.class, 1, Side.CLIENT);
// 		instance.registerMessage(MessageBookSave.class, MessageBookSave.class, 2, Side.SERVER);
// 	}
// }


// Path: src/main/java/eureka/core/PlayerResearch.java
import java.util.HashMap;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties;
import eureka.api.EurekaAPI;
import eureka.api.IEurekaInfo;
import eureka.networking.MessageResearchFinished;
import eureka.networking.PacketHandler;


	public void loadOldResearch(NBTTagCompound compound) {
		if (compound.getCompoundTag("ForgeData") != null && compound.getCompoundTag("ForgeData").getCompoundTag("PlayerPersisted") != null) {
			NBTTagCompound tag = compound.getCompoundTag("ForgeData").getCompoundTag("PlayerPersisted");
			for (IEurekaInfo research : EurekaAPI.API.getAllKeys()) {
				progressList.put(research.getName(), tag.getInteger(research.getName() + "Progress"));
				finished.put(research.getName(), tag.getBoolean(research.getName() + "Finished"));
				tag.removeTag(research.getName() + "Progress");
				tag.removeTag(research.getName() + "Finished");
			}
		}
	}

	@Override
	public void init(Entity entity, World world) {
	}

	public void makeProgress(String key) {
		try {
			List<String> keys = EurekaAPI.API.getInfo(key).getRequiredResearch();
			for (String checkKey : keys)
				if (!isFinished(checkKey))
					return;
			if (!progressList.containsKey(key))
				progressList.put(key, 0);
			int progress = progressList.get(key);
			progress++;
			if (progress >= EurekaAPI.API.getMaxProgress(key)) {
				progress = EurekaAPI.API.getMaxProgress(key);
				if (finished != null && key != null && !finished.get(key)) {
					PacketHandler.instance.sendTo(new MessageResearchFinished(key), (EntityPlayerMP) player);