Skip to content

Commit

Permalink
Added MC Tweaks: enchantedBookHint
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan-1F committed Aug 8, 2022
1 parent cebd527 commit eaa0c62
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 6 deletions.
35 changes: 32 additions & 3 deletions docs/document-zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ TweakerPlus提供的新功能
- 分类: `功能`
- 配置类型: `工具`

### 自动交易-总开关 (tweakpAutoTrade)
### 自动交易总开关 (tweakpAutoTrade)

自动交易相关功能的总开关,影响:

Expand Down Expand Up @@ -56,7 +56,7 @@ TweakerPlus提供的新功能
- 依赖模组:
- Item Scroller (`itemscroller`)

### 自动交易-储存配方 (tweakpAutoTradeStoreRecipe)
### 自动交易储存配方 (tweakpAutoTradeStoreRecipe)

将鼠标悬停在交易输出槽位上时存储交易配方

Expand All @@ -70,7 +70,7 @@ TweakerPlus提供的新功能
- 依赖模组:
- Item Scroller (`itemscroller`)

### 自动交易-扔出输出 (tweakpAutoTradeThrowOutput)
### 自动交易扔出输出 (tweakpAutoTradeThrowOutput)

强制将自动交易得到的输出扔出背包,而不是放入背包

Expand Down Expand Up @@ -165,6 +165,35 @@ TweakerPlus提供的新功能
- 分类: `MC修改`
- 配置类型: `热键`

### 禁用地狱门传送音效 (disablePortalTeleportSound)

禁用在使用玩家站在传送门里与玩家被地狱门传送后时的音效

- 类型: `可开关型热键`
- 默认值: *无快捷键*, `false`
- 分类: `MC修改`
- 配置类型: `禁用`

### 禁用末影人生气音效 (disableEndermanAngrySound)

禁用末影人被激怒后的音效

- 类型: `可开关型热键`
- 默认值: *无快捷键*, `false`
- 分类: `MC修改`
- 配置类型: `禁用`

### 附魔书附魔提示 (enchantedBookHint)

在附魔书物品上渲染它的所有附魔

在附魔较多时文字可能会阻挡

- 类型: `可开关型热键`
- 默认值: *无快捷键*, `false`
- 分类: `MC修改`
- 配置类型: `通用`

## 模组修改

对模组已有内容修改
Expand Down
29 changes: 29 additions & 0 deletions docs/document.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,35 @@ Reload options.txt
- Category: `MC Tweaks`
- Config Type: `Hotkey`

### disablePortalTeleportSound

Disable the sound played when standing in the nether portal and being teleported through the portal

- Type: `togglable hotkey`
- Default value: *no hotkey*, `false`
- Category: `MC Tweaks`
- Config Type: `Disable`

### disableEndermanAngrySound

Disable the enderman angry sound

- Type: `togglable hotkey`
- Default value: *no hotkey*, `false`
- Category: `MC Tweaks`
- Config Type: `Disable`

### enchantedBookHint

Render all its enchantments on the enchantment book item

Texts may be blocked if there are too many enchantments

- Type: `togglable hotkey`
- Default value: *no hotkey*, `false`
- Category: `MC Tweaks`
- Config Type: `Generic`

## Mods Tweaks

Tweaks on mods
Expand Down
9 changes: 6 additions & 3 deletions docs/readme-zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

- [限制世界修改](document-zh_cn.md#限制世界修改-limitWorldModification)
- [立即重生](document-zh_cn.md#立即重生-immediatelyRespawn)
- [自动交易-总开关](document-zh_cn.md#自动交易-总开关-tweakpAutoTrade)
- [自动交易总开关](document-zh_cn.md#自动交易总开关-tweakpAutoTrade)
- [交易全部物品](document-zh_cn.md#交易全部物品-tweakpTradeEverything)
- [自动交易-储存配方](document-zh_cn.md#自动交易-储存配方-tweakpAutoTradeStoreRecipe)
- [自动交易-扔出输出](document-zh_cn.md#自动交易-扔出输出-tweakpAutoTradeThrowOutput)
- [自动交易储存配方](document-zh_cn.md#自动交易储存配方-tweakpAutoTradeStoreRecipe)
- [自动交易扔出输出](document-zh_cn.md#自动交易扔出输出-tweakpAutoTradeThrowOutput)
- [自动交易全部物品](document-zh_cn.md#自动交易全部物品-tweakpAutoTradeEverything)

## [MC修改](document-zh_cn.md#mc修改)
Expand All @@ -21,6 +21,9 @@
- [禁用气泡柱渲染](document-zh_cn.md#禁用气泡柱渲染-disableBubbleColumnRendering)
- [忽略资源包不兼容](document-zh_cn.md#忽略资源包不兼容-resourcePackIncompatibleIgnored)
- [重新加载游戏选项](document-zh_cn.md#重新加载游戏选项-reloadGameOptions)
- [禁用地狱门传送音效](document-zh_cn.md#禁用地狱门传送音效-disablePortalTeleportSound)
- [禁用末影人生气音效](document-zh_cn.md#禁用末影人生气音效-disableEndermanAngrySound)
- [附魔书附魔提示](document-zh_cn.md#附魔书附魔提示-enchantedBookHint)

## [模组修改](document-zh_cn.md#模组修改)

Expand Down
3 changes: 3 additions & 0 deletions docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
- [disableBubbleColumnRendering](document.md#disableBubbleColumnRendering)
- [resourcePackIncompatibleIgnored](document.md#resourcePackIncompatibleIgnored)
- [reloadGameOptions](document.md#reloadGameOptions)
- [disablePortalTeleportSound](document.md#disablePortalTeleportSound)
- [disableEndermanAngrySound](document.md#disableEndermanAngrySound)
- [enchantedBookHint](document.md#enchantedBookHint)

## [Mods Tweaks](document.md#mods-tweaks)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public class TweakerPlusConfigs {
@Config(type = Config.Type.DISABLE, category = Config.Category.MC_TWEAKS)
public static final TweakerPlusConfigBooleanHotkeyed DISABLE_ENDERMAN_ANGRY_SOUND = ConfigFactory.newConfigBooleanHotkeyed("disableEndermanAngrySound", false, "");

@Config(type = Config.Type.GENERIC, category = Config.Category.MC_TWEAKS)
public static final TweakerPlusConfigBooleanHotkeyed ENCHANTED_BOOK_HINT = ConfigFactory.newConfigBooleanHotkeyed("enchantedBookHint", false, "");

////////////////////
// Mod Tweaks //
////////////////////
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package me.ivan1f.tweakerplus.mixins.tweaks.enchantmentBookHint;

import me.ivan1f.tweakerplus.config.TweakerPlusConfigs;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.item.EnchantedBookItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.Map;
import java.util.Set;

@Mixin(ItemRenderer.class)
public class ItemRendererMixin {
@Shadow
public float zOffset;

@Inject(
method = "renderGuiItemOverlay(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V",
at = @At(value = "RETURN")
)
private void onRenderItem(TextRenderer fontRenderer, ItemStack stack, int x, int y, String amountText, CallbackInfo ci) {
if (!TweakerPlusConfigs.ENCHANTED_BOOK_HINT.getBooleanValue()) return;

Item item = stack.getItem();
if (!(item instanceof EnchantedBookItem)) return;
MatrixStack matrixStack = new MatrixStack();
matrixStack.translate(x / 2.0, y / 2.0, (this.zOffset + 200.0F));
matrixStack.scale(0.5F, 0.5F, 0.5F);
VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer());

Set<Map.Entry<Enchantment, Integer>> entries = EnchantmentHelper.getEnchantments(stack).entrySet();
int currentY = y + 17 - entries.size() * 9 / 2;

for (Map.Entry<Enchantment, Integer> entry : entries) {
String string = entry.getKey().getName(entry.getValue()).getString();
fontRenderer.draw(
string,
(float) (x + 17 - fontRenderer.getStringWidth(string) / 2),
(float) (currentY),
16777215,
true,
matrixStack.peek().getModel(),
immediate,
false,
0,
15728880
);
currentY += 9;
}
immediate.draw();
}
}
4 changes: 4 additions & 0 deletions src/main/resources/assets/tweakerplus/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
"tweakerplus.config.disableEndermanAngrySound.comment": "Disable the enderman angry sound",
"tweakerplus.config.disableEndermanAngrySound.pretty_name": "Disable Enderman Angry Sound",

"tweakerplus.config.enchantedBookHint": "enchantedBookHint",
"tweakerplus.config.enchantedBookHint.comment": "Render all its enchantments on the enchantment book item\nTexts may be blocked if there are too many enchantments",
"tweakerplus.config.enchantedBookHint.pretty_name": "Enchanted Book Hint",

"// Mod Tweaks": "================================================",

"tweakerplus.config.leftAlignTitleGlobally": "leftAlignTitleGlobally",
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/assets/tweakerplus/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
"tweakerplus.config.disableEndermanAngrySound.comment": "禁用末影人被激怒后的音效",
"tweakerplus.config.disableEndermanAngrySound.pretty_name": "禁用末影人生气音效",

"tweakerplus.config.enchantedBookHint": "附魔书附魔提示",
"tweakerplus.config.enchantedBookHint.comment": "在附魔书物品上渲染它的所有附魔\n在附魔较多时文字可能会阻挡",
"tweakerplus.config.enchantedBookHint.pretty_name": "附魔书附魔提示",

"// Mod Tweaks": "================================================",

"tweakerplus.config.leftAlignTitleGlobally": "全局左对齐标题",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/tweakerplus.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"tweaks.disablePortalTeleportSound.WorldRendererMixin",
"tweaks.disablePumpkinOverlay.InGameHudMixin",
"tweaks.disableWitherSpawnSound.WorldRendererMixin",
"tweaks.enchantmentBookHint.ItemRendererMixin",
"tweaks.immediatelyRespawn.ClientPlayNetworkHandlerMixin",
"tweaks.limitWorldModification.ClientPlayerInteractionManagerMixin",
"tweaks.playerListScale.PlayerListHudMixin",
Expand Down

0 comments on commit eaa0c62

Please sign in to comment.