Java Code Examples for net.minecraft.util.NonNullList#add()
The following examples show how to use
net.minecraft.util.NonNullList#add() .
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: BlockLeekCrop.java From TofuCraftReload with MIT License | 6 votes |
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { Random rand = world instanceof World ? ((World) world).rand : RANDOM; int age = getAge(state); int count = quantityDropped(state, fortune, rand); for (int i = 0; i < count; i++) { Item item = this.getItemDropped(state, rand, fortune); if (item != Items.AIR) { drops.add(new ItemStack(item, 1, this.damageDropped(state))); } } if (age >= getMaxAge()) { int k = 3 + fortune; for (int i = 0; i < k; ++i) { if (rand.nextInt(2 * getMaxAge()) <= age) { drops.add(new ItemStack(this.getSeed(), 1, this.damageDropped(state))); } } } }
Example 2
Source File: ItemAgriSeed.java From AgriCraft with MIT License | 6 votes |
@Override public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> list) { if (tab == this.getCreativeTab() || tab == CreativeTabs.SEARCH) { final PlantStats baseStat = new PlantStats(); for (IAgriPlant plant : AgriApi.getPlantRegistry().all()) { if (plant.getSeedItems().stream().anyMatch(s -> s.isItemEqual(this))) { ItemStack stack = new ItemStack(this); NBTTagCompound tag = new NBTTagCompound(); tag.setString(AgriNBT.SEED, plant.getId()); baseStat.writeToNBT(tag); stack.setTagCompound(tag); list.add(stack); } } } }
Example 3
Source File: BlockTerra.java From TFC2 with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList list) { if(showInCreative) { if(hasMeta()) { if(itemIn instanceof ItemBlock && ((ItemBlock)itemIn).block instanceof INeedOffset) { for(int l = 0; l < META_PROP.getAllowedValues().size(); l++) list.add(new ItemStack(itemIn, 1, ((INeedOffset)(((ItemBlock)itemIn).block)).convertMetaToItem(l))); } else { for(int l = 0; l < META_PROP.getAllowedValues().size(); l++) list.add(new ItemStack(itemIn, 1, l)); } } else super.getSubBlocks(itemIn, tab, list); } }
Example 4
Source File: ItemFluidContainer.java From customstuff4 with GNU General Public License v3.0 | 6 votes |
@SideOnly(Side.CLIENT) @Override public void getSubItems(@Nullable CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems) { if (isInCreativeTab(tab)) { subItems.add(new ItemStack(this)); for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) { if (!fluid.getName().equals("milk")) { // add all fluids that the bucket can be filled with FluidStack fs = new FluidStack(fluid, content.capacity); ItemStack stack = new ItemStack(this); IFluidHandlerItem fluidHandler = new FluidHandlerItemStack(stack, content.capacity); if (fluidHandler.fill(fs, true) == fs.amount) { ItemStack filled = fluidHandler.getContainer(); subItems.add(filled); } } } } }
Example 5
Source File: ItemOrb.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void getSubItems(@Nullable CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems) { if (isInCreativeTab(tab)) { subItems.add(new ItemStack(this)); for (int i = 1; i < 10; i++) { ItemStack stack = new ItemStack(this, 1, 1); ManaManager.forObject(stack) .setMana(ManaManager.getMaxMana(stack) * i / 10.0) .close(); subItems.add(stack); } subItems.add(new ItemStack(this, 1, 1)); } }
Example 6
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 7
Source File: DefaultSubItemHandler.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void getSubItems(ItemStack itemStack, CreativeTabs creativeTab, NonNullList<ItemStack> subItems) { subItems.add(itemStack.copy()); IElectricItem electricItem = itemStack.getCapability(GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM, null); if (electricItem != null) { electricItem.charge(Long.MAX_VALUE, Integer.MAX_VALUE, true, false); subItems.add(itemStack); } if (creativeTab == CreativeTabs.SEARCH) { if (itemStack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) { addFluidContainerVariants(itemStack, subItems); } } }
Example 8
Source File: BlockMSU.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) { for (int i = 0; i < EnumStorageType.values().length; i++) { list.add(new ItemStack(this, 1, EnumStorageType.values()[i].getMeta())); } }
Example 9
Source File: BlockStorage.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) { for (int i = 0; i < EnumStorageType.values().length; i++) { list.add(new ItemStack(this, 1, EnumStorageType.values()[i].getMeta())); } }
Example 10
Source File: BlockChestnut.java From Sakura_mod with MIT License | 5 votes |
@Override public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { if(getMetaFromState(state) >= 3) { if(!fruitRemoval) { drops.add(new ItemStack(ItemLoader.MATERIAL, 1,15)); } drops.add(new ItemStack(ItemLoader.MATERIAL, 1,15)); } }
Example 11
Source File: BlockFluidPipe.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> items) { for (Material material : enabledMaterials.keySet()) { for (FluidPipeType fluidPipeType : FluidPipeType.values()) { items.add(getItem(fluidPipeType, material)); } } }
Example 12
Source File: NacrePearlSpell.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void getSubItems(@Nullable CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems) { if (isInCreativeTab(tab)) { subItems.add(new ItemStack(this)); ItemStack stack = new ItemStack(this); NBTHelper.setFloat(stack, NBTConstants.NBT.PURITY_OVERRIDE, 2f); subItems.add(stack); } }
Example 13
Source File: BlockOre.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) { if(tab == CreativeTabs.SEARCH) { blockState.getValidStates().forEach(blockState -> list.add(getItem(blockState))); } else if(tab == GregTechAPI.TAB_GREGTECH_ORES) { list.add(getItem(getDefaultState())); } }
Example 14
Source File: MaterialMetaItem.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override @SideOnly(Side.CLIENT) public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) { super.getSubItems(tab, subItems); if (tab == GregTechAPI.TAB_GREGTECH_MATERIALS || tab == CreativeTabs.SEARCH) { for (short metadata : generatedItems) { subItems.add(new ItemStack(this, 1, metadata)); } } }
Example 15
Source File: GTItemFluidTube.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void getSubItems(@Nullable final CreativeTabs tab, final NonNullList<ItemStack> subItems) { if (this.isInCreativeTab(tab)) { subItems.add(empty); for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) { subItems.add(GTMaterialGen.getModdedTube(fluid.getName(), 1)); } } }
Example 16
Source File: BlockMinecoprocessor.java From Minecoprocessors with GNU General Public License v3.0 | 4 votes |
@Override public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> items) { items.add(new ItemStack(ITEM_INSTANCE)); items.add(new ItemStack(ITEM_INSTANCE, 1, 4)); }
Example 17
Source File: MetaGeneric.java From OpenModsLib with MIT License | 4 votes |
@Override public void addToCreativeList(Item item, int meta, NonNullList<ItemStack> result) { if (visibleInCreative) { result.add(new ItemStack(item, 1, meta)); } }
Example 18
Source File: BlockDrawbridge.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) { list.add(new ItemStack(this, 1, 0)); list.add(new ItemStack(this, 1, 1)); }
Example 19
Source File: ItemRing.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void getSubItems(@Nullable CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems) { if (isInCreativeTab(tab)) subItems.add(new ItemStack(this)); }
Example 20
Source File: BlockTraverseDeadGrass.java From Traverse-Legacy-1-12-2 with MIT License | 4 votes |
@SideOnly(Side.CLIENT) public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> items) { items.add(new ItemStack(this, 1, 0)); }