Interface PreviewProvider
- All Known Implementing Classes:
BlockEntityPreviewProvider,EmptyPreviewProvider
public interface PreviewProvider
Describes preview properties for a registered set of items.
- Since:
- 1.3.0
-
Method Summary
Modifier and TypeMethodDescriptiondefault List<net.minecraft.network.chat.Component> addTooltip(PreviewContext context) Adds lines the stack tooltip.default intgetCompactMaxRowSize(PreviewContext context) The maximum number of item stacks to be displayed in a row in compact preview mode.default StringgetFullTooltipHintLangKey(PreviewContext context) The translation key for a hint that tells the user how to enter full preview mode.List<net.minecraft.world.item.ItemStack> getInventory(PreviewContext context) Fetches the items to be displayed in the preview.intgetInventoryMaxSize(PreviewContext context) Returns the maximum amount of slots this preview can display.default StringThe translation key for a hint that tells the user how to lock the tooltip window.default intgetMaxRowSize(PreviewContext context) The maximum number of item stacks to be displayed in a row in full preview mode.default intPriority of this preview provider, relative to other providers targeting the same item.default PreviewRendererGet the renderer to use for this type of preview.default net.minecraft.resources.ResourceLocationgetTextureOverride(PreviewContext context) Overrides the texture used to display the preview window.default StringgetTooltipHintLangKey(PreviewContext context) The translation key for a hint that tells the user how to enter compact preview mode.default ColorKeygetWindowColorKey(PreviewContext context) Which color the preview window should be in?default booleanisFullPreviewAvailable(PreviewContext context) Returns whether this provider supports full preview mode.default voidonInventoryAccessStart(PreviewContext context) This method should be called every time the inventory of the stack starts being accessed (i.e.booleanshouldDisplay(PreviewContext context) Queries if the preview window should be displayed for the given context.default booleanshowTooltipHints(PreviewContext context) Should hint be shown in the item's tooltip?
-
Method Details
-
shouldDisplay
Queries if the preview window should be displayed for the given context. Should returnfalseif the inventory is empty.- Parameters:
context- The preview context.- Returns:
- Whether the preview should be displayed.
- Since:
- 2.0.0
-
getInventory
Fetches the items to be displayed in the preview.- Parameters:
context- The preview context.- Returns:
- The list of items, may not be null or contain null elements.
- Since:
- 2.0.0
-
getInventoryMaxSize
Returns the maximum amount of slots this preview can display.- Parameters:
context- The preview context.- Returns:
- The maximum inventory size for the given stack.
- Since:
- 2.0.0
-
getMaxRowSize
The maximum number of item stacks to be displayed in a row in full preview mode.- Parameters:
context- The preview context.- Returns:
- the row size, defaults to the max row size in config if 0.
- Since:
- 2.0.0
-
getCompactMaxRowSize
The maximum number of item stacks to be displayed in a row in compact preview mode.- Parameters:
context- The preview context.- Returns:
- the row size in compact mode, defaults to the max row size in config if 0.
- Since:
- 5.2.0
-
isFullPreviewAvailable
Returns whether this provider supports full preview mode.- Parameters:
context- The preview context.- Returns:
- If false, compact mode will be the only type of preview.
- Since:
- 2.0.0
-
showTooltipHints
Should hint be shown in the item's tooltip?- Parameters:
context- The preview context.- Returns:
- whether the hints should be shown.
- Since:
- 2.0.0
-
getTooltipHintLangKey
The translation key for a hint that tells the user how to enter compact preview mode.- Parameters:
context- The preview context.- Returns:
- The text to be displayed for the compact preview mode.
- Since:
- 2.0.0
-
getFullTooltipHintLangKey
The translation key for a hint that tells the user how to enter full preview mode.- Parameters:
context- The preview context.- Returns:
- The text to be displayed for the full preview mode.
- Since:
- 2.0.0
-
getLockKeyTooltipHintLangKey
The translation key for a hint that tells the user how to lock the tooltip window.- Parameters:
context- The preview context.- Returns:
- The text to be displayed for the lock tooltip hint.
- Since:
- 3.4.0
-
getWindowColorKey
Which color the preview window should be in?- Parameters:
context- The preview context.- Returns:
- The desired ColorKey instance.
- Since:
- 3.2.0
-
getRenderer
Get the renderer to use for this type of preview.- Returns:
- A
PreviewRendererinstance. - Since:
- 1.3.0
-
addTooltip
Adds lines the stack tooltip. Returned lines are added only if tooltip type is set toMODDEDin the config.- Parameters:
context- The preview context.- Returns:
- A list of Text components. If empty, no text will be added to the tooltip.
- Since:
- 2.0.0
-
onInventoryAccessStart
This method should be called every time the inventory of the stack starts being accessed (i.e. by hovering it).- Parameters:
context- The preview context.- Since:
- 2.0.0
-
getTextureOverride
@Nullable @Environment(CLIENT) default net.minecraft.resources.ResourceLocation getTextureOverride(PreviewContext context) Overrides the texture used to display the preview window.- Parameters:
context- The preview context.- Returns:
- The texture path, or null for the default texture.
- Since:
- 2.2.0
-
getPriority
default int getPriority()Priority of this preview provider, relative to other providers targeting the same item. The provider that returns the highest number will be chosen, in case the priorities are equal, the provider will be chosen arbitrarily chosen.- Returns:
- The priority of this preview provider.
- Since:
- 2.3.0
-