初始化错误 - 预期“:”在行

时间:2015-07-08 12:44:38

标签: java json minecraft-forge

我正在做一个项目。我收到了一个错误:

  

预期':'在第7行第11栏

我正在寻找错误,我找不到它。

日志:

[14:05:31] [Client thread/ERROR] [FML]: Exception loading model utm:item/uraniumingot with loader instance, skipping
com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Expected ':' at line 7 column 11
at com.google.gson.internal.Streams.parse(Streams.java:56) ~[Streams.class:?]
at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:54) ~[TreeTypeAdapter.class:?]
at com.google.gson.Gson.fromJson(Gson.java:803) ~[Gson.class:?]
at com.google.gson.Gson.fromJson(Gson.java:741) ~[Gson.class:?]
at net.minecraft.client.renderer.block.model.ModelBlock.deserialize(ModelBlock.java:47) ~[ModelBlock.class:?]
at net.minecraft.client.resources.model.ModelBakery.loadModel(ModelBakery.java:269) ~[ModelBakery.class:?]
at net.minecraftforge.client.model.ModelLoader.access$800(ModelLoader.java:73) ~[ModelLoader.class:?]
at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:650) ~[ModelLoader$VanillaLoader.class:?]
at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:107) [ModelLoaderRegistry.class:?]
at net.minecraftforge.client.model.ModelLoader.loadAnyModel(ModelLoader.java:228) [ModelLoader.class:?]
at net.minecraftforge.client.model.ModelLoader.getModel(ModelLoader.java:211) [ModelLoader.class:?]
at net.minecraftforge.client.model.ModelLoader.loadItems(ModelLoader.java:190) [ModelLoader.class:?]
at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:99) [ModelLoader.class:?]
at net.minecraft.client.resources.model.ModelManager.onResourceManagerReload(ModelManager.java:29) [ModelManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.notifyReloadListeners(SimpleReloadableResourceManager.java:143) [SimpleReloadableResourceManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.reloadResources(SimpleReloadableResourceManager.java:121) [SimpleReloadableResourceManager.class:?]
at net.minecraft.client.Minecraft.refreshResources(Minecraft.java:774) [Minecraft.class:?]
at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:332) [FMLClientHandler.class:?]
at net.minecraft.client.Minecraft.startGame(Minecraft.java:528) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:356) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_45]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]
at GradleStart.main(Unknown Source) [start/:?]
Caused by: com.google.gson.stream.MalformedJsonException: Expected ':' at line 7 column 11at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1505) ~[JsonReader.class:?]
at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:519) ~[JsonReader.class:?]
at com.google.gson.stream.JsonReader.peek(JsonReader.java:414) ~[JsonReader.class:?]
at com.google.gson.internal.bind.TypeAdapters$25.read(TypeAdapters.java:644) ~[TypeAdapters$25.class:?]
at com.google.gson.internal.bind.TypeAdapters$25.read(TypeAdapters.java:667) ~[TypeAdapters$25.class:?]
at com.google.gson.internal.bind.TypeAdapters$25.read(TypeAdapters.java:642) ~[TypeAdapters$25.class:?]
at com.google.gson.internal.Streams.parse(Streams.java:44) ~[Streams.class:?]
... 28 more
[14:05:31] [Client thread/INFO] [FML]: Max texture size: 16384
[14:05:31] [Client thread/INFO]: Created: 512x512 textures-atlas
[14:05:32] [Client thread/ERROR] [FML]: Model definition for location utm:uraniumingot#inventory not found

主:

package com.mk.utm;

import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;

import com.mk.utm.items.UraniumIngot;
import com.mk.utm.util.UraniumCT;

@Mod(modid = Main.MODID, name = Main.NAME, version = Main.VERSION)
public class Main {

    public static final String MODID = "utm";
    public static final String NAME = "Uranium Things Mod";
    public static final String VERSION = "1.0";


    public static Item uraniumingot = new UraniumIngot();

    public static CreativeTabs tabUCT = new UraniumCT();

    @EventHandler
    public void preInit(FMLPreInitializationEvent e) {

    }

    @EventHandler
    public void init(FMLInitializationEvent e) {
        GameRegistry.registerItem(uraniumingot, "uraniumingot");
        Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(uraniumin    got, 0, new ModelResourceLocation("utm:uraniumingot", "inventory"));
    }

    @EventHandler
    public void postInit(FMLPostInitializationEvent e) {

    }
}

uraniumingot.json:

{
    "parent": "builtin/generated",
    "textures": {
        "layer0": "utm:items/uraniumingot"
    },
    "display: {
        "thirdperson": {
            "rotation": [ -90, 0, 0 ],
            "translation": [ 0, 1, -3 ],
            "scale": [ 0.55, 0.55, 0.55 ]
        },
        "firstperson": {
            "rotation": [ 0, -135, 25 ],
            "translation": [ 0, 4, 2 ],
            "scale": [ 1.7, 1.7, 1.7 ]
        }
    }
}

UraniumIngot类:

package com.mk.utm.items;

import net.minecraft.item.Item;

import com.mk.utm.Main;

public class UraniumIngot extends Item {

    public UraniumIngot() {
        this.setCreativeTab(Main.tabUCT);
        this.setUnlocalizedName("uraniumingot");
    }

}

2 个答案:

答案 0 :(得分:2)

您的JSON文件中存在语法错误。 "显示"属性未包含在引号中:

"display: {

你需要把它括起来:

"display": {

请参阅官方JSON规范:http://json.org/

答案 1 :(得分:0)

public static List<BiliLiver> getBiliLivers() throws IOException {
    HttpURLConnection conn = (HttpURLConnection) new URL(BotConstants.cfg.getLiveApi()).openConnection();
    conn.connect();
    if (conn.getResponseCode() == HttpURLConnection.HTTP_OK){
        BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        return gson.fromJson(br.readLine().trim(), new TypeToken<List<BiliLiver>>(){}.getType());
    }
    conn.disconnect();
    return new ArrayList<>();
}