Well-rounded Minecraft 1.18.2 modpack featuring Tech, Magic, Exploration and Decoration content. Made with love. 💚
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.3 KiB

// priority: 0
onEvent("item.tooltip", event => {
const ItemDescription = java("com.simibubi.create.foundation.item.ItemDescription");
const Palette = java("com.simibubi.create.foundation.item.ItemDescription$Palette");
event.addAdvanced("tiab:time_in_a_bottle", (item, _, tooltip) => {
let name = tooltip[0];
tooltip.pop(); // Remove "Stored time hh:mm:ss" line.
let storedTime = item.nbt.getInt("storedTime");
let totalSeconds = Math.floor(storedTime / 20);
let totalMinutes = Math.floor(totalSeconds / 60)
let totalHours = Math.floor(totalMinutes / 60);
if (totalSeconds > 0) {
name.append(" (");
if (totalHours > 0) name.append(`${totalHours}h`);
if (totalMinutes > 0) name.append(`${totalMinutes % 60}m`);
name.append(`${totalSeconds % 60}s)`);
}
new ItemDescription(Palette.Gray)
.withSummary(Component.translate("item.tiab.time_in_a_bottle.tooltip.summary"))
// Create expects localized strings instead of components here, so we localize ourselves
.withControl(Component.translate("item.tiab.time_in_a_bottle.tooltip.condition").string,
Component.translate("item.tiab.time_in_a_bottle.tooltip.behaviour").string)
.createTabs()
.addInformation(tooltip);
});
});