本文整理了Java中net.minecraft.util.JsonUtils.getJsonArray()
方法的一些代码示例,展示了JsonUtils.getJsonArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonUtils.getJsonArray()
方法的具体详情如下:
包路径:net.minecraft.util.JsonUtils
类名称:JsonUtils
方法名:getJsonArray
暂无
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
if( json.has( "conditions" ) && !CraftingHelper.processConditions( JsonUtils.getJsonArray( json, "conditions" ), this.ctx ) )
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
JsonArray patternJ = JsonUtils.getJsonArray( json, "pattern" );
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
@Override
public BooleanSupplier parse( JsonContext jsonContext, JsonObject jsonObject )
{
final boolean result;
if( JsonUtils.isJsonArray( jsonObject, JSON_FEATURES_KEY ) )
{
final JsonArray features = JsonUtils.getJsonArray( jsonObject, JSON_FEATURES_KEY );
result = Stream.of( features )
.allMatch( p -> AEConfig.instance().isFeatureEnabled( AEFeature.valueOf( p.getAsString().toUpperCase( Locale.ENGLISH ) ) ) );
}
else if( JsonUtils.isString( jsonObject, JSON_FEATURES_KEY ) )
{
final String featureName = JsonUtils.getString( jsonObject, JSON_FEATURES_KEY ).toUpperCase( Locale.ENGLISH );
final AEFeature feature = AEFeature.valueOf( featureName );
result = AEConfig.instance().isFeatureEnabled( feature );
}
else
{
result = false;
}
return () -> result;
}
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
private static ShapelessOreRecipe shapelessFactory( 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" );
}
return new ShapelessOreRecipe( group.isEmpty() ? null : new ResourceLocation( group ), ings, getResult( json, context ) );
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
private Set<String> parseTargetList(JsonObject json) {
if (!json.has(ENTITIES_TO_TARGET)) {
return Collections.emptySet();
}
JsonArray targets = JsonUtils.getJsonArray(json, ENTITIES_TO_TARGET);
return StreamSupport.stream(targets.spliterator(), false).map(e -> JsonUtils.getString(e, ""))
.collect(Collectors.toCollection(HashSet::new));
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@Override
public void parse(JsonObject json) {
STATE_TO_ITEM.putAll(JsonHelper.mapFromObjectArray(JsonUtils.getJsonArray(json, "blockstate_to_item"),
BLOCK_PROPERTY, "item", JsonHelper::getBlockStateMatcher, JsonHelper::getItemStack));
STATE_TO_REMAINING_ITEM.putAll(JsonHelper.mapFromObjectArray(JsonUtils.getJsonArray(json, "blockstate_to_item"),
BLOCK_PROPERTY, "remaining_item", JsonHelper::getBlockStateMatcher, e -> e != null ? JsonHelper.getItemStack(e) : ItemStack.EMPTY));
STATE_PASS.putAll(JsonHelper.mapFromObjectArray(JsonUtils.getJsonArray(json, "block_passes"),
BLOCK_PROPERTY, "build_pass", JsonHelper::getBlockStateMatcher, e -> Integer.parseInt(JsonUtils.getString(e, "build_pass"))));
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
private Set<String> getTargetList(JsonObject json) {
if (!json.has("entities_to_target")) {
return Collections.emptySet();
}
JsonArray targets = JsonUtils.getJsonArray(json, "entities_to_target");
return StreamSupport.stream(targets.spliterator(), false).map(e -> JsonUtils.getString(e, ""))
.collect(Collectors.toCollection(HashSet::new));
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
private Set<Ingredient> getResources(JsonObject json) {
JsonArray res = JsonUtils.getJsonArray(json, "resources");
JsonContext context = new JsonContext(AncientWarfareCore.MOD_ID);
return StreamSupport.stream(res.spliterator(), false).map(e -> CraftingHelper.getIngredient(e, context)).collect(Collectors.toSet());
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@Override
public void parse(JsonObject json) {
JsonArray plantables = JsonUtils.getJsonArray(json, "soils");
for (JsonElement t : plantables) {
soilBlocks.add(JsonHelper.getBlockStateMatcher(JsonUtils.getJsonObject(t, "")));
}
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@Override
public void parse(JsonObject json) {
JsonArray soils = JsonUtils.getJsonArray(json, "soils");
for (JsonElement t : soils) {
soilBlocks.add(JsonHelper.getBlockStateMatcher(JsonUtils.getJsonObject(t, "")));
}
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
private void parseFactionDefaults(JsonObject json) {
factionTemplates = JsonHelper.mapFromJson(json, "faction_defaults",
Map.Entry::getKey,
e -> parseTradeLists(JsonUtils.getJsonArray(e.getValue(), "trade_list")));
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@Override
public void parse(JsonObject json) {
defaultTemplates = parseTradeLists(JsonUtils.getJsonArray(json, "defaults"));
parseFactionDefaults(json);
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@Override
public void parse(JsonObject json) {
JsonArray fruits = JsonUtils.getJsonArray(json, "fruits");
for (JsonElement e : fruits) {
JsonObject fruit = JsonUtils.getJsonObject(e, "");
parseFruit(fruit);
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
private List<FactionTradeTemplate> parseTrades(JsonArray trades) {
List<FactionTradeTemplate> ret = new ArrayList<>();
for (JsonElement tradeElement : trades) {
JsonObject trade = JsonUtils.getJsonObject(tradeElement, "trade");
int refillFrequency = JsonUtils.getInt(trade, "refill_frequency");
int maxTrades = JsonUtils.getInt(trade, "max_trades");
List<ItemStack> input = JsonHelper.getItemStacks(JsonUtils.getJsonArray(trade, "input"));
List<ItemStack> output = JsonHelper.getItemStacks(JsonUtils.getJsonArray(trade, "output"));
ret.add(new FactionTradeTemplate(input, output, refillFrequency, maxTrades));
}
return ret;
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@Override
public void parse(JsonObject json) {
JsonArray tillables = JsonUtils.getJsonArray(json, "tillable_mapping");
for (JsonElement t : tillables) {
JsonObject tillableMapping = JsonUtils.getJsonObject(t, "");
BlockStateMatcher tillableState = JsonHelper.getBlockStateMatcher(tillableMapping, "tillable");
IBlockState tilledState = JsonHelper.getBlockState(tillableMapping, "tilled");
tillableBlocks.put(tillableState, tilledState);
soilBlocks.add(JsonHelper.getBlockStateMatcher(tillableMapping, "tilled"));
}
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
private Map<String, FactionTradeListTemplate> parseTradeLists(JsonArray tradeLists) {
Map<String, FactionTradeListTemplate> ret = new HashMap<>();
for (JsonElement tradeListElement : tradeLists) {
JsonObject tradeList = JsonUtils.getJsonObject(tradeListElement, "trade_list");
String name = JsonUtils.getString(tradeList, "name");
JsonArray tradesArray = JsonUtils.getJsonArray(tradeList, "trades");
List<FactionTradeTemplate> trades = parseTrades(tradesArray);
ret.put(name, new FactionTradeListTemplate(name, trades));
}
return ret;
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@Override
public void parse(JsonObject json) {
JsonArray treeScanners = JsonUtils.getJsonArray(json, "tree_scanners");
for (JsonElement ts : treeScanners) {
JsonObject treeScanner = JsonUtils.getJsonObject(ts, "");
switch (JsonUtils.getString(treeScanner, "type")) {
case "default":
default:
DefaultSearchParser.parse(treeScanner);
}
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@Override
public void parse(JsonObject json) {
JsonArray saplings = JsonUtils.getJsonArray(json, "saplings");
for (JsonElement e : saplings) {
JsonObject saplingDefinition = JsonUtils.getJsonObject(e, "");
TreeFarmRegistry.saplings.add(new Sapling(JsonHelper.getItemStackMatcher(JsonUtils.getJsonObject(saplingDefinition, "sapling")),
saplingDefinition.has("right_click") && JsonUtils.getBoolean(saplingDefinition, "right_click")));
}
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
public static TableOfContentsElement parse(JsonObject elementJson) {
JsonArray contents = JsonUtils.getJsonArray(elementJson, "items");
ArrayList<TableOfContentsItem> tocItems = new ArrayList<>();
for (JsonElement e : contents) {
JsonObject contentItem = JsonUtils.getJsonObject(e, "");
tocItems.add(new TableOfContentsItem(JsonUtils.getString(contentItem, "text"), JsonUtils.getString(contentItem, "category_link")));
}
return new TableOfContentsElement(tocItems);
}
代码示例来源:origin: TeamWizardry/Wizardry
@Override
public IRecipe parse(JsonContext context, JsonObject json) {
String group = JsonUtils.getString(json, "group", "");
NonNullList<Ingredient> ingredients = NonNullList.create();
for (JsonElement element : JsonUtils.getJsonArray(json, "ingredients"))
ingredients.add(CraftingHelper.getIngredient(element, context));
if (ingredients.isEmpty())
throw new JsonParseException("No ingredients in shapeless recipe");
ItemStack result = CraftingHelper.getItemStack(JsonUtils.getJsonObject(json, "result"), context);
RecipeShapelessFluid recipe = new RecipeShapelessFluid(group.isEmpty() ? null : new ResourceLocation(group), result, ingredients);
return recipe;
}
}
内容来源于网络,如有侵权,请联系作者删除!