Java Code Examples for net.minecraft.item.Item.REGISTRY

The following are Jave code examples for showing how to use REGISTRY of the net.minecraft.item.Item class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: pnc-repressurized   File: GuiSearcher.java   View Source Code Vote up 6 votes
/**
 * 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();
}
 
Example 2
Project: Backmemed   File: StatList.java   View Source Code Vote up 6 votes
private static void initStats()
{
    for (Item item : Item.REGISTRY)
    {
        if (item != null)
        {
            int i = Item.getIdFromItem(item);
            String s = getItemName(item);

            if (s != null)
            {
                OBJECT_USE_STATS[i] = (new StatCrafting("stat.useItem.", s, new TextComponentTranslation("stat.useItem", new Object[] {(new ItemStack(item)).getTextComponent()}), item)).registerStat();

                if (!(item instanceof ItemBlock))
                {
                    USE_ITEM_STATS.add((StatCrafting)OBJECT_USE_STATS[i]);
                }
            }
        }
    }

    replaceAllSimilarBlocks(OBJECT_USE_STATS);
}
 
Example 3
Project: Backmemed   File: StatList.java   View Source Code Vote up 6 votes
private static void initItemDepleteStats()
{
    for (Item item : Item.REGISTRY)
    {
        if (item != null)
        {
            int i = Item.getIdFromItem(item);
            String s = getItemName(item);

            if (s != null && item.isDamageable())
            {
                OBJECT_BREAK_STATS[i] = (new StatCrafting("stat.breakItem.", s, new TextComponentTranslation("stat.breakItem", new Object[] {(new ItemStack(item)).getTextComponent()}), item)).registerStat();
            }
        }
    }

    replaceAllSimilarBlocks(OBJECT_BREAK_STATS);
}
 
Example 4
Project: Backmemed   File: StatList.java   View Source Code Vote up 6 votes
private static void initPickedUpAndDroppedStats()
{
    for (Item item : Item.REGISTRY)
    {
        if (item != null)
        {
            int i = Item.getIdFromItem(item);
            String s = getItemName(item);

            if (s != null)
            {
                OBJECTS_PICKED_UP_STATS[i] = (new StatCrafting("stat.pickup.", s, new TextComponentTranslation("stat.pickup", new Object[] {(new ItemStack(item)).getTextComponent()}), item)).registerStat();
                OBJECTS_DROPPED_STATS[i] = (new StatCrafting("stat.drop.", s, new TextComponentTranslation("stat.drop", new Object[] {(new ItemStack(item)).getTextComponent()}), item)).registerStat();
            }
        }
    }

    replaceAllSimilarBlocks(OBJECT_BREAK_STATS);
}
 
Example 5
Project: Backmemed   File: CreativeTabs.java   View Source Code Vote up 6 votes
/**
 * only shows items which have tabToDisplayOn == this
 */
public void displayAllRelevantItems(NonNullList<ItemStack> p_78018_1_)
{
    for (Item item : Item.REGISTRY)
    {
        if (item != null && item.getCreativeTab() == this)
        {
            item.getSubItems(item, this, p_78018_1_);
        }
    }

    if (this.getRelevantEnchantmentTypes() != null)
    {
        this.addEnchantmentBooksToList(p_78018_1_, this.getRelevantEnchantmentTypes());
    }
}
 
Example 6
Project: CustomWorldGen   File: GuiContainerCreative.java   View Source Code Vote up 6 votes
private void updateCreativeSearch()
{
    GuiContainerCreative.ContainerCreative guicontainercreative$containercreative = (GuiContainerCreative.ContainerCreative)this.inventorySlots;
    guicontainercreative$containercreative.itemList.clear();

    CreativeTabs tab = CreativeTabs.CREATIVE_TAB_ARRAY[selectedTabIndex];
    if (tab.hasSearchBar() && tab != CreativeTabs.SEARCH)
    {
        tab.displayAllRelevantItems(guicontainercreative$containercreative.itemList);
        updateFilteredItems(guicontainercreative$containercreative);
        return;
    }

    for (Item item : Item.REGISTRY)
    {
        if (item != null && item.getCreativeTab() != null)
        {
            item.getSubItems(item, (CreativeTabs)null, guicontainercreative$containercreative.itemList);
        }
    }
    updateFilteredItems(guicontainercreative$containercreative);
}
 
Example 7
Project: CustomWorldGen   File: CreativeTabs.java   View Source Code Vote up 6 votes
/**
 * only shows items which have tabToDisplayOn == this
 */
@SideOnly(Side.CLIENT)
public void displayAllRelevantItems(List<ItemStack> p_78018_1_)
{
    for (Item item : Item.REGISTRY)
    {
        if (item == null)
        {
            continue;
        }
        for (CreativeTabs tab : item.getCreativeTabs())
        {
            if (tab == this)
            {
                item.getSubItems(item, this, p_78018_1_);
            }
        }
    }

    if (this.getRelevantEnchantmentTypes() != null)
    {
        this.addEnchantmentBooksToList(p_78018_1_, this.getRelevantEnchantmentTypes());
    }
}
 
Example 8
Project: Soot   File: JEI.java   View Source Code Vote up 5 votes
private List<RecipeDawnstoneAnvil> generateDawnstoneAnvilRecipes()
{
    //I'm basicly sorry for all of this. Please forgive me.
    ArrayList<RecipeDawnstoneAnvil> repairRecipes = new ArrayList<>();
    ArrayList<RecipeDawnstoneAnvil> destroyRecipes = new ArrayList<>();

    for (Item item : Item.REGISTRY) {
        ItemStack stack = item.getDefaultInstance();
        ItemStack repairItem = ItemStack.EMPTY;
        try {
            repairItem = Misc.getRepairItem(stack);
        }
        catch (Exception e) { //Gotta catch em all
            e.printStackTrace();
        }
        boolean isRepairable = item.getIsRepairable(stack, repairItem);
        boolean materiaAllowed = item.isRepairable();
        if(isRepairable || materiaAllowed)
        {
            ArrayList<ItemStack> repairMaterials = new ArrayList<>();
            repairMaterials.add(repairItem.copy());
            if(materiaAllowed)
                repairMaterials.add(new ItemStack(RegistryManager.isolated_materia));
            ItemStack[] repairMaterialsArray = repairMaterials.toArray(new ItemStack[repairMaterials.size()]);
            repairRecipes.add(new RecipeDawnstoneAnvil(new ItemStack[]{stack.copy()}, Ingredient.fromStacks(makeDamaged(stack)),Ingredient.fromStacks(repairMaterialsArray)));
            if(Misc.getResourceCount(stack) != -1) {
                ItemStack material = repairItem.copy();
                material.setCount(Misc.getResourceCount(stack));
                destroyRecipes.add(new RecipeDawnstoneAnvil(new ItemStack[]{material}, Ingredient.fromStacks(makeDamaged(stack)), Ingredient.EMPTY));
            }
        }
    }

    return Stream.concat(repairRecipes.stream(),destroyRecipes.stream()).collect(Collectors.toList());
}
 
Example 9
Project: Bewitchment   File: ModelHandler.java   View Source Code Vote up 5 votes
/**
 * Register all Item and Block models from the registry.
 */
public static void registerModels() {
	for (Block block : Block.REGISTRY) {
		if (block instanceof IModelRegister)
			((IModelRegister) block).registerModel();
	}

	for (Item item : Item.REGISTRY) {
		if (item instanceof IModelRegister)
			((IModelRegister) item).registerModel();
	}
}
 
Example 10
Project: Solar   File: ModelHandler.java   View Source Code Vote up 5 votes
public static void registerModels() {
	for(Block block : Block.REGISTRY) {
		if(block instanceof IModel)
			((IModel) block).registerModel();
	}

	for(Item item : Item.REGISTRY) {
		if(item instanceof IModel)
			((IModel) item).registerModel();
	}
	Solar.LOG.info("[BAKING CHOCOLATE COOKIES!]");
}
 
Example 11
Project: Anima-Mundi   File: AnimaItems.java   View Source Code Vote up 5 votes
public static void postInit()
{
	for(Item item : Item.REGISTRY)
	{
		if(item instanceof ItemAnimaShield)
		{
			shieldItems.add((ItemAnimaShield) item);
		}
	}
}
 
Example 12
Project: Backmemed   File: ModelBakery.java   View Source Code Vote up 5 votes
private void loadItemModels()
{
    this.registerVariantNames();

    for (Item item : Item.REGISTRY)
    {
        for (String s : this.getVariantNames(item))
        {
            ResourceLocation resourcelocation = this.getItemLocation(s);
            ResourceLocation resourcelocation1 = (ResourceLocation)Item.REGISTRY.getNameForObject(item);
            this.loadItemModel(s, resourcelocation, resourcelocation1);

            if (item.hasCustomProperties())
            {
                ModelBlock modelblock = (ModelBlock)this.models.get(resourcelocation);

                if (modelblock != null)
                {
                    for (ResourceLocation resourcelocation2 : modelblock.getOverrideLocations())
                    {
                        this.loadItemModel(resourcelocation2.toString(), resourcelocation2, resourcelocation1);
                    }
                }
            }
        }
    }
}
 
Example 13
Project: CustomWorldGen   File: ModelBakery.java   View Source Code Vote up 5 votes
protected void loadItemModels()
{
    this.registerVariantNames();

    for (Item item : Item.REGISTRY)
    {
        for (String s : this.getVariantNames(item))
        {
            ResourceLocation resourcelocation = this.getItemLocation(s);
            ResourceLocation resourcelocation1 = (ResourceLocation)Item.REGISTRY.getNameForObject(item);
            this.loadItemModel(s, resourcelocation, resourcelocation1);

            if (item.hasCustomProperties())
            {
                ModelBlock modelblock = (ModelBlock)this.models.get(resourcelocation);

                if (modelblock != null)
                {
                    for (ResourceLocation resourcelocation2 : modelblock.getOverrideLocations())
                    {
                        this.loadItemModel(resourcelocation2.toString(), resourcelocation2, resourcelocation1);
                    }
                }
            }
        }
    }
}
 
Example 14
Project: Backmemed   File: GuiContainerCreative.java   View Source Code Vote up 4 votes
private void updateCreativeSearch()
{
    GuiContainerCreative.ContainerCreative guicontainercreative$containercreative = (GuiContainerCreative.ContainerCreative)this.inventorySlots;
    guicontainercreative$containercreative.itemList.clear();

    for (Item item : Item.REGISTRY)
    {
        if (item != null && item.getCreativeTab() != null)
        {
            item.getSubItems(item, (CreativeTabs)null, guicontainercreative$containercreative.itemList);
        }
    }

    for (Enchantment enchantment : Enchantment.REGISTRY)
    {
        if (enchantment != null && enchantment.type != null)
        {
            Items.ENCHANTED_BOOK.getAll(enchantment, guicontainercreative$containercreative.itemList);
        }
    }

    Iterator<ItemStack> iterator = guicontainercreative$containercreative.itemList.iterator();
    String s1 = this.searchField.getText().toLowerCase(Locale.ROOT);

    while (iterator.hasNext())
    {
        ItemStack itemstack = (ItemStack)iterator.next();
        boolean flag = false;

        for (String s : itemstack.getTooltip(this.mc.player, this.mc.gameSettings.advancedItemTooltips))
        {
            if (TextFormatting.getTextWithoutFormattingCodes(s).toLowerCase(Locale.ROOT).contains(s1))
            {
                flag = true;
                break;
            }
        }

        if (!flag)
        {
            iterator.remove();
        }
    }

    this.currentScroll = 0.0F;
    guicontainercreative$containercreative.scrollTo(0.0F);
}