Class BlockEntityPreviewProvider
java.lang.Object
com.misterpemodder.shulkerboxtooltip.api.provider.BlockEntityPreviewProvider
- All Implemented Interfaces:
PreviewProvider
A PreviewProvider that works on items that carries block entity data.
Use/extend this when the target item(s) has the Inventory inside BlockEntityData
as created by ContainerHelper.saveAllItems(net.minecraft.world.level.storage.ValueOutput, NonNullList).
- Since:
- 1.3.0
-
Constructor Summary
ConstructorsConstructorDescriptionBlockEntityPreviewProvider(int defaultMaxInvSize, boolean defaultCanUseLootTables) Creates a BlockEntityPreviewProvider instance.BlockEntityPreviewProvider(int defaultMaxInvSize, boolean defaultCanUseLootTables, int defaultMaxRowSize) Creates a BlockEntityPreviewProvider instance.BlockEntityPreviewProvider(int defaultMaxInvSize, boolean defaultCanUseLootTables, int defaultMaxRowSize, int defaultCompactMaxRowSize) Creates a BlockEntityPreviewProvider instance. -
Method Summary
Modifier and TypeMethodDescriptionList<net.minecraft.network.chat.Component> addTooltip(PreviewContext context) Adds lines the stack tooltip.booleanIf true, previews will not be shown when theLootTabletag insideBlockEntityDatais present.intgetCompactMaxRowSize(PreviewContext context) The maximum number of item stacks to be displayed in a row in compact 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.static List<net.minecraft.network.chat.Component> getItemCountTooltip(List<net.minecraft.network.chat.Component> tooltip, List<net.minecraft.world.item.ItemStack> items) Adds the number of items to the passed tooltip, adds 'empty' if there is no items to count.static List<net.minecraft.network.chat.Component> getItemListTooltip(List<net.minecraft.network.chat.Component> tooltip, List<net.minecraft.world.item.ItemStack> items, net.minecraft.network.chat.Style style) Adds the number of items to the passed tooltip, adds 'empty' if there is no items to count.intgetMaxRowSize(PreviewContext context) The maximum number of item stacks to be displayed in a row in full preview mode.booleanshouldDisplay(PreviewContext context) Queries if the preview window should be displayed for the given context.booleanshowTooltipHints(PreviewContext context) Should hint be shown in the item's tooltip?Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.misterpemodder.shulkerboxtooltip.api.provider.PreviewProvider
getFullTooltipHintLangKey, getLockKeyTooltipHintLangKey, getPriority, getRenderer, getTextureOverride, getTooltipHintLangKey, getWindowColorKey, isFullPreviewAvailable, onInventoryAccessStart
-
Constructor Details
-
BlockEntityPreviewProvider
public BlockEntityPreviewProvider(int defaultMaxInvSize, boolean defaultCanUseLootTables) Creates a BlockEntityPreviewProvider instance.- Parameters:
defaultMaxInvSize- The maximum preview inventory size of the item (maybe lower than the actual inventory size). If the inventory size isn't constant, overridegetInventoryMaxSize(PreviewContext)and usemaxInvSizeas a default value.defaultCanUseLootTables- If true, previews will not be shown when theLootTabletag insideBlockEntityDatais present.- Since:
- 1.3.0
-
BlockEntityPreviewProvider
public BlockEntityPreviewProvider(int defaultMaxInvSize, boolean defaultCanUseLootTables, int defaultMaxRowSize) Creates a BlockEntityPreviewProvider instance.- Parameters:
defaultMaxInvSize- The maximum preview inventory size of the item (maybe lower than the actual inventory size). If the inventory size isn't constant, overridegetInventoryMaxSize(PreviewContext)and usemaxInvSizeas a default value.defaultCanUseLootTables- If true, previews will not be shown when theLootTabletag insideBlockEntityDatais present.defaultMaxRowSize- The maximum number of item stacks to be displayed in a row. If less or equal to zero, defaults to 9.- Since:
- 2.0.0
-
BlockEntityPreviewProvider
public BlockEntityPreviewProvider(int defaultMaxInvSize, boolean defaultCanUseLootTables, int defaultMaxRowSize, int defaultCompactMaxRowSize) Creates a BlockEntityPreviewProvider instance.- Parameters:
defaultMaxInvSize- The maximum preview inventory size of the item (maybe lower than the actual inventory size). If the inventory size isn't constant, overridegetInventoryMaxSize(PreviewContext)and usemaxInvSizeas a default value.defaultCanUseLootTables- If true, previews will not be shown when theLootTabletag insideBlockEntityDatais present.defaultMaxRowSize- The maximum number of item stacks to be displayed in a row in full preview mode. If less or equal to zero, defaults to 9.defaultCompactMaxRowSize- The maximum number of item stacks to be displayed in a row in compact preview mode.- Since:
- 5.2.0
-
-
Method Details
-
shouldDisplay
Description copied from interface:PreviewProviderQueries if the preview window should be displayed for the given context. Should returnfalseif the inventory is empty.- Specified by:
shouldDisplayin interfacePreviewProvider- Parameters:
context- The preview context.- Returns:
- Whether the preview should be displayed.
-
showTooltipHints
Description copied from interface:PreviewProviderShould hint be shown in the item's tooltip?- Specified by:
showTooltipHintsin interfacePreviewProvider- Parameters:
context- The preview context.- Returns:
- whether the hints should be shown.
-
getInventory
Description copied from interface:PreviewProviderFetches the items to be displayed in the preview.- Specified by:
getInventoryin interfacePreviewProvider- Parameters:
context- The preview context.- Returns:
- The list of items, may not be null or contain null elements.
-
getInventoryMaxSize
Description copied from interface:PreviewProviderReturns the maximum amount of slots this preview can display.- Specified by:
getInventoryMaxSizein interfacePreviewProvider- Parameters:
context- The preview context.- Returns:
- The maximum inventory size for the given stack.
-
addTooltip
Description copied from interface:PreviewProviderAdds lines the stack tooltip. Returned lines are added only if tooltip type is set toMODDEDin the config.- Specified by:
addTooltipin interfacePreviewProvider- Parameters:
context- The preview context.- Returns:
- A list of Text components. If empty, no text will be added to the tooltip.
-
getItemCountTooltip
public static List<net.minecraft.network.chat.Component> getItemCountTooltip(List<net.minecraft.network.chat.Component> tooltip, @Nullable List<net.minecraft.world.item.ItemStack> items) Adds the number of items to the passed tooltip, adds 'empty' if there is no items to count.- Parameters:
tooltip- The tooltip in which to add the item count.items- The list of items to display, may be null or empty.- Returns:
- The passed tooltip, to allow chaining.
- Since:
- 2.0.0
-
getItemListTooltip
public static List<net.minecraft.network.chat.Component> getItemListTooltip(List<net.minecraft.network.chat.Component> tooltip, @Nullable List<net.minecraft.world.item.ItemStack> items, net.minecraft.network.chat.Style style) Adds the number of items to the passed tooltip, adds 'empty' if there is no items to count.- Parameters:
tooltip- The tooltip in which to add the item count.items- The list of items to display, may be null or empty.style- The formatting style of the tooltip.- Returns:
- The passed tooltip, to allow chaining.
- Since:
- 2.0.0
-
getMaxRowSize
Description copied from interface:PreviewProviderThe maximum number of item stacks to be displayed in a row in full preview mode.- Specified by:
getMaxRowSizein interfacePreviewProvider- Parameters:
context- The preview context.- Returns:
- the row size, defaults to the max row size in config if 0.
-
getCompactMaxRowSize
Description copied from interface:PreviewProviderThe maximum number of item stacks to be displayed in a row in compact preview mode.- Specified by:
getCompactMaxRowSizein interfacePreviewProvider- Parameters:
context- The preview context.- Returns:
- the row size in compact mode, defaults to the max row size in config if 0.
-
canUseLootTables
public boolean canUseLootTables()If true, previews will not be shown when theLootTabletag insideBlockEntityDatais present.- Returns:
- whether this container support loot tables.
- Since:
- 4.0.8
-