当前位置: 首页>>代码示例>>Java>>正文


Java JsonUtils.getJsonArray方法代码示例

本文整理汇总了Java中net.minecraft.util.JsonUtils.getJsonArray方法的典型用法代码示例。如果您正苦于以下问题:Java JsonUtils.getJsonArray方法的具体用法?Java JsonUtils.getJsonArray怎么用?Java JsonUtils.getJsonArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.util.JsonUtils的用法示例。


在下文中一共展示了JsonUtils.getJsonArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
@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);
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:23,代码来源:RandoresForgeUpgradeRecipeFactory.java

示例2: deserialize

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
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;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:27,代码来源:ServerStatusResponse.java

示例3: deserialize

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
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;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:27,代码来源:ServerStatusResponse.java

示例4: deserialize

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:SetAttributes.java

示例5: parsePosition

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
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]);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:21,代码来源:BlockPart.java

示例6: getModelElements

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
protected List<BlockPart> getModelElements(JsonDeserializationContext p_178325_1_, JsonObject p_178325_2_)
{
    List<BlockPart> list = Lists.<BlockPart>newArrayList();

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

    return list;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:15,代码来源:ModelBlock.java

示例7: parseVector3f

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
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]);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:28,代码来源:ItemTransformVec3f.java

示例8: getModelElements

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
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;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:15,代码来源:ModelBlock.java

示例9: parseMultipart

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
@Nullable
protected Multipart parseMultipart(JsonDeserializationContext deserializationContext, JsonObject object)
{
    if (!object.has("multipart"))
    {
        return null;
    }
    else
    {
        JsonArray jsonarray = JsonUtils.getJsonArray(object, "multipart");
        return (Multipart)deserializationContext.deserialize(jsonarray, Multipart.class);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:14,代码来源:ModelBlockDefinition.java

示例10: parseUV

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
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;
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:28,代码来源:BlockFaceUV.java

示例11: deserialize

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
public SoundList deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "entry");
    SoundList soundlist = new SoundList();
    soundlist.setReplaceExisting(JsonUtils.getBoolean(jsonobject, "replace", false));
    SoundCategory soundcategory = SoundCategory.getCategory(JsonUtils.getString(jsonobject, "category", SoundCategory.MASTER.getCategoryName()));
    soundlist.setSoundCategory(soundcategory);
    Validate.notNull(soundcategory, "Invalid category", new Object[0]);

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

        for (int i = 0; i < jsonarray.size(); ++i)
        {
            JsonElement jsonelement = jsonarray.get(i);
            SoundList.SoundEntry soundlist$soundentry = new SoundList.SoundEntry();

            if (JsonUtils.isString(jsonelement))
            {
                soundlist$soundentry.setSoundEntryName(JsonUtils.getString(jsonelement, "sound"));
            }
            else
            {
                JsonObject jsonobject1 = JsonUtils.getJsonObject(jsonelement, "sound");
                soundlist$soundentry.setSoundEntryName(JsonUtils.getString(jsonobject1, "name"));

                if (jsonobject1.has("type"))
                {
                    SoundList.SoundEntry.Type soundlist$soundentry$type = SoundList.SoundEntry.Type.getType(JsonUtils.getString(jsonobject1, "type"));
                    Validate.notNull(soundlist$soundentry$type, "Invalid type", new Object[0]);
                    soundlist$soundentry.setSoundEntryType(soundlist$soundentry$type);
                }

                if (jsonobject1.has("volume"))
                {
                    float f = JsonUtils.getFloat(jsonobject1, "volume");
                    Validate.isTrue(f > 0.0F, "Invalid volume", new Object[0]);
                    soundlist$soundentry.setSoundEntryVolume(f);
                }

                if (jsonobject1.has("pitch"))
                {
                    float f1 = JsonUtils.getFloat(jsonobject1, "pitch");
                    Validate.isTrue(f1 > 0.0F, "Invalid pitch", new Object[0]);
                    soundlist$soundentry.setSoundEntryPitch(f1);
                }

                if (jsonobject1.has("weight"))
                {
                    int j = JsonUtils.getInt(jsonobject1, "weight");
                    Validate.isTrue(j > 0, "Invalid weight", new Object[0]);
                    soundlist$soundentry.setSoundEntryWeight(j);
                }

                if (jsonobject1.has("stream"))
                {
                    soundlist$soundentry.setStreaming(JsonUtils.getBoolean(jsonobject1, "stream"));
                }
            }

            soundlist.getSoundList().add(soundlist$soundentry);
        }
    }

    return soundlist;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:68,代码来源:SoundListSerializer.java

示例12: initUniform

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
private void initUniform(JsonElement p_148028_1_) throws JsonException
{
    JsonObject jsonobject = JsonUtils.getJsonObject(p_148028_1_, "uniform");
    String s = JsonUtils.getString(jsonobject, "name");
    ShaderUniform shaderuniform = ((Shader)this.listShaders.get(this.listShaders.size() - 1)).getShaderManager().getShaderUniform(s);

    if (shaderuniform == null)
    {
        throw new JsonException("Uniform \'" + s + "\' does not exist");
    }
    else
    {
        float[] afloat = new float[4];
        int i = 0;

        for (JsonElement jsonelement : JsonUtils.getJsonArray(jsonobject, "values"))
        {
            try
            {
                afloat[i] = JsonUtils.getFloat(jsonelement, "value");
            }
            catch (Exception exception)
            {
                JsonException jsonexception = JsonException.func_151379_a(exception);
                jsonexception.func_151380_a("values[" + i + "]");
                throw jsonexception;
            }

            ++i;
        }

        switch (i)
        {
            case 0:
            default:
                break;

            case 1:
                shaderuniform.set(afloat[0]);
                break;

            case 2:
                shaderuniform.set(afloat[0], afloat[1]);
                break;

            case 3:
                shaderuniform.set(afloat[0], afloat[1], afloat[2]);
                break;

            case 4:
                shaderuniform.set(afloat[0], afloat[1], afloat[2], afloat[3]);
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:55,代码来源:ShaderGroup.java

示例13: deserialize

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
public AnimationMetadataSection deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    List<AnimationFrame> list = Lists.<AnimationFrame>newArrayList();
    JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "metadata section");
    int i = JsonUtils.getInt(jsonobject, "frametime", 1);

    if (i != 1)
    {
        Validate.inclusiveBetween(1L, 2147483647L, (long)i, "Invalid default frame time");
    }

    if (jsonobject.has("frames"))
    {
        try
        {
            JsonArray jsonarray = JsonUtils.getJsonArray(jsonobject, "frames");

            for (int j = 0; j < jsonarray.size(); ++j)
            {
                JsonElement jsonelement = jsonarray.get(j);
                AnimationFrame animationframe = this.parseAnimationFrame(j, jsonelement);

                if (animationframe != null)
                {
                    list.add(animationframe);
                }
            }
        }
        catch (ClassCastException classcastexception)
        {
            throw new JsonParseException("Invalid animation->frames: expected array, was " + jsonobject.get("frames"), classcastexception);
        }
    }

    int k = JsonUtils.getInt(jsonobject, "width", -1);
    int l = JsonUtils.getInt(jsonobject, "height", -1);

    if (k != -1)
    {
        Validate.inclusiveBetween(1L, 2147483647L, (long)k, "Invalid width");
    }

    if (l != -1)
    {
        Validate.inclusiveBetween(1L, 2147483647L, (long)l, "Invalid height");
    }

    boolean flag = JsonUtils.getBoolean(jsonobject, "interpolate", false);
    return new AnimationMetadataSection(list, k, l, i, flag);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:51,代码来源:AnimationMetadataSectionSerializer.java

示例14: parseUniform

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
private void parseUniform(JsonElement p_147987_1_) throws JsonException
{
    JsonObject jsonobject = JsonUtils.getJsonObject(p_147987_1_, "uniform");
    String s = JsonUtils.getString(jsonobject, "name");
    int i = ShaderUniform.parseType(JsonUtils.getString(jsonobject, "type"));
    int j = JsonUtils.getInt(jsonobject, "count");
    float[] afloat = new float[Math.max(j, 16)];
    JsonArray jsonarray = JsonUtils.getJsonArray(jsonobject, "values");

    if (jsonarray.size() != j && jsonarray.size() > 1)
    {
        throw new JsonException("Invalid amount of values specified (expected " + j + ", found " + jsonarray.size() + ")");
    }
    else
    {
        int k = 0;

        for (JsonElement jsonelement : jsonarray)
        {
            try
            {
                afloat[k] = JsonUtils.getFloat(jsonelement, "value");
            }
            catch (Exception exception)
            {
                JsonException jsonexception = JsonException.func_151379_a(exception);
                jsonexception.func_151380_a("values[" + k + "]");
                throw jsonexception;
            }

            ++k;
        }

        if (j > 1 && jsonarray.size() == 1)
        {
            while (k < j)
            {
                afloat[k] = afloat[0];
                ++k;
            }
        }

        int l = j > 1 && j <= 4 && i < 8 ? j - 1 : 0;
        ShaderUniform shaderuniform = new ShaderUniform(s, i + l, j, this);

        if (i <= 3)
        {
            shaderuniform.set((int)afloat[0], (int)afloat[1], (int)afloat[2], (int)afloat[3]);
        }
        else if (i <= 7)
        {
            shaderuniform.func_148092_b(afloat[0], afloat[1], afloat[2], afloat[3]);
        }
        else
        {
            shaderuniform.set(afloat);
        }

        this.shaderUniforms.add(shaderuniform);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:62,代码来源:ShaderManager.java

示例15: deserialize

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
public static SetAttributes.Modifier deserialize(JsonObject jsonObj, JsonDeserializationContext context)
{
    String s = JsonUtils.getString(jsonObj, "name");
    String s1 = JsonUtils.getString(jsonObj, "attribute");
    int i = getOperationFromInt(JsonUtils.getString(jsonObj, "operation"));
    RandomValueRange randomvaluerange = (RandomValueRange)JsonUtils.deserializeClass(jsonObj, "amount", context, RandomValueRange.class);
    UUID uuid = null;
    EntityEquipmentSlot[] aentityequipmentslot;

    if (JsonUtils.isString(jsonObj, "slot"))
    {
        aentityequipmentslot = new EntityEquipmentSlot[] {EntityEquipmentSlot.fromString(JsonUtils.getString(jsonObj, "slot"))};
    }
    else
    {
        if (!JsonUtils.isJsonArray(jsonObj, "slot"))
        {
            throw new JsonSyntaxException("Invalid or missing attribute modifier slot; must be either string or array of strings.");
        }

        JsonArray jsonarray = JsonUtils.getJsonArray(jsonObj, "slot");
        aentityequipmentslot = new EntityEquipmentSlot[jsonarray.size()];
        int j = 0;

        for (JsonElement jsonelement : jsonarray)
        {
            aentityequipmentslot[j++] = EntityEquipmentSlot.fromString(JsonUtils.getString(jsonelement, "slot"));
        }

        if (aentityequipmentslot.length == 0)
        {
            throw new JsonSyntaxException("Invalid attribute modifier slot; must contain at least one entry.");
        }
    }

    if (jsonObj.has("id"))
    {
        String s2 = JsonUtils.getString(jsonObj, "id");

        try
        {
            uuid = UUID.fromString(s2);
        }
        catch (IllegalArgumentException var12)
        {
            throw new JsonSyntaxException("Invalid attribute modifier id \'" + s2 + "\' (must be UUID format, with dashes)");
        }
    }

    return new SetAttributes.Modifier(s, s1, i, randomvaluerange, aentityequipmentslot, uuid);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:52,代码来源:SetAttributes.java


注:本文中的net.minecraft.util.JsonUtils.getJsonArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。