Skip to content

Commit

Permalink
Added Tooltip for Canister Holding Items
Browse files Browse the repository at this point in the history
  • Loading branch information
Traverse-Joe committed Nov 19, 2024
1 parent 39c7b18 commit 0e3d45e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mod_name=Baubley Heart Canisters
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=MIT
# The mod version. See https://semver.org/
mod_version=1.1.2
mod_version=1.2.0
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/traverse/bhc/common/items/ItemHeartAmulet.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.traverse.bhc.common.items;

import com.traverse.bhc.common.BaubleyHeartCanisters;
import com.traverse.bhc.common.container.HeartAmuletContainer;
import com.traverse.bhc.common.init.RegistryHandler;
import com.traverse.bhc.common.util.HealthModifier;
import com.traverse.bhc.common.util.HeartType;
import com.traverse.bhc.common.util.SoulContainerProvider;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.LivingEntity;
Expand All @@ -22,6 +26,7 @@

import java.util.Arrays;
import java.util.List;
import java.util.stream.IntStream;

import static com.traverse.bhc.common.util.HealthModifier.updatePlayerHealth;

Expand All @@ -48,6 +53,11 @@ public InteractionResultHolder<ItemStack> use(Level level, Player player, Intera
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
tooltipComponents.add(Component.translatable(Util.makeDescriptionId("tooltip", RegistryHandler.HEART_AMULET.getId())).withStyle(ChatFormatting.GOLD));
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
if(Screen.hasShiftDown()) {
int[] heartCount = new int[]{HealthModifier.getHeartCount(stack)};
int heartTotal = IntStream.of(heartCount).sum();
tooltipComponents.add(Component.translatable(Util.makeDescriptionId("tooltip", BaubleyHeartCanisters.id("heart_amount")), heartTotal).setStyle(Style.EMPTY.applyFormat(ChatFormatting.DARK_RED)));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.traverse.bhc.common.items;

import com.traverse.bhc.common.BaubleyHeartCanisters;
import com.traverse.bhc.common.container.SoulHeartAmuletContainer;
import com.traverse.bhc.common.init.RegistryHandler;
import com.traverse.bhc.common.util.HealthModifier;
import com.traverse.bhc.common.util.SoulContainerProvider;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.world.InteractionHand;
Expand All @@ -18,6 +21,7 @@
import top.theillusivec4.curios.api.type.capability.ICurioItem;

import java.util.List;
import java.util.stream.IntStream;

import static com.traverse.bhc.common.util.HealthModifier.updatePlayerHealth;

Expand Down Expand Up @@ -46,6 +50,11 @@ public InteractionResultHolder<ItemStack> use(Level level, Player player, Intera
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
tooltipComponents.add(Component.translatable(Util.makeDescriptionId("tooltip", RegistryHandler.HEART_AMULET.getId())).setStyle(Style.EMPTY.applyFormat(ChatFormatting.GOLD)));
if(Screen.hasShiftDown()) {
int[] heartCount = new int[]{HealthModifier.getHeartCount(stack)};
int heartTotal = IntStream.of(heartCount).sum();
tooltipComponents.add(Component.translatable(Util.makeDescriptionId("tooltip", BaubleyHeartCanisters.id("heart_amount")), heartTotal).setStyle(Style.EMPTY.applyFormat(ChatFormatting.DARK_RED)));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.traverse.bhc.common.util.SoulContainerProvider;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.Holder;
import net.minecraft.core.component.DataComponents;
import net.minecraft.network.chat.Component;
Expand All @@ -31,6 +32,7 @@
import net.neoforged.neoforge.event.ItemAttributeModifierEvent;

import java.util.List;
import java.util.stream.IntStream;

@EventBusSubscriber(modid = BaubleyHeartCanisters.MODID, bus = EventBusSubscriber.Bus.GAME)
public class ItemBladeOfVitality extends SwordItem implements SoulContainerProvider {
Expand Down Expand Up @@ -101,6 +103,11 @@ public static void onAttributeModifiers(ItemAttributeModifierEvent event) {
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
tooltipComponents.add(Component.translatable(Util.makeDescriptionId("tooltip", RegistryHandler.BLADE_OF_VITALITY.getId())).setStyle(Style.EMPTY.applyFormat(ChatFormatting.GOLD)));
if(Screen.hasShiftDown()) {
int[] heartCount = new int[]{HealthModifier.getHeartCount(stack)};
int heartTotal = IntStream.of(heartCount).sum();
tooltipComponents.add(Component.translatable(Util.makeDescriptionId("tooltip", BaubleyHeartCanisters.id("heart_amount")), heartTotal).setStyle(Style.EMPTY.applyFormat(ChatFormatting.DARK_RED)));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.traverse.bhc.common.util.SoulContainerProvider;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -26,6 +27,7 @@
import net.neoforged.neoforge.event.EventHooks;

import java.util.List;
import java.util.stream.IntStream;

public class ItemVigorBow extends BowItem implements SoulContainerProvider {

Expand Down Expand Up @@ -126,5 +128,11 @@ public void appendHoverText(ItemStack stack, TooltipContext context, List<Compon
if(HealthModifier.getHeartCount(stack) > 0) {
tooltipComponents.add(Component.translatable(Util.makeDescriptionId("tooltip", BaubleyHeartCanisters.id("bonus")), HealthModifier.getHeartCount(stack)).setStyle(Style.EMPTY.applyFormat(ChatFormatting.BLUE)));
}
if(Screen.hasShiftDown()) {
int[] heartCount = new int[]{HealthModifier.getHeartCount(stack)};
int heartTotal = IntStream.of(heartCount).sum();
tooltipComponents.add(Component.translatable(Util.makeDescriptionId("tooltip", BaubleyHeartCanisters.id("heart_amount")), heartTotal).setStyle(Style.EMPTY.applyFormat(ChatFormatting.DARK_RED)));
}

}
}
2 changes: 1 addition & 1 deletion src/main/resources/assets/bhc/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"tooltip.bhc.blade_of_vitality": "Sneak + right click to open!",
"tooltip.bhc.patch_amount": "Heal Amount: %s",
"tooltip.bhc.patch_durability": "Remaining uses: %s",
"tooltip.bhc.heart_amount": "Total Canisters: %s",
"tooltip.bhc.bonus": "+%s Bonus Damage",

"message.bhc.soul_heart_used": "Soul Heart Has Been Consumed!",
"curios.identifier.heart_amulet": "Heart Amulet"
}

0 comments on commit 0e3d45e

Please sign in to comment.