Files
ClientSideFarming.sk
Code
1 71
ClientSideFarming.sk
# ============================================================
# ClientSideFarming.sk
# Client-side block farming — fake breaks per player only
# Requires: SkBee, SkPoa
# ============================================================
options:
# World where client-side farming is active
farming-world: world
# Delay in seconds before the block visually restores
default-regen-delay: 30
crop-regen-delay: 20
prefix: &8[&aFarming&8]&r
# ---- Crop type check function ----
# Returns true if the block is a crop-type (should show air on break)
function isCropBlock(b: block) :: boolean:
set {_type} to type of {_b}
if {_type} is wheat, carrots, potatoes, beetroots, nether wart, cocoa, sweet berry bush, cave vines, cave vines plant, pitcher crop, torchflower crop:
return true
return false
# ---- On block break ----
on break:
# Only active in the configured world
if world of event-block is not world({@farming-world}):
stop
# Only players
if event is not cancelled:
set {_loc} to location of event-block
set {_block} to event-block
set {_type} to type of event-block
set {_player} to player
# Cancel the real break — block stays for everyone else
cancel event
# Determine what fake block to show the breaking player
if isCropBlock(event-block) is true:
set {_fake} to air
set {_delay} to {@crop-regen-delay}
else:
set {_fake} to bedrock
set {_delay} to {@default-regen-delay}
# Show the fake broken state only to this player
set {_player}'s fake block at {_loc} to {_fake}
# Mark this location as "broken" for this player
set {clientfarm::%{_player}%::%{_loc}%} to {_type}
# Schedule regen for this player at this location
wait {_delay} seconds
# Only restore if still marked (not already restored)
if {clientfarm::%{_player}%::%{_loc}%} is set:
# Remove the fake block — player sees the real block again
reset {_player}'s fake block at {_loc}
delete {clientfarm::%{_player}%::%{_loc}%}
# ---- Cleanup on player quit ----
on quit:
# Clear all fake block entries for this player
loop indices of {clientfarm::%player%::*}:
set {_loc} to loop-value parsed as location
if {_loc} is set:
reset player's fake block at {_loc}
delete {clientfarm::%player%::*}