Skip to content

Commit

Permalink
tooltip&rarity
Browse files Browse the repository at this point in the history
  • Loading branch information
PTOM76 committed Jan 26, 2023
1 parent f6f97bc commit 6b609d1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
package com.github.ptom76.tutorialfabricmod.item;

import net.minecraft.client.item.TooltipContext;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Rarity;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class TutorialItem extends Item {
public TutorialItem(Settings settings) {
super(settings);
}

@Override
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
super.appendTooltip(stack, world, tooltip, context);
// ツールチップ追加
// 1.18以前では↓new TranslatableText(key);
tooltip.add(Text.translatable("item.tutorialfabricmod.tutorial_item.tooltip").formatted(Formatting.RED));

// 1.18以前では↓new LiteralText(string);
tooltip.add(Text.literal("§dHello, §bWorld!!"));
}

@Override
public Rarity getRarity(ItemStack stack) {
// レア度
return Rarity.UNCOMMON;
}
}
3 changes: 3 additions & 0 deletions src/main/resources/assets/tutorialfabricmod/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"block.tutorialfabricmod.tutorial_block": "Tutorial Block",
"block.tutorialfabricmod.click_count_block": "Click Count Block",
"block.tutorialfabricmod.blue_apple_generator": "Blue Apple Generator",

"item.tutorialfabricmod.tutorial_item.tooltip": "The item is blue apple.",

"enchantment.tutorialfabricmod.freeze": "Freeze",

"itemGroup.tutorialfabricmod.tutorial": "Tutorial Mod"
Expand Down

0 comments on commit 6b609d1

Please sign in to comment.