Package net.minecraftforge.registries
Class ForgeRegistry<V>
java.lang.Object
net.minecraftforge.registries.ForgeRegistry<V>
- All Implemented Interfaces:
Iterable<V>
,IForgeRegistry<V>
,IForgeRegistryInternal<V>
,IForgeRegistryModifiable<V>
@Internal
public class ForgeRegistry<V>
extends Object
implements IForgeRegistryInternal<V>, IForgeRegistryModifiable<V>
Internal - use the public
IForgeRegistry
and ForgeRegistries
APIs to get the data-
Nested Class Summary
Modifier and TypeClassDescriptionprivate static final record
private static final record
private class
static class
Nested classes/interfaces inherited from interface net.minecraftforge.registries.IForgeRegistry
IForgeRegistry.AddCallback<V>, IForgeRegistry.BakeCallback<V>, IForgeRegistry.ClearCallback<V>, IForgeRegistry.CreateCallback<V>, IForgeRegistry.MissingFactory<V>, IForgeRegistry.ValidateCallback<V>
-
Field Summary
Modifier and TypeFieldDescriptionprivate final IForgeRegistry.AddCallback<V>
private final Map<ResourceLocation,
ResourceLocation> private final boolean
private final BitSet
private final IForgeRegistry.BakeCallback<V>
private final it.unimi.dsi.fastutil.ints.IntSet
private final RegistryBuilder<V>
private final IForgeRegistry.ClearCallback<V>
private final com.mojang.serialization.Codec<V>
private final IForgeRegistry.CreateCallback<V>
private final ResourceLocation
private V
private final Map<ResourceLocation,
Holder.Reference<V>> private final Map<V,
Holder.Reference<V>> private final boolean
(package private) boolean
private final boolean
private final ResourceKey<Registry<V>>
private final com.google.common.collect.BiMap<ResourceKey<V>,
V> private static final org.apache.logging.log4j.Logger
private final int
private final int
private final IForgeRegistry.MissingFactory<V>
private final ResourceLocation
private final com.google.common.collect.BiMap<ResourceLocation,
V> private final com.google.common.collect.Multimap<ResourceLocation,
V> private final com.google.common.collect.BiMap<ForgeRegistry.OverrideOwner<V>,
V> static final org.apache.logging.log4j.Marker
private static final org.apache.logging.log4j.Marker
(package private) final Map<ResourceLocation,
?> private final RegistryManager
private final ForgeRegistryTagManager<V>
private final IForgeRegistry.ValidateCallback<V>
-
Constructor Summary
ConstructorDescriptionForgeRegistry
(RegistryManager stage, ResourceLocation name, RegistryBuilder<V> builder) -
Method Summary
Modifier and TypeMethodDescription(package private) int
add
(int id, ResourceLocation key, V value) (package private) int
add
(int id, ResourceLocation key, V value, String owner) void
addAlias
(ResourceLocation src, ResourceLocation dst) Adds an alias that maps from the name specified bysrc
to the name specified bydst
.void
bake()
private Holder.Reference<V>
bindDelegate
(ResourceKey<V> rkey, V value) (package private) void
block
(int id) void
clear()
boolean
boolean
containsValue
(V value) (package private) ForgeRegistry<V>
copy
(RegistryManager stage) (package private) void
dump
(ResourceLocation name) void
freeze()
Used to control the times where people can modify this registry.(package private) RegistryBuilder<V>
@NotNull com.mojang.serialization.Codec<V>
getCodec()
(package private) V
@Nullable ResourceLocation
@NotNull Optional<Holder.Reference<V>>
getDelegate
(ResourceKey<V> rkey) @NotNull Optional<Holder.Reference<V>>
@NotNull Optional<Holder.Reference<V>>
getDelegate
(V value) getDelegateOrThrow
(ResourceKey<V> rkey) getDelegateOrThrow
(V value) @NotNull Set<Map.Entry<ResourceKey<V>,
V>> getHolder
(ResourceKey<V> key) This method exists purely as a stopgap for vanilla compatibility.getHolder
(ResourceLocation location) This method exists purely as a stopgap for vanilla compatibility.This method exists purely as a stopgap for vanilla compatibility.int
getID
(ResourceLocation name) int
private int
getIDRaw
(ResourceLocation name) private int
@Nullable ResourceKey<V>
getKey
(int id) @NotNull Set<ResourceLocation>
getKeys()
getMissingEvent
(ResourceLocation name, it.unimi.dsi.fastutil.objects.Object2IntMap<ResourceLocation> map) (package private) Map<ResourceLocation,
String> getRaw
(ResourceLocation key) @NotNull Optional<ResourceKey<V>>
getResourceKey
(V value) (package private) @NotNull Set<ResourceKey<V>>
<T> T
getSlaveMap
(ResourceLocation name, Class<T> type) Retrieve the slave map of type T from the registry.getValue
(int id) getValue
(ResourceLocation key) @NotNull Collection<V>
(package private) @Nullable NamespacedWrapper<V>
(package private) @NotNull NamespacedWrapper<V>
boolean
isEmpty()
boolean
isLocked()
iterator()
void
loadIds
(it.unimi.dsi.fastutil.objects.Object2IntMap<ResourceLocation> ids, Map<ResourceLocation, String> overrides, it.unimi.dsi.fastutil.objects.Object2IntMap<ResourceLocation> missing, Map<ResourceLocation, IdMappingEvent.IdRemapping> remapped, ForgeRegistry<V> old, ResourceLocation name) (package private) void
onBindTags
(Map<TagKey<V>, HolderSet.Named<V>> tags, Set<TagKey<V>> defaultedTags) (package private) void
processMissingEvent
(ResourceLocation name, ForgeRegistry<V> pool, List<MissingMappingsEvent.Mapping<V>> mappings, it.unimi.dsi.fastutil.objects.Object2IntMap<ResourceLocation> missing, Map<ResourceLocation, IdMappingEvent.IdRemapping> remaps, Collection<ResourceLocation> defaulted, Collection<ResourceLocation> failed, boolean injectNetworkDummies) void
register
(int id, ResourceLocation key, V value) void
The supplied string key will be prefixed with the currently active mod's mod id.void
register
(ResourceLocation key, V value) remove
(ResourceLocation key) (package private) void
void
setSlaveMap
(ResourceLocation name, Object obj) (package private) int
size()
(package private) void
sync
(ResourceLocation name, ForgeRegistry<V> from) @Nullable ITagManager<V>
tags()
void
unfreeze()
(package private) void
validateContent
(ResourceLocation registryName) (package private) void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
REGISTRIES
public static final org.apache.logging.log4j.Marker REGISTRIES -
REGISTRYDUMP
private static final org.apache.logging.log4j.Marker REGISTRYDUMP -
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER -
stage
-
ids
-
names
-
keys
-
aliases
-
slaves
-
defaultKey
-
create
-
add
-
clear
-
validate
-
bake
-
missing
-
availabilityMap
-
blocked
private final it.unimi.dsi.fastutil.ints.IntSet blocked -
overrides
-
delegatesByName
-
delegatesByValue
-
owners
-
tagManager
-
min
private final int min -
max
private final int max -
allowOverrides
private final boolean allowOverrides -
isModifiable
private final boolean isModifiable -
hasWrapper
private final boolean hasWrapper -
defaultValue
-
isFrozen
boolean isFrozen -
name
-
key
-
builder
-
codec
-
-
Constructor Details
-
ForgeRegistry
ForgeRegistry(RegistryManager stage, ResourceLocation name, RegistryBuilder<V> builder)
-
-
Method Details
-
register
Description copied from interface:IForgeRegistry
The supplied string key will be prefixed with the currently active mod's mod id. If the supplied name already has a prefix that is different, it will be used and a warning will be logged.- Specified by:
register
in interfaceIForgeRegistry<V>
-
register
- Specified by:
register
in interfaceIForgeRegistry<V>
-
iterator
-
getRegistryName
- Specified by:
getRegistryName
in interfaceIForgeRegistry<V>
-
getRegistryKey
- Specified by:
getRegistryKey
in interfaceIForgeRegistry<V>
-
getCodec
- Specified by:
getCodec
in interfaceIForgeRegistry<V>
- See Also:
-
containsKey
- Specified by:
containsKey
in interfaceIForgeRegistry<V>
-
containsValue
- Specified by:
containsValue
in interfaceIForgeRegistry<V>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceIForgeRegistry<V>
-
size
int size() -
getValue
- Specified by:
getValue
in interfaceIForgeRegistry<V>
-
getKey
- Specified by:
getKey
in interfaceIForgeRegistry<V>
-
getResourceKey
- Specified by:
getResourceKey
in interfaceIForgeRegistry<V>
-
getWrapper
-
getWrapperOrThrow
-
onBindTags
-
getHolder
Description copied from interface:IForgeRegistry
This method exists purely as a stopgap for vanilla compatibility. For anything tag related, useIForgeRegistry.tags()
.- Specified by:
getHolder
in interfaceIForgeRegistry<V>
- See Also:
-
getHolder
Description copied from interface:IForgeRegistry
This method exists purely as a stopgap for vanilla compatibility. For anything tag related, useIForgeRegistry.tags()
.- Specified by:
getHolder
in interfaceIForgeRegistry<V>
-
getHolder
Description copied from interface:IForgeRegistry
This method exists purely as a stopgap for vanilla compatibility. For anything tag related, useIForgeRegistry.tags()
.- Specified by:
getHolder
in interfaceIForgeRegistry<V>
-
tags
- Specified by:
tags
in interfaceIForgeRegistry<V>
- Returns:
- an instance of
ITagManager
if this registry supports tags and/or has a wrapper registry, null otherwise
-
getKeys
- Specified by:
getKeys
in interfaceIForgeRegistry<V>
-
getResourceKeys
-
getValues
- Specified by:
getValues
in interfaceIForgeRegistry<V>
-
getEntries
- Specified by:
getEntries
in interfaceIForgeRegistry<V>
-
getSlaveMap
Description copied from interface:IForgeRegistry
Retrieve the slave map of type T from the registry. Slave maps are maps which are dependent on registry content in some way.- Specified by:
getSlaveMap
in interfaceIForgeRegistry<V>
- Type Parameters:
T
- Type to return- Parameters:
name
- The name of the slavemaptype
- The type- Returns:
- The slavemap if present
-
setSlaveMap
- Specified by:
setSlaveMap
in interfaceIForgeRegistryInternal<V>
-
getID
-
getID
-
getIDRaw
-
getIDRaw
-
getValue
- Specified by:
getValue
in interfaceIForgeRegistryInternal<V>
-
getKey
-
validateKey
void validateKey() -
getDefaultKey
- Specified by:
getDefaultKey
in interfaceIForgeRegistry<V>
-
copy
-
register
- Specified by:
register
in interfaceIForgeRegistryInternal<V>
-
add
-
add
-
getRaw
-
addAlias
Adds an alias that maps from the name specified bysrc
to the name specified bydst
.Any registry lookups that target the first name will resolve as the second name, if the first name is not present.
- Parameters:
src
- The source registry name to alias from.dst
- The target registry name to alias to. TODO: Add as public API in IForgeRegistry and DeferredRegister.
-
getDelegate
- Specified by:
getDelegate
in interfaceIForgeRegistry<V>
-
getDelegateOrThrow
- Specified by:
getDelegateOrThrow
in interfaceIForgeRegistry<V>
-
getDelegate
- Specified by:
getDelegate
in interfaceIForgeRegistry<V>
-
getDelegateOrThrow
- Specified by:
getDelegateOrThrow
in interfaceIForgeRegistry<V>
-
getDelegate
- Specified by:
getDelegate
in interfaceIForgeRegistry<V>
-
getDelegateOrThrow
- Specified by:
getDelegateOrThrow
in interfaceIForgeRegistry<V>
-
bindDelegate
-
resetDelegates
void resetDelegates() -
getDefault
V getDefault() -
validateContent
-
bake
public void bake() -
sync
-
clear
public void clear()- Specified by:
clear
in interfaceIForgeRegistryModifiable<V>
-
remove
- Specified by:
remove
in interfaceIForgeRegistryModifiable<V>
-
block
void block(int id) -
isLocked
public boolean isLocked()- Specified by:
isLocked
in interfaceIForgeRegistryModifiable<V>
-
freeze
public void freeze()Used to control the times where people can modify this registry. Users should only ever register things in the Register<?> events! -
unfreeze
public void unfreeze() -
dump
-
loadIds
public void loadIds(it.unimi.dsi.fastutil.objects.Object2IntMap<ResourceLocation> ids, Map<ResourceLocation, String> overrides, it.unimi.dsi.fastutil.objects.Object2IntMap<ResourceLocation> missing, Map<ResourceLocation, IdMappingEvent.IdRemapping> remapped, ForgeRegistry<V> old, ResourceLocation name) -
makeSnapshot
-
getOverrideOwners
Map<ResourceLocation,String> getOverrideOwners() -
getMissingEvent
public MissingMappingsEvent getMissingEvent(ResourceLocation name, it.unimi.dsi.fastutil.objects.Object2IntMap<ResourceLocation> map) -
processMissingEvent
void processMissingEvent(ResourceLocation name, ForgeRegistry<V> pool, List<MissingMappingsEvent.Mapping<V>> mappings, it.unimi.dsi.fastutil.objects.Object2IntMap<ResourceLocation> missing, Map<ResourceLocation, IdMappingEvent.IdRemapping> remaps, Collection<ResourceLocation> defaulted, Collection<ResourceLocation> failed, boolean injectNetworkDummies) -
getBuilder
RegistryBuilder<V> getBuilder()
-