Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For ShulkerBoxContentHint, added customization possibility #77

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/document-en_us.md
Original file line number Diff line number Diff line change
Expand Up @@ -1809,6 +1809,17 @@ By default, the fill-level bar will only show up for non-mixed boxes
- Type: boolean (Generic)
- Default value: `false`

### shulkerBoxItemContentHintCustomNamesOverrideItem

This allows you to override the icon that is shown in the hint by renaming the box in an anvil with the name of the item to be shwon, when shulkerBoxItemContentHint is enabled.

For example, renaming a box "redstone_dust" will make it show the item "minecraft:redstone_dust"
If you want to use the item of a mod, you can specify the namespace in the name (both "redstone_dust" and "minecraft:redstone_dust" work).

- Category: MC Tweaks
- Type: boolean (Generic)
- Default value: `false`


### shulkerBoxTooltipEnchantmentHint

Expand Down
12 changes: 12 additions & 0 deletions docs/document-zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -1806,6 +1806,18 @@ FOV覆盖的开关
- 默认值: `false`


### 潜影盒物品内容提示-自定义名称覆盖物品 (shulkerBoxItemContentHintCustomNamesOverrideItem)

启用潜影盒物品内容提示时,通过在铁砧中将盒子重命名为要显示的物品名称,可以覆盖提示中显示的图标。

例如,将盒子重命名为 "redstone_dust" 将使其显示物品 "minecraft:redstone_dust"。
如果要使用模组的物品,可以在名称中指定命名空间(“redstone_dust” 和 “minecraft:redstone_dust” 都有效)。

- 分类: MC修改
- 类型: 布尔值 (通用)
- 默认值: `false`


### 潜影盒物品附魔提示 (shulkerBoxTooltipEnchantmentHint)

在潜影盒物品的工具提示中显示物品的附魔
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,9 @@ public class TweakerMoreConfigs
@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);

@Config(type = Config.Type.GENERIC, category = Config.Category.MC_TWEAKS)
public static final TweakerMoreConfigBoolean SHULKER_BOX_ITEM_CONTENT_HINT_CUSTOM_NAMES_OVERRIDE_ITEM = newConfigBoolean("shulkerBoxItemContentHintCustomNamesOverrideItem", false);

@Config(type = Config.Type.GENERIC, category = Config.Category.MC_TWEAKS)
public static final TweakerMoreConfigBoolean SHULKER_BOX_TOOLTIP_ENCHANTMENT_HINT = newConfigBoolean("shulkerBoxTooltipEnchantmentHint", false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@

package me.fallenbreath.tweakermore.impl.mc_tweaks.shulkerBoxItemContentHint;

import me.fallenbreath.tweakermore.TweakerMoreMod;
import me.fallenbreath.tweakermore.config.TweakerMoreConfigs;
import me.fallenbreath.tweakermore.util.InventoryUtil;
import me.fallenbreath.tweakermore.util.ItemUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DefaultedList;
import net.minecraft.item.Item;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;

import java.util.Optional;

Expand Down Expand Up @@ -93,6 +97,14 @@ public static Info prepareInformation(ItemStack itemStack)
}
}
}

// If option activated and box is not custom named
if (TweakerMoreConfigs.SHULKER_BOX_ITEM_CONTENT_HINT_CUSTOM_NAMES_OVERRIDE_ITEM.getBooleanValue() &&
!itemStack.getName().getString().equals(itemStack.getItem().getName().getString()) )
{
std = getFromCustomNameOrDefault(itemStack, info, std);
}

if (std == null)
{
return info;
Expand Down Expand Up @@ -126,4 +138,39 @@ public static Info prepareInformation(ItemStack itemStack)

return info;
}
}


/**
* Try to get a stack with the name or "minecraft:" + the name. In case the stack has a valid name, the info.allItemSame gets ovewritten to true.
*
*/
private static ItemStack getFromCustomNameOrDefault(ItemStack itemStack, Info info, ItemStack def)
{

//#if MC >= 12020
//$$ Identifier itemId = Identifier.tryParse("", itemStack.getName().getString());
//#else
Identifier itemId = Identifier.tryParse(itemStack.getName().getString());
//#endif

if(!Registry.ITEM.containsId(itemId)){
//#if MC >= 12020
//$$ itemId = Identifier.tryParse(itemStack.getName().getString());
//#else
itemId = Identifier.tryParse("minecraft:"+ itemStack.getName().getString());
//#endif
}

if(!Registry.ITEM.containsId(itemId))
{
return def;
}

// Overwrite info
info.allItemSame = true;
info.allItemSameIgnoreNbt = true;

Item item = Registry.ITEM.get(itemId);
return new ItemStack(item);
}
}
9 changes: 9 additions & 0 deletions src/main/resources/assets/tweakermore/lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,15 @@ tweakermore:
shulkerBoxTooltipPotionInfoHint:
.: shulkerBoxTooltipPotionInfoHint
comment: Display potion information of items in the tooltip of shulker box items
shulkerBoxItemContentHintCustomNamesOverrideItem:
.: shulkerBoxItemContentHintCustomNamesOverrideItem
comment: |-
This allows you to override the icon that is shown in the
hint by renaming the box in an anvil with the name of the item to be shwon, when shulkerBoxItemContentHint is enabled.
For example, renaming a box "redstone_dust" will make it
show the item "minecraft:redstone_dust".
If you want to use the item of a mod, you can specify the
namespace in the name (both "redstone_dust" and "minecraft:redstone_dust" work).
signEditScreenCancelButton:
.: signEditScreenCancelButton
comment: Add a cancel button to the sign edit screen that cancels the editing and discard all changes
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/assets/tweakermore/lang/zh_cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,12 @@ tweakermore:
shulkerBoxTooltipPotionInfoHint:
.: 潜影盒物品药水提示
comment: 在潜影盒物品的工具提示中显示物品提供的药水效果
shulkerBoxItemContentHintCustomNamesOverrideItem:
.: shulkerBoxItemContentHintCustomNamesOverrideItem
comment: |-
启用潜影盒物品内容提示时,通过在铁砧中将盒子重命名为要显示的物品名称,可以覆盖提示中显示的图标。
例如,将盒子重命名为 "redstone_dust" 将使其显示物品 "minecraft:redstone_dust"。
如果要使用模组的物品,可以在名称中指定命名空间(“redstone_dust” 和 “minecraft:redstone_dust” 都有效)。
signEditScreenCancelButton:
.: 告示牌编辑界面取消按钮
comment: 在标牌编辑界面添加一个取消按钮,用于取消编辑并丢弃所有更改
Expand Down