Class ResourceImpl

java.lang.Object
net.minecraft.resource.ResourceImpl
All Implemented Interfaces:
Closeable, AutoCloseable, Resource

public class ResourceImpl
extends Object
implements Resource
  • Field Details

    • packName

      private final String packName
    • id

      private final Identifier id
    • inputStream

      private final InputStream inputStream
    • metaInputStream

      private final InputStream metaInputStream
    • readMetadata

      @Environment(CLIENT) private boolean readMetadata
    • metadata

      @Environment(CLIENT) private JsonObject metadata
  • Constructor Details

  • Method Details

    • getId

      @Environment(CLIENT) public Identifier getId()
      Returns the location of this resource.

      Within each resource pack, this location is a unique identifer for a resource; however, in a resource manager, there may be multiple resources with the same location available.

      Specified by:
      getId in interface Resource
    • getInputStream

      public InputStream getInputStream()
      Returns the input stream of this resource.

      This input stream is closed when this resource is closed.

      Specified by:
      getInputStream in interface Resource
    • hasMetadata

      @Environment(CLIENT) public boolean hasMetadata()
    • getMetadata

      @Environment(CLIENT) @Nullable public <T> T getMetadata​(ResourceMetadataReader<T> metaReader)
      Returns a metadata of this resource by the metaReader, or null if no such metadata exists.
      Specified by:
      getMetadata in interface Resource
      Parameters:
      metaReader - the metadata reader
    • getResourcePackName

      public String getResourcePackName()
      Returns the user-friendly name of the pack this resource is from.
      Specified by:
      getResourcePackName in interface Resource
    • equals

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

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

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException