本文整理汇总了Java中net.minecraft.util.JsonUtils.getString方法的典型用法代码示例。如果您正苦于以下问题:Java JsonUtils.getString方法的具体用法?Java JsonUtils.getString怎么用?Java JsonUtils.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.JsonUtils
的用法示例。
在下文中一共展示了JsonUtils.getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialize
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
public LootCondition deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "condition");
ResourceLocation resourcelocation = new ResourceLocation(JsonUtils.getString(jsonobject, "condition"));
LootCondition.Serializer<?> serializer;
try
{
serializer = LootConditionManager.getSerializerForName(resourcelocation);
}
catch (IllegalArgumentException var8)
{
throw new JsonSyntaxException("Unknown condition \'" + resourcelocation + "\'");
}
return serializer.deserialize(jsonobject, p_deserialize_3_);
}
示例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;
}
示例3: parse
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
@Override
public Ingredient parse(JsonContext context, JsonObject json)
{
String name = JsonUtils.getString(json, "name");
ItemStack stack = null;
// If item with variant.
if (name.contains("#")) {
String[] parts = name.split("#");
stack = IC2Items.getItem(parts[0], parts[1]);
} else {
stack = IC2Items.getItem(name);
}
if (stack == null)
throw new JsonSyntaxException("IC2 item with name " + name + " could not be found");
return Ingredient.fromStacks(stack);
}
示例4: deserializeSounds
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
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;
}
示例5: deserialize
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
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));
}
示例6: 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);
}
示例7: parseSampler
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
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);
}
}
示例8: parseAxis
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
private EnumFacing.Axis parseAxis(JsonObject p_178252_1_)
{
String s = JsonUtils.getString(p_178252_1_, "axis");
EnumFacing.Axis enumfacing$axis = EnumFacing.Axis.byName(s.toLowerCase());
if (enumfacing$axis == null)
{
throw new JsonParseException("Invalid rotation axis: " + s);
}
else
{
return enumfacing$axis;
}
}
示例9: parse
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
@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");
ItemStack itemstack = CraftingHelper.getItemStack(JsonUtils.getJsonObject(json, "result"), context);
int[] damage = new int[ings.size()];
if (JsonUtils.hasField(json, "damage"))
{
JsonArray array = JsonUtils.getJsonArray(json, "damage");
if (array.size() > damage.length)
throw new JsonParseException("Too many values for damage array: got " + array.size() + ", expected " + damage.length);
for (int i = 0; i < array.size(); i++)
{
JsonElement element = array.get(i);
if (!element.isJsonPrimitive() || !element.getAsJsonPrimitive().isNumber())
throw new JsonSyntaxException("Entry in damage array is not a number, got " + element);
damage[i] = element.getAsJsonPrimitive().getAsInt();
}
}
return new DamageableShapelessOreRecipe(group.isEmpty() ? null : new ResourceLocation(group), damage, ings, itemstack);
}
示例10: parseTexture
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
private String parseTexture(JsonObject p_178340_1_)
{
return JsonUtils.getString(p_178340_1_, "texture");
}
示例11: parse
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
@Override
public IRecipe parse(JsonContext context, JsonObject json) {
JsonArray pattern = JsonUtils.getJsonArray(json, "pattern");
List<String> strs = new ArrayList<>();
for (JsonElement element : pattern) {
strs.add(element.getAsString());
}
char[][] grid = new char[strs.size()][];
for (int i = 0; i < strs.size(); i++) {
grid[i] = strs.get(i).toCharArray();
}
if (grid.length > 3 || (grid.length > 0 && grid[0].length > 3)) {
throw new JsonSyntaxException("Pattern may not be larger than 3x3");
}
Map<Character, Ingredient> ingredientMap = new HashMap<>();
if (json.has("key")) {
JsonObject keys = JsonUtils.getJsonObject(json, "key");
keys.entrySet().forEach(entry -> {
String key = entry.getKey();
if (key.length() != 1) {
throw new JsonSyntaxException("Keys must be 1 character, was: " + key);
} else if (key.equals(" ")) {
throw new JsonSyntaxException("' ' is a reserved key");
} else if (key.equals("#")) {
throw new JsonSyntaxException("'#' is a reserved key");
}
Ingredient ingredient = CraftingHelper.getIngredient(entry.getValue(), context);
ingredientMap.put(key.charAt(0), ingredient);
});
}
String component = JsonUtils.getString(json, "component");
CraftableType type = CraftableTypeRegistry.instance().get(component);
if (type == null) {
throw new JsonSyntaxException("Unknown component " + component);
}
RandoresItemRecipe recipe = new RandoresItemRecipe(ingredientMap, type, grid, JsonUtils.getInt(json, "quantity"));
RECIPES.put(type, recipe);
return recipe;
}
示例12: parseCullFace
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
private EnumFacing parseCullFace(JsonObject p_178339_1_)
{
String s = JsonUtils.getString(p_178339_1_, "cullface", "");
return EnumFacing.byName(s);
}
示例13: getStringModel
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
protected String getStringModel(JsonObject json)
{
return JsonUtils.getString(json, "model");
}
示例14: getParent
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
private String getParent(JsonObject p_178326_1_)
{
return JsonUtils.getString(p_178326_1_, "parent", "");
}
示例15: ResourceIndex
import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
public ResourceIndex(File p_i1047_1_, String p_i1047_2_)
{
if (p_i1047_2_ != null)
{
File file1 = new File(p_i1047_1_, "objects");
File file2 = new File(p_i1047_1_, "indexes/" + p_i1047_2_ + ".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: " + file2);
}
catch (FileNotFoundException var21)
{
logger.error("Can\'t find the resource index file: " + file2);
}
finally
{
IOUtils.closeQuietly((Reader)bufferedreader);
}
}
}