Java 类net.minecraft.util.JsonUtils 实例源码

项目:Torched    文件:RecipeTorchGun.java   
@Override
public IRecipe parse(JsonContext context, JsonObject json)
{
    String group = JsonUtils.getString(json, "group", "");

    NonNullList<Ingredient> ings = NonNullList.create();
    for(JsonElement ele : JsonUtils.getJsonArray(json, "ingredients"))
        ings.add(CraftingHelper.getIngredient(ele, context));

    if(ings.isEmpty())
        throw new JsonParseException("No ingredients for shapeless recipe");
    if(ings.size() > 9)
        throw new JsonParseException("Too many ingredients for shapeless recipe");

    ItemStack itemstack = CraftingHelper.getItemStack(JsonUtils.getJsonObject(json, "result"), context);
    return new RecipeTorchGun(group, itemstack, ings);
}
项目:Randores2    文件:RandoresForgeUpgradeRecipeFactory.java   
@Override
public IRecipe parse(JsonContext context, JsonObject json) {
    int clamp = JsonUtils.getInt(json, "clamp");
    boolean combining = JsonUtils.getBoolean(json, "combining");

    JsonArray upgradeList = JsonUtils.getJsonArray(json, "upgrades");
    Map<Ingredient, Double> upgrades = new LinkedHashMap<>();
    int n = 0;
    for (JsonElement element : upgradeList) {
        if (element.isJsonObject()) {
            JsonObject upgrade = element.getAsJsonObject();
            double amount = JsonUtils.getFloat(upgrade, "amount");
            Ingredient ingredient = CraftingHelper.getIngredient(upgrade.get("ingredient"), context);
            upgrades.put(ingredient, amount);
        } else {
            throw new JsonSyntaxException("Expected " + n + " to be a JsonObject, was " + JsonUtils.toString(json));
        }
        n++;
    }

    return new RandoresForgeUpgradeRecipe(clamp, combining, upgrades);
}
项目:CustomWorldGen    文件:ForgeHooks.java   
public static String readPoolName(JsonObject json)
{
    LootTableContext ctx = ForgeHooks.getLootTableContext();
    ctx.resetPoolCtx();

    if (json.has("name"))
        return JsonUtils.getString(json, "name");

    if (ctx.custom)
        return "custom#" + json.hashCode(); //We don't care about custom ones modders shouldn't be editing them!

    ctx.poolCount++;

    if (!ctx.vanilla)
        throw new JsonParseException("Loot Table \"" + ctx.name.toString() + "\" Missing `name` entry for pool #" + (ctx.poolCount - 1));

    return ctx.poolCount == 1 ? "main" : "pool" + (ctx.poolCount - 1);
}
项目:CustomWorldGen    文件:ForgeHooks.java   
public static String readLootEntryName(JsonObject json, String type)
{
    LootTableContext ctx = ForgeHooks.getLootTableContext();
    ctx.entryCount++;

    if (json.has("entryName"))
        return ctx.validateEntryName(JsonUtils.getString(json, "entryName"));

    if (ctx.custom)
        return "custom#" + json.hashCode(); //We don't care about custom ones modders shouldn't be editing them!

    String name = null;
    if ("item".equals(type))
        name = JsonUtils.getString(json, "name");
    else if ("loot_table".equals(type))
        name = JsonUtils.getString(json, "name");
    else if ("empty".equals(type))
        name = "empty";

    return ctx.validateEntryName(name);
}
项目:Backmemed    文件:ShaderGroup.java   
private void initTarget(JsonElement p_148027_1_) throws JsonException
{
    if (JsonUtils.isString(p_148027_1_))
    {
        this.addFramebuffer(p_148027_1_.getAsString(), this.mainFramebufferWidth, this.mainFramebufferHeight);
    }
    else
    {
        JsonObject jsonobject = JsonUtils.getJsonObject(p_148027_1_, "target");
        String s = JsonUtils.getString(jsonobject, "name");
        int i = JsonUtils.getInt(jsonobject, "width", this.mainFramebufferWidth);
        int j = JsonUtils.getInt(jsonobject, "height", this.mainFramebufferHeight);

        if (this.mapFramebuffers.containsKey(s))
        {
            throw new JsonException(s + " is already defined");
        }

        this.addFramebuffer(s, i, j);
    }
}
项目:CustomWorldGen    文件:SetAttributes.java   
public SetAttributes deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditionsIn)
{
    JsonArray jsonarray = JsonUtils.getJsonArray(object, "modifiers");
    SetAttributes.Modifier[] asetattributes$modifier = new SetAttributes.Modifier[jsonarray.size()];
    int i = 0;

    for (JsonElement jsonelement : jsonarray)
    {
        asetattributes$modifier[i++] = SetAttributes.Modifier.deserialize(JsonUtils.getJsonObject(jsonelement, "modifier"), deserializationContext);
    }

    if (asetattributes$modifier.length == 0)
    {
        throw new JsonSyntaxException("Invalid attribute modifiers array; cannot be empty");
    }
    else
    {
        return new SetAttributes(conditionsIn, asetattributes$modifier);
    }
}
项目:Backmemed    文件:ModelBlockDefinition.java   
protected Map<String, VariantList> parseMapVariants(JsonDeserializationContext deserializationContext, JsonObject object)
{
    Map<String, VariantList> map = Maps.<String, VariantList>newHashMap();

    if (object.has("variants"))
    {
        JsonObject jsonobject = JsonUtils.getJsonObject(object, "variants");

        for (Entry<String, JsonElement> entry : jsonobject.entrySet())
        {
            map.put(entry.getKey(), (VariantList)deserializationContext.deserialize((JsonElement)entry.getValue(), VariantList.class));
        }
    }

    return map;
}
项目:DecompiledMinecraft    文件:BlockPart.java   
public BlockPart deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
    Vector3f vector3f = this.parsePositionFrom(jsonobject);
    Vector3f vector3f1 = this.parsePositionTo(jsonobject);
    BlockPartRotation blockpartrotation = this.parseRotation(jsonobject);
    Map<EnumFacing, BlockPartFace> map = this.parseFacesCheck(p_deserialize_3_, jsonobject);

    if (jsonobject.has("shade") && !JsonUtils.isBoolean(jsonobject, "shade"))
    {
        throw new JsonParseException("Expected shade to be a Boolean");
    }
    else
    {
        boolean flag = JsonUtils.getBoolean(jsonobject, "shade", true);
        return new BlockPart(vector3f, vector3f1, map, blockpartrotation, flag);
    }
}
项目:DecompiledMinecraft    文件:BlockPart.java   
private Vector3f parsePosition(JsonObject p_178251_1_, String p_178251_2_)
{
    JsonArray jsonarray = JsonUtils.getJsonArray(p_178251_1_, p_178251_2_);

    if (jsonarray.size() != 3)
    {
        throw new JsonParseException("Expected 3 " + p_178251_2_ + " values, found: " + jsonarray.size());
    }
    else
    {
        float[] afloat = new float[3];

        for (int i = 0; i < afloat.length; ++i)
        {
            afloat[i] = JsonUtils.getFloat(jsonarray.get(i), p_178251_2_ + "[" + i + "]");
        }

        return new Vector3f(afloat[0], afloat[1], afloat[2]);
    }
}
项目:CustomWorldGen    文件:ChunkProviderSettings.java   
public static ChunkProviderSettings.Factory jsonToFactory(String p_177865_0_)
{
    if (p_177865_0_.isEmpty())
    {
        return new ChunkProviderSettings.Factory();
    }
    else
    {
        try
        {
            return (ChunkProviderSettings.Factory)JsonUtils.gsonDeserialize(JSON_ADAPTER, p_177865_0_, ChunkProviderSettings.Factory.class);
        }
        catch (Exception var2)
        {
            return new ChunkProviderSettings.Factory();
        }
    }
}
项目:CustomWorldGen    文件:LootFunctionManager.java   
public LootFunction deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "function");
    ResourceLocation resourcelocation = new ResourceLocation(JsonUtils.getString(jsonobject, "function"));
    LootFunction.Serializer<?> serializer;

    try
    {
        serializer = LootFunctionManager.getSerializerForName(resourcelocation);
    }
    catch (IllegalArgumentException var8)
    {
        throw new JsonSyntaxException("Unknown function \'" + resourcelocation + "\'");
    }

    return serializer.deserialize(jsonobject, p_deserialize_3_, (LootCondition[])JsonUtils.deserializeClass(jsonobject, "conditions", new LootCondition[0], p_deserialize_3_, LootCondition[].class));
}
项目:Backmemed    文件:BlockPart.java   
@Nullable
private BlockPartRotation parseRotation(JsonObject object)
{
    BlockPartRotation blockpartrotation = null;

    if (object.has("rotation"))
    {
        JsonObject jsonobject = JsonUtils.getJsonObject(object, "rotation");
        Vector3f vector3f = this.parsePosition(jsonobject, "origin");
        vector3f.scale(0.0625F);
        EnumFacing.Axis enumfacing$axis = this.parseAxis(jsonobject);
        float f = this.parseAngle(jsonobject);
        boolean flag = JsonUtils.getBoolean(jsonobject, "rescale", false);
        blockpartrotation = new BlockPartRotation(vector3f, enumfacing$axis, f, flag);
    }

    return blockpartrotation;
}
项目:BaseClient    文件:ServerStatusResponse.java   
public ServerStatusResponse.PlayerCountData deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "players");
    ServerStatusResponse.PlayerCountData serverstatusresponse$playercountdata = new ServerStatusResponse.PlayerCountData(JsonUtils.getInt(jsonobject, "max"), JsonUtils.getInt(jsonobject, "online"));

    if (JsonUtils.isJsonArray(jsonobject, "sample"))
    {
        JsonArray jsonarray = JsonUtils.getJsonArray(jsonobject, "sample");

        if (jsonarray.size() > 0)
        {
            GameProfile[] agameprofile = new GameProfile[jsonarray.size()];

            for (int i = 0; i < agameprofile.length; ++i)
            {
                JsonObject jsonobject1 = JsonUtils.getJsonObject(jsonarray.get(i), "player[" + i + "]");
                String s = JsonUtils.getString(jsonobject1, "id");
                agameprofile[i] = new GameProfile(UUID.fromString(s), JsonUtils.getString(jsonobject1, "name"));
            }

            serverstatusresponse$playercountdata.setPlayers(agameprofile);
        }
    }

    return serverstatusresponse$playercountdata;
}
项目:BaseClient    文件:BlockPart.java   
public BlockPart deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
    Vector3f vector3f = this.parsePositionFrom(jsonobject);
    Vector3f vector3f1 = this.parsePositionTo(jsonobject);
    BlockPartRotation blockpartrotation = this.parseRotation(jsonobject);
    Map<EnumFacing, BlockPartFace> map = this.parseFacesCheck(p_deserialize_3_, jsonobject);

    if (jsonobject.has("shade") && !JsonUtils.isBoolean(jsonobject, "shade"))
    {
        throw new JsonParseException("Expected shade to be a Boolean");
    }
    else
    {
        boolean flag = JsonUtils.getBoolean(jsonobject, "shade", true);
        return new BlockPart(vector3f, vector3f1, map, blockpartrotation, flag);
    }
}
项目:Backmemed    文件:LootEntryItem.java   
public static LootEntryItem deserialize(JsonObject object, JsonDeserializationContext deserializationContext, int weightIn, int qualityIn, LootCondition[] conditionsIn)
{
    Item item = JsonUtils.getItem(object, "name");
    LootFunction[] alootfunction;

    if (object.has("functions"))
    {
        alootfunction = (LootFunction[])JsonUtils.deserializeClass(object, "functions", deserializationContext, LootFunction[].class);
    }
    else
    {
        alootfunction = new LootFunction[0];
    }

    return new LootEntryItem(item, weightIn, qualityIn, alootfunction, conditionsIn);
}
项目:BaseClient    文件:BlockPart.java   
public BlockPart deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
    Vector3f vector3f = this.parsePositionFrom(jsonobject);
    Vector3f vector3f1 = this.parsePositionTo(jsonobject);
    BlockPartRotation blockpartrotation = this.parseRotation(jsonobject);
    Map<EnumFacing, BlockPartFace> map = this.parseFacesCheck(p_deserialize_3_, jsonobject);

    if (jsonobject.has("shade") && !JsonUtils.isBoolean(jsonobject, "shade"))
    {
        throw new JsonParseException("Expected shade to be a Boolean");
    }
    else
    {
        boolean flag = JsonUtils.getBoolean(jsonobject, "shade", true);
        return new BlockPart(vector3f, vector3f1, map, blockpartrotation, flag);
    }
}
项目:Backmemed    文件:SoundListSerializer.java   
private List<Sound> deserializeSounds(JsonObject object)
{
    List<Sound> list = Lists.<Sound>newArrayList();

    if (object.has("sounds"))
    {
        JsonArray jsonarray = JsonUtils.getJsonArray(object, "sounds");

        for (int i = 0; i < jsonarray.size(); ++i)
        {
            JsonElement jsonelement = jsonarray.get(i);

            if (JsonUtils.isString(jsonelement))
            {
                String s = JsonUtils.getString(jsonelement, "sound");
                list.add(new Sound(s, 1.0F, 1.0F, 1, Sound.Type.FILE, false));
            }
            else
            {
                list.add(this.deserializeSound(JsonUtils.getJsonObject(jsonelement, "sound")));
            }
        }
    }

    return list;
}
项目:BaseClient    文件:BlockPart.java   
private Vector3f parsePosition(JsonObject p_178251_1_, String p_178251_2_)
{
    JsonArray jsonarray = JsonUtils.getJsonArray(p_178251_1_, p_178251_2_);

    if (jsonarray.size() != 3)
    {
        throw new JsonParseException("Expected 3 " + p_178251_2_ + " values, found: " + jsonarray.size());
    }
    else
    {
        float[] afloat = new float[3];

        for (int i = 0; i < afloat.length; ++i)
        {
            afloat[i] = JsonUtils.getFloat(jsonarray.get(i), p_178251_2_ + "[" + i + "]");
        }

        return new Vector3f(afloat[0], afloat[1], afloat[2]);
    }
}
项目:CustomWorldGen    文件:ServerStatusResponse.java   
public ServerStatusResponse.Players deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "players");
    ServerStatusResponse.Players serverstatusresponse$players = new ServerStatusResponse.Players(JsonUtils.getInt(jsonobject, "max"), JsonUtils.getInt(jsonobject, "online"));

    if (JsonUtils.isJsonArray(jsonobject, "sample"))
    {
        JsonArray jsonarray = JsonUtils.getJsonArray(jsonobject, "sample");

        if (jsonarray.size() > 0)
        {
            GameProfile[] agameprofile = new GameProfile[jsonarray.size()];

            for (int i = 0; i < agameprofile.length; ++i)
            {
                JsonObject jsonobject1 = JsonUtils.getJsonObject(jsonarray.get(i), "player[" + i + "]");
                String s = JsonUtils.getString(jsonobject1, "id");
                agameprofile[i] = new GameProfile(UUID.fromString(s), JsonUtils.getString(jsonobject1, "name"));
            }

            serverstatusresponse$players.setPlayers(agameprofile);
        }
    }

    return serverstatusresponse$players;
}
项目:CustomWorldGen    文件:BlockPart.java   
@Nullable
private BlockPartRotation parseRotation(JsonObject object)
{
    BlockPartRotation blockpartrotation = null;

    if (object.has("rotation"))
    {
        JsonObject jsonobject = JsonUtils.getJsonObject(object, "rotation");
        Vector3f vector3f = this.parsePosition(jsonobject, "origin");
        vector3f.scale(0.0625F);
        EnumFacing.Axis enumfacing$axis = this.parseAxis(jsonobject);
        float f = this.parseAngle(jsonobject);
        boolean flag = JsonUtils.getBoolean(jsonobject, "rescale", false);
        blockpartrotation = new BlockPartRotation(vector3f, enumfacing$axis, f, flag);
    }

    return blockpartrotation;
}
项目:CustomWorldGen    文件:SoundListSerializer.java   
private List<Sound> deserializeSounds(JsonObject object)
{
    List<Sound> list = Lists.<Sound>newArrayList();

    if (object.has("sounds"))
    {
        JsonArray jsonarray = JsonUtils.getJsonArray(object, "sounds");

        for (int i = 0; i < jsonarray.size(); ++i)
        {
            JsonElement jsonelement = jsonarray.get(i);

            if (JsonUtils.isString(jsonelement))
            {
                String s = JsonUtils.getString(jsonelement, "sound");
                list.add(new Sound(s, 1.0F, 1.0F, 1, Sound.Type.FILE, false));
            }
            else
            {
                list.add(this.deserializeSound(JsonUtils.getJsonObject(jsonelement, "sound")));
            }
        }
    }

    return list;
}
项目:BaseClient    文件:BlockPart.java   
private Vector3f parsePosition(JsonObject p_178251_1_, String p_178251_2_)
{
    JsonArray jsonarray = JsonUtils.getJsonArray(p_178251_1_, p_178251_2_);

    if (jsonarray.size() != 3)
    {
        throw new JsonParseException("Expected 3 " + p_178251_2_ + " values, found: " + jsonarray.size());
    }
    else
    {
        float[] afloat = new float[3];

        for (int i = 0; i < afloat.length; ++i)
        {
            afloat[i] = JsonUtils.getFloat(jsonarray.get(i), p_178251_2_ + "[" + i + "]");
        }

        return new Vector3f(afloat[0], afloat[1], afloat[2]);
    }
}
项目:CustomWorldGen    文件:SoundListSerializer.java   
private Sound.Type deserializeType(JsonObject object, Sound.Type defaultValue)
{
    Sound.Type sound$type = defaultValue;

    if (object.has("type"))
    {
        sound$type = Sound.Type.getByName(JsonUtils.getString(object, "type"));
        Validate.notNull(sound$type, "Invalid type", new Object[0]);
    }

    return sound$type;
}
项目:Backmemed    文件:PackMetadataSectionSerializer.java   
public PackMetadataSection deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
    ITextComponent itextcomponent = (ITextComponent)p_deserialize_3_.deserialize(jsonobject.get("description"), ITextComponent.class);

    if (itextcomponent == null)
    {
        throw new JsonParseException("Invalid/missing description!");
    }
    else
    {
        int i = JsonUtils.getInt(jsonobject, "pack_format");
        return new PackMetadataSection(itextcomponent, i);
    }
}
项目:DecompiledMinecraft    文件:ServerStatusResponse.java   
public ServerStatusResponse deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "status");
    ServerStatusResponse serverstatusresponse = new ServerStatusResponse();

    if (jsonobject.has("description"))
    {
        serverstatusresponse.setServerDescription((IChatComponent)p_deserialize_3_.deserialize(jsonobject.get("description"), IChatComponent.class));
    }

    if (jsonobject.has("players"))
    {
        serverstatusresponse.setPlayerCountData((ServerStatusResponse.PlayerCountData)p_deserialize_3_.deserialize(jsonobject.get("players"), ServerStatusResponse.PlayerCountData.class));
    }

    if (jsonobject.has("version"))
    {
        serverstatusresponse.setProtocolVersionInfo((ServerStatusResponse.MinecraftProtocolVersionIdentifier)p_deserialize_3_.deserialize(jsonobject.get("version"), ServerStatusResponse.MinecraftProtocolVersionIdentifier.class));
    }

    if (jsonobject.has("favicon"))
    {
        serverstatusresponse.setFavicon(JsonUtils.getString(jsonobject, "favicon"));
    }

    return serverstatusresponse;
}
项目:Backmemed    文件:LootEntry.java   
public LootEntry deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "loot item");
    String s = JsonUtils.getString(jsonobject, "type");
    int i = JsonUtils.getInt(jsonobject, "weight", 1);
    int j = JsonUtils.getInt(jsonobject, "quality", 0);
    LootCondition[] alootcondition;

    if (jsonobject.has("conditions"))
    {
        alootcondition = (LootCondition[])JsonUtils.deserializeClass(jsonobject, "conditions", p_deserialize_3_, LootCondition[].class);
    }
    else
    {
        alootcondition = new LootCondition[0];
    }

    if ("item".equals(s))
    {
        return LootEntryItem.deserialize(jsonobject, p_deserialize_3_, i, j, alootcondition);
    }
    else if ("loot_table".equals(s))
    {
        return LootEntryTable.deserialize(jsonobject, p_deserialize_3_, i, j, alootcondition);
    }
    else if ("empty".equals(s))
    {
        return LootEntryEmpty.deserialize(jsonobject, p_deserialize_3_, i, j, alootcondition);
    }
    else
    {
        throw new JsonSyntaxException("Unknown loot entry type \'" + s + "\'");
    }
}
项目:Backmemed    文件:Selector.java   
@VisibleForTesting
static ICondition getOrAndCondition(JsonObject json)
{
    Set<Entry<String, JsonElement>> set = json.entrySet();

    if (set.isEmpty())
    {
        throw new JsonParseException("No elements found in selector");
    }
    else
    {
        return (ICondition)(set.size() == 1 ? (json.has("OR") ? new ConditionOr(Iterables.transform(JsonUtils.getJsonArray(json, "OR"), FUNCTION_OR_AND)) : (json.has("AND") ? new ConditionAnd(Iterables.transform(JsonUtils.getJsonArray(json, "AND"), FUNCTION_OR_AND)) : makePropertyValue((Entry)set.iterator().next()))) : new ConditionAnd(Iterables.transform(set, FUNCTION_PROPERTY_VALUE)));
    }
}
项目:DecompiledMinecraft    文件:ShaderManager.java   
private void parseSampler(JsonElement p_147996_1_) throws JsonException
{
    JsonObject jsonobject = JsonUtils.getJsonObject(p_147996_1_, "sampler");
    String s = JsonUtils.getString(jsonobject, "name");

    if (!JsonUtils.isString(jsonobject, "file"))
    {
        this.shaderSamplers.put(s, (Object)null);
        this.samplerNames.add(s);
    }
    else
    {
        this.samplerNames.add(s);
    }
}
项目:CustomWorldGen    文件:ItemOverride.java   
protected Map<ResourceLocation, Float> makeMapResourceValues(JsonObject p_188025_1_)
{
    Map<ResourceLocation, Float> map = Maps.<ResourceLocation, Float>newLinkedHashMap();
    JsonObject jsonobject = JsonUtils.getJsonObject(p_188025_1_, "predicate");

    for (Entry<String, JsonElement> entry : jsonobject.entrySet())
    {
        map.put(new ResourceLocation((String)entry.getKey()), Float.valueOf(JsonUtils.getFloat((JsonElement)entry.getValue(), (String)entry.getKey())));
    }

    return map;
}
项目:Backmemed    文件:SoundListSerializer.java   
private Sound deserializeSound(JsonObject object)
{
    String s = JsonUtils.getString(object, "name");
    Sound.Type sound$type = this.deserializeType(object, Sound.Type.FILE);
    float f = JsonUtils.getFloat(object, "volume", 1.0F);
    Validate.isTrue(f > 0.0F, "Invalid volume", new Object[0]);
    float f1 = JsonUtils.getFloat(object, "pitch", 1.0F);
    Validate.isTrue(f1 > 0.0F, "Invalid pitch", new Object[0]);
    int i = JsonUtils.getInt(object, "weight", 1);
    Validate.isTrue(i > 0, "Invalid weight", new Object[0]);
    boolean flag = JsonUtils.getBoolean(object, "stream", false);
    return new Sound(s, f, f1, i, sound$type, flag);
}
项目:CustomWorldGen    文件:LanguageMetadataSectionSerializer.java   
public LanguageMetadataSection deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
    Set<Language> set = Sets.<Language>newHashSet();

    for (Entry<String, JsonElement> entry : jsonobject.entrySet())
    {
        String s = (String)entry.getKey();
        JsonObject jsonobject1 = JsonUtils.getJsonObject((JsonElement)entry.getValue(), "language");
        String s1 = JsonUtils.getString(jsonobject1, "region");
        String s2 = JsonUtils.getString(jsonobject1, "name");
        boolean flag = JsonUtils.getBoolean(jsonobject1, "bidirectional", false);

        if (s1.isEmpty())
        {
            throw new JsonParseException("Invalid language->\'" + s + "\'->region: empty value");
        }

        if (s2.isEmpty())
        {
            throw new JsonParseException("Invalid language->\'" + s + "\'->name: empty value");
        }

        if (!set.add(new Language(s, s1, s2, flag)))
        {
            throw new JsonParseException("Duplicate language->\'" + s + "\' defined");
        }
    }

    return new LanguageMetadataSection(set);
}
项目:CustomWorldGen    文件:ModelBlock.java   
protected List<BlockPart> getModelElements(JsonDeserializationContext deserializationContext, JsonObject object)
{
    List<BlockPart> list = Lists.<BlockPart>newArrayList();

    if (object.has("elements"))
    {
        for (JsonElement jsonelement : JsonUtils.getJsonArray(object, "elements"))
        {
            list.add((BlockPart)deserializationContext.deserialize(jsonelement, BlockPart.class));
        }
    }

    return list;
}
项目:CustomWorldGen    文件:ResourceIndex.java   
public ResourceIndex(File assetsFolder, String indexName)
{
    File file1 = new File(assetsFolder, "objects");
    File file2 = new File(assetsFolder, "indexes/" + indexName + ".json");
    BufferedReader bufferedreader = null;

    try
    {
        bufferedreader = Files.newReader(file2, Charsets.UTF_8);
        JsonObject jsonobject = (new JsonParser()).parse((Reader)bufferedreader).getAsJsonObject();
        JsonObject jsonobject1 = JsonUtils.getJsonObject(jsonobject, "objects", (JsonObject)null);

        if (jsonobject1 != null)
        {
            for (Entry<String, JsonElement> entry : jsonobject1.entrySet())
            {
                JsonObject jsonobject2 = (JsonObject)entry.getValue();
                String s = (String)entry.getKey();
                String[] astring = s.split("/", 2);
                String s1 = astring.length == 1 ? astring[0] : astring[0] + ":" + astring[1];
                String s2 = JsonUtils.getString(jsonobject2, "hash");
                File file3 = new File(file1, s2.substring(0, 2) + "/" + s2);
                this.resourceMap.put(s1, file3);
            }
        }
    }
    catch (JsonParseException var20)
    {
        LOGGER.error("Unable to parse resource index file: {}", new Object[] {file2});
    }
    catch (FileNotFoundException var21)
    {
        LOGGER.error("Can\'t find the resource index file: {}", new Object[] {file2});
    }
    finally
    {
        IOUtils.closeQuietly((Reader)bufferedreader);
    }
}
项目:DecompiledMinecraft    文件:BlockFaceUV.java   
private float[] parseUV(JsonObject p_178292_1_)
{
    if (!p_178292_1_.has("uv"))
    {
        return null;
    }
    else
    {
        JsonArray jsonarray = JsonUtils.getJsonArray(p_178292_1_, "uv");

        if (jsonarray.size() != 4)
        {
            throw new JsonParseException("Expected 4 uv values, found: " + jsonarray.size());
        }
        else
        {
            float[] afloat = new float[4];

            for (int i = 0; i < afloat.length; ++i)
            {
                afloat[i] = JsonUtils.getFloat(jsonarray.get(i), "uv[" + i + "]");
            }

            return afloat;
        }
    }
}
项目:DecompiledMinecraft    文件:ItemTransformVec3f.java   
private Vector3f parseVector3f(JsonObject jsonObject, String key, Vector3f defaultValue)
{
    if (!jsonObject.has(key))
    {
        return defaultValue;
    }
    else
    {
        JsonArray jsonarray = JsonUtils.getJsonArray(jsonObject, key);

        if (jsonarray.size() != 3)
        {
            throw new JsonParseException("Expected 3 " + key + " values, found: " + jsonarray.size());
        }
        else
        {
            float[] afloat = new float[3];

            for (int i = 0; i < afloat.length; ++i)
            {
                afloat[i] = JsonUtils.getFloat(jsonarray.get(i), key + "[" + i + "]");
            }

            return new Vector3f(afloat[0], afloat[1], afloat[2]);
        }
    }
}
项目:CustomWorldGen    文件:EntityHasScore.java   
public EntityHasScore deserialize(JsonObject json, JsonDeserializationContext context)
{
    Set<Entry<String, JsonElement>> set = JsonUtils.getJsonObject(json, "scores").entrySet();
    Map<String, RandomValueRange> map = Maps.<String, RandomValueRange>newLinkedHashMap();

    for (Entry<String, JsonElement> entry : set)
    {
        map.put(entry.getKey(), JsonUtils.deserializeClass((JsonElement)entry.getValue(), "score", context, RandomValueRange.class));
    }

    return new EntityHasScore(map, (LootContext.EntityTarget)JsonUtils.deserializeClass(json, "entity", context, LootContext.EntityTarget.class));
}
项目:BaseClient    文件:ModelBlockDefinition.java   
protected ModelRotation parseRotation(JsonObject p_178428_1_)
{
    int i = JsonUtils.getInt(p_178428_1_, "x", 0);
    int j = JsonUtils.getInt(p_178428_1_, "y", 0);
    ModelRotation modelrotation = ModelRotation.getModelRotation(i, j);

    if (modelrotation == null)
    {
        throw new JsonParseException("Invalid BlockModelRotation x: " + i + ", y: " + j);
    }
    else
    {
        return modelrotation;
    }
}
项目:DecompiledMinecraft    文件:ModelBlock.java   
public ModelBlock deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
    List<BlockPart> list = this.getModelElements(p_deserialize_3_, jsonobject);
    String s = this.getParent(jsonobject);
    boolean flag = StringUtils.isEmpty(s);
    boolean flag1 = list.isEmpty();

    if (flag1 && flag)
    {
        throw new JsonParseException("BlockModel requires either elements or parent, found neither");
    }
    else if (!flag && !flag1)
    {
        throw new JsonParseException("BlockModel requires either elements or parent, found both");
    }
    else
    {
        Map<String, String> map = this.getTextures(jsonobject);
        boolean flag2 = this.getAmbientOcclusionEnabled(jsonobject);
        ItemCameraTransforms itemcameratransforms = ItemCameraTransforms.DEFAULT;

        if (jsonobject.has("display"))
        {
            JsonObject jsonobject1 = JsonUtils.getJsonObject(jsonobject, "display");
            itemcameratransforms = (ItemCameraTransforms)p_deserialize_3_.deserialize(jsonobject1, ItemCameraTransforms.class);
        }

        return flag1 ? new ModelBlock(new ResourceLocation(s), map, flag2, true, itemcameratransforms) : new ModelBlock(list, map, flag2, true, itemcameratransforms);
    }
}
项目:CustomWorldGen    文件:LootEntry.java   
public LootEntry deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "loot item");
    String s = JsonUtils.getString(jsonobject, "type");
    int i = JsonUtils.getInt(jsonobject, "weight", 1);
    int j = JsonUtils.getInt(jsonobject, "quality", 0);
    LootCondition[] alootcondition;

    if (jsonobject.has("conditions"))
    {
        alootcondition = (LootCondition[])JsonUtils.deserializeClass(jsonobject, "conditions", p_deserialize_3_, LootCondition[].class);
    }
    else
    {
        alootcondition = new LootCondition[0];
    }

    LootEntry ret = net.minecraftforge.common.ForgeHooks.deserializeJsonLootEntry(s, jsonobject, i, j, alootcondition);
    if (ret != null) return ret;

    if ("item".equals(s))
    {
        return LootEntryItem.deserialize(jsonobject, p_deserialize_3_, i, j, alootcondition);
    }
    else if ("loot_table".equals(s))
    {
        return LootEntryTable.deserialize(jsonobject, p_deserialize_3_, i, j, alootcondition);
    }
    else if ("empty".equals(s))
    {
        return LootEntryEmpty.deserialize(jsonobject, p_deserialize_3_, i, j, alootcondition);
    }
    else
    {
        throw new JsonSyntaxException("Unknown loot entry type \'" + s + "\'");
    }
}
项目:BaseClient    文件:PackMetadataSectionSerializer.java   
public PackMetadataSection deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
    IChatComponent ichatcomponent = (IChatComponent)p_deserialize_3_.deserialize(jsonobject.get("description"), IChatComponent.class);

    if (ichatcomponent == null)
    {
        throw new JsonParseException("Invalid/missing description!");
    }
    else
    {
        int i = JsonUtils.getInt(jsonobject, "pack_format");
        return new PackMetadataSection(ichatcomponent, i);
    }
}