import:
eu.decentsoftware.holograms.api.DHAPI
eu.decentsoftware.holograms.api.holograms.Hologram
java.util.List
java.util.ArrayList
java.util.Collection
options:
world: world "world"
on unload:
loop {brokenWheats::*}:
set block at loop-value to ripe wheat plant
DHAPI.removeHologram(loop-index)
delete {brokenWheats::%loop-index%}
delete {brokenWheats::*}
on break:
if {brokenWheats::farmland::*} contains event-block:
cancel event
stop
if {brokenWheats::*} contains event-block:
cancel event
stop
if event-block is a ripe wheat plant:
wheatBreak(event-block)
local function wheatBreak(block: block):
if world of location of {_block} is {@world}:
set {_id} to size of {brokenWheats::*} + 1
set {brokenWheats::%{_id}%} to {_block}
set {brokenWheats::time::%{_id}%} to 180 # süre
set {brokenWheats::farmland::%{_id}%} to block under {_block}
set {_hloc} to location of {_block}
add 0.77 to y-coord of {_hloc}
set {_lines} to new ArrayList()
{_lines}.add("")
DHAPI.createHologram("%{_id}%", {_hloc}, false, {_lines})
updateWheatTime({_id})
wait a tick
set block at {_block} to wheat item
local function updateWheatTime(id: int):
while {brokenWheats::%{_id}%} is set:
set {_holo} to DHAPI.getHologram("%{_id}%")
set {_page} to DHAPI.getHologramPage({_holo}, 0)
set {_hololine} to DHAPI.getHologramLine({_page}, 0)
DHAPI.setHologramLine({_hololine}, "<#40ff00>%getFormattedTime({brokenWheats::time::%{_id}%})%")
wait a second
remove 1 from {brokenWheats::time::%{_id}%}
if {brokenWheats::time::%{_id}%} <= 0:
set block at {brokenWheats::%{_id}%} to ripe wheat plant
DHAPI.removeHologram("%{_id}%")
delete {brokenWheats::farmland::%{_id}%}
delete {brokenWheats::%{_id}%}
DHAPI.removeHologram("%{_id}%")
local function getFormattedTime(t: int) :: string:
set {_minutes} to floor({_t} / 60)
set {_seconds} to mod({_t}, 60)
# Eğer dakika tek haneliyse başına 0 ekle
set {_formattedMinutes} to "%{_minutes}%"
if {_minutes} < 10:
set {_formattedMinutes} to "0%{_minutes}%"
# Eğer saniye tek haneliyse başına 0 ekle
set {_formattedSeconds} to "%{_seconds}%"
if {_seconds} < 10:
set {_formattedSeconds} to "0%{_seconds}%"
set {_time} to "%{_formattedMinutes}%:%{_formattedSeconds}%"
return {_time}