package me.exz.wailanbt.util;

import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;

public class NBTHelper {
    public static String NBTTypeToString(NBTTagCompound n, String id) {
        if (n.hasKey(id)) {
            NBTBase tag = n.getTag(id);
            return tag.toString();
        }else{
            return "__ERROR__";
        }

    }

    @SuppressWarnings({"UnusedDeclaration", "deprecation"})
    @Deprecated
    public static String NBTTypeToString_old(NBTTagCompound n, String id, String type) {
        try {
            switch (NBTTypeName.TypeNameToID("TAG_" + type)) {
                case TAG_End:
                    return "TAG_End";
                case TAG_Byte:
                    return String.valueOf(n.getByte(id));
                case TAG_Short:
                    return String.valueOf(n.getShort(id));
                case TAG_Integer:
                    return String.valueOf(n.getInteger(id));
                case TAG_Long:
                    return String.valueOf(n.getLong(id));
                case TAG_Float:
                    return String.valueOf(n.getFloat(id));
                case TAG_Double:
                    return String.valueOf(n.getDouble(id));
                case TAG_ByteArray:
                    return "TAG_ByteArray";
                case TAG_String:
                    return n.getString(id);
                case TAG_List:
                    return "TAG_List";
                case TAG_Compound:
                    return "TAG_Compound";
                case TAG_IntArray:
                    return "TAG_IntArray";
                default:
                    return "Bad Type";
            }
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

    }

    @Deprecated
    public static enum NBTTypeName {
        TAG_End, TAG_Byte, TAG_Short, TAG_Integer, TAG_Long, TAG_Float, TAG_Double, TAG_ByteArray, TAG_String, TAG_List, TAG_Compound, TAG_IntArray, ERROR_VALUE;

        @SuppressWarnings("deprecation")
        public static NBTTypeName TypeNameToID(String name) {
            try {
                return valueOf(name);
            } catch (Exception e) {
                e.printStackTrace();
                return ERROR_VALUE;
            }
        }
    }


}

@@ -99,16 +99,62 @@
 mpound;%0A
+import org.apache.commons.lang3.StringUtils;%0A%0A
 %0Apublic 
@@ -327,44 +327,605 @@
     
-return tag.toString();%0A        %7D
+switch (tag.getId()) %7B%0A                case 0:%0A                case 3:%0A                case 7:%0A                case 9:%0A                case 10:%0A                case 11:%0A                    return tag.toString();%0A                case 1:%0A                case 2:%0A                case 4:%0A                case 5:%0A                case 6:%0A                    return StringUtils.substring(tag.toString(), 0, -1);%0A                case 8:%0A                    return StringUtils.substring(tag.toString(), 1, -1);%0A                default:%0A                    return %22__ERROR__%22;%0A%0A            %7D%0A        %7D 
 else
+ 
 %7B%0A  
@@ -954,16 +954,16 @@
 ROR__%22;%0A
-
         
@@ -957,32 +957,33 @@
 __%22;%0A        %7D%0A%0A
+%0A
     %7D%0A%0A    @Supp

fix postfix