Files
plugins
Code
3 540
plugins/Skript/scripts/redstoneperformance-core.sk
# Redstone Performance Core
# Place this file in plugins/Skript/scripts/
#
# Important:
# Skript cannot directly modify a Minecraft client's renderer, measure client FPS,
# create client keybinds, or hide blocks without packet/client modifications.
# This script therefore performs safe server-side detection, chunk caching,
# activity scoring, render-profile selection, and optional HUD/config integration.
# It never changes redstone mechanics, block states, packets, explosions, or inventories.
options:
prefix: &8[&cRedstonePerformance&8]&r
scan-radius: 16
scan-interval: 10 seconds
rescan-distance: 8
max-dirty-updates: 200
default-mode: SMART
dynamic-optimization: true
target-fps: 60
debug-by-default: false
on script load:
if {rp.enabled} is not set:
set {rp.enabled} to true
if {rp.global-mode} is not set:
set {rp.global-mode} to "{@default-mode}"
if {rp.debug} is not set:
set {rp.debug} to {@debug-by-default}
loop all players:
set {_id} to uuid of loop-player
if {rp.settings::%{_id}%::enabled} is not set:
set {rp.settings::%{_id}%::enabled} to true
if {rp.settings::%{_id}%::mode} is not set:
set {rp.settings::%{_id}%::mode} to "{@default-mode}"
if {rp.settings::%{_id}%::hud} is not set:
set {rp.settings::%{_id}%::hud} to false
if {rp.settings::%{_id}%::emergency} is not set:
set {rp.settings::%{_id}%::emergency} to false
if {rp.settings::%{_id}%::dust} is not set:
set {rp.settings::%{_id}%::dust} to true
if {rp.settings::%{_id}%::pistons} is not set:
set {rp.settings::%{_id}%::pistons} to true
if {rp.settings::%{_id}%::observers} is not set:
set {rp.settings::%{_id}%::observers} to true
if {rp.settings::%{_id}%::tnt} is not set:
set {rp.settings::%{_id}%::tnt} to true
if {rp.settings::%{_id}%::particles} is not set:
set {rp.settings::%{_id}%::particles} to true
send "{@prefix} &aLoaded safely. Redstone mechanics remain unchanged." to console
function rp_is_redstone_component(b: block) :: boolean:
if {_b} is redstone wire:
return true
if {_b} is redstone block:
return true
if {_b} is redstone torch:
return true
if {_b} is redstone wall torch:
return true
if {_b} is piston:
return true
if {_b} is sticky piston:
return true
if {_b} is observer:
return true
if {_b} is dispenser:
return true
if {_b} is dropper:
return true
if {_b} is hopper:
return true
if {_b} is redstone repeater:
return true
if {_b} is redstone comparator:
return true
if {_b} is note block:
return true
if {_b} is tnt:
return true
if {_b} is lever:
return true
if {_b} is stone pressure plate:
return true
if {_b} is oak pressure plate:
return true
if {_b} is redstone ore:
return true
if {_b} is deepslate redstone ore:
return true
return false
function rp_chunk_key(b: block) :: text:
return "%world of {_b}%::%chunk at {_b}%"
function rp_activity_name(score: number) :: text:
if {_score} <= 10:
return "LOW"
if {_score} <= 50:
return "MEDIUM"
if {_score} <= 150:
return "HIGH"
return "EXTREME"
function rp_scan(p: player):
set {_id} to uuid of {_p}
set {_chunk-key} to "%world of {_p}%::%chunk at {_p}%"
set {_updates} to {rp.dirty-updates::%{_chunk-key}%}
if {_updates} is not set:
set {_updates} to 0
set {_moved} to true
if {rp.last-location::%{_id}%} is set:
if distance between {_p} and {rp.last-location::%{_id}%} is less than {@rescan-distance}:
set {_moved} to false
set {_should-scan} to false
if {rp.last-scan::%{_id}%} is not set:
set {_should-scan} to true
else if {_moved} is true:
set {_should-scan} to true
else if {_updates} is greater than 0:
set {_should-scan} to true
if {_should-scan} is false:
stop
set {_dust} to 0
set {_redstone-blocks} to 0
set {_pistons} to 0
set {_observers} to 0
set {_dispensers} to 0
set {_droppers} to 0
set {_hoppers} to 0
set {_repeaters} to 0
set {_comparators} to 0
set {_note-blocks} to 0
set {_tnt-blocks} to 0
set {_torches} to 0
set {_controllers} to 0
loop blocks in radius {@scan-radius} around {_p}:
if loop-block is redstone wire:
add 1 to {_dust}
else if loop-block is redstone block:
add 1 to {_redstone-blocks}
else if loop-block is piston:
add 1 to {_pistons}
else if loop-block is sticky piston:
add 1 to {_pistons}
else if loop-block is observer:
add 1 to {_observers}
else if loop-block is dispenser:
add 1 to {_dispensers}
else if loop-block is dropper:
add 1 to {_droppers}
else if loop-block is hopper:
add 1 to {_hoppers}
else if loop-block is redstone repeater:
add 1 to {_repeaters}
else if loop-block is redstone comparator:
add 1 to {_comparators}
else if loop-block is note block:
add 1 to {_note-blocks}
else if loop-block is tnt:
add 1 to {_tnt-blocks}
else if loop-block is redstone torch:
add 1 to {_torches}
else if loop-block is redstone wall torch:
add 1 to {_torches}
else if loop-block is lever:
add 1 to {_controllers}
else if loop-block is stone pressure plate:
add 1 to {_controllers}
else if loop-block is oak pressure plate:
add 1 to {_controllers}
set {_tnt-entities} to 0
set {_tnt-minecarts} to 0
loop entities in radius {@scan-radius} around {_p}:
if loop-entity is primed tnt:
add 1 to {_tnt-entities}
else if loop-entity is tnt minecart:
add 1 to {_tnt-minecarts}
set {_score} to {_dust}
add {_redstone-blocks} to {_score}
add {_pistons} * 3 to {_score}
add {_observers} * 3 to {_score}
add {_dispensers} * 2 to {_score}
add {_droppers} * 2 to {_score}
add {_hoppers} * 2 to {_score}
add {_repeaters} * 2 to {_score}
add {_comparators} * 2 to {_score}
add {_note-blocks} to {_score}
add {_tnt-blocks} * 2 to {_score}