6 Images And Assets
ABKQPO edited this page 2026-11-13 20:18:42 +08:00

Images And Assets

GuideNH supports both normal markdown images and several runtime-specific visual elements.

Asset Resolution Rules

Guide assets resolve with the same rules used by page links.

Path form Example Meaning
relative test1.png relative to the current page file
rooted /assets/example_structure.snbt relative to the current guide root
explicit resource id guidenh:textures/gui/example.png absolute modid:path lookup

Markdown Images

Normal markdown images are supported:

![Example](test1.png)

GuideNH resolves the path and loads the binary asset from the guide content root.

FloatingImage

With wrap="inline", the image is vertically centered with the surrounding text and its line expands to contain the full image. Adjacent text lines keep their normal height; there is no fixed line-height cap. For a very tall image that should occupy its own line, place the tag in a separate paragraph with blank lines before and after it.

<FloatingImage> renders a cropped bitmap region that can float with text or sit truly inline inside a paragraph. It also accepts explicit modid:path texture ids, so it can reference texture assets from other mods directly.

Attributes

Attribute Required Meaning
src yes image path
x when cropping crop start X in source-image pixels
y when cropping crop start Y in source-image pixels
width / w when cropping crop width in source-image pixels; exactly one spelling must be used
height / h when cropping crop height in source-image pixels; exactly one spelling must be used
scaleX no horizontal display multiplier, default 1.0
scaleY no vertical display multiplier, default 1.0
displayWidth no final display width in pixels; preserves the crop aspect ratio when used alone
displayHeight no final display height in pixels; preserves the crop aspect ratio when used alone
wrap no inline places the image on the text line; otherwise align chooses the floating side
align no left or right for floating placement; ignored when wrap="inline"
title no tooltip/title text
alt no Alternative text
sound no sound event played by the whole image
soundSrc no sound file path for the whole image
trigger no click by default, or hover for hover playback

Notes

  • x, y, width / w, and height / h are all required together when cropping
  • when the crop attributes are all omitted, displayWidth or displayHeight displays the full source image
  • width and height specify the source crop size. Use displayWidth / displayHeight or scale multipliers for the displayed size.
  • scaleX and scaleY calculate the final display size as cropWidth * scaleX by cropHeight * scaleY
  • displayWidth or displayHeight sets the final display size in pixels; when only one is present, the other dimension is calculated from the crop aspect ratio
  • providing both displayWidth and displayHeight allows intentional non-proportional stretching
  • displayWidth / displayHeight cannot be combined with scaleX / scaleY
  • single-axis stretching is supported by setting only one scale differently
  • width with w, or height with h, is invalid and renders a visible error

Example

<FloatingImage
  src="minecraft:textures/gui/options_background.png"
  x="0"
  y="0"
  width="32"
  height="32"
  displayWidth="64"
  displayHeight="64"
  wrap="inline"
  title="Example"
/>

ImageAnnotation

<ImageAnnotation> is a child element of <FloatingImage> that attaches a rich-text tooltip (and an optional colored border) to a rectangular region of the image. Coordinates are specified in cropped-image pixels and are automatically proportionally scaled when the cropped image is resized or stretched.

Attributes

Attribute Required Default Meaning
x no — left edge of the region in image pixels
y no — top edge of the region in image pixels
w no — width of the region in image pixels
h no — height of the region in image pixels
border no false show a colored border around the region
borderColor no random border color (#RRGGBB or #AARRGGBB)
borderThickness no 1 border thickness in display pixels
sound no none optional sound event played for this region
src no none optional sound file path; converted to a sound event id
trigger no click click or hover

Notes

  • omitting all four of x, y, w, h makes the annotation cover the whole image
  • if any of the four is present, the remaining omitted ones default to 0 (origin) or 1 (size)
  • border is not shown by default; add border or border={true} to enable it
  • when borderColor is omitted and border is enabled, a random fully-opaque color is used
  • child MDX content is rendered as the tooltip body and may include any inline/block elements
  • later annotations (lower in the list) take hover priority over earlier ones when regions overlap

Example

Whole-image annotation:

<FloatingImage displayWidth="128" displayHeight="128" src="test1.png" align="left" x="0" y="0" width="32" height="32">
  <ImageAnnotation>
    Hover anywhere on the image to see this tooltip.
  </ImageAnnotation>
</FloatingImage>

Region annotation with a visible border:

<FloatingImage displayWidth="128" displayHeight="128" src="test1.png" align="left" x="0" y="0" width="32" height="32">
  <ImageAnnotation x="2" y="2" w="15" h="10" border borderColor="#FFFF4444" borderThickness="2">
    This is the **highlighted region** tooltip.
  </ImageAnnotation>
</FloatingImage>

Multiple regions on one image:

<FloatingImage displayWidth="128" displayHeight="128" src="test1.png" align="left" x="0" y="0" width="32" height="32">
  <ImageAnnotation x="0" y="0" w="16" h="32" border borderColor="#FF44FF44">
    Left half
  </ImageAnnotation>
  <ImageAnnotation x="16" y="0" w="16" h="32" border borderColor="#FF4444FF">
    Right half
  </ImageAnnotation>
</FloatingImage>

Image regions can also play sounds. Use <SoundArea> when you only need sound, or put sound directly on <ImageAnnotation> when the same region also has a tooltip or border.

<FloatingImage
  displayWidth="128" displayHeight="128" src="test1.png"
  align="left"
  x="0"
  y="0"
  width="32"
  height="32"
  sound="guidenh:guide.sample_click"
>
  <SoundArea x="0" y="0" w="16" h="32" sound="guidenh:guide.sample_left" />
  <SoundArea x="16" y="0" w="16" h="32" sound="guidenh:guide.sample_hover" trigger="hover" />
  <ImageAnnotation x="2" y="2" w="10" h="10" border sound="guidenh:guide.sample_click">
    This region has both tooltip content and a click sound.
  </ImageAnnotation>
</FloatingImage>

<FloatingImage sound="..."> covers the whole image. Region sounds use cropped-image coordinates and obey the same overlap priority as tooltips: later regions win.

Content Embedding and Text Wrapping

Block tags compiled by BlockTagCompiler, including <Recipe>, <GameScene>, and <BlockImage>, accept wrap and align.

<FloatingImage> follows its own rules: wrap="inline" places it on the text line; otherwise align="left" or "right" floats it. <ItemImage> is an inline icon; place it in a <Column> or <Row> to control layout.

Attribute Default Meaning
wrap inline inline: normal placement. square, tight, and through: float left or right. top-bottom, behind, and front currently use normal aligned placement; they do not create separate text layers.
align left left, center, or right in block context. With a floating wrap mode, right floats right; other values float left. For a centered block, use wrap="inline" align="center".
float — Legacy left / right in flow context when wrap and align are absent. Prefer those explicit attributes.
<BlockImage id="minecraft:stone" wrap="square" align="right" />

<BlockImage id="minecraft:diamond_block" wrap="inline" align="center" />

<Column align="center">
  <ItemImage id="minecraft:diamond" nbt='{display:{Name:"Custom Diamond"}}' />
</Column>

Navigation Texture Icons

Frontmatter can use icon_texture to show a texture instead of an item in navigation/search:

navigation:
  title: Root
  icon_texture: test1.png

The file must decode as an image. The path is resolved like any other guide asset path.

Non-Image Assets

GuideNH pages may also reference non-image runtime assets, especially structure files, for example:

<ImportStructure src="/assets/example_structure.snbt" />

These assets are loaded through the same guide asset pipeline but are consumed by custom tags rather than rendered directly as images.

Best Practices

  • keep page-local images near the page that uses them
  • keep reusable files under the guide root assets/ folder
  • prefer rooted /assets/... paths for shared files referenced by multiple pages
  • use texture icons only for real image assets

BlockImage

<BlockImage> renders a placed block as a transparent 3D preview. It supports the block layout attributes above, including horizontal alignment and floating text wrap.

Key behavior:

  • transparent background and border
  • no scene buttons, no layer slider, no annotation authoring surface
  • hover still shows the selected block outline and tooltip
  • scale changes camera zoom and defaults to 4
  • perspective accepts isometric-north-east, isometric-north-west, and up
  • nbt supplies tile-entity SNBT; inline id="mod:block:meta:{...}" SNBT still works, but the standalone nbt attribute is easier to read and is preferred

Example:

<BlockImage id="minecraft:stone" />
<BlockImage id="minecraft:furnace" perspective="isometric-north-west" scale="2.5" />
<BlockImage
  id="minecraft:chest"
  scale="2"
  nbt='{id:"Chest",Items:[{Slot:0b,id:"minecraft:apple",Count:8b,Damage:0s}]}'
/>

Runtime Example Files

  • wiki/resourcepack/assets/guidenh/guidenh/_en_us/test1.png
  • wiki/resourcepack/assets/guidenh/guidenh/assets/example_structure.snbt