// Path: src/main/java/com/panicnot42/warpbook/net/packet/PacketSyncWaypoints.java
// public class PacketSyncWaypoints implements IMessage, IMessageHandler<PacketSyncWaypoints, IMessage> {
// 	public HashMap<String, Waypoint> table;
// 	
// 	public PacketSyncWaypoints() {
// 	}
// 	
// 	public PacketSyncWaypoints(HashMap<String, Waypoint> table) {
// 		this.table = table;
// 	}
// 	
// 	@Override
// 	public void fromBytes(ByteBuf buffer) {
// 		NBTTagCompound tag = ByteBufUtils.readTag(buffer);
// 		table = NBTUtils.readHashMapFromNBT(tag.getTagList("data", Constants.NBT.TAG_COMPOUND), Waypoint.class);
// 	}
// 	
// 	@Override
// 	public void toBytes(ByteBuf buffer) {
// 		NBTTagCompound tag = new NBTTagCompound();
// 		NBTUtils.writeHashMapToNBT(tag.getTagList("data", Constants.NBT.TAG_COMPOUND), table);
// 		ByteBufUtils.writeTag(buffer, tag);
// 	}
// 	
// 	@Override
// 	public IMessage onMessage(PacketSyncWaypoints message, MessageContext ctx) {
// 		World world = Minecraft.getMinecraft().player.world;
// 		WarpWorldStorage s = WarpWorldStorage.get(world);
// 		s.table = message.table;
// 		s.save(world);
// 		return null;
// 	}
// 	
// }
// 
// Path: src/main/java/com/panicnot42/warpbook/util/MathUtils.java
// public class MathUtils {
// 	public static int round(double value, RoundingMode mode) {
// 		return new BigDecimal(value).setScale(0, mode).intValue();
// 	}
// }
// 
// Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java
// public class Waypoint implements INBTSerializable {
// 	public String friendlyName, name;
// 	public int x, y, z, dim;
// 	
// 	public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) {
// 		this.friendlyName = friendlyName;
// 		this.name = name;
// 		this.x = x;
// 		this.y = y;
// 		this.z = z;
// 		this.dim = dim;
// 	}
// 	
// 	public Waypoint(NBTTagCompound var1) {
// 		readFromNBT(var1);
// 	}
// 	
// 	@Override
// 	public void readFromNBT(NBTTagCompound var1) {
// 		this.friendlyName = var1.getString("friendlyName");
// 		this.x = var1.getInteger("x");
// 		this.y = var1.getInteger("y");
// 		this.z = var1.getInteger("z");
// 		this.dim = var1.getInteger("dim");
// 		this.name = var1.getString("name");
// 	}
// 	
// 	@Override
// 	public void writeToNBT(NBTTagCompound var1) {
// 		var1.setString("friendlyName", this.friendlyName);
// 		var1.setInteger("x", this.x);
// 		var1.setInteger("y", this.y);
// 		var1.setInteger("z", this.z);
// 		var1.setInteger("dim", this.dim);
// 		var1.setString("name", this.name);
// 	}
// 
// }


import java.math.RoundingMode;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import com.panicnot42.warpbook.net.packet.PacketSyncWaypoints;
import com.panicnot42.warpbook.util.MathUtils;
import com.panicnot42.warpbook.util.Waypoint;
import io.netty.channel.ChannelFutureListener;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import net.minecraft.world.storage.WorldSavedData;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fml.common.network.FMLEmbeddedChannel;
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerConnectionFromClientEvent;
import net.minecraftforge.fml.common.network.FMLOutboundHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher;
import net.minecraftforge.fml.relauncher.Side;
		FMLEmbeddedChannel channel = NetworkRegistry.INSTANCE.getChannel(Properties.modid, Side.SERVER);
		channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DISPATCHER);
		channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(NetworkDispatcher.get(e.getManager()));
		channel.writeAndFlush(new PacketSyncWaypoints(table)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
	}
	
	public boolean waypointExists(String name) {
		return table.containsKey(name);
	}
	
	public Waypoint getWaypoint(String name) {
		return table.get(name);
	}
	
	public void addWaypoint(Waypoint point) {
		table.put(point.name, point);
		this.markDirty();
	}
	
	public Set<String> listWaypoints() {
		return table.keySet();
	}
	
	public boolean deleteWaypoint(String waypoint) {
		boolean res = table.remove(waypoint) != null;
		this.markDirty();
		return res;
	}
	
	public void setLastDeath(UUID id, double posX, double posY, double posZ, int dim) {
// Path: src/main/java/com/panicnot42/warpbook/net/packet/PacketSyncWaypoints.java
// public class PacketSyncWaypoints implements IMessage, IMessageHandler<PacketSyncWaypoints, IMessage> {
// 	public HashMap<String, Waypoint> table;
// 	
// 	public PacketSyncWaypoints() {
// 	}
// 	
// 	public PacketSyncWaypoints(HashMap<String, Waypoint> table) {
// 		this.table = table;
// 	}
// 	
// 	@Override
// 	public void fromBytes(ByteBuf buffer) {
// 		NBTTagCompound tag = ByteBufUtils.readTag(buffer);
// 		table = NBTUtils.readHashMapFromNBT(tag.getTagList("data", Constants.NBT.TAG_COMPOUND), Waypoint.class);
// 	}
// 	
// 	@Override
// 	public void toBytes(ByteBuf buffer) {
// 		NBTTagCompound tag = new NBTTagCompound();
// 		NBTUtils.writeHashMapToNBT(tag.getTagList("data", Constants.NBT.TAG_COMPOUND), table);
// 		ByteBufUtils.writeTag(buffer, tag);
// 	}
// 	
// 	@Override
// 	public IMessage onMessage(PacketSyncWaypoints message, MessageContext ctx) {
// 		World world = Minecraft.getMinecraft().player.world;
// 		WarpWorldStorage s = WarpWorldStorage.get(world);
// 		s.table = message.table;
// 		s.save(world);
// 		return null;
// 	}
// 	
// }
// 
// Path: src/main/java/com/panicnot42/warpbook/util/MathUtils.java
// public class MathUtils {
// 	public static int round(double value, RoundingMode mode) {
// 		return new BigDecimal(value).setScale(0, mode).intValue();
// 	}
// }
// 
// Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java
// public class Waypoint implements INBTSerializable {
// 	public String friendlyName, name;
// 	public int x, y, z, dim;
// 	
// 	public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) {
// 		this.friendlyName = friendlyName;
// 		this.name = name;
// 		this.x = x;
// 		this.y = y;
// 		this.z = z;
// 		this.dim = dim;
// 	}
// 	
// 	public Waypoint(NBTTagCompound var1) {
// 		readFromNBT(var1);
// 	}
// 	
// 	@Override
// 	public void readFromNBT(NBTTagCompound var1) {
// 		this.friendlyName = var1.getString("friendlyName");
// 		this.x = var1.getInteger("x");
// 		this.y = var1.getInteger("y");
// 		this.z = var1.getInteger("z");
// 		this.dim = var1.getInteger("dim");
// 		this.name = var1.getString("name");
// 	}
// 	
// 	@Override
// 	public void writeToNBT(NBTTagCompound var1) {
// 		var1.setString("friendlyName", this.friendlyName);
// 		var1.setInteger("x", this.x);
// 		var1.setInteger("y", this.y);
// 		var1.setInteger("z", this.z);
// 		var1.setInteger("dim", this.dim);
// 		var1.setString("name", this.name);
// 	}
// 
// }


// Path: src/main/java/com/panicnot42/warpbook/WarpWorldStorage.java
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import com.panicnot42.warpbook.net.packet.PacketSyncWaypoints;
import com.panicnot42.warpbook.util.MathUtils;
import com.panicnot42.warpbook.util.Waypoint;
import io.netty.channel.ChannelFutureListener;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import net.minecraft.world.storage.WorldSavedData;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fml.common.network.FMLEmbeddedChannel;
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerConnectionFromClientEvent;
import net.minecraftforge.fml.common.network.FMLOutboundHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher;
import net.minecraftforge.fml.relauncher.Side;

		FMLEmbeddedChannel channel = NetworkRegistry.INSTANCE.getChannel(Properties.modid, Side.SERVER);
		channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DISPATCHER);
		channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(NetworkDispatcher.get(e.getManager()));
		channel.writeAndFlush(new PacketSyncWaypoints(table)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
	}
	
	public boolean waypointExists(String name) {
		return table.containsKey(name);
	}
	
	public Waypoint getWaypoint(String name) {
		return table.get(name);
	}
	
	public void addWaypoint(Waypoint point) {
		table.put(point.name, point);
		this.markDirty();
	}
	
	public Set<String> listWaypoints() {
		return table.keySet();
	}
	
	public boolean deleteWaypoint(String waypoint) {
		boolean res = table.remove(waypoint) != null;
		this.markDirty();
		return res;
	}
	
	public void setLastDeath(UUID id, double posX, double posY, double posZ, int dim) {
		deaths.put(id, new Waypoint("Death Point", "death", MathUtils.round(posX, RoundingMode.DOWN), MathUtils.round(posY, RoundingMode.DOWN), MathUtils.round(posZ, RoundingMode.DOWN), dim));