# Contributors:
# - Pierrelasse#3737
# - Lolzy#7652
# - DeafMole#2930
on load:
set {-cache::wheatgen} to hay block named "&e&lWheat Gen" with lore "&7-----&8-----%nl%&7Produces wheat every 10 seconds%nl%&7Upgrade cost: &e500⛃%nl%&7-----&8-----"
set {-cache::wheatdrop} to wheat named "&e&lWheat" with lore "&7-----&8-----%nl%&eWorth 10⛃%nl%&7-----&8-----"
on command:
if command is "ggen":
cancel event
give {-cache::wheatgen} to player
on place of hay block:
event is not cancelled
if 1 of player's tool is {-cache::wheatgen}:
set {_i} to 0
loop {gens::*}:
loop-value is player's uuid
add 1 to {_i}
if {_i} > 10 -1:
send "%nl%&bYou reached your Gen-Cap! &7%{_i}%&8/&710%nl%"
cancel event
else:
if {gens::%event-block's location%} is set:
broadcast "&4%player% is tryin to exploit da system! or sum bug is ther"
stop
set {gens::%event-block's location%} to player's uuid
play sound "block.note_block.pling" at volume 1 at pitch 2 to player
make 10 of poof at event-block
send "&aGen placed!"
every 80 tick:
loop {gens::*}:
(loop-value parsed as player) is online
set {_l::*} to loop-index split at ":"
set {_c::*} to {_l::2} split at ","
set {_loc} to location({_c::1} parsed as number,{_c::2} parsed as number,{_c::3} parsed as number, world {_l::1})
set {_b} to block at {_loc}
if type of {_b} is hay block:
drop {-cache::wheatdrop} above {_b} without velocity
else:
clear {gens::%loop-index%}
send "[Gen] Removed gen from list since there is no gen!" to console
on leftclick on hay block:
set {_e} to "%event-block's world%:%event-block's x-coord%,%event-block's y-coord%,%event-block's z-coord%"
if ({gens::%{_e}%} parsed as player) is not player:
send "&cSorry, but you cant break gens from others!"
cancel event
stop
if player is not sneaking:
send "&cPlease sneak to confirm removing the gen!"
stop
clear {gens::%event-block's location%}
set event-block to air
give {-cache::wheatgen} to player
send "&aGen destoryed!"
play sound "block.note_block.pling" at volume 1 at pitch 1 to player
make 10 of poof above event-block
on block break:
event-block is hay block
cancel event