convertToMcSafeType

When Registering an Object using the Register Class most of the time you receive a Modloader dependent Object (1). In some creation process's such as making a BlockEntity you need direct access to the Registered Block, which you won't get in the case of Forge/NeoForge you need to call the get() function from the RegisteryObject to access it, this is naturally not possible in the Commons project of a mod, so this function deals with the messiness of the mod loaders by doing the casting work itself

  1. The Actual registered Object for Fabric/Quilt and a RegistryObject for Forge/NeoForge

convertToMcSafeType(Object obj)
1.0.0

Parameters:

  • obj: The Object to convert.
  • T: The type to convert to.

Returns: The converted data data.

Example: Creation of a BlockEntity

1
2
3
4
5
6
public class Foo extends BlockEntity  {

    public Foo(BlockPos pos, BlockState state) {
        super((BlockEntityType<?>) Utils.convertToMcSafeType(BLOCK_OBJECT), pos, state);
    }
}