本文整理汇总了Java中net.minecraft.util.JsonUtils.getFloat方法的典型用法代码示例。如果您正苦于以下问题:Java JsonUtils.getFloat方法的具体用法?Java JsonUtils.getFloat怎么用?Java JsonUtils.getFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.JsonUtils
的用法示例。
在下文中一共展示了JsonUtils.getFloat方法的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);
}
示例2: parsePosition
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
private Vector3f parsePosition(JsonObject object, String memberName)
{
JsonArray jsonarray = JsonUtils.getJsonArray(object, memberName);
if (jsonarray.size() != 3)
{
throw new JsonParseException("Expected 3 " + memberName + " 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), memberName + "[" + i + "]");
}
return new Vector3f(afloat[0], afloat[1], afloat[2]);
}
}
示例3: 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]);
}
}
示例4: parseAngle
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
private float parseAngle(JsonObject object)
{
float f = JsonUtils.getFloat(object, "angle");
if (f != 0.0F && MathHelper.abs(f) != 22.5F && MathHelper.abs(f) != 45.0F)
{
throw new JsonParseException("Invalid rotation " + f + " found, only -45/-22.5/0/22.5/45 allowed");
}
else
{
return f;
}
}
示例5: 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;
}
}
}
示例6: 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]);
}
}
}
示例7: deserializeSound
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
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);
}
示例8: deserialize
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
public RandomValueRange deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
if (JsonUtils.isNumber(p_deserialize_1_))
{
return new RandomValueRange(JsonUtils.getFloat(p_deserialize_1_, "value"));
}
else
{
JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "value");
float f = JsonUtils.getFloat(jsonobject, "min");
float f1 = JsonUtils.getFloat(jsonobject, "max");
return new RandomValueRange(f, f1);
}
}
示例9: 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);
}
}
示例10: deserialize
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
public FontMetadataSection deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
float[] afloat = new float[256];
float[] afloat1 = new float[256];
float[] afloat2 = new float[256];
float f = 1.0F;
float f1 = 0.0F;
float f2 = 0.0F;
if (jsonobject.has("characters"))
{
if (!jsonobject.get("characters").isJsonObject())
{
throw new JsonParseException("Invalid font->characters: expected object, was " + jsonobject.get("characters"));
}
JsonObject jsonobject1 = jsonobject.getAsJsonObject("characters");
if (jsonobject1.has("default"))
{
if (!jsonobject1.get("default").isJsonObject())
{
throw new JsonParseException("Invalid font->characters->default: expected object, was " + jsonobject1.get("default"));
}
JsonObject jsonobject2 = jsonobject1.getAsJsonObject("default");
f = JsonUtils.getFloat(jsonobject2, "width", f);
Validate.inclusiveBetween(0.0D, 3.4028234663852886E38D, (double)f, "Invalid default width");
f1 = JsonUtils.getFloat(jsonobject2, "spacing", f1);
Validate.inclusiveBetween(0.0D, 3.4028234663852886E38D, (double)f1, "Invalid default spacing");
f2 = JsonUtils.getFloat(jsonobject2, "left", f1);
Validate.inclusiveBetween(0.0D, 3.4028234663852886E38D, (double)f2, "Invalid default left");
}
for (int i = 0; i < 256; ++i)
{
JsonElement jsonelement = jsonobject1.get(Integer.toString(i));
float f3 = f;
float f4 = f1;
float f5 = f2;
if (jsonelement != null)
{
JsonObject jsonobject3 = JsonUtils.getJsonObject(jsonelement, "characters[" + i + "]");
f3 = JsonUtils.getFloat(jsonobject3, "width", f);
Validate.inclusiveBetween(0.0D, 3.4028234663852886E38D, (double)f3, "Invalid width");
f4 = JsonUtils.getFloat(jsonobject3, "spacing", f1);
Validate.inclusiveBetween(0.0D, 3.4028234663852886E38D, (double)f4, "Invalid spacing");
f5 = JsonUtils.getFloat(jsonobject3, "left", f2);
Validate.inclusiveBetween(0.0D, 3.4028234663852886E38D, (double)f5, "Invalid left");
}
afloat[i] = f3;
afloat1[i] = f4;
afloat2[i] = f5;
}
}
return new FontMetadataSection(afloat, afloat2, afloat1);
}
示例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;
}
示例12: deserialize
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
public RandomChanceWithLooting deserialize(JsonObject json, JsonDeserializationContext context)
{
return new RandomChanceWithLooting(JsonUtils.getFloat(json, "chance"), JsonUtils.getFloat(json, "looting_multiplier"));
}
示例13: 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]);
}
}
}
示例14: deserialize
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
public RandomChance deserialize(JsonObject json, JsonDeserializationContext context)
{
return new RandomChance(JsonUtils.getFloat(json, "chance"));
}
示例15: 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.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]);
}
}
}