Class ModRegistry

java.lang.Object
me.tnoctua.nmodutils.util.ModRegistry

public class ModRegistry extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final ArrayList<net.minecraft.block.entity.BlockEntityType<?>>
     
    final ArrayList<net.minecraft.registry.tag.TagKey<net.minecraft.block.Block>>
     
    final ArrayList<net.minecraft.block.Block>
     
    final ArrayList<net.minecraft.component.ComponentType<?>>
     
    final ArrayList<net.minecraft.registry.RegistryKey<net.minecraft.entity.damage.DamageType>>
     
    final ArrayList<net.minecraft.registry.tag.TagKey<net.minecraft.entity.EntityType<?>>>
     
    final HashSet<net.minecraft.item.ItemGroup>
     
    final ArrayList<net.minecraft.registry.tag.TagKey<net.minecraft.item.Item>>
     
    final ArrayList<net.minecraft.item.Item>
     
    final ArrayList<net.minecraft.sound.SoundEvent>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ModRegistry(String modIdentifier)
    Implements various registry helper methods to add content to the game.
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.registry.tag.TagKey<net.minecraft.block.Block>
    Registers a block tag to the game.
    net.minecraft.registry.RegistryKey<net.minecraft.entity.damage.DamageType>
    Registers a damage type to the game.
    net.minecraft.registry.tag.TagKey<net.minecraft.entity.EntityType<?>>
    Registers an entity tag to the game.
    net.minecraft.registry.tag.TagKey<net.minecraft.item.Item>
    Registers an item tag to the game.
    net.minecraft.block.Block
    register(boolean enabled, boolean item, String key, Function<net.minecraft.block.AbstractBlock.Settings,? extends net.minecraft.block.Block> factory, net.minecraft.block.AbstractBlock.Settings settings)
    Registers a block to the game.
    net.minecraft.block.Block
    register(boolean enabled, String key, Function<net.minecraft.block.AbstractBlock.Settings,? extends net.minecraft.block.Block> factory, net.minecraft.block.AbstractBlock.Settings settings)
    Registers a block to the game.
    net.minecraft.item.Item
    register(boolean enabled, String key, Function<net.minecraft.item.Item.Settings,net.minecraft.item.Item> factory, net.minecraft.item.Item.Settings settings)
    Registers an item to the game.
    net.minecraft.registry.RegistryKey<net.minecraft.item.ItemGroup>
    register(boolean enabled, String key, net.minecraft.item.ItemGroup itemGroup)
    Registers an item group to the game.
    net.minecraft.block.Block
    register(String key, Function<net.minecraft.block.AbstractBlock.Settings,? extends net.minecraft.block.Block> factory, net.minecraft.block.AbstractBlock.Settings settings)
    Registers a block to the game.
    net.minecraft.item.Item
    register(String key, Function<net.minecraft.item.Item.Settings,net.minecraft.item.Item> factory, net.minecraft.item.Item.Settings settings)
    Registers an item to the game.
    <T> net.minecraft.component.ComponentType<T>
    register(String key, UnaryOperator<net.minecraft.component.ComponentType.Builder<T>> builder)
    Registers a component type to the game.
    <T extends net.minecraft.block.entity.BlockEntity>
    net.minecraft.block.entity.BlockEntityType<T>
    register(String key, net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder.Factory<? extends T> factory, net.minecraft.block.Block... blocks)
    Registers a block entity to the game.
    net.minecraft.registry.RegistryKey<net.minecraft.item.ItemGroup>
    register(String key, net.minecraft.item.ItemGroup itemGroup)
    Registers an item group to the game.
    net.minecraft.sound.SoundEvent
    soundEvent(boolean enabled, String key)
    Registers a sound event to the game.
    net.minecraft.sound.SoundEvent
    Registers a sound event to the game.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • BLOCKS

      public final ArrayList<net.minecraft.block.Block> BLOCKS
    • ITEM_GROUPS

      public final HashSet<net.minecraft.item.ItemGroup> ITEM_GROUPS
    • ITEMS

      public final ArrayList<net.minecraft.item.Item> ITEMS
    • SOUNDS

      public final ArrayList<net.minecraft.sound.SoundEvent> SOUNDS
    • BLOCK_TAGS

      public final ArrayList<net.minecraft.registry.tag.TagKey<net.minecraft.block.Block>> BLOCK_TAGS
    • ITEM_TAGS

      public final ArrayList<net.minecraft.registry.tag.TagKey<net.minecraft.item.Item>> ITEM_TAGS
    • ENTITY_TAGS

      public final ArrayList<net.minecraft.registry.tag.TagKey<net.minecraft.entity.EntityType<?>>> ENTITY_TAGS
    • DAMAGE_TYPES

      public final ArrayList<net.minecraft.registry.RegistryKey<net.minecraft.entity.damage.DamageType>> DAMAGE_TYPES
    • BLOCK_ENTITIES

      public final ArrayList<net.minecraft.block.entity.BlockEntityType<?>> BLOCK_ENTITIES
    • COMPONENTS

      public final ArrayList<net.minecraft.component.ComponentType<?>> COMPONENTS
  • Constructor Details

    • ModRegistry

      public ModRegistry(String modIdentifier)
      Implements various registry helper methods to add content to the game.
      Parameters:
      modIdentifier - identifier to use for the registry (which should always be your mod's ID)
  • Method Details

    • register

      public <T extends net.minecraft.block.entity.BlockEntity> net.minecraft.block.entity.BlockEntityType<T> register(String key, net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder.Factory<? extends T> factory, net.minecraft.block.Block... blocks)
      Registers a block entity to the game.
      Type Parameters:
      T - block entity subclass
      Parameters:
      key - block entity ID/key
      factory - block entity factory
      blocks - blocks applicable to the block entity
      Returns:
      block entity type
    • register

      public net.minecraft.block.Block register(String key, Function<net.minecraft.block.AbstractBlock.Settings,? extends net.minecraft.block.Block> factory, net.minecraft.block.AbstractBlock.Settings settings)
      Registers a block to the game.
      Parameters:
      key - block ID/key
      Returns:
      the registered block
    • register

      public net.minecraft.block.Block register(boolean enabled, String key, Function<net.minecraft.block.AbstractBlock.Settings,? extends net.minecraft.block.Block> factory, net.minecraft.block.AbstractBlock.Settings settings)
      Registers a block to the game.
      Parameters:
      enabled - whether the block should be registered
      key - block ID/key
      Returns:
      the registered block
    • register

      public net.minecraft.block.Block register(boolean enabled, boolean item, String key, Function<net.minecraft.block.AbstractBlock.Settings,? extends net.minecraft.block.Block> factory, net.minecraft.block.AbstractBlock.Settings settings)
      Registers a block to the game.
      Parameters:
      enabled - whether the block should be registered
      item - whether the block should have an item registered
      key - block ID/key
      Returns:
      the registered block
    • register

      public net.minecraft.registry.RegistryKey<net.minecraft.item.ItemGroup> register(String key, net.minecraft.item.ItemGroup itemGroup)
      Registers an item group to the game.
      Parameters:
      key - key/ID of the item group
      itemGroup - item group instance
      Returns:
      the registered item group's registry key
    • register

      public net.minecraft.registry.RegistryKey<net.minecraft.item.ItemGroup> register(boolean enabled, String key, net.minecraft.item.ItemGroup itemGroup)
      Registers an item group to the game.
      Parameters:
      enabled - condition for registering the item group
      key - key/ID of the item group
      itemGroup - item group instance
      Returns:
      the registered item group's registry key
    • register

      public net.minecraft.item.Item register(String key, Function<net.minecraft.item.Item.Settings,net.minecraft.item.Item> factory, net.minecraft.item.Item.Settings settings)
      Registers an item to the game.
      Parameters:
      key - item ID/key
      Returns:
      the registered item
    • register

      public net.minecraft.item.Item register(boolean enabled, String key, Function<net.minecraft.item.Item.Settings,net.minecraft.item.Item> factory, net.minecraft.item.Item.Settings settings)
      Registers an item to the game.
      Parameters:
      enabled - whether the item should be registered
      key - item ID/key
      Returns:
      the registered item
    • soundEvent

      public net.minecraft.sound.SoundEvent soundEvent(String key)
      Registers a sound event to the game.
      Parameters:
      key - sound event ID/key
      Returns:
      the registered sound event
    • soundEvent

      public net.minecraft.sound.SoundEvent soundEvent(boolean enabled, String key)
      Registers a sound event to the game.
      Parameters:
      enabled - whether the sound event should be registered
      key - sound event ID/key
      Returns:
      the registered sound event
    • blockTag

      public net.minecraft.registry.tag.TagKey<net.minecraft.block.Block> blockTag(String key)
      Registers a block tag to the game.
      Parameters:
      key - block tag ID/key
      Returns:
      the block tag key
    • itemTag

      public net.minecraft.registry.tag.TagKey<net.minecraft.item.Item> itemTag(String key)
      Registers an item tag to the game.
      Parameters:
      key - item tag ID/key
      Returns:
      the item tag key
    • entityTag

      public net.minecraft.registry.tag.TagKey<net.minecraft.entity.EntityType<?>> entityTag(String key)
      Registers an entity tag to the game.
      Parameters:
      key - entity tag ID/key
      Returns:
      the entity tag key
    • damageType

      public net.minecraft.registry.RegistryKey<net.minecraft.entity.damage.DamageType> damageType(String key)
      Registers a damage type to the game.

      This method does not create the resource required in /data/modid/damage_type

      Parameters:
      key - damage type ID/key
      Returns:
      the damage type key
    • register

      public <T> net.minecraft.component.ComponentType<T> register(String key, UnaryOperator<net.minecraft.component.ComponentType.Builder<T>> builder)
      Registers a component type to the game.
      Type Parameters:
      T - type of component
      Parameters:
      key - component type ID/key
      builder - component builder
      Returns:
      component type instance