net.minecraft.util.NonNullList#isEmpty ( )源码实例Demo

下面列出了net.minecraft.util.NonNullList#isEmpty ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Sakura_mod   文件: LiquidToItemRecipe.java
public ItemStack getResultItemStack(FluidStack fluid, ItemStack stack) {
	for (Entry<FluidStack, Map<Object, ItemStack>> entry : RecipesList.entrySet()) {
		if(entry.getKey().isFluidEqual(fluid))
		for (Entry<Object, ItemStack> entry2 : entry.getValue().entrySet()) {
			if (entry2.getKey() instanceof ItemStack) {
				if (ItemStack.areItemsEqual(stack, (ItemStack) entry2.getKey())) {
					return entry2.getValue();
				}
			} else if (entry2.getKey() instanceof String) {
				String dict = (String) entry2.getKey();
				NonNullList<ItemStack> ore = OreDictionary.getOres(dict);
				if (!ore.isEmpty() && RecipesUtil.containsMatch(true, ore, stack))
					return entry2.getValue();
			}
		}
	}

	return ItemStack.EMPTY;
}
 
源代码2 项目: GregTech   文件: MetaItemShapelessRecipeFactory.java
@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");

    JsonObject result = JsonUtils.getJsonObject(json, "result");
    String name = JsonUtils.getString(result, "name");
    int amount = JsonUtils.getInt(result, "amount", 1);
    ItemStack stack = ItemStack.EMPTY;
    for (MetaItem<?> item : MetaItems.ITEMS) {
        MetaItem<?>.MetaValueItem value = item.getItem(name);
        if (value != null) {
            stack = value.getStackForm(amount);
        }
    }
    return new ShapelessOreRecipe(group.isEmpty() ? null : new ResourceLocation(group), ings, stack);
}
 
源代码3 项目: Sakura_mod   文件: BarrelRecipes.java
public FluidStack getResultFluidStack(FluidStack fluid, ItemStack[] inputs) {
	for (Entry<FluidStack, Map<Object[], FluidStack>> entry : RecipesList.entrySet()) {
		if(entry.getKey().isFluidEqual(fluid))
	        for(Entry<Object[], FluidStack> entry2 : entry.getValue().entrySet()){
	            boolean flg1 = true;
            	for (Object obj1 : entry2.getKey()) {
	        		boolean flg2 = false;
	        		for (ItemStack input:inputs) {
	                	if(obj1 instanceof ItemStack){
	                		ItemStack stack1 = (ItemStack) obj1;
	    	                if (ItemStack.areItemsEqual(stack1, input)) {
	    	                    flg2 = true;
	    	                    break;
	    	                }
	                    }else if(obj1 instanceof String){
	                    	NonNullList<ItemStack> ore = OreDictionary.getOres((String) obj1);
	                    	if (!ore.isEmpty()&&RecipesUtil.containsMatch(false, ore, input)) {
	                            flg2 = true;
	    	                    break;
	                        }
	                    }
	                }
	                if (!flg2) {
	                    flg1 = false;
	                    break;
	                }
	            }

	            if (flg1) {
	                return entry2.getValue();
	            }
	        }
	}

	return null;
}
 
源代码4 项目: Sakura_mod   文件: PotRecipes.java
public ItemStack getResultItemStack(FluidStack fluid, List<ItemStack> inputs) {
	for (Entry<FluidStack, Map<Object[], ItemStack>> entry : RecipesList.entrySet()) {
		if(entry.getKey().isFluidEqual(fluid))
	        for(Entry<Object[], ItemStack> entry2 : entry.getValue().entrySet()){
	            boolean flg1 = true;
	            if ((inputs.size() != entry2.getKey().length)) 
	                continue;
            	for (Object obj1 : entry2.getKey()) {
	        		boolean flg2 = false;
	        		for (ItemStack input:inputs) {
	                	if(obj1 instanceof ItemStack){
	                		ItemStack stack1 = (ItemStack) obj1;
	    	                if (ItemStack.areItemsEqual(stack1, input)) {
	    	                    flg2 = true;
	    	                    break;
	    	                }
	                    }else if(obj1 instanceof String){
	                    	NonNullList<ItemStack> ore = OreDictionary.getOres((String) obj1);
	                    	if (!ore.isEmpty()&&RecipesUtil.containsMatch(false, ore, input)) {
	                            flg2 = true;
	    	                    break;
	                        }
	                    }
	                }
	                if (!flg2) {
	                    flg1 = false;
	                    break;
	                }
	            }

	            if (flg1) {
	                return entry2.getValue();
	            }
	        }
	}

	return ItemStack.EMPTY;
}
 
源代码5 项目: Sakura_mod   文件: DistillationRecipes.java
public FluidStack getResultFluidStack(FluidStack fluid, ItemStack[] inputs) {
	for (Entry<FluidStack, Map<Object[], FluidStack>> entry : RecipesList.entrySet()) {
		if(entry.getKey().isFluidEqual(fluid))
	        for(Entry<Object[], FluidStack> entry2 : entry.getValue().entrySet()){
	            boolean flg1 = true;
            	for (Object obj1 : entry2.getKey()) {
	        		boolean flg2 = false;
	        		for (ItemStack input:inputs) {
	                	if(obj1 instanceof ItemStack){
	                		ItemStack stack1 = (ItemStack) obj1;
	    	                if (ItemStack.areItemsEqual(stack1, input)) {
	    	                    flg2 = true;
	    	                    break;
	    	                }
	                    }else if(obj1 instanceof String){
	                    	NonNullList<ItemStack> ore = OreDictionary.getOres((String) obj1);
	                    	if (!ore.isEmpty()&&RecipesUtil.containsMatch(false, ore, input)) {
	                            flg2 = true;
	    	                    break;
	                        }
	                    }
	                }
	                if (!flg2) {
	                    flg1 = false;
	                    break;
	                }
	            }

	            if (flg1) {
	                return entry2.getValue();
	            }
	        }
	}

	return null;
}
 
源代码6 项目: Sakura_mod   文件: MortarRecipes.java
public ItemStack[] getResult(List<ItemStack> inputs) {
    ItemStack[] retStack = new ItemStack[0];

    for(Entry<Object[], ItemStack[]> entry : RecipesList.entrySet()){
        boolean flg1 = true;
        if ((inputs.size() != entry.getKey().length)) 
            continue;
    	for (Object obj1 : entry.getKey()) {
    		boolean flg2 = false;
    		for (ItemStack input:inputs) {
    			if(input.isEmpty()) break;
            	if(obj1 instanceof ItemStack){
            		ItemStack stack1 = (ItemStack) obj1;
	                if (ItemStack.areItemsEqual(stack1, input)) {
	                	inputs.remove(input);
	                    flg2 = true;
	                    break;
	                }
                }else if(obj1 instanceof String){
                	NonNullList<ItemStack> ore = OreDictionary.getOres((String) obj1);
                	if (!ore.isEmpty()&&RecipesUtil.containsMatch(false, ore, input)) {
	                	inputs.remove(input);
                        flg2 = true;
	                    break;
                    }
                }
            }
            if (!flg2) {
                flg1 = false;
                break;
            }
        }

        if (flg1) {
            return entry.getValue();
        }
    }
    
    return retStack;
}
 
源代码7 项目: GT-Classic   文件: GTHelperStack.java
public static ItemStack getStackFromOreDict(String entry) {
	ItemStack stack = null;
	if (OreDictionary.doesOreNameExist(entry)) {
		NonNullList<ItemStack> list = OreDictionary.getOres(entry, false);
		if (!list.isEmpty()) {
			stack = list.get(0);
		}
	}
	return stack;
}
 
@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);
}
 
源代码9 项目: Wizardry   文件: RecipeShapelessFluidFactory.java
@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;
}
 
源代码10 项目: GT-Classic   文件: GTRecipeIterators.java
/** Ran post init **/
public static void createUniversalProcessingRecipes() {
	String[] oreDict = OreDictionary.getOreNames();
	int oreDictSize = oreDict.length;
	for (int i = 0; i < oreDictSize; ++i) {
		String id = oreDict[i];
		String dust;
		NonNullList<ItemStack> list;
		// block to dust iterator
		if (id.startsWith("block")) {
			dust = "dust" + id.substring(5);
			if (OreDictionary.doesOreNameExist(dust)) {
				list = OreDictionary.getOres(dust, false);
				if (!list.isEmpty() && !id.contains("Chromium") && !id.contains("Aluminum") && !id.contains("Coal")
						&& !id.contains("Charcoal") && !id.contains("Quartz") && !id.contains("Prismarine")) {
					TileEntityMacerator.addRecipe((String) id, 1, GTHelperStack.copyWithSize((ItemStack) list.get(0), 9), 0.1F);
				}
			}
		}
		// ingot to block iterator
		String block;
		if (id.startsWith("ingot")) {
			block = "block" + id.substring(5);
			if (OreDictionary.doesOreNameExist(block)) {
				list = OreDictionary.getOres(block, false);
				if (!list.isEmpty() && !id.contains("Copper") && !id.contains("Chromium")
						&& !id.contains("Aluminum")) {
					TileEntityCompressor.addRecipe((String) id, 9, GTHelperStack.copyWithSize((ItemStack) list.get(0), 1), 0.1F);
				}
			}
		} else
		// gems to block iterator
		if (id.startsWith("gem")) {
			block = "block" + id.substring(3);
			if (OreDictionary.doesOreNameExist(block)) {
				list = OreDictionary.getOres(block, false);
				if (!list.isEmpty() && !id.contains("Coal") && !id.contains("Quartz")) {
					TileEntityCompressor.addRecipe((String) id, 9, GTHelperStack.copyWithSize((ItemStack) list.get(0), 1), 0.1F);
				}
			}
		}
	}
}