35 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package com.smthng.jennyutil.items;
 | |
| 
 | |
| import com.smthng.jennyutil.Jennyutil;
 | |
| import net.minecraft.ChatFormatting;
 | |
| import net.minecraft.network.chat.Component;
 | |
| import net.minecraft.network.chat.MutableComponent;
 | |
| import net.minecraft.world.item.BlockItem;
 | |
| import net.minecraft.world.item.ItemStack;
 | |
| import net.minecraft.world.item.TooltipFlag;
 | |
| import net.minecraft.world.level.Level;
 | |
| import net.minecraft.world.level.block.Block;
 | |
| import net.minecraftforge.registries.ForgeRegistries;
 | |
| import org.jetbrains.annotations.NotNull;
 | |
| import org.jetbrains.annotations.Nullable;
 | |
| 
 | |
| import java.util.List;
 | |
| 
 | |
| public class BlockItemTooltip extends BlockItem {
 | |
|     public BlockItemTooltip(Block pBlock, Properties pProperties) {
 | |
|         super(pBlock, pProperties);
 | |
|     }
 | |
| 
 | |
|     @Override
 | |
|     public void appendHoverText(@NotNull ItemStack pStack, @Nullable Level pLevel, @NotNull List<Component> pTooltipComponents, @NotNull TooltipFlag pIsAdvanced) {
 | |
|         String key = String.format("tooltip.%s", ForgeRegistries.ITEMS.getKey(this).toString().replaceFirst(":", "."));
 | |
|         MutableComponent toolTip = Component.translatable(key);
 | |
|         if (!toolTip.getString().equals(key)) {
 | |
|             pTooltipComponents.add(toolTip.withStyle(ChatFormatting.DARK_BLUE));
 | |
|             super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced);
 | |
|         } else {
 | |
|             Jennyutil.LOGGER.debug(String.format("BlockItemTooltip missing tooltip \"%s\"", key));
 | |
|         }
 | |
|     }
 | |
| }
 |