T
- The base registry type, must be a concrete base class, do not use subclasses or wild cards.public class DeferredRegister<T extends IForgeRegistryEntry<T>>
extends java.lang.Object
private static final DeferredRegister- 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()); }
Modifier and Type | Field and Description |
---|---|
private java.util.Map<RegistryObject<T>,java.util.function.Supplier<? extends T>> |
entries |
private java.util.Set<RegistryObject<T>> |
entriesView |
private java.lang.String |
modid |
private java.util.function.Supplier<RegistryBuilder<T>> |
registryFactory |
private boolean |
seenRegisterEvent |
private java.lang.Class<T> |
superType |
private IForgeRegistry<T> |
type |
Modifier | Constructor and Description |
---|---|
private |
DeferredRegister(java.lang.Class<T> base,
java.lang.String modid) |
|
DeferredRegister(IForgeRegistry<T> reg,
java.lang.String modid)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
private void |
addEntries(RegistryEvent.Register<?> event) |
private void |
captureRegistry(RegistryEvent.NewRegistry event) |
static <B extends IForgeRegistryEntry<B>> |
create(java.lang.Class<B> base,
java.lang.String modid)
Use for custom registries that are made during the NewRegistry event.
|
static <B extends IForgeRegistryEntry<B>> |
create(IForgeRegistry<B> reg,
java.lang.String modid)
Use for vanilla/forge registries.
|
private void |
createRegistry(RegistryEvent.NewRegistry event) |
java.util.Collection<RegistryObject<T>> |
getEntries() |
java.util.function.Supplier<IForgeRegistry<T>> |
makeRegistry(java.lang.String name,
java.util.function.Supplier<RegistryBuilder<T>> sup)
For custom registries only, fills the
registryFactory to be called later see register(IEventBus)
Calls RegistryBuilder.setName(net.minecraft.util.ResourceLocation) and RegistryBuilder.setType(java.lang.Class<T>) automatically. |
void |
register(net.minecraftforge.eventbus.api.IEventBus bus)
Adds our event handler to the specified event bus, this MUST be called in order for this class to function.
|
<I extends T> |
register(java.lang.String name,
java.util.function.Supplier<? extends I> sup)
Adds a new supplier to the list of entries to be registered, and returns a RegistryObject that will be populated with the created entry automatically.
|
private final java.lang.Class<T extends IForgeRegistryEntry<T>> superType
private final java.lang.String modid
private final java.util.Map<RegistryObject<T extends IForgeRegistryEntry<T>>,java.util.function.Supplier<? extends T extends IForgeRegistryEntry<T>>> entries
private final java.util.Set<RegistryObject<T extends IForgeRegistryEntry<T>>> entriesView
private IForgeRegistry<T extends IForgeRegistryEntry<T>> type
private java.util.function.Supplier<RegistryBuilder<T extends IForgeRegistryEntry<T>>> registryFactory
private boolean seenRegisterEvent
private DeferredRegister(java.lang.Class<T> base, java.lang.String modid)
@Deprecated public DeferredRegister(IForgeRegistry<T> reg, java.lang.String modid)
public static <B extends IForgeRegistryEntry<B>> DeferredRegister<B> create(IForgeRegistry<B> reg, java.lang.String modid)
public static <B extends IForgeRegistryEntry<B>> DeferredRegister<B> create(java.lang.Class<B> base, java.lang.String modid)
public <I extends T> RegistryObject<I> register(java.lang.String name, java.util.function.Supplier<? extends I> sup)
name
- The new entry's name, it will automatically have the modid prefixed.sup
- A factory for the new entry, it should return a new instance every time it is called.public java.util.function.Supplier<IForgeRegistry<T>> makeRegistry(java.lang.String name, java.util.function.Supplier<RegistryBuilder<T>> sup)
registryFactory
to be called later see register(IEventBus)
Calls RegistryBuilder.setName(net.minecraft.util.ResourceLocation)
and RegistryBuilder.setType(java.lang.Class<T>)
automatically.name
- Path of the registry's ResourceLocation
sup
- Supplier of the RegistryBuilder that is called to fill type
during the NewRegistry eventIForgeRegistry
created by the builder.public void register(net.minecraftforge.eventbus.api.IEventBus bus)
bus
- The Mod Specific event bus.public java.util.Collection<RegistryObject<T>> getEntries()
private void addEntries(RegistryEvent.Register<?> event)
private void createRegistry(RegistryEvent.NewRegistry event)
private void captureRegistry(RegistryEvent.NewRegistry event)