@SideOnly(Side.CLIENT) @Override public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) { for (int i = 0; i < EnumRockClass.values().length; ++i) { list.add(new ItemStack(this, 1, i)); } }
@Override @SideOnly(Side.CLIENT) public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) { if(!Config.DISABLED_TOOLS.contains("hammer")) { ItemStack stack1 = new ItemStack(this); NBTTagCompound tag = new NBTTagCompound(); tag.setString(HEAD_TAG, Materials.randomHead().getName()); tag.setString(HAFT_TAG, Materials.randomHaft().getName()); tag.setString(HANDLE_TAG, Materials.randomHandle().getName()); tag.setString(ADORNMENT_TAG, Materials.randomAdornment().getName()); stack1.setTagCompound(tag); if (isInCreativeTab(tab)) { subItems.add(stack1); } } }
/** * Lazy cache. * @return */ private Stream<SearchEntry> getSearchEntries(){ if(cachedSearchEntries == null){ NonNullList<ItemStack> itemList = NonNullList.create(); for(Item item : Item.REGISTRY){ if (item != null && item.getCreativeTab() != null) { item.getSubItems(item.getCreativeTab(), itemList); } } for (Enchantment enchantment : Enchantment.REGISTRY) { if (enchantment != null && enchantment.type != null) { getAllEnchantedBooks(enchantment, itemList); } } cachedSearchEntries = itemList.stream().map(SearchEntry::new).collect(Collectors.toList()); } return cachedSearchEntries.stream(); }
public static void reArrangeStacks(InventoryDankNull inventory) { if (inventory != null) { int count = 0; NonNullList<ItemStack> stackList = NonNullList.withSize(inventory.getSizeInventory(), ItemStack.EMPTY); for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack stack = inventory.getStackInSlot(i); if (!stack.isEmpty()) { stackList.set(count, inventory.getStackInSlot(i)); count++; } } if (stackList.size() == 0) { setSelectedStackIndex(inventory, -1); } else { for (int i = 0; i < stackList.size(); i++) { inventory.setInventorySlotContents(i, stackList.get(i)); } for (int i = stackList.size(); i < inventory.getSizeInventory(); i++) { inventory.setInventorySlotContents(i, ItemStack.EMPTY); } } setSelectedIndexApplicable(inventory); } }
/** * Creates a list of ingredients based on an Object[]. Valid types are {@link String}, {@link ItemStack}, {@link Item}, and {@link Block}. * Used for elemental recipes. */ private static NonNullList<Ingredient> createElementalInput(Object[] input) { if (input[0] instanceof List) input = ((List<?>) input[0]).toArray(); else if (input[0] instanceof Object[]) input = (Object[]) input[0]; NonNullList<Ingredient> inputL = NonNullList.withSize(9, Ingredient.EMPTY); for (int i = 0; i < input.length; i++) { Object k = input[i]; if (k instanceof String) inputL.set(i, new OreIngredient((String) k)); else if (k instanceof ItemStack && !((ItemStack) k).isEmpty()) inputL.set(i, Ingredient.fromStacks((ItemStack) k)); else if (k instanceof IForgeRegistryEntry) inputL.set(i, Ingredient.fromStacks(makeStack((IForgeRegistryEntry<?>) k))); } return inputL; }
public static ArrayList<Block> getBlocksFromString(String blockName) { ArrayList<Block> blocks = new ArrayList<>(); if(!HarshenUtils.toArray(Blocks.AIR, null).contains(Block.getBlockFromName(blockName))) blocks.add(Block.getBlockFromName(blockName)); for(ItemStack oreStack : OreDictionary.getOres(blockName)) if(oreStack.getItem() instanceof ItemBlock) blocks.add(((ItemBlock)oreStack.getItem()).getBlock()); ArrayList<Block> finalBlocks = new ArrayList<>(); for(Block b : blocks) { NonNullList<ItemStack> items = NonNullList.create(); b.getSubBlocks(CreativeTabs.SEARCH, items); for(ItemStack stack : items) if(!stack.isEmpty()) finalBlocks.add(Block.getBlockFromItem(stack.getItem())); else finalBlocks.add(b); } return finalBlocks; }
@Override public IMessage handleServerMessage(EntityPlayer player, MessageSyncClearList message, MessageContext ctx) { if ((player != null) && (message != null) && (ctx != null)) { EntityPlayer en = (EntityPlayer) player.getEntityWorld().getEntityByID(message.entityId); if (en != null) { if (player.getEntityId() == en.getEntityId() && en.getEntityWorld() != null && en.hasCapability(Currency.CART_DATA, null)) { CartCapability entityData = en.getCapability(Currency.CART_DATA, null); entityData.setCart(NonNullList.withSize(entityData.getSizeInventory(), ItemStack.EMPTY), true); List<Float> prices = Arrays.asList(new Float[25]); for (int i = 0; i < prices.size(); i++) { prices.set(i, (float) 0); } } } } return null; }
@Override public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> list) { if (tab.equals(this.getCreativeTab())) { { //Construct a sample scarf NBTTagCompound tag = new NBTTagCompound(); NBTTagList leftScarf = new NBTTagList(); NBTTagList rightScarf = new NBTTagList(); for(int i=0; i<14; i++) { NBTTagCompound node = new NBTTagCompound(); int col = 0x60d9bb; if (i%2==1) col = 0x1b5c64; node.setInteger("Color", col); leftScarf.appendTag(node); rightScarf.appendTag(node.copy()); } tag.setTag("LeftScarf", leftScarf); tag.setTag("RightScarf", rightScarf); ItemStack stack = new ItemStack(this, 1); stack.setTagCompound(tag); list.add(stack); } } }
@Override @SideOnly(Side.CLIENT) /** * returns a list of items with the same ID, but different meta (eg: dye * returns 16 items) */ public void getSubItems(CreativeTabs par2CreativeTabs, NonNullList<ItemStack> par3List) { if(!this.isInCreativeTab(par2CreativeTabs)) return; for (int i = 0; i < 18; i++) par3List.add(new ItemStack(this, 1, i)); par3List.add(new ItemStack(this, 1, 26)); par3List.add(new ItemStack(this, 1, 27)); par3List.add(new ItemStack(this, 1, 28)); par3List.add(new ItemStack(this, 1, 29)); par3List.add(new ItemStack(this, 1, 30)); }
/** * For every ingredient, we need to check each itemstack. * Then, if we find a match, mark that itemstack so it cannot be checked again. */ @Override public boolean matches(EntityPlayer player, ItemStack wand, NonNullList<ItemStack> stacks, World world) { List<ItemStack> toCheck = Lists.newArrayList(stacks); for (Ingredient i : this.inputs) { for (int ix = 0; ix < toCheck.size(); ix++) { if (i.apply(toCheck.get(ix))) { toCheck.remove(ix); break; } else if (i == Ingredient.EMPTY && toCheck.get(ix).isEmpty()) toCheck.remove(ix); } } IArcaneTransfigurationItem crafter = (IArcaneTransfigurationItem) wand.getItem(); if (!crafter.matches(this, player, wand, stacks, world)) return false; return toCheck.isEmpty() && (anima.isEmpty() || (crafter.containsAnimus() && wand.getCapability(IAnimaStorage.CAP, null).take(anima, true) == null)); }
@Override public void displayAllRelevantItems(NonNullList<ItemStack> items) { for (int i = 0; i < 6; i++) { items.add(new ItemStack(ModItems.DANK_NULL, 1, i)); } for (Item item : ModItems.getList()) { if (!(item instanceof ItemDankNull) && !(item instanceof ItemDankNullHolder) && !(item instanceof ItemBlock) && !(item instanceof ItemDankNullPanel)) { items.add(new ItemStack(item)); } } for (int i = 0; i < 6; i++) { items.add(new ItemStack(ModItems.DANK_NULL_PANEL, 1, i)); } for (Block block : ModBlocks.getList()) { items.add(new ItemStack(block)); } }
@Override @SideOnly(Side.CLIENT) public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) { if(!Config.DISABLED_TOOLS.contains("shovel")) { ItemStack stack1 = new ItemStack(this); NBTTagCompound tag = new NBTTagCompound(); tag.setString(HEAD_TAG, Materials.randomHead().getName()); tag.setString(HAFT_TAG, Materials.randomHaft().getName()); tag.setString(HANDLE_TAG, Materials.randomHandle().getName()); tag.setString(ADORNMENT_TAG, Materials.randomAdornment().getName()); stack1.setTagCompound(tag); if (isInCreativeTab(tab)) { subItems.add(stack1); } } }
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) { NonNullList<ItemStack> nonnulllist = NonNullList.<ItemStack>func_191197_a(inv.getSizeInventory(), ItemStack.field_190927_a); for (int i = 0; i < nonnulllist.size(); ++i) { ItemStack itemstack = inv.getStackInSlot(i); if (itemstack.getItem().hasContainerItem()) { nonnulllist.set(i, new ItemStack(itemstack.getItem().getContainerItem())); } } return nonnulllist; }
/** * (abstract) Protected helper method to read subclass entity data from NBT. */ protected void readEntityFromNBT(NBTTagCompound compound) { super.readEntityFromNBT(compound); this.minecartContainerItems = NonNullList.<ItemStack>func_191197_a(this.getSizeInventory(), ItemStack.field_190927_a); if (compound.hasKey("LootTable", 8)) { this.lootTable = new ResourceLocation(compound.getString("LootTable")); this.lootTableSeed = compound.getLong("LootTableSeed"); } else { ItemStackHelper.func_191283_b(compound, this.minecartContainerItems); } }
@Override protected void innerUpdate() { if (this.world.isRemote) return; ++tick; if (crafting.getLocked() && tick >= 40 && hasOnlyOneFluid()) { Fluid fluid = getRecipeFluid(); if (fluid == null) return; int bucketAmount = getFluidAmount(fluid); FluidStack stack = tank.drain(bucketAmount * 1000, false); if (stack != null && stack.getFluid().equals(fluid) && stack.amount == bucketAmount * 1000) { IRecipe recipe = CraftingUtils.findRecipe(world, simulateRecipeEntries(fluid)); if (recipe == null || recipe.getRecipeOutput().isEmpty()) return; if (ItemHandlerHelper.insertItem(this.output, recipe.getRecipeOutput().copy(), true).isEmpty() && areAllSolidsPresent(fluid)) { NonNullList<ItemStack> remaining = recipe.getRemainingItems(CraftingUtils.genCraftingInventory(world, simulateRecipeEntries(fluid))); for (int i = 0; i < crafting.getSlots(); ++i) { if (isStackCurrentFluid(fluid, crafting.getFilterStack(i))) continue; if (remaining.get(i).isEmpty()) crafting.getStackInSlot(i).shrink(1); else crafting.setStackInSlot(i, remaining.get(i).copy()); } tank.drain(bucketAmount * 1000, true); ItemHandlerHelper.insertItem(this.output, recipe.getRecipeOutput().copy(), false); } } tick = 0; } }
@Override public boolean matches(EntityPlayer player, ItemStack wand, NonNullList<ItemStack> stacks, World world) { for (int i = 0; i < 9; i++) { if (this.inputs.get(i) == Ingredient.EMPTY && stacks.get(i).isEmpty()) continue; if (!this.inputs.get(i).apply(stacks.get(i))) return false; } IArcaneTransfigurationItem crafter = (IArcaneTransfigurationItem) wand.getItem(); if (!crafter.matches(this, player, wand, stacks, world)) return false; return anima.isEmpty() || (crafter.containsAnimus() && wand.getCapability(IAnimaStorage.CAP, null).take(anima, true) == null); }
@Override public void initGui() { super.initGui(); this.guiLeft=this.width/2-146; this.guiTop=this.height/2-120; this.buttonsItem=new GuiButtonToggleItem[16*6]; itemsToRender=NonNullList.<ItemStack>create(); TF2weapons.tabweapontf2.displayAllRelevantItems(itemsToRender); TF2weapons.tabutilitytf2.displayAllRelevantItems(itemsToRender); TF2weapons.tabsurvivaltf2.displayAllRelevantItems(itemsToRender); for (int x = 0; x < 16; x++) for (int y = 0; y < 6; y++) { if(x+y*16<itemsToRender.size()) { GuiButtonToggleItem button=buttonsItem[x + y * 16]=new GuiButtonToggleItem(x + y * 16, this.guiLeft + 4 + x * 18, this.guiTop + 34 + y * 18, 18, 18); this.buttonList.add(button); } } this.buttonList.add(new GuiButton(96, this.guiLeft+200, this.guiTop+14, "Back")); //this.buttonList.get(96).visible=false; this.setButtons(); }
@Override @SideOnly(Side.CLIENT) public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) { if (isInCreativeTab(tab)) { for (SipType t : PurMag.INSTANCE.getSipRegistry().getTypes()) { items.add(SipUtils.getStackWithSip(new ItemStack(this), t.getName())); } } }
public static IArcaneTransfigurationRecipe getArcaneTransfigurationRecipe(EntityPlayer player, ItemStack wand, NonNullList<ItemStack> inputs, World world) { Preconditions.checkArgument(inputs.size() == 9, "[Arcane Magic]: Attempting to retrieve an arcane transfiguration recipe with an invalid input list size!"); Preconditions.checkArgument(wand.getItem() instanceof IArcaneTransfigurationItem, "[Arcane Magic]: Attempting to retrieve an arcane transfiguration recipe with an invalid wand stack! (Must be IElementalCraftingItem)"); for (IArcaneTransfigurationRecipe curRecipe : ARCANE_TRANSFIGURATION_RECIPES) if (curRecipe.matches(player, wand, inputs, world)) return curRecipe; return null; }
public static void addMeatCompressionRecipe(IForgeRegistry<IRecipe> registry, EnumEdibleMeat meat, boolean cooked, ItemStack ingredient) { ResourceLocation group = new ResourceLocation("thermionics_world", "compress.meat"); Ingredient input = Ingredient.fromStacks(ingredient); ShapedRecipes recipe = new ShapedRecipes(group.toString(), 3, 3, NonNullList.withSize(3*3, input), new ItemStack(TWBlocks.MEAT_EDIBLE, 1, BlockMeatEdible.getMetaFromValue(meat, cooked)) ); recipe.setRegistryName(new ResourceLocation("thermionics_world", meat.getName()+((cooked)?".cooked":".raw")+"_CompressToBlock")); registry.register(recipe); }
@Override @SideOnly(Side.CLIENT) public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) { if (tab!=this.getCreativeTabToDisplayOn()) return; for (int i=0; i<16; i++) { list.add(new ItemStack(ItemBlock.getItemFromBlock(this), 1, i)); } }
/** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) { list.add(new ItemStack(itemIn, 1, BlockPlanks.EnumType.OAK.getMetadata())); list.add(new ItemStack(itemIn, 1, BlockPlanks.EnumType.SPRUCE.getMetadata())); list.add(new ItemStack(itemIn, 1, BlockPlanks.EnumType.BIRCH.getMetadata())); list.add(new ItemStack(itemIn, 1, BlockPlanks.EnumType.JUNGLE.getMetadata())); }
private static ItemStack[] asItemStackArray(NonNullList<ItemStack> stacks) { ItemStack[] result = new ItemStack[stacks.size()]; for (int i = 0; i < stacks.size(); i++) { result[i] = stacks.get(i); } return result; }
private void drawNemesisArmor(int mouseX, int mouseY) { if (nemesisData.nemesis.getArmorInventory() == null) { return; } NonNullList<ItemStack> armorSet = nemesisData.nemesis.getArmorInventory(); for (int i = 0; i < Math.min(4, armorSet.size()); i++) { drawItemStack(armorSet.get(i), 86, 84 - (i * 18), mouseX, mouseY); } }
/** * Adds recipes like 9 gold ingot --> 1 gold block, and 1 gold block --> 9 gold ingots. */ public static void addPressureChamberStorageBlockRecipes() { // search for a 3x3 recipe where all 9 ingredients are the same for (IRecipe recipe : CraftingManager.REGISTRY) { if (recipe instanceof ShapedRecipes) { ShapedRecipes shaped = (ShapedRecipes) recipe; NonNullList<Ingredient> ingredients = recipe.getIngredients(); ItemStack ref = ingredients.get(0).getMatchingStacks()[0]; if (ref.isEmpty() || ingredients.size() < 9) continue; boolean valid = true; for (int i = 0; i < 9; i++) { ItemStack stack = ingredients.get(i).getMatchingStacks()[0]; if (!stack.isItemEqual(ref)) { valid = false; break; } } if (valid) { ItemStack inputStack = ref.copy(); inputStack.setCount(9); PressureChamberRecipe.chamberRecipes.add(new PressureChamberRecipe(new ItemStack[]{inputStack}, 1.0F, new ItemStack[]{shaped.getRecipeOutput()}, false)); ItemStack inputStack2 = shaped.getRecipeOutput().copy(); inputStack2.setCount(1); PressureChamberRecipe.chamberRecipes.add(new PressureChamberRecipe(new ItemStack[]{inputStack2}, -0.5F, new ItemStack[]{inputStack}, false)); } } } }
public InventoryCrafting(Container eventHandlerIn, int width, int height) { this.stackList = NonNullList.<ItemStack>func_191197_a(width * height, ItemStack.field_190927_a); this.eventHandler = eventHandlerIn; this.inventoryWidth = width; this.inventoryHeight = height; }
@Override @SideOnly(Side.CLIENT) public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) { if (isInCreativeTab(tab)) { for (int i = 0; i < COMPONENT_AMOUNT; i++) { subItems.add(new ItemStack(this, 1, i)); } } }
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) { NonNullList<ItemStack> nonnulllist = NonNullList.<ItemStack>withSize(inv.getSizeInventory(), ItemStack.EMPTY); for (int i = 0; i < nonnulllist.size(); ++i) { ItemStack itemstack = inv.getStackInSlot(i); nonnulllist.set(i, net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack)); } return nonnulllist; }
@Override @SideOnly(Side.CLIENT) public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) { if (isInCreativeTab(tab)) { for (int i = 0; i < 3; i++) { subItems.add(new ItemStack(this, 1, i)); } } }
@Override public void fromBytes(ByteBuf buf) { int i = buf.readShort(); itemStacks = NonNullList.<ItemStack>withSize(i, ItemStack.EMPTY); stackSizes = new int[i]; for (int j = 0; j < i; ++j) { itemStacks.set(j, ByteBufUtils.readItemStack(buf)); } for (int j = 0; j < i; ++j) { stackSizes[j] = buf.readInt(); } }
@Override @SideOnly(Side.CLIENT) public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> list) { if (this.isInCreativeTab(tab)) { super.getSubItems(tab, list); NonNullList<ItemStack> potions = NonNullList.create(); Items.POTIONITEM.getSubItems(tab, potions); for (ItemStack potion : potions) { ItemStack ammo = new ItemStack(this); setPotion(ammo, potion); list.add(ammo); } } }
@Override public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) { if (tab != this.getCreativeTab()) { return; } for (int i = 0; i < EnumCrop.values().length - 1; ++i) { subItems.add(new ItemStack(this, 1, i)); } }
@Override @SideOnly(Side.CLIENT) public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) { if (this.isInCreativeTab(tab)) { for (EnumCandyFlavour value : EnumCandyFlavour.values()) { subItems.add(new ItemStack(this, 1, value.getMetadata())); } } }
@Override public void getSubBlocks(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> items) { { for (int i = 0; i < Gem.values().length; ++i) { items.add(new ItemStack(this, 1, i)); } } }
/** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) { if (itemIn != Item.getItemFromBlock(Blocks.DOUBLE_STONE_SLAB2)) { for (BlockStoneSlabNew.EnumType blockstoneslabnew$enumtype : BlockStoneSlabNew.EnumType.values()) { list.add(new ItemStack(itemIn, 1, blockstoneslabnew$enumtype.getMetadata())); } } }
/** * Attempt to insert fluid into the given fluid handler from the given fluid container item. * * @param handler the handler to extract from * @param srcStack the fluid container item to insert to * @param returnedItems the modified fluid container after insertion * @return true if any fluid was moved, false otherwise */ public static boolean tryFluidInsertion(IFluidHandler handler, ItemStack srcStack, NonNullList<ItemStack> returnedItems) { FluidActionResult result = FluidUtil.tryEmptyContainer(srcStack, handler, 1000, null, true); if (result.isSuccess()) { returnedItems.add(result.getResult()); srcStack.shrink(1); return true; } else { return false; } }
public void displayAllRelevantItems(NonNullList<ItemStack> list) { //Blocks list.add(new ItemStack(proxy.blockTube, 1, 0)); list.add(new ItemStack(proxy.blockDisplacer, 1, 0)); //Items for (int i = 0; i < 17; i++) list.add(new ItemStack(proxy.itemPaintbrush, 1, i)); list.add(new ItemStack(proxy.itemUpgrade, 1, 0)); }
@Override @SideOnly(Side.CLIENT) public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) { for (int i = 0; i < meta_map.size(); i++) { if (!Config.HIDE_UNCRAFTABLE_HEADS || (OreDictionary.getOres(meta_map.get(i).getCraftingItem()).size() > 0 && OreDictionary.getOres(meta_map.get(i).getSmallCraftingItem()).size() > 0)) { ItemStack stack = new ItemStack(this, 1, i); if (isInCreativeTab(tab)) { subItems.add(stack); } } } }