Skip to content

Commit

Permalink
Add MiningLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
flier268 committed Nov 27, 2020
1 parent e8919ce commit 4150389
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/flier268/more_tooltips/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class ModConfig implements ConfigData {
public Options TranslationKey = Options.onDebug;
public Options RepairCost = Options.onShift;
public Options Enchantability = Options.onShift;
public Options MiningLevel = Options.show;

public enum Options {
hide,
Expand Down
23 changes: 18 additions & 5 deletions src/main/java/com/flier268/more_tooltips/TooltipEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import net.minecraft.block.entity.AbstractFurnaceBlockEntity;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.PickaxeItem;
import net.minecraft.item.ToolItem;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.tag.ItemTags;
import net.minecraft.text.LiteralText;
Expand All @@ -14,6 +17,7 @@
import net.minecraft.util.Formatting;
import net.minecraft.util.registry.Registry;

import javax.tools.Tool;
import java.awt.*;
import java.text.DecimalFormat;

Expand All @@ -37,10 +41,11 @@ public static void addMoreTooltip() {
if (itemStack.isEmpty()) {
return;
}
Item item = itemStack.getItem();
// Tooltip - Burn Time
if (config.BurnTime.isShown(isShiftDown, config.debug)) {
if (ItemTags.getTagGroup().getTags().size() > 0) {
int burnTime = AbstractFurnaceBlockEntity.createFuelTimeMap().getOrDefault(itemStack.getItem(), 0);
int burnTime = AbstractFurnaceBlockEntity.createFuelTimeMap().getOrDefault(item, 0);
if (burnTime > 0) {
list.add(new TranslatableText("tooltip.more_tooltips.burnTime")
.append(new LiteralText(" " + decimalFormat.format(burnTime) + " "))
Expand All @@ -49,7 +54,15 @@ public static void addMoreTooltip() {
}
}
}


// Tooltip - MiningLevel
if (config.MiningLevel.isShown(isShiftDown, config.debug)) {
if(item instanceof ToolItem) {
int miningLevel = ((ToolItem) item).getMaterial().getMiningLevel();
list.add(1, new TranslatableText("tooltip.more_tooltips.MiningLevel")
.append(new LiteralText(" " + miningLevel)));
}
}

// Tooltip - Durability
if (config.Durability.isShown(isShiftDown, config.debug)) {
Expand All @@ -64,7 +77,7 @@ public static void addMoreTooltip() {
// Tooltip - Hunger / Saturation
if (config.Food.isShown(isShiftDown, config.debug)) {
if (itemStack.isFood()) {
FoodComponent foodComponent = itemStack.getItem().getFoodComponent();
FoodComponent foodComponent = item.getFoodComponent();
int healVal = foodComponent.getHunger();
float satVal = healVal * (foodComponent.getSaturationModifier()) * 2;
list.add(new TranslatableText("tooltip.more_tooltips.hunger")
Expand All @@ -89,7 +102,7 @@ public static void addMoreTooltip() {
// Tooltip - Registry Name
if (config.ID.isShown(isShiftDown, config.debug)) {
list.add(new TranslatableText("tooltip.more_tooltips.registryName")
.append(new LiteralText(" " + Registry.ITEM.getId(itemStack.getItem()).toString()))
.append(new LiteralText(" " + Registry.ITEM.getId(item).toString()))
.fillStyle(DARK_GRAY));
}

Expand Down Expand Up @@ -121,7 +134,7 @@ public static void addMoreTooltip() {
if (config.Enchantability.isShown(isShiftDown, config.debug)) {
if (itemStack.isEnchantable()) {
list.add(new TranslatableText("tooltip.more_tooltips.Enchantability")
.append(new LiteralText(" " + itemStack.getItem().getEnchantability()))
.append(new LiteralText(" " + item.getEnchantability()))
.fillStyle(DARK_GRAY));
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/assets/more_tooltips/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"text.autoconfig.more_tooltips.option.TranslationKey": "Translation Key Tooltip",
"text.autoconfig.more_tooltips.option.RepairCost": "Exp Cost when repair",
"text.autoconfig.more_tooltips.option.Enchantability": "Enchantability of tool",
"text.autoconfig.more_tooltips.option.MiningLevel": "Mining Level of tool",

"_comment": "Tooltips",
"tooltip.more_tooltips.burnTime": "Burn Time:",
Expand All @@ -27,5 +28,6 @@
"tooltip.more_tooltips.registryName": "ID:",
"tooltip.more_tooltips.translationKey": "Translation Key:",
"tooltip.more_tooltips.RepairCost": "Repair Cost:",
"tooltip.more_tooltips.Enchantability": "Enchantability:"
"tooltip.more_tooltips.Enchantability": "Enchantability:",
"tooltip.more_tooltips.MiningLevel": "Mining Level:"
}
4 changes: 3 additions & 1 deletion src/main/resources/assets/more_tooltips/lang/zh_tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"text.autoconfig.more_tooltips.option.TranslationKey": "語言文件ID",
"text.autoconfig.more_tooltips.option.RepairCost": "修復所需經驗",
"text.autoconfig.more_tooltips.option.Enchantability": "附魔性",
"text.autoconfig.more_tooltips.option.MiningLevel": "挖掘等級",

"_comment": "Tooltips",
"tooltip.more_tooltips.burnTime": "燃燒時間:",
Expand All @@ -27,5 +28,6 @@
"tooltip.more_tooltips.registryName": "ID:",
"tooltip.more_tooltips.translationKey": "語言文件ID:",
"tooltip.more_tooltips.RepairCost": "修復需要經驗:",
"tooltip.more_tooltips.Enchantability": "附魔性:"
"tooltip.more_tooltips.Enchantability": "附魔性:",
"tooltip.more_tooltips.MiningLevel": "挖掘等級:"
}

0 comments on commit 4150389

Please sign in to comment.