本文整理汇总了Java中net.minecraft.client.util.JsonException.forException方法的典型用法代码示例。如果您正苦于以下问题:Java JsonException.forException方法的具体用法?Java JsonException.forException怎么用?Java JsonException.forException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.client.util.JsonException
的用法示例。
在下文中一共展示了JsonException.forException方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseUniform
import net.minecraft.client.util.JsonException; //导入方法依赖的package包/类
private void parseUniform(JsonElement element) throws JsonException
{
JsonObject jsonobject = JsonUtils.getJsonObject(element, "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.forException(exception);
jsonexception.prependJsonKey("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.setSafe(afloat[0], afloat[1], afloat[2], afloat[3]);
}
else
{
shaderuniform.set(afloat);
}
this.shaderUniforms.add(shaderuniform);
}
}
示例2: parseGroup
import net.minecraft.client.util.JsonException; //导入方法依赖的package包/类
public void parseGroup(TextureManager p_152765_1_, ResourceLocation p_152765_2_) throws JsonException, IOException, JsonSyntaxException
{
JsonParser jsonparser = new JsonParser();
IResource iresource = null;
try
{
iresource = this.resourceManager.getResource(p_152765_2_);
JsonObject jsonobject = jsonparser.parse(IOUtils.toString(iresource.getInputStream(), Charsets.UTF_8)).getAsJsonObject();
if (JsonUtils.isJsonArray(jsonobject, "targets"))
{
JsonArray jsonarray = jsonobject.getAsJsonArray("targets");
int i = 0;
for (JsonElement jsonelement : jsonarray)
{
try
{
this.initTarget(jsonelement);
}
catch (Exception exception1)
{
JsonException jsonexception1 = JsonException.forException(exception1);
jsonexception1.prependJsonKey("targets[" + i + "]");
throw jsonexception1;
}
++i;
}
}
if (JsonUtils.isJsonArray(jsonobject, "passes"))
{
JsonArray jsonarray1 = jsonobject.getAsJsonArray("passes");
int j = 0;
for (JsonElement jsonelement1 : jsonarray1)
{
try
{
this.parsePass(p_152765_1_, jsonelement1);
}
catch (Exception exception)
{
JsonException jsonexception2 = JsonException.forException(exception);
jsonexception2.prependJsonKey("passes[" + j + "]");
throw jsonexception2;
}
++j;
}
}
}
catch (Exception exception2)
{
JsonException jsonexception = JsonException.forException(exception2);
jsonexception.setFilenameAndFlush(p_152765_2_.getResourcePath());
throw jsonexception;
}
finally
{
IOUtils.closeQuietly((Closeable)iresource);
}
}
示例3: initUniform
import net.minecraft.client.util.JsonException; //导入方法依赖的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.forException(exception);
jsonexception.prependJsonKey("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]);
}
}
}
示例4: initUniform
import net.minecraft.client.util.JsonException; //导入方法依赖的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.forException(exception);
jsonexception.prependJsonKey("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]);
}
}
}