Class MapImage

java.lang.Object
journeymap.api.v2.client.model.MapImage

public final class MapImage extends Object
Defines attributes needed to display an image on the map.

Note that the default anchorX and anchorY will cause the top left of the image to be placed at an associated BlockPos. To center the image on a BlockPos, use: mapImage.setAnchorX(mapImage.getDisplayWidth()/2.0).setAnchorY(mapImage.getDisplayHeight()/2.0);

Setters use the Builder pattern so they can be chained.

  • Constructor Summary

    Constructors
    Constructor
    Description
    MapImage(com.mojang.blaze3d.platform.NativeImage image)
    Constructor.
    MapImage(com.mojang.blaze3d.platform.NativeImage image, int textureX, int textureY, int textureWidth, int textureHeight, int color, float opacity)
    Constructor.
    MapImage(net.minecraft.resources.ResourceLocation imageLocation, int textureWidth, int textureHeight)
    Constructor.
    MapImage(net.minecraft.resources.ResourceLocation imageLocation, int textureX, int textureY, int textureWidth, int textureHeight, int color, float opacity)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    Centers the image on the associated position.
    boolean
     
    double
    Gets anchor x.
    double
    Gets anchor y.
    int
    Gets color.
    double
    Gets the image height in pixels when rendered.
    double
    Gets the display width in pixels when rendered.
    com.mojang.blaze3d.platform.NativeImage
    Gets the image, if there is one.
    net.minecraft.resources.ResourceLocation
    Gets the image location, if there is one.
    float
    Gets opacity.
    int
    Gets the rotation in degrees the image should be oriented.
    int
    Gets the image textureHeight.
    int
    Gets the image textureWidth.
    int
    Gets X coordinate in BufferedImage where image begins.
    int
    Gets Y coordinate in BufferedImage where image begins.
    int
     
    boolean
     
    setAnchorX(double anchorX)
    Sets anchor x.
    setAnchorY(double anchorY)
    Sets anchor y.
    setBlur(boolean blur)
    Sets the blur, True will use GL_LINEAR which will give AA to the image.
    setColor(int color)
    Sets color used to tint the image.
    setDisplayHeight(double displayHeight)
    Sets the image height in pixels when rendered, allowing the image to be scaled if needed.
    setDisplayWidth(double displayWidth)
    Sets the image width in pixels when rendered, allowing the image to be scaled if needed.
    setOpacity(float opacity)
    Sets opacity.
    setRotation(int rotation)
    Sets the rotation in degrees the image should be oriented.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MapImage

      public MapImage(com.mojang.blaze3d.platform.NativeImage image)
      Constructor.

      Defaults tint to white (0xffffff) and opacity to 1f. Defaults displayWidth and displayHeight to the texture dimensions.

      Parameters:
      image - Image texture
    • MapImage

      public MapImage(com.mojang.blaze3d.platform.NativeImage image, int textureX, int textureY, int textureWidth, int textureHeight, int color, float opacity)
      Constructor.

      Defaults displayWidth and displayHeight to the texture dimensions.

      Parameters:
      image - Image texture
      textureX - Start x of texture within image. Useful in sprite sheets.
      textureY - Start y of texture within image. Useful in sprite sheets.
      textureWidth - texture width
      textureHeight - texture height
      color - Sets a color tint (rgb) on the image. Use white (0xffffff) for no tint.
      opacity - opacity between 0 and 1
    • MapImage

      public MapImage(net.minecraft.resources.ResourceLocation imageLocation, int textureWidth, int textureHeight)
      Constructor. Defaults tint to white (0xffffff) and opacity to 1f. Defaults displayWidth and displayHeight to the texture dimensions.
      Parameters:
      imageLocation - location for image
      textureWidth - width of texture
      textureHeight - height of texture
    • MapImage

      public MapImage(net.minecraft.resources.ResourceLocation imageLocation, int textureX, int textureY, int textureWidth, int textureHeight, int color, float opacity)
      Constructor. Defaults displayWidth and displayHeight to the texture dimensions.
      Parameters:
      imageLocation - Resource location for texture image.
      textureX - Start x of texture within image. Useful in sprite sheets.
      textureY - Start y of texture within image. Useful in sprite sheets.
      textureWidth - texture width
      textureHeight - texture height
      color - Sets a color tint (rgb) on the image. Use white (0xffffff) for no tint.
      opacity - opacity between 0 and 1
  • Method Details

    • getColor

      public int getColor()
      Gets color.
      Returns:
      the color
    • setColor

      public MapImage setColor(int color)
      Sets color used to tint the image. Use 0xffffff for white (no tint).
      Parameters:
      color - the color
      Returns:
      this
    • getOpacity

      public float getOpacity()
      Gets opacity.
      Returns:
      the opacity
    • setOpacity

      public MapImage setOpacity(float opacity)
      Sets opacity.
      Parameters:
      opacity - the opacity
      Returns:
      this
    • getTextureX

      public int getTextureX()
      Gets X coordinate in BufferedImage where image begins. Useful in sprite sheets.
      Returns:
      textureX
    • getTextureY

      public int getTextureY()
      Gets Y coordinate in BufferedImage where image begins. Useful in sprite sheets.
      Returns:
      textureY
    • getAnchorX

      public double getAnchorX()
      Gets anchor x.
      Returns:
      the anchor x
    • setAnchorX

      public MapImage setAnchorX(double anchorX)
      Sets anchor x.
      Parameters:
      anchorX - the anchor x
      Returns:
      this
    • getAnchorY

      public double getAnchorY()
      Gets anchor y.
      Returns:
      the anchor y
    • setAnchorY

      public MapImage setAnchorY(double anchorY)
      Sets anchor y.
      Parameters:
      anchorY - the anchor y
      Returns:
      this
    • centerAnchors

      public MapImage centerAnchors()
      Centers the image on the associated position.
      Returns:
      this
    • isBlur

      public boolean isBlur()
    • setBlur

      public MapImage setBlur(boolean blur)
      Sets the blur, True will use GL_LINEAR which will give AA to the image. This is the default False will use GL_NEAREST which will keep the image pixelated.
      Parameters:
      blur -
      Returns:
    • getTextureWidth

      public int getTextureWidth()
      Gets the image textureWidth.
      Returns:
      textureWidth
    • getTextureHeight

      public int getTextureHeight()
      Gets the image textureHeight.
      Returns:
      textureHeight
    • getImageLocation

      @Nullable public net.minecraft.resources.ResourceLocation getImageLocation()
      Gets the image location, if there is one.
      Returns:
      the location
    • getImage

      @Nullable public com.mojang.blaze3d.platform.NativeImage getImage()
      Gets the image, if there is one.
      Returns:
      the location
    • getRotation

      public int getRotation()
      Gets the rotation in degrees the image should be oriented. Zero is the default.
      Returns:
      degrees
    • setRotation

      public MapImage setRotation(int rotation)
      Sets the rotation in degrees the image should be oriented. Zero is the default.
      Parameters:
      rotation - in degrees
      Returns:
      this
    • getDisplayWidth

      public double getDisplayWidth()
      Gets the display width in pixels when rendered. Default value is the texture width itself.
      Returns:
      display width
    • setDisplayWidth

      public MapImage setDisplayWidth(double displayWidth)
      Sets the image width in pixels when rendered, allowing the image to be scaled if needed.
      Returns:
      this
    • getDisplayHeight

      public double getDisplayHeight()
      Gets the image height in pixels when rendered. Default value is the texture width itself.
      Returns:
      display width
    • setDisplayHeight

      public MapImage setDisplayHeight(double displayHeight)
      Sets the image height in pixels when rendered, allowing the image to be scaled if needed.
      Returns:
      this
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object