Skip to content
This repository was archived by the owner on Nov 29, 2025. It is now read-only.
melontini edited this page Jan 6, 2024 · 3 revisions

This page covers the Enums module of Dark Matter.

ExtendableEnum

ExtendableEnum is an interface implemented on enums which can be extended using this module.

As of 3.0.0 Dark Matter patches:

  • RecipeBookCategory
  • Rarity
  • Formatting
  • BoatEntity.Type
  • AbstractMinecartEntity.Type
  • RecipeBookGroup
  • EnchantmentTarget
  • Raid.Member

Tip

It's better to use Recipe Book to extend RecipeBookCategory and RecipeBookGroup.

EnumWrapper provides proper constructor types and checks for enums. For example, instead of calling:

EnchantmentTarget.values()[0].dark_matter$extend("ENUM_NAME", new Object[]{((Predicate<Item>) item -> isAllowed(item))});

You can call:

EnumWrapper.EnchantmentTarget.extend("ENUM_NAME", item -> isAllowed(item))

Note

This terrible hack may be fixed once either this PR is merged, or this issue is resolved.

EnumUtils

EnumUtils contains experimental and "should probably be in impl" utils.


extendByReflecting()

This is an experimental method, which attempts to extend enums using reflection, handles and Unsafe. Stability of this method is questionable.


clearEnumCache() and callEnumInvoker()

Those methods are not useful, unless you're trying to transform enums yourself.

Warning

It is much safer to extend enums using ASM or Mixins. These methods do not require access to private java.lang fields.

Clone this wiki locally