Package net.minecraftforge.common
Interface IExtensibleEnum
-
- All Known Implementing Classes:
BannerPattern,BiomeAmbience.GrassColorModifier,EnchantmentType,EntityClassification,EntitySpawnPlacementRegistry.PlacementType,JigsawPattern.PlacementBehaviour,Raid.WaveMember,Rarity
public interface IExtensibleEnumTo be implemented on vanilla enums that should be enhanced with ASM to be extensible. If this is implemented on a class, the class must define a static method called "create" which takes a String (enum name), and the rest of the parameters matching a constructor.For example, an enum with the constructor
MyEnum(Object foo)would require the method:public static MyEnum create(String name, Object foo) { throw new IllegalStateException("Enum not extended"); }The method contents will be replaced with ASM at runtime. Multiplecreatemethods can be defined as long as each matches a constructor.
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Deprecated Methods Modifier and Type Method Description static <E extends java.lang.Enum<E> & IStringSerializable>
com.mojang.serialization.Codec<E>createCodecForExtensibleEnum(java.util.function.Supplier<E[]> valuesSupplier, java.util.function.Function<? super java.lang.String,? extends E> enumValueFromNameFunction)Use this instead ofIStringSerializable#createEnumCodec(Supplier, Function)for extensible enums because this not cache the enum values on constructiondefault voidinit()Deprecated.
-
-
-
Method Detail
-
init
@Deprecated default void init()
Deprecated.Called by generated factory code to do any post-constructor setup required by the enum. Should not be called manually.
-
createCodecForExtensibleEnum
static <E extends java.lang.Enum<E> & IStringSerializable> com.mojang.serialization.Codec<E> createCodecForExtensibleEnum(java.util.function.Supplier<E[]> valuesSupplier, java.util.function.Function<? super java.lang.String,? extends E> enumValueFromNameFunction)
Use this instead ofIStringSerializable#createEnumCodec(Supplier, Function)for extensible enums because this not cache the enum values on construction
-
-