當前位置: 首頁>>代碼示例>>Java>>正文


Java NonNullList.from方法代碼示例

本文整理匯總了Java中net.minecraft.util.NonNullList.from方法的典型用法代碼示例。如果您正苦於以下問題:Java NonNullList.from方法的具體用法?Java NonNullList.from怎麽用?Java NonNullList.from使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.util.NonNullList的用法示例。


在下文中一共展示了NonNullList.from方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: craftRecipe

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
@Override
public NonNullList<ItemStack> craftRecipe(ItemStackHandler inputStacks) {
    ItemStack enchantedStack = getDisenchantableItem(inputStacks);
    getBook(inputStacks).shrink(1);
    
    // take a random enchantment off the enchanted item...
    Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(enchantedStack);
    List<Enchantment> l = new ArrayList<>(enchantments.keySet());
    Enchantment strippedEnchantment = l.get(new Random().nextInt(l.size()));
    int level = enchantments.get(strippedEnchantment);
    enchantments.remove(strippedEnchantment);
    EnchantmentHelper.setEnchantments(enchantments, enchantedStack);

    // ...and create an enchanted book with it
    ItemStack enchantedBook = new ItemStack(Items.ENCHANTED_BOOK);
    EnchantmentHelper.setEnchantments(ImmutableMap.of(strippedEnchantment, level), enchantedBook);

    return NonNullList.from(ItemStack.EMPTY, enchantedBook);
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:20,代碼來源:PressureChamberVacuumEnchantHandler.java

示例2: PressureChamberRecipe

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
public PressureChamberRecipe(Object[] input, float pressureRequired, ItemStack[] output) {
    for (Object o : input) {
        if (!(o instanceof ItemStack) && !(o instanceof Pair))
            throw new IllegalArgumentException("Input objects need to be of type ItemStack or (Apache's) Pair<String, Integer>. Violating object: " + o);
        if (o instanceof Pair) {
            Pair pair = (Pair) o;
            if (!(pair.getKey() instanceof String))
                throw new IllegalArgumentException("Pair key needs to be a String (ore dict entry)");
            if (!(pair.getValue() instanceof Integer))
                throw new IllegalArgumentException("Value key needs to be an Integer (amount)");
        }
    }
    this.input = input;
    this.output = NonNullList.from(ItemStack.EMPTY, output);
    pressure = pressureRequired;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:17,代碼來源:PressureChamberRecipe.java

示例3: craftRecipe

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
@Override
public NonNullList<ItemStack> craftRecipe(ItemStackHandler inputStacks) {
    ItemStack[] recipeIngredients = getRecipeIngredients(inputStacks);
    ItemStack enchantedTool = recipeIngredients[0];
    ItemStack enchantedBook = recipeIngredients[1];
    
    Map<Enchantment, Integer> bookMap = EnchantmentHelper.getEnchantments(enchantedBook);
    bookMap.forEach((enchant, lvl) -> enchantedTool.addEnchantment(enchant, lvl));
    
    enchantedBook.shrink(1);
    return NonNullList.from(ItemStack.EMPTY, new ItemStack(Items.BOOK));
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:13,代碼來源:PressureChamberPressureEnchantHandler.java

示例4: of

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
public static NonNullList<Ingredient> of(Ingredient... list) {
	return NonNullList.<Ingredient>from(Ingredient.EMPTY, list);
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:4,代碼來源:ModRituals.java

示例5: ofs

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
public static NonNullList<ItemStack> ofs(ItemStack... list) {
	if (list == null || list.length == 0)
		return none;
	return NonNullList.<ItemStack>from(ItemStack.EMPTY, list);
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:6,代碼來源:ModRituals.java


注:本文中的net.minecraft.util.NonNullList.from方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。