Skip to content

API usage

Crystal Spider edited this page Oct 7, 2024 · 5 revisions

CustomPortalChecker

CustomPortalChecker is a utility interface used within the mod itself, but that can prove useful for other mods too.

It's essentially an interface applied via mixins to the Vanilla PortalShape class, adding a single instance method, ResourceKey<Level> dimension(), that can be used to query the dimension the referenced portal structure is linked to (Nether portals included).
To access this method via a PortalShape instance, you can safely cast it to CustomPortalChecker.

CustomPortalChecker also provides several static utility methods that can be accessed directly through the interface itself:

  • ResourceKey<Level> getPortalDimension(Level, BlockPos):
    Returns the Custom Dimension related to the Custom Portal found at the given position in the given Level.
    Can be used to avoid explicit instantiations of PortalShapes.

  • boolean isPortalForDimension(Level, BlockPos, ResourceKey<Level>):
    Checks whether the Portal at the given position in the given Level is for the specified dimension.
    In this overload, the dimension is referenced by its explicit ResourceKey.
    Can be used to check whether a Portal is for the Nether.

  • boolean isPortalForDimension(Level, BlockPos, String):
    Checks whether the Portal at the given position in the given Level is for the specified dimension.
    In this overload, the dimension is referenced by its name, and the namespace is assumed to be server_sided_portals.
    Cannot be used to check whether a Portal is for the Nether.

  • boolean isCustomPortal(Level, BlockPos):
    Checks whether there is a Custom Portal in the given Level at the given position.

  • List<ResourceKey<Level>> getCustomDimensions(ServerLevel):
    Returns the list of Custom Dimensions.

  • boolean isCustomDimension(Level):
    Returns whether the given Level is a Custom one.

  • boolean isCustomDimension(ResourceKey<Level> dimension):
    Returns whether the specified dimension is a Custom one.

  • TagKey<Block> getCustomPortalFrameBlockTag(ResourceKey<Level>):
    Returns the Block Tag for the Custom Portal frame related to the specified dimension.

  • Block getCustomPortalFrameBlock(Level level):
    Returns a random Block for the Custom Portal frame related to the given dimension.