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 StringgetFullTooltipHintLangKey(PreviewContext context) List<net.minecraft.world.item.ItemStack> getInventory(PreviewContext context) Fetches the items to be displayed in the preview.intgetInventoryMaxSize(PreviewContext context) default Stringdefault intgetMaxRowSize(PreviewContext context) The maximum number of item stacks to be displayed in a row.default intPriority of this preview provider, relative to other providers targeting the same item.default PreviewRendererdefault net.minecraft.resources.ResourceLocationgetTextureOverride(PreviewContext context) Overrides the texture used to display the preview window.default StringgetTooltipHintLangKey(PreviewContext context) default ColorKeygetWindowColorKey(PreviewContext context) Which color the preview window should be in?default booleanisFullPreviewAvailable(PreviewContext context) 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
- 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.- Parameters:
context- The preview context.- Returns:
- the row size, defaults to the max row size in config if 0.
- Since:
- 2.0.0
-
isFullPreviewAvailable
- 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
- Parameters:
context- The preview context.- Returns:
- The text to be displayed for the compact preview mode.
- Since:
- 2.0.0
-
getFullTooltipHintLangKey
- Parameters:
context- The preview context.- Returns:
- The text to be displayed for the full preview mode.
- Since:
- 2.0.0
-
getLockKeyTooltipHintLangKey
- 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
- 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
-