|
|
|
// 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);
|
|
|
|
});
|
|
|
|
});
|