Minecraft Modpack
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.
 

39 lines
1.4 KiB

// priority: 0
const ItemDescription = java('com.simibubi.create.foundation.item.ItemDescription');
const Palette = java('com.simibubi.create.foundation.item.ItemDescription$Palette');
onEvent('item.tooltip', event => {
event.addAdvanced('tiab:time_in_a_bottle', (item, _, tooltip) => {
tooltip.pop(); // Remove "Stored time hh:mm:ss" line
let name = tooltip[0];
let time = item.nbt.getInt('storedTime') / 20;
let hours = Math.floor(time / 3600);
let minutes = Math.floor(time % 3600 / 60);
let seconds = Math.floor(time % 3600 % 60);
if (hours > 0 || minutes > 0 || seconds > 0) {
name.append(Component.string(" ("));
if (hours > 0)
name.append(Component.string(`${hours}h`));
if (minutes > 0)
name.append(Component.string(`${minutes}m`));
if (seconds > 0)
name.append(Component.string(`${seconds}s`));
name.append(Component.string(")"));
}
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);
});
});