Created
January 12, 2015 05:23
-
-
Save Unh0lyTigg/2b51aa2ef4c302fe40d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.reflect.Type; | |
import net.minecraft.nbt.JsonToNBT; | |
import net.minecraft.nbt.NBTBase; | |
import net.minecraft.nbt.NBTException; | |
import com.google.gson.Gson; | |
import com.google.gson.GsonBuilder; | |
import com.google.gson.TypeAdapter; | |
public class Nson { | |
private final GsonBuilder builder = new GsonBuilder(); | |
private Gson gson = new Gson(); | |
public Nson() { } | |
public NBTBase toNBT(Object obj) throws NBTException { | |
return JsonToNBT.func_180713_a(gson.toJson(obj)); | |
} | |
public <T> void registerTypeAdapter(Type type, TypeAdapter<T> adapter) { | |
builder.registerTypeAdapter(type, adapter); | |
gson = builder.create(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment