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 Details

    • MapImage

      public MapImage(BufferedImage 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(BufferedImage 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.util.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.util.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.util.ResourceLocation getImageLocation()
      Gets the image location, if there is one.
      Returns:
      the location
    • getImage

      @Nullable public BufferedImage 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