diff --git a/docs/assets/shulkerBoxItemContentHint.png b/docs/assets/shulkerBoxItemContentHint.png index 41724790..489b7686 100644 Binary files a/docs/assets/shulkerBoxItemContentHint.png and b/docs/assets/shulkerBoxItemContentHint.png differ diff --git a/docs/document-en_us.md b/docs/document-en_us.md index 910e8a08..d46edf93 100644 --- a/docs/document-en_us.md +++ b/docs/document-en_us.md @@ -1747,6 +1747,8 @@ Show a hint of content of shulker box item at the lower-left corner of the shulk If the shulker box contains only 1 item type, then that item in the box will be shown +If the shulker box contains only 1 item type with different nbt, then "*" will be appended + If the shulker box contains multiple types of item, then "..." will be shown If the shulker box is empty, no hint will be shown @@ -1770,7 +1772,7 @@ The scale of the hint stuffs in option shulkerBoxItemContentHint - Type: double (Generic) - Default value: `0.5` - Minimum value: `0.01` -- Maximum value: `1.0` +- Maximum value: `0.75` ### shulkerBoxItemContentHintShowBarOnMixed diff --git a/docs/document-zh_cn.md b/docs/document-zh_cn.md index 1df8d72b..ebda447b 100644 --- a/docs/document-zh_cn.md +++ b/docs/document-zh_cn.md @@ -1743,6 +1743,8 @@ FOV覆盖的开关 若潜影盒仅包含1种物品类型,将显示盒中的那一种物品 +若潜影盒仅包含1种物品类型但nbt有不同,将追加显示一个“*” + 若潜影盒包含多种物品类型,将显示“...” 若潜影盒为空,则不显示内容提示 @@ -1766,7 +1768,7 @@ FOV覆盖的开关 - 类型: 实数 (通用) - 默认值: `0.5` - 最小值: `0.01` -- 最大值: `1.0` +- 最大值: `0.75` ### 潜影盒物品内容提示-杂盒也有容量条 (shulkerBoxItemContentHintShowBarOnMixed) diff --git a/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java b/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java index ea701533..7cb0d800 100644 --- a/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java +++ b/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java @@ -555,7 +555,7 @@ public class TweakerMoreConfigs public static final TweakerMoreConfigBoolean SHULKER_BOX_ITEM_CONTENT_HINT = newConfigBoolean("shulkerBoxItemContentHint", false); @Config(type = Config.Type.GENERIC, category = Config.Category.MC_TWEAKS) - public static final TweakerMoreConfigDouble SHULKER_BOX_ITEM_CONTENT_HINT_SCALE = newConfigDouble("shulkerBoxItemContentHintScale", 0.5, 0.01, 1); + public static final TweakerMoreConfigDouble SHULKER_BOX_ITEM_CONTENT_HINT_SCALE = newConfigDouble("shulkerBoxItemContentHintScale", 0.5, 0.01, 0.75); @Config(type = Config.Type.GENERIC, category = Config.Category.MC_TWEAKS) public static final TweakerMoreConfigBoolean SHULKER_BOX_ITEM_CONTENT_HINT_SHOW_BAR_ON_MIXED = newConfigBoolean("shulkerBoxItemContentHintShowBarOnMixed", false); diff --git a/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/shulkerBoxItemContentHint/ShulkerBoxItemContentHintCommon.java b/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/shulkerBoxItemContentHint/ShulkerBoxItemContentHintCommon.java index f90c647b..729386ec 100644 --- a/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/shulkerBoxItemContentHint/ShulkerBoxItemContentHintCommon.java +++ b/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/shulkerBoxItemContentHint/ShulkerBoxItemContentHintCommon.java @@ -34,6 +34,7 @@ public static class Info { public boolean enabled; public boolean allItemSame; + public boolean allItemSameIgnoreNbt; public double scale; public ItemStack stack; public double fillRatio; @@ -63,6 +64,7 @@ public static Info prepareInformation(ItemStack itemStack) ItemStack std = null; info.allItemSame = true; + info.allItemSameIgnoreNbt = true; for (ItemStack stack : stackList.get()) { if (!stack.isEmpty()) @@ -70,16 +72,24 @@ public static Info prepareInformation(ItemStack itemStack) if (std == null) { std = stack; + continue; } - // to be equal: item type equals, item nbt equals - //#if MC >= 12000 - //$$ else if (!ItemStack.canCombine(stack, std)) - //#else - else if (!(ItemStack.areItemsEqual(stack, std) && ItemStack.areTagsEqual(stack, std))) + + boolean itemEqual = ItemStack.areItemsEqual(stack, std); + boolean itemAndNbtEqual = + //#if MC >= 12000 + //$$ ItemStack.canCombine(stack, std) + //#else + itemEqual && ItemStack.areTagsEqual(stack, std); //#endif + + if (!itemAndNbtEqual) { info.allItemSame = false; - break; + } + if (!itemEqual) + { + info.allItemSameIgnoreNbt = false; } } } diff --git a/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/shulkerBoxItemContentHint/ShulkerBoxItemContentHintRenderer.java b/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/shulkerBoxItemContentHint/ShulkerBoxItemContentHintRenderer.java index 98abca30..7ec05eb0 100644 --- a/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/shulkerBoxItemContentHint/ShulkerBoxItemContentHintRenderer.java +++ b/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/shulkerBoxItemContentHint/ShulkerBoxItemContentHintRenderer.java @@ -96,7 +96,7 @@ public static void render( RenderUtil.Scaler scaler = RenderUtil.createScaler(x, y + SLOT_WIDTH, info.scale); scaler.apply(renderContext); - if (info.allItemSame) + if (info.allItemSame || info.allItemSameIgnoreNbt) { renderMiniItem( renderContext, @@ -108,9 +108,9 @@ public static void render( info, x, y ); } - else + if (!info.allItemSame) { - renderQuestionMark( + renderText( //#if MC >= 11500 textMatrixStack, //#endif @@ -128,8 +128,9 @@ public static void render( //$$ RenderSystem.applyModelViewMatrix(); //#endif + boolean mixedBox = !info.allItemSameIgnoreNbt && !info.allItemSame; if ( - (info.allItemSame || TweakerMoreConfigs.SHULKER_BOX_ITEM_CONTENT_HINT_SHOW_BAR_ON_MIXED.getBooleanValue()) + (!mixedBox || TweakerMoreConfigs.SHULKER_BOX_ITEM_CONTENT_HINT_SHOW_BAR_ON_MIXED.getBooleanValue()) && (0 < info.fillRatio && info.fillRatio < 1) ) { @@ -199,21 +200,23 @@ private static void renderMiniItem( } } - private static void renderQuestionMark( + private static void renderText( //#if MC >= 11500 MatrixStack textMatrixStack, //#endif double zOffset, ShulkerBoxItemContentHintCommon.Info info, int x, int y ) { - String text = "..."; + String text = info.allItemSameIgnoreNbt ? "*" : "..."; + boolean putTextOnRight = info.allItemSameIgnoreNbt && info.scale <= 0.75; float width = RenderUtil.getRenderWidth(text); float height = RenderUtil.TEXT_HEIGHT; - float textX = x + (SLOT_WIDTH - width) * 0.5F; - float textY = y + SLOT_WIDTH - height - 3; - int color = 0xDDDDDD; + float textX = putTextOnRight ? x + SLOT_WIDTH + 0.5F : x + (SLOT_WIDTH - width) * 0.5F; + float textY = putTextOnRight ? y + (SLOT_WIDTH - height) * 0.5F : y + SLOT_WIDTH - height - 3; + double textScale = SLOT_WIDTH / height * 0.7 * (putTextOnRight ? 0.9 : 1); + int textColor = 0xDDDDDD; - RenderUtil.Scaler textScaler = RenderUtil.createScaler(textX + width * 0.5, textY + height * 0.5, SLOT_WIDTH / height * 0.7); + RenderUtil.Scaler textScaler = RenderUtil.createScaler(textX + width * 0.5, textY + height * 0.5, textScale); textScaler.apply(RenderContext.of( //#if MC >= 11600 //$$ textMatrixStack @@ -228,7 +231,7 @@ private static void renderQuestionMark( text, textX, textY, - color, + textColor, true, // TODO: check why this doesn't get remapped //#if MC >= 11800 @@ -250,7 +253,7 @@ private static void renderQuestionMark( //$$ GlStateManager.disableLighting(); //$$ GlStateManager.disableDepthTest(); //$$ GlStateManager.disableBlend(); - //$$ textRenderer.drawWithShadow(text, textX, textY, color); + //$$ textRenderer.drawWithShadow(text, textX, textY, textColor); //$$ GlStateManager.enableBlend(); //$$ GlStateManager.enableLighting(); //$$ GlStateManager.enableDepthTest(); diff --git a/src/main/resources/assets/tweakermore/lang/en_us.yml b/src/main/resources/assets/tweakermore/lang/en_us.yml index 0ca5c6f2..e2ef117d 100644 --- a/src/main/resources/assets/tweakermore/lang/en_us.yml +++ b/src/main/resources/assets/tweakermore/lang/en_us.yml @@ -670,6 +670,7 @@ tweakermore: comment: |- Show a hint of content of shulker box item at the lower-left corner of the shulker box If the shulker box contains only 1 item type, then that item in the box will be shown + If the shulker box contains only 1 item type with different nbt, then "*" will be appended If the shulker box contains multiple types of item, then "..." will be shown If the shulker box is empty, no hint will be shown Also, a fill-level bar will be rendered at the lower-right corner, diff --git a/src/main/resources/assets/tweakermore/lang/zh_cn.yml b/src/main/resources/assets/tweakermore/lang/zh_cn.yml index 886554ba..5a0d239f 100644 --- a/src/main/resources/assets/tweakermore/lang/zh_cn.yml +++ b/src/main/resources/assets/tweakermore/lang/zh_cn.yml @@ -670,6 +670,7 @@ tweakermore: comment: |- 在渲染潜影盒物品时,在潜影盒的左下角显示一个盒中内容的提示 若潜影盒仅包含1种物品类型,将显示盒中的那一种物品 + 若潜影盒仅包含1种物品类型但nbt有不同,将追加显示一个“*” 若潜影盒包含多种物品类型,将显示“...” 若潜影盒为空,则不显示内容提示 除此之外,若潜影盒非空且非全满,