Converted charge item tooltip to use lang file. Improved tooltip to display corresponding totem's name.
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
package dev.micle.totem_of_reviving.item.charge;
|
||||
|
||||
import dev.micle.totem_of_reviving.util.LangAsset;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.Item;
|
||||
@ -10,11 +11,13 @@ import net.minecraft.world.item.TooltipFlag;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.List;
|
||||
|
||||
public class ChargeItem extends Item {
|
||||
public abstract class ChargeItem extends Item {
|
||||
public ChargeItem(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public abstract Component getTotemDisplayName();
|
||||
|
||||
public static Properties createProperties(Rarity rarity, boolean isFireResistant) {
|
||||
Properties properties = new Properties().stacksTo(64).rarity(rarity);
|
||||
|
||||
@ -26,7 +29,9 @@ public class ChargeItem extends Item {
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
|
||||
tooltipComponents.add(Component.literal(ChatFormatting.WHITE + "Used for charging its corresponding totem."));
|
||||
tooltipComponents.add(LangAsset.TOOLTIP_CHARGE.getComponent(
|
||||
getTotemDisplayName()
|
||||
).withStyle(ChatFormatting.GRAY));
|
||||
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package dev.micle.totem_of_reviving.item.charge;
|
||||
|
||||
import dev.micle.totem_of_reviving.setup.ModItems;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
|
||||
public class DiamondChargeItem extends ChargeItem {
|
||||
@ -10,4 +12,9 @@ public class DiamondChargeItem extends ChargeItem {
|
||||
public static String getName() {
|
||||
return "diamond_charge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTotemDisplayName() {
|
||||
return ModItems.DIAMOND_TOTEM.get().getDefaultInstance().getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package dev.micle.totem_of_reviving.item.charge;
|
||||
|
||||
import dev.micle.totem_of_reviving.setup.ModItems;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
|
||||
public class IronChargeItem extends ChargeItem {
|
||||
@ -10,4 +12,9 @@ public class IronChargeItem extends ChargeItem {
|
||||
public static String getName() {
|
||||
return "iron_charge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTotemDisplayName() {
|
||||
return ModItems.IRON_TOTEM.get().getDefaultInstance().getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package dev.micle.totem_of_reviving.item.charge;
|
||||
|
||||
import dev.micle.totem_of_reviving.setup.ModItems;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
|
||||
public class NetheriteChargeItem extends ChargeItem {
|
||||
@ -10,4 +12,9 @@ public class NetheriteChargeItem extends ChargeItem {
|
||||
public static String getName() {
|
||||
return "netherite_charge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTotemDisplayName() {
|
||||
return ModItems.NETHERITE_TOTEM.get().getDefaultInstance().getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package dev.micle.totem_of_reviving.item.charge;
|
||||
|
||||
import dev.micle.totem_of_reviving.setup.ModItems;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
|
||||
public class StrawChargeItem extends ChargeItem {
|
||||
@ -10,4 +12,9 @@ public class StrawChargeItem extends ChargeItem {
|
||||
public static String getName() {
|
||||
return "straw_charge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTotemDisplayName() {
|
||||
return ModItems.STRAW_TOTEM.get().getDefaultInstance().getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ public enum LangAsset {
|
||||
TOOLTIP_TOTEM_REVIVE_INSTRUCTION("tooltip", "totem_revive_instruction"),
|
||||
TOOLTIP_TOTEM_CHARGE_INSTRUCTION("tooltip", "totem_charge_instruction"),
|
||||
TOOLTIP_TOTEM_CHANGE_TARGET_INSTRUCTION("tooltip", "totem_change_target_instructions"),
|
||||
TOOLTIP_CHARGE("tooltip", "charge"),
|
||||
TOOLTIP_ADVANCED_TOOLTIP_HIDDEN("tooltip", "advanced_tooltip_hidden"),
|
||||
TOOLTIP_ADVANCED_TOOLTIP_SHOWN("tooltip", "advanced_tooltip_shown"),
|
||||
GENERAL_NA("general", "na"),
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
"tooltip.totem_of_reviving.totem_revive_instruction": "When second hand is empty: revive target.",
|
||||
"tooltip.totem_of_reviving.totem_charge_instruction": "When second hand has a reviving charge: charge totem.",
|
||||
"tooltip.totem_of_reviving.totem_change_target_instructions": "Change target.",
|
||||
"tooltip.totem_of_reviving.charge": "Used for charging the %s",
|
||||
"tooltip.totem_of_reviving.advanced_tooltip_hidden": "Hold %s for advanced tooltip.",
|
||||
"tooltip.totem_of_reviving.advanced_tooltip_shown": "Showing advanced tooltip:",
|
||||
"general.totem_of_reviving.na": "N/A",
|
||||
|
||||
Reference in New Issue
Block a user