Java Code Examples for net.minecraft.util.NonNullList#isEmpty()
The following examples show how to use
net.minecraft.util.NonNullList#isEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LiquidToItemRecipe.java From Sakura_mod with MIT License | 6 votes |
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; }
Example 2
Source File: MetaItemShapelessRecipeFactory.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@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); }
Example 3
Source File: BarrelRecipes.java From Sakura_mod with MIT License | 5 votes |
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; }
Example 4
Source File: PotRecipes.java From Sakura_mod with MIT License | 5 votes |
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; }
Example 5
Source File: DistillationRecipes.java From Sakura_mod with MIT License | 5 votes |
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; }
Example 6
Source File: MortarRecipes.java From Sakura_mod with MIT License | 5 votes |
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; }
Example 7
Source File: GTHelperStack.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
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; }
Example 8
Source File: DamageableShapelessOreRecipe.java From customstuff4 with GNU General Public License v3.0 | 5 votes |
@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); }
Example 9
Source File: RecipeShapelessFluidFactory.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@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; }
Example 10
Source File: GTRecipeIterators.java From GT-Classic with GNU Lesser General Public License v3.0 | 4 votes |
/** 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); } } } } }