Class SimpleRegistry<T>

  • All Implemented Interfaces:
    com.mojang.serialization.Codec<T>, com.mojang.serialization.Decoder<T>, com.mojang.serialization.Encoder<T>, com.mojang.serialization.Keyable, java.lang.Iterable<T>, IObjectIntIterable<T>
    Direct Known Subclasses:
    DefaultedRegistry, NamespacedWrapper

    public class SimpleRegistry<T>
    extends MutableRegistry<T>
    • Field Detail

      • LOGGER

        protected static final org.apache.logging.log4j.Logger LOGGER
      • byId

        private final it.unimi.dsi.fastutil.objects.ObjectList<T> byId
      • toId

        private final it.unimi.dsi.fastutil.objects.Object2IntMap<T> toId
      • storage

        private final com.google.common.collect.BiMap<ResourceLocation,​T> storage
      • keyStorage

        private final com.google.common.collect.BiMap<RegistryKey<T>,​T> keyStorage
      • lifecycles

        private final java.util.Map<T,​com.mojang.serialization.Lifecycle> lifecycles
      • elementsLifecycle

        private com.mojang.serialization.Lifecycle elementsLifecycle
      • randomCache

        protected java.lang.Object[] randomCache
      • nextId

        private int nextId
    • Constructor Detail

      • SimpleRegistry

        public SimpleRegistry​(RegistryKey<? extends Registry<T>> p_i232509_1_,
                              com.mojang.serialization.Lifecycle p_i232509_2_)
    • Method Detail

      • withNameAndId

        public static <T> com.mojang.serialization.MapCodec<SimpleRegistry.Entry<T>> withNameAndId​(RegistryKey<? extends Registry<T>> p_243541_0_,
                                                                                                   com.mojang.serialization.MapCodec<T> p_243541_1_)
      • registerMapping

        public <V extends T> V registerMapping​(int p_218382_1_,
                                               RegistryKey<T> p_218382_2_,
                                               V p_218382_3_,
                                               com.mojang.serialization.Lifecycle p_218382_4_)
        Specified by:
        registerMapping in class MutableRegistry<T>
      • registerMapping

        private <V extends T> V registerMapping​(int p_243537_1_,
                                                RegistryKey<T> p_243537_2_,
                                                V p_243537_3_,
                                                com.mojang.serialization.Lifecycle p_243537_4_,
                                                boolean p_243537_5_)
      • register

        public <V extends T> V register​(RegistryKey<T> p_218381_1_,
                                        V p_218381_2_,
                                        com.mojang.serialization.Lifecycle p_218381_3_)
        Specified by:
        register in class MutableRegistry<T>
      • registerOrOverride

        public <V extends T> V registerOrOverride​(java.util.OptionalInt p_241874_1_,
                                                  RegistryKey<T> p_241874_2_,
                                                  V p_241874_3_,
                                                  com.mojang.serialization.Lifecycle p_241874_4_)
        Specified by:
        registerOrOverride in class MutableRegistry<T>
      • byId

        @Nullable
        public T byId​(int p_148745_1_)
      • lifecycle

        public com.mojang.serialization.Lifecycle lifecycle​(T p_241876_1_)
        Specified by:
        lifecycle in class Registry<T>
      • elementsLifecycle

        public com.mojang.serialization.Lifecycle elementsLifecycle()
        Specified by:
        elementsLifecycle in class Registry<T>
      • iterator

        public java.util.Iterator<T> iterator()
      • getRandom

        @Nullable
        public T getRandom​(java.util.Random p_186801_1_)
      • networkCodec

        public static <T> com.mojang.serialization.Codec<SimpleRegistry<T>> networkCodec​(RegistryKey<? extends Registry<T>> p_243539_0_,
                                                                                         com.mojang.serialization.Lifecycle p_243539_1_,
                                                                                         com.mojang.serialization.Codec<T> p_243539_2_)
      • dataPackCodec

        public static <T> com.mojang.serialization.Codec<SimpleRegistry<T>> dataPackCodec​(RegistryKey<? extends Registry<T>> p_241744_0_,
                                                                                          com.mojang.serialization.Lifecycle p_241744_1_,
                                                                                          com.mojang.serialization.Codec<T> p_241744_2_)
      • directCodec

        public static <T> com.mojang.serialization.Codec<SimpleRegistry<T>> directCodec​(RegistryKey<? extends Registry<T>> p_241745_0_,
                                                                                        com.mojang.serialization.Lifecycle p_241745_1_,
                                                                                        com.mojang.serialization.Codec<T> p_241745_2_)