Package net.minecraftforge.registries
Class ForgeRegistryEntry<V extends IForgeRegistryEntry<V>>
- java.lang.Object
-
- net.minecraftforge.registries.ForgeRegistryEntry<V>
-
- All Implemented Interfaces:
IForgeRegistryEntry<V>
- Direct Known Subclasses:
AbstractBlock
,Activity
,Attribute
,BlockPlacerType
,BlockStateProviderType
,ChunkStatus
,ContainerType
,CookingRecipeSerializer
,CustomTagTypesTest.Custom
,DataSerializerEntry
,DeferredRegistryTest.Custom
,Effect
,Enchantment
,EntityType
,Feature
,Fluid
,FoliagePlacerType
,ForgeRegistryEntry.UncheckedRegistryEntry
,ForgeWorldType
,Item
,MemoryModuleType
,PaintingType
,ParticleType
,Placement
,PointOfInterestType
,Potion
,Schedule
,SensorType
,ShapedRecipe.Serializer
,ShapelessRecipe.Serializer
,SingleItemRecipe.Serializer
,SmithingRecipe.Serializer
,SoundEvent
,SpecialRecipeSerializer
,StatType
,Structure
,SurfaceBuilder
,TileEntityType
,TreeDecoratorType
,VillagerProfession
,WorldCarver
public abstract class ForgeRegistryEntry<V extends IForgeRegistryEntry<V>> extends java.lang.Object implements IForgeRegistryEntry<V>
Default implementation of IForgeRegistryEntry, this is necessary to reduce redundant code. This also enables the registrie's ability to manage delegates. Which are automatically updated if another entry overrides existing ones in the registry.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ForgeRegistryEntry.UncheckedRegistryEntry<V extends IForgeRegistryEntry<V>>
This class exists for registry entries which are dynamic (e.g.
-
Field Summary
Fields Modifier and Type Field Description IRegistryDelegate<V>
delegate
private ResourceLocation
registryName
private com.google.common.reflect.TypeToken<V>
token
-
Constructor Summary
Constructors Constructor Description ForgeRegistryEntry()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) ResourceLocation
checkRegistryName(java.lang.String name)
This will assert that the registry name is valid and warn about potential registry overrides It is important as it detects cases where modders unintentionally register objects with the "minecraft" namespace, leading to dangerous errors later.ResourceLocation
getRegistryName()
A unique identifier for this entry, if this entry is registered already it will return it's official registry name.java.lang.Class<V>
getRegistryType()
Determines the type for this entry, used to look up the correct registry in the global registries list as there can only be one registry per concrete class.V
setRegistryName(java.lang.String name)
V
setRegistryName(java.lang.String modID, java.lang.String name)
V
setRegistryName(ResourceLocation name)
Sets a unique name for this Item.
-
-
-
Field Detail
-
token
private final com.google.common.reflect.TypeToken<V extends IForgeRegistryEntry<V>> token
-
delegate
public final IRegistryDelegate<V extends IForgeRegistryEntry<V>> delegate
-
registryName
private ResourceLocation registryName
-
-
Method Detail
-
setRegistryName
public final V setRegistryName(java.lang.String name)
-
setRegistryName
public final V setRegistryName(ResourceLocation name)
Description copied from interface:IForgeRegistryEntry
Sets a unique name for this Item. This should be used for uniquely identify the instance of the Item. This is the valid replacement for the atrocious 'getUnlocalizedName().substring(6)' stuff that everyone does. Unlocalized names have NOTHING to do with unique identifiers. As demonstrated by vanilla blocks and items. The supplied name will be prefixed with the currently active mod's modId. If the supplied name already has a prefix that is different, it will be used and a warning will be logged. If a name already exists, or this Item is already registered in a registry, then an IllegalStateException is thrown. Returns 'this' to allow for chaining.- Specified by:
setRegistryName
in interfaceIForgeRegistryEntry<V extends IForgeRegistryEntry<V>>
- Parameters:
name
- Unique registry name- Returns:
- This instance
-
setRegistryName
public final V setRegistryName(java.lang.String modID, java.lang.String name)
-
getRegistryName
@Nullable public final ResourceLocation getRegistryName()
Description copied from interface:IForgeRegistryEntry
A unique identifier for this entry, if this entry is registered already it will return it's official registry name. Otherwise it will return the name set in setRegistryName(). If neither are valid null is returned.- Specified by:
getRegistryName
in interfaceIForgeRegistryEntry<V extends IForgeRegistryEntry<V>>
- Returns:
- Unique identifier or null.
-
getRegistryType
public final java.lang.Class<V> getRegistryType()
Description copied from interface:IForgeRegistryEntry
Determines the type for this entry, used to look up the correct registry in the global registries list as there can only be one registry per concrete class.- Specified by:
getRegistryType
in interfaceIForgeRegistryEntry<V extends IForgeRegistryEntry<V>>
- Returns:
- Root registry type.
-
checkRegistryName
ResourceLocation checkRegistryName(java.lang.String name)
This will assert that the registry name is valid and warn about potential registry overrides It is important as it detects cases where modders unintentionally register objects with the "minecraft" namespace, leading to dangerous errors later.- Parameters:
name
- The registry name- Returns:
- A verified "correct" registry name
-
-