Package journeymap.api.v2.client.model
Class MapImage
java.lang.Object
journeymap.api.v2.client.model.MapImage
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
ConstructorsConstructorDescriptionMapImage(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 TypeMethodDescriptionCenters the image on the associated position.booleandoubleGets anchor x.doubleGets anchor y.intgetColor()Gets color.doubleGets the image height in pixels when rendered.doubleGets the display width in pixels when rendered.com.mojang.blaze3d.platform.NativeImagegetImage()Gets the image, if there is one.net.minecraft.resources.ResourceLocationGets the image location, if there is one.floatGets opacity.intGets the rotation in degrees the image should be oriented.intGets the image textureHeight.intGets the image textureWidth.intGets X coordinate in BufferedImage where image begins.intGets Y coordinate in BufferedImage where image begins.inthashCode()booleanisBlur()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.toString()
-
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 texturetextureX- Start x of texture within image. Useful in sprite sheets.textureY- Start y of texture within image. Useful in sprite sheets.textureWidth- texture widthtextureHeight- texture heightcolor- 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 imagetextureWidth- width of texturetextureHeight- 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 widthtextureHeight- texture heightcolor- 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
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
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
Sets anchor x.- Parameters:
anchorX- the anchor x- Returns:
- this
-
getAnchorY
public double getAnchorY()Gets anchor y.- Returns:
- the anchor y
-
setAnchorY
Sets anchor y.- Parameters:
anchorY- the anchor y- Returns:
- this
-
centerAnchors
Centers the image on the associated position.- Returns:
- this
-
isBlur
public boolean isBlur() -
setBlur
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
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
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
Sets the image height in pixels when rendered, allowing the image to be scaled if needed.- Returns:
- this
-
equals
-
hashCode
public int hashCode() -
toString
-