当前位置: 首页>>代码示例>>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;未经允许,请勿转载。