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 0c086b0 commit 8f0d979
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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.20.4-1.0.0
mod_version=1.20.4-1.1.2
# 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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.traverse.bhc.common.util.HeartType;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
Expand All @@ -27,6 +28,7 @@
import top.theillusivec4.curios.api.type.capability.ICuriosItemHandler;

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

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

Expand Down Expand Up @@ -75,6 +77,11 @@ public AbstractContainerMenu createMenu(int id, Inventory inventory, Player play
public void appendHoverText(ItemStack stack, Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
super.appendHoverText(stack, worldIn, tooltip, flagIn);
tooltip.add(Component.translatable(Util.makeDescriptionId("tooltip", new ResourceLocation(BaubleyHeartCanisters.MODID, "heartamulet"))).setStyle(Style.EMPTY.applyFormat(ChatFormatting.GOLD)));
if(Screen.hasShiftDown()) {
int[] heartCount = getHeartCount(stack);
int heartTotal = IntStream.of(heartCount).sum() / 2;
tooltip.add(Component.translatable(Util.makeDescriptionId("tooltip", new ResourceLocation(BaubleyHeartCanisters.MODID, "heart_amount")), heartTotal).setStyle(Style.EMPTY.applyFormat(ChatFormatting.DARK_RED)));
}
}

public static InteractionHand getHandForAmulet(Player player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.traverse.bhc.common.util.HeartType;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
Expand All @@ -27,6 +28,7 @@
import top.theillusivec4.curios.api.type.capability.ICuriosItemHandler;

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

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

Expand Down Expand Up @@ -73,6 +75,11 @@ public AbstractContainerMenu createMenu(int id, Inventory inventory, Player play
public void appendHoverText(ItemStack stack, Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
super.appendHoverText(stack, worldIn, tooltip, flagIn);
tooltip.add(Component.translatable(Util.makeDescriptionId("tooltip", new ResourceLocation(BaubleyHeartCanisters.MODID, "heartamulet"))).setStyle(Style.EMPTY.applyFormat(ChatFormatting.GOLD)));
if(Screen.hasShiftDown()) {
int[] heartCount = getHeartCount(stack);
int heartTotal = IntStream.of(heartCount).sum() / 2;
tooltip.add(Component.translatable(Util.makeDescriptionId("tooltip", new ResourceLocation(BaubleyHeartCanisters.MODID, "heart_amount")), heartTotal).setStyle(Style.EMPTY.applyFormat(ChatFormatting.DARK_RED)));
}
}

public static InteractionHand getHandForAmulet(Player player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.traverse.bhc.common.util.HeartType;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -111,6 +112,11 @@ public AbstractContainerMenu createMenu(int id, Inventory inventory, Player play
public void appendHoverText(ItemStack stack, Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
super.appendHoverText(stack, worldIn, tooltip, flagIn);
tooltip.add(Component.translatable(Util.makeDescriptionId("tooltip", new ResourceLocation(BaubleyHeartCanisters.MODID, "vitality_blade"))).setStyle(Style.EMPTY.applyFormat(ChatFormatting.GOLD)));
if(Screen.hasShiftDown()) {
int[] heartCount = getHeartCount(stack);
int heartTotal = IntStream.of(heartCount).sum() / 2;
tooltip.add(Component.translatable(Util.makeDescriptionId("tooltip", new ResourceLocation(BaubleyHeartCanisters.MODID, "heart_amount")), heartTotal).setStyle(Style.EMPTY.applyFormat(ChatFormatting.DARK_RED)));
}
}

@Override
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/bhc/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"tooltip.bhc.vitality_blade": "Shift-Right click to open!",
"tooltip.bhc.patch_amount": "Heal Amount: %s",
"tooltip.bhc.patch_durability": "Uses Left: %s",
"tooltip.bhc.heart_amount": "Total Canisters: %s",
"container.bhc.blade_of_vitality": "Vitality Blade",
"soulheartused.bhc.message": "Soul Heart Has Been Consumed!",
"curios.identifier.heart_amulet": "Heart Amulet"
Expand Down

0 comments on commit 8f0d979

Please sign in to comment.