Class ResourceName

java.lang.Object
de.ellpeck.rockbottom.api.util.reg.ResourceName
All Implemented Interfaces:
Comparable<ResourceName>

public final class ResourceName extends Object implements Comparable<ResourceName>
A resource name that defines the name of a resource and the domain that it is created from. A resource name is structured in the following way: The domain, followed by Constants.RESOURCE_SEPARATOR, followed by the actual resource name.

The game's internal resource names use the IGameInstance instance from RockBottomAPI.getGame() as the domain. Using this in mods is highly discouraged and, if anything, should only be used to access existing internal resources, not create new ones.

  • Constructor Details

    • ResourceName

      public ResourceName(IMod mod, String resourceName)
      Creates a resource name with the given IMod as the domain.
      Parameters:
      mod - The mod domain
      resourceName - The resource name
    • ResourceName

      public ResourceName(String combined)
      Creates a resource name from a combined string. If the string does not contain the Constants.RESOURCE_SEPARATOR, then it will throw an IllegalArgumentException.
      Parameters:
      combined - The combined resource string
      See Also:
  • Method Details

    • intern

      @ApiInternal public static ResourceName intern(String resourceName)
      Creates an internal resource name that uses the IGameInstance instance from RockBottomAPI.getGame() as the domain. Using this in mods is highly discouraged and, if anything, should only be used to access existing internal resources, not create new ones.
      Parameters:
      resourceName - The name of the resource
      Returns:
      A new internal resource name
    • getDomain

      public String getDomain()
      Returns the domain of this resource name.
      Returns:
      The domain
      See Also:
    • getResourceName

      public String getResourceName()
      Returns the name of this resource
      Returns:
      The name
      See Also:
    • addPrefix

      public ResourceName addPrefix(String prefix)
      Returns a new resource name with the given prefix added to the front of the resource. For example, the resource name rockbottom/stone with the prefix dirty_ added to it would result in a new resource name rockbottom/dirty_stone, meaning the domain of the resource name stays unaffected by this action.
      Parameters:
      prefix - The prefix to add
      Returns:
      A new name with the prefix added
    • addSuffix

      public ResourceName addSuffix(String suffix)
      Returns a new resource name with the given suffix added to the end of the resource. For example, the resource name rockbottom/stone with the suffix _pickaxe added to it would result in a new resource name rockbottom/stone_pickaxe, meaning the domain of the resource name stays unaffected by this action.
      Parameters:
      suffix - The suffix to add
      Returns:
      A new name with the suffix added
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(ResourceName o)
      Specified by:
      compareTo in interface Comparable<ResourceName>
    • toString

      public String toString()
      Overrides:
      toString in class Object