/* * Minecraft Forge * Copyright (c) 2016-2019. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version 2.1 * of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ package net.minecraftforge.registries; import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.RegistryObject; import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Objects; import java.util.function.Supplier; /** * Utility class to help with managing registry entries. * Maintains a list of all suppliers for entries and registers them during the proper Register event. * Suppliers should return NEW instances every time. * *Example Usage: *
* private static final DeferredRegister* * @param- ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, MODID); * private static final DeferredRegister
BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, MODID); * * public static final RegistryObject ROCK_BLOCK = BLOCKS.register("rock", () -> new Block(Block.Properties.create(Material.ROCK))); * public static final RegistryObject - ROCK_ITEM = ITEMS.register("rock", () -> new BlockItem(ROCK_BLOCK.get(), new Item.Properties().group(ItemGroup.MISC))); * * public ExampleMod() { * ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus()); * BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus()); * } *