Add Create-themed tooltip for Time In A Bottle #2
Merged
copygirl
merged 1 commits from HeckinChloe/heck:time-in-a-bottle
into main
2 years ago
2 changed files with 45 additions and 0 deletions
@ -0,0 +1,6 @@ |
|||||||
|
{ |
||||||
|
"item.tiab.time_in_a_bottle": "Time In A Bottle", |
||||||
|
"item.tiab.time_in_a_bottle.tooltip.summary": "A _solitary_ bottle of tick-manipulating power that _accumulates time_ when carried in _your inventory_. Can be used to _accelerate_ machine speed and plant growth.", |
||||||
|
"item.tiab.time_in_a_bottle.tooltip.condition": "R-Click on Block", |
||||||
|
"item.tiab.time_in_a_bottle.tooltip.behaviour": "_Multiplies_ the speed of the targeted block by a power of two, _consuming_ 30s from the bottle per multiplier. The effect _expires_ after 30s." |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
// 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); |
||||||
|
}); |
||||||
|
}); |
Loading…
Reference in new issue