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

The following examples show how to use net.minecraft.item.Item#REGISTRY . 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: SignalsConfig.java    From Signals with GNU General Public License v3.0 6 votes vote down vote up
public void initDefaults(){
    if(validItems.length == 0) {
        List<Item> items = new ArrayList<>();
        items.add(ModItems.RAIL_CONFIGURATOR);
        items.add(Item.getItemFromBlock(ModBlocks.RAIL_LINK));

        for(Item item : Item.REGISTRY) {
            if(item instanceof ItemBlock) {
                Block block = ((ItemBlock)item).getBlock();
                if(block instanceof BlockSignalBase || block instanceof BlockRailBase) {
                    items.add(item);
                }
            }
        }

        validItems = new String[items.size()];
        for(int i = 0; i < items.size(); i++) {
            validItems[i] = Item.REGISTRY.getNameForObject(items.get(i)).toString();
        }
    }
}
 
Example 2
Source File: GTProxyClient.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void registerTintedItems() {
	GTColorItem colors = new GTColorItem();
	ItemColors registry = Minecraft.getMinecraft().getItemColors();
	for (Item item : Item.REGISTRY) {
		if (item instanceof IGTColorItem) {
			registry.registerItemColorHandler(colors, item);
		}
	}
}
 
Example 3
Source File: GTRecipeIterators.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** Iterates through loaded itemstacks for all mods **/
public static void postInit() {
	createMortarRecipe();
	if (GTConfig.general.addCompressorRecipesForBlocks) {
		createUniversalProcessingRecipes();
	}
	for (Item item : Item.REGISTRY) {
		NonNullList<ItemStack> items = NonNullList.create();
		item.getSubItems(CreativeTabs.SEARCH, items);
		for (ItemStack stack : items) {
			if (GTConfig.general.oreDictWroughtIron && GTHelperStack.matchOreDict(stack, "ingotWroughtIron")
					&& !GTHelperStack.matchOreDict(stack, "ingotRefinedIron")) {
				OreDictionary.registerOre("ingotRefinedIron", stack);
			}
			if (GTHelperStack.matchOreDict(stack, "ingotAluminum")
					&& !GTHelperStack.matchOreDict(stack, "ingotAluminium")) {
				OreDictionary.registerOre("ingotAluminium", stack);
			}
			if (GTHelperStack.matchOreDict(stack, "dustAluminum")
					&& !GTHelperStack.matchOreDict(stack, "dustAluminium")) {
				OreDictionary.registerOre("dustAluminium", stack);
			}
			if (GTHelperStack.matchOreDict(stack, "ingotChromium")
					&& !GTHelperStack.matchOreDict(stack, "ingotChrome")) {
				OreDictionary.registerOre("ingotChrome", stack);
			}
		}
	}
	for (Block block : Block.REGISTRY) {
		if (block.getDefaultState().getMaterial() == Material.ROCK
				&& !GTHelperStack.oreDictStartsWith(GTMaterialGen.get(block), "ore")) {
			GTItemJackHammer.rocks.add(block);
		}
	}
	GTMod.logger.info("Jack Hammer stone list populated with " + GTItemJackHammer.rocks.size() + " entries");
}
 
Example 4
Source File: CompostRegistry.java    From ExNihiloAdscensio with MIT License 4 votes vote down vote up
public static void recommendAllFood(File file)
{
    if(FMLCommonHandler.instance().getSide().isServer())
    {
        return;
    }
    
    IBlockState dirt = Blocks.DIRT.getDefaultState();
    Color brown = new Color("7F3F0F");
    
    Map<String, Compostable> recommended = Maps.newHashMap();
    
    for(Item item : Item.REGISTRY)
    {
        if(item instanceof ItemFood)
        {
            ItemFood food = (ItemFood) item;
            
            List<ItemStack> stacks = Lists.newArrayList();
            food.getSubItems(food, null, stacks);
            
            for(ItemStack foodStack : stacks)
            {
                ItemInfo foodItemInfo = new ItemInfo(foodStack);
                
                if(!containsItem(foodItemInfo))
                {
   	                int hungerRestored = food.getHealAmount(foodStack);
   	                
   	                recommended.put(foodItemInfo.toString(), new Compostable(hungerRestored * 0.025F, brown, new ItemInfo(dirt)));
   	            }
            }
        }
    }
    
    String json = gson.toJson(recommended, new TypeToken<Map<String, Compostable>>(){}.getType());
    
    try
       {
           Files.write(file.toPath(), json.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
       }
       catch (IOException e)
       {
           e.printStackTrace();
       }
}
 
Example 5
Source File: ItemList.java    From NotEnoughItems with MIT License 4 votes vote down vote up
@Override
public void execute() {
    ThreadOperationTimer timer = getTimer(500);

    LinkedList<ItemStack> items = new LinkedList<>();
    LinkedList<ItemStack> permutations = new LinkedList<>();
    ListMultimap<Item, ItemStack> itemMap = ArrayListMultimap.create();

    timer.setLimit(500);
    for (Item item : Item.REGISTRY) {
        if (interrupted()) {
            return;
        }

        if (item == null || erroredItems.contains(item) || item == Items.AIR) {
            continue;
        }

        try {
            timer.reset(item);

            permutations.clear();
            permutations.addAll(ItemInfo.itemOverrides.get(item));

            if (permutations.isEmpty()) {
                item.getSubItems(CreativeTabs.SEARCH, new NonNullList<>(permutations, null));
            }

            //TODO, the implementation of damageSearch is wrong, not sure if this is actually needed ever.
            //if (permutations.isEmpty()) {
            //    damageSearch(item, permutations);
            //}

            permutations.addAll(ItemInfo.itemVariants.get(item));

            timer.reset();
            items.addAll(permutations);
            itemMap.putAll(item, permutations);
        } catch (Throwable t) {
            LogHelper.errorError("Removing item: %s from list.", t, item);
            erroredItems.add(item);
        }
    }

    if (interrupted()) {
        return;
    }
    ItemList.items = items;
    ItemList.itemMap = itemMap;
    synchronized (loadCallbacks) {
        for (ItemsLoadedCallback callback : loadCallbacks) {
            callback.itemsLoaded();
        }
    }

    updateFilter.restart();
}