本文整理汇总了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);
}
示例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;
}
示例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));
}
示例4: of
import net.minecraft.util.NonNullList; //导入方法依赖的package包/类
public static NonNullList<Ingredient> of(Ingredient... list) {
return NonNullList.<Ingredient>from(Ingredient.EMPTY, list);
}
示例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);
}