Package net.minecraftforge.registries
Class RegistryBuilder<T extends IForgeRegistryEntry<T>>
java.lang.Object
net.minecraftforge.registries.RegistryBuilder<T>
-
Field Summary
Modifier and TypeFieldDescriptionprivate List<IForgeRegistry.AddCallback<T>>
private boolean
private boolean
private List<IForgeRegistry.BakeCallback<T>>
private List<IForgeRegistry.ClearCallback<T>>
private List<IForgeRegistry.CreateCallback<T>>
private Supplier<RegistryAccess.RegistryData<T>>
private IForgeRegistry.DummyFactory<T>
private boolean
private Set<ResourceLocation>
private static final int
private int
private int
private IForgeRegistry.MissingFactory<T>
private ResourceLocation
private ResourceLocation
private boolean
private boolean
private List<IForgeRegistry.ValidateCallback<T>>
private Function<T,
Holder.Reference<T>> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadd
(IForgeRegistry.AddCallback<T> add) add
(IForgeRegistry.BakeCallback<T> bake) add
(IForgeRegistry.ClearCallback<T> clear) add
(IForgeRegistry.CreateCallback<T> create) add
(IForgeRegistry.ValidateCallback<T> validate) addCallback
(Object inst) (package private) IForgeRegistry<T>
create()
Modders: UseNewRegistryEvent.create(RegistryBuilder)
insteaddataPackRegistry
(com.mojang.serialization.Codec<T> codec) Register this registry as an unsynced datapack registry, which will cause data to be loaded from a datapack folder based on the registry's name.dataPackRegistry
(com.mojang.serialization.Codec<T> codec, com.mojang.serialization.Codec<T> networkCodec) Register this registry as a datapack registry, which will cause data to be loaded from a datapack folder based on the registry's name.Prevents the registry from being synced to clients.dummy
(IForgeRegistry.DummyFactory<T> factory) getAdd()
boolean
boolean
getBake()
getClear()
(package private) RegistryAccess.RegistryData<T>
Retrieves datapack registry information, if any.(package private) boolean
int
getMaxId()
int
getMinId()
boolean
boolean
getSync()
getType()
(package private) Function<T,
Holder.Reference<T>> hasTags()
Enables tags for this registry if not already.(package private) RegistryBuilder<T>
legacyName
(String name) legacyName
(ResourceLocation name) missing
(IForgeRegistry.MissingFactory<T> missing) onAdd
(IForgeRegistry.AddCallback<T> add) onBake
(IForgeRegistry.BakeCallback<T> bake) onClear
(IForgeRegistry.ClearCallback<T> clear) onCreate
(IForgeRegistry.CreateCallback<T> create) onValidate
(IForgeRegistry.ValidateCallback<T> validate) set
(IForgeRegistry.DummyFactory<T> factory) set
(IForgeRegistry.MissingFactory<T> missing) setIDRange
(int min, int max) setMaxID
(int max) setName
(ResourceLocation name) (package private) RegistryBuilder<T>
vanillaHolder
(Function<T, Holder.Reference<T>> func)
-
Field Details
-
MAX_ID
private static final int MAX_ID- See Also:
-
registryName
-
registryType
-
optionalDefaultKey
-
minId
private int minId -
maxId
private int maxId -
addCallback
-
clearCallback
-
createCallback
-
validateCallback
-
bakeCallback
-
vanillaHolder
private Function<T extends IForgeRegistryEntry<T>,Holder.Reference<T extends IForgeRegistryEntry<T>>> vanillaHolder -
saveToDisc
private boolean saveToDisc -
sync
private boolean sync -
allowOverrides
private boolean allowOverrides -
allowModifications
private boolean allowModifications -
hasWrapper
private boolean hasWrapper -
dataPackRegistryData
private Supplier<RegistryAccess.RegistryData<T extends IForgeRegistryEntry<T>>> dataPackRegistryData -
dummyFactory
-
missingFactory
-
legacyNames
-
-
Constructor Details
-
RegistryBuilder
public RegistryBuilder()
-
-
Method Details
-
setName
-
setType
-
setIDRange
-
setMaxID
-
setDefaultKey
-
addCallback
-
add
-
onAdd
-
add
-
onClear
-
add
-
onCreate
-
add
-
onValidate
-
add
-
onBake
-
set
-
dummy
-
set
-
missing
-
disableSaving
-
disableSync
Prevents the registry from being synced to clients. Does *not* affect datapack registries, datapack registries are unsynced by default unless a non-null network codec is registered viadataPackRegistry(Codec, Codec)
- Returns:
- this
-
disableOverrides
-
allowModification
-
hasWrapper
RegistryBuilder<T> hasWrapper() -
legacyName
-
legacyName
-
vanillaHolder
-
hasTags
Enables tags for this registry if not already. All forge registries with wrappers inherently support tags.- Returns:
- this builder
- See Also:
-
dataPackRegistry
Register this registry as an unsynced datapack registry, which will cause data to be loaded from a datapack folder based on the registry's name. The mod that registers this registry does not need to exist on the client to connect to servers with the mod/registry.
Data JSONs will be loaded from
data/<datapack_namespace>/modid/registryname/
, where modid is the mod that registered this registry.- Parameters:
codec
- the codec to be used for loading data from datapacks on servers- Returns:
- this builder
- See Also:
-
dataPackRegistry
public RegistryBuilder<T> dataPackRegistry(com.mojang.serialization.Codec<T> codec, @Nullable com.mojang.serialization.Codec<T> networkCodec) Register this registry as a datapack registry, which will cause data to be loaded from a datapack folder based on the registry's name.
Data JSONs will be loaded from
data/<datapack_namespace>/modid/registryname/
, where modid is the mod that registered this registry.- Parameters:
codec
- the codec to be used for loading data from datapacks on serversnetworkCodec
- the codec to be used for syncing loaded data to clients.
If networkCodec is null, data will not be synced, and clients without the mod that registered this registry can connect to servers with the mod.
If networkCodec is not null, then data will be synced (accessible viaClientPacketListener.registryAccess()
), and the mod must be present on a client to connect to servers with the mod.- Returns:
- this builder
- See Also:
-
getDataPackRegistryData
Retrieves datapack registry information, if any.- Returns:
- RegistryData containing the registry's key and codec(s). If returned data is null, this has not been marked as a datapack registry.
- Throws:
IllegalStateException
- if this has been marked as a datapack registry, but registry name has not been set.
-
create
IForgeRegistry<T> create()Modders: UseNewRegistryEvent.create(RegistryBuilder)
instead -
getAdd
-
getClear
-
getCreate
-
getValidate
-
getBake
-
getType
-
getDefault
-
getMinId
public int getMinId() -
getMaxId
public int getMaxId() -
getAllowOverrides
public boolean getAllowOverrides() -
getAllowModifications
public boolean getAllowModifications() -
getDummyFactory
-
getMissingFactory
-
getSaveToDisc
public boolean getSaveToDisc() -
getSync
public boolean getSync() -
getLegacyNames
-
getVanillaHolder
Function<T,Holder.Reference<T>> getVanillaHolder() -
getHasWrapper
boolean getHasWrapper()
-