本文整理了Java中net.minecraft.util.NonNullList.toArray()
方法的一些代码示例,展示了NonNullList.toArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NonNullList.toArray()
方法的具体详情如下:
包路径:net.minecraft.util.NonNullList
类名称:NonNullList
方法名:toArray
暂无
代码示例来源:origin: WayofTime/BloodMagic
@Override
@Nonnull
public ItemStack[] getMatchingStacks() {
if (items == null)
items = orbs.toArray(new ItemStack[0]);
return items;
}
代码示例来源:origin: Darkhax-Minecraft/Bookshelf
/**
* Gets an array of all variations of an item. This method will grab items from the
* creative tab entries of an item, and can possibly be slow.
*
* @param item The item to get variations of.
* @return An array of all the variations of the item.
*/
public static ItemStack[] getAllItems (Item item) {
return findVariations(item).toArray(new ItemStack[0]);
}
代码示例来源:origin: lorddusk/HQM
@Override
public ItemStack[] getPermutations(ItemStack stack) {
NonNullList<ItemStack> items = NonNullList.create();
stack.getItem().getSubItems(null, items);
return items.toArray(new ItemStack[items.size()]);
}
};
代码示例来源:origin: PrinceOfAmber/Cyclic
private static boolean doesMatch(Block blockCheck, ScytheConfig type) {
if (UtilString.isInList(type.blockWhitelist, blockCheck.getRegistryName())) {
return true;
}
else {
ItemStack bStack = new ItemStack(blockCheck);
return UtilOreDictionary.doesMatchOreDict(bStack, type.oreDictWhitelist.toArray(new String[0]));
}
}
代码示例来源:origin: WayofTime/BloodMagic
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;
ItemStack compressedStack = CompressionRegistry.compressInventory(player.inventory.mainInventory.toArray(new ItemStack[player.inventory.mainInventory.size()]), world);
if (compressedStack != null) {
EntityItem entityItem = new EntityItem(world, player.posX, player.posY, player.posZ, compressedStack);
world.spawnEntity(entityItem);
}
}
}
代码示例来源:origin: CoFH/CoFHCore
@Override
public IRecipe parse(JsonContext context, JsonObject json) {
ShapelessOreRecipe recipe = ShapelessOreRecipe.factory(context, json);
return new ShapelessUpgradeKitRecipe(new ResourceLocation("cofh", "upgrade_kit_shapeless"), recipe.getRecipeOutput(), recipe.getIngredients().toArray());
}
代码示例来源:origin: CoFH/CoFHCore
@Override
public IRecipe parse(JsonContext context, JsonObject json) {
ShapelessOreRecipe recipe = ShapelessOreRecipe.factory(context, json);
return new ShapelessColorRemoveRecipe(new ResourceLocation("cofh", "color_remove_shapeless"), recipe.getRecipeOutput(), recipe.getIngredients().toArray());
}
代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition
@SideOnly(Side.CLIENT)
public MOGuideEntry setStackIcons(Block block) {
NonNullList<ItemStack> stacks = NonNullList.create();
block.getSubBlocks(CreativeTabs.SEARCH, stacks);
if (stacks.size() > 0) {
this.stackIcons = new ItemStack[stacks.size()];
this.stackIcons = stacks.toArray(this.stackIcons);
} else {
this.stackIcons = new ItemStack[]{new ItemStack(block)};
}
return this;
}
代码示例来源:origin: CoFH/CoFHCore
@Override
public IRecipe parse(JsonContext context, JsonObject json) {
ShapelessOreRecipe recipe = ShapelessOreRecipe.factory(context, json);
return new ShapelessFluidRecipe(new ResourceLocation("cofh", "fluid_shapeless"), recipe.getRecipeOutput(), recipe.getIngredients().toArray());
}
代码示例来源:origin: CoFH/CoFHCore
@Override
public IRecipe parse(JsonContext context, JsonObject json) {
ShapelessOreRecipe recipe = ShapelessOreRecipe.factory(context, json);
return new ShapelessSecureRecipe(new ResourceLocation("cofh", "secure_shapeless"), recipe.getRecipeOutput(), recipe.getIngredients().toArray());
}
代码示例来源:origin: CoFH/ThermalFoundation
@Override
public IRecipe parse(JsonContext context, JsonObject json) {
ShapelessOreRecipe recipe = ShapelessOreRecipe.factory(context, json);
return new ShapelessPotionFillRecipe(new ResourceLocation("thermalfoundation", "potion_fill_shapeless"), recipe.getRecipeOutput(), recipe.getIngredients().toArray());
}
代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition
@SideOnly(Side.CLIENT)
public MOGuideEntry setStackIcons(Item item) {
NonNullList<ItemStack> stacks = NonNullList.create();
item.getSubItems(CreativeTabs.SEARCH, stacks);
if (stacks.size() > 0) {
this.stackIcons = new ItemStack[stacks.size()];
this.stackIcons = stacks.toArray(this.stackIcons);
} else {
this.stackIcons = new ItemStack[]{new ItemStack(item)};
}
return this;
}
代码示例来源:origin: CoFH/CoFHCore
@Override
public IRecipe parse(JsonContext context, JsonObject json) {
ShapelessOreRecipe recipe = ShapelessOreRecipe.factory(context, json);
return new ShapelessColorRecipe(new ResourceLocation("cofh", "color_shapeless"), recipe.getRecipeOutput(), recipe.getIngredients().toArray());
}
代码示例来源:origin: gr8pefish/IronBackpacks
@Override
public ItemStack[] getMatchingStacks() {
if (this.items == null) {
NonNullList<ItemStack> stacks = NonNullList.withSize(types.size(), ItemStack.EMPTY);
for (int i = 0; i < types.size(); i++) {
ItemStack stack = IronBackpacksAPI.getStack(types.get(i), specialty);
stacks.set(i, stack);
}
this.items = stacks.toArray(new ItemStack[0]);
}
return this.items;
}
代码示例来源:origin: ForestryMC/Binnie
@Override
@Nonnull
public ItemStack[] getMatchingStacks() {
if (array == null || this.array.length != ores.size()) {
NonNullList<ItemStack> lst = NonNullList.create();
for (ItemStack itemstack : this.ores) {
if (itemstack.getMetadata() == OreDictionary.WILDCARD_VALUE) {
itemstack.getItem().getSubItems(CreativeTabs.SEARCH, lst);
} else {
lst.add(itemstack);
}
}
Collections.rotate(lst, offset);
this.array = lst.toArray(new ItemStack[0]);
}
return this.array;
}
代码示例来源:origin: GregTechCE/GregTech
public R fromRecipe(Recipe recipe) {
this.inputs = recipe.getInputs();
this.outputs = NonNullList.from(ItemStack.EMPTY, recipe.getOutputs().toArray(new ItemStack[0]));
this.chancedOutputs = new TObjectIntHashMap<>(recipe.getChancedOutputs());
this.fluidInputs = new ArrayList<>(recipe.getFluidInputs());
this.fluidOutputs = new ArrayList<>(recipe.getFluidOutputs());
this.duration = recipe.getDuration();
this.EUt = recipe.getEUt();
this.hidden = recipe.isHidden();
this.canBeBuffered = recipe.canBeBuffered();
this.needsEmptyOutput = recipe.needsEmptyOutput();
return (R) this;
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@Override
public IRecipe getCraftingRecipe() {
//noinspection ConstantConditions
return new ShapelessOreRecipe(null, getRecipeOutput(), getIngredients().toArray(new Ingredient[getIngredients().size()])).setRegistryName(getRegistryName());
}
}
代码示例来源:origin: CoFH/ThermalDynamics
public static void addTransposerFill(int energy, ItemStack input, ItemStack output, FluidStack fluid, boolean reversible) {
if (!Loader.isModLoaded("thermalexpansion")) {
int numDucts = MathHelper.clamp(Fluid.BUCKET_VOLUME / fluid.amount, 1, 8);
NonNullList<Object> ingredients = NonNullList.create();
for (int i = 0; i < numDucts; i++) {
ingredients.add(ItemHelper.cloneStack(input, 1));
}
ingredients.add(new FluidIngredient(fluid.getFluid().getName()));
addShapelessFluidRecipe(ItemHelper.cloneStack(output, numDucts), ingredients.toArray());
} else {
ThermalExpansionHelper.addTransposerFill(energy, input, output, fluid, reversible);
}
}
代码示例来源:origin: ForestryMC/ForestryMC
@Override
protected void onIndexUpdate(int index, ICarpenterRecipe recipe) {
selectedElement.add(new TankElement(91, 1, null, () -> new FluidTankInfo(recipe.getFluidResource(), Constants.PROCESSOR_TANK_CAPACITY), CARPENTER_TANK_OVERLAY));
IDescriptiveRecipe gridRecipe = recipe.getCraftingGridRecipe();
NonNullList<NonNullList<ItemStack>> ingredients = gridRecipe.getRawIngredients();
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 3; y++) {
int ingredientIndex = y * 3 + x;
if (ingredientIndex >= ingredients.size()) {
continue;
}
NonNullList<ItemStack> items = ingredients.get(ingredientIndex);
selectedElement.add(new IngredientElement(1 + x * 19, 3 + y * 19, Ingredient.fromStacks(items.toArray(new ItemStack[items.size()]))));
}
}
selectedElement.item(71, 41, gridRecipe.getOutput());
}
}
代码示例来源:origin: ForestryMC/ForestryMC
@Override
protected void onIndexUpdate(int index, IFabricatorRecipe recipe) {
selectedElement.add(new TankElement(1, 33, null, () -> new FluidTankInfo(recipe.getLiquid(), 2000), FABRICATOR_TANK_OVERLAY, 16, 16));
NonNullList<NonNullList<ItemStack>> ingredients = recipe.getIngredients();
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 3; y++) {
int ingredientIndex = y * 3 + x;
if (ingredientIndex >= ingredients.size()) {
continue;
}
NonNullList<ItemStack> items = ingredients.get(ingredientIndex);
selectedElement.add(new IngredientElement(21 + x * 19, 1 + y * 19, Ingredient.fromStacks(items.toArray(new ItemStack[items.size()]))));
}
}
ItemStack plan = recipe.getPlan();
if (!plan.isEmpty()) {
selectedElement.item(91, 1, plan);
}
selectedElement.item(91, 39, recipe.getRecipeOutput());
NonNullList<ItemStack> smeltingInput = NonNullList.create();
Fluid recipeFluid = recipe.getLiquid().getFluid();
for (IFabricatorSmeltingRecipe s : getSmeltingInputs().get(recipeFluid)) {
smeltingInput.add(s.getResource());
}
if (!smeltingInput.isEmpty()) {
selectedElement.add(new IngredientElement(1, 6, smeltingInput));
}
}
内容来源于网络,如有侵权,请联系作者删除!