Add 'belowname_display_1.16.5-skript-packet.sk'
This commit is contained in:
parent
c6d97972d3
commit
765579bbec
102
belowname_display_1.16.5-skript-packet.sk
Normal file
102
belowname_display_1.16.5-skript-packet.sk
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
#made by Govindas @ limework.net
|
||||||
|
|
||||||
|
import:
|
||||||
|
net.minecraft.server.v1_16_R3.IScoreboardCriteria$EnumScoreboardHealthDisplay
|
||||||
|
net.minecraft.server.v1_16_R3.ScoreboardServer$Action
|
||||||
|
on script load:
|
||||||
|
#remove scoreboard objective packet
|
||||||
|
|
||||||
|
set {-scoreboard_objective_remove_packet} to new play_server_scoreboard_objective packet
|
||||||
|
|
||||||
|
set field 3 of {-scoreboard_objective_remove_packet} to 1 #1 means remove
|
||||||
|
|
||||||
|
#create scoreboard objective packet
|
||||||
|
|
||||||
|
set {-scoreboard_objective_create_packet} to new play_server_scoreboard_objective packet
|
||||||
|
|
||||||
|
set field 3 of {-scoreboard_objective_create_packet} to 0 #0 means create
|
||||||
|
set field 2 of {-scoreboard_objective_create_packet} to EnumScoreboardHealthDisplay.HEARTS
|
||||||
|
|
||||||
|
#update scoreboard objective packet
|
||||||
|
|
||||||
|
set {-scoreboard_objective_update_packet} to new play_server_scoreboard_objective packet
|
||||||
|
set field 3 of {-scoreboard_objective_update_packet} to 2 #2 means update
|
||||||
|
|
||||||
|
#set objective display slot
|
||||||
|
#2 = below name
|
||||||
|
#0 = sidebar
|
||||||
|
|
||||||
|
set {-belowname_display_packet} to new play_server_scoreboard_display_objective packet
|
||||||
|
set field 0 of {-belowname_display_packet} to 2
|
||||||
|
|
||||||
|
#set the number displayed
|
||||||
|
|
||||||
|
set {-scoreboard_score_packet} to new play_server_scoreboard_score packet
|
||||||
|
|
||||||
|
effect set below[ ]name of %player/string% for %player% to %number% named %string%:
|
||||||
|
trigger:
|
||||||
|
#register scoreboard objective
|
||||||
|
if {-hpbelowpacket::%expression 2%} is not set:
|
||||||
|
set {_packet} to {-scoreboard_objective_create_packet}
|
||||||
|
|
||||||
|
#random scoreboard name to support bungeecord
|
||||||
|
|
||||||
|
|
||||||
|
set {_uuid} to first 16 characters of random uuid
|
||||||
|
|
||||||
|
set field 0 of {_packet} to {_uuid}
|
||||||
|
|
||||||
|
set field 1 of {_packet} to nms textcomponent from text (expression 4)
|
||||||
|
|
||||||
|
send packet {_packet} to expression 2
|
||||||
|
set {-hpbelowpacket::%expression 2%} to expression 4
|
||||||
|
|
||||||
|
set {-hpbelowpacketid::%expression 2%} to {_uuid}
|
||||||
|
|
||||||
|
|
||||||
|
#below name display packet, MUST be sent only once
|
||||||
|
set {_packet} to {-belowname_display_packet}
|
||||||
|
set field 1 of {_packet} to {-hpbelowpacketid::%expression 2%}
|
||||||
|
send packet {_packet} to expression 2
|
||||||
|
|
||||||
|
#update the name if objective already present
|
||||||
|
|
||||||
|
else if {-hpbelowpacket::%expression 2%} is not expression 4:
|
||||||
|
|
||||||
|
set {_packet} to {-scoreboard_objective_update_packet}
|
||||||
|
set field 0 of {_packet} to {-hpbelowpacketid::%expression 2%}
|
||||||
|
#1.16
|
||||||
|
set field 1 of {_packet} to nms textcomponent from text (expression 4)
|
||||||
|
|
||||||
|
send packet {_packet} to expression 2
|
||||||
|
set {-hpbelowpacket::%expression 2%} to expression 4
|
||||||
|
|
||||||
|
#set the number displayed
|
||||||
|
|
||||||
|
set {_packet} to {-scoreboard_score_packet}
|
||||||
|
set field 2 of {_packet} to expression 3 #number
|
||||||
|
set field 0 of {_packet} to "%expression 1%" #player name
|
||||||
|
set field 1 of {_packet} to {-hpbelowpacketid::%expression 2%}
|
||||||
|
send packet {_packet} to expression 2
|
||||||
|
|
||||||
|
effect (remove|reset|delete|clear) below[ ]name (for|of) %player%:
|
||||||
|
trigger:
|
||||||
|
#removed this condition... as it was sometimes preventing legitimate reset, maybe sometimes it just needs to do it twice?)
|
||||||
|
#{-hpbelowpacketid::%expression 1%} is set:
|
||||||
|
#needed to re-create the display, to reset it easier
|
||||||
|
#somehow without re-setting it before removing, it bugs out and doesn't let to remove it anymore without relog sometimes
|
||||||
|
set {_id} to "%{-hpbelowpacketid::%expression 1%}%"
|
||||||
|
wait 2 ticks
|
||||||
|
{_id} is "%{-hpbelowpacketid::%expression 1%}%"
|
||||||
|
set belowname of expression 1 for expression 1 to 0 named "reset"
|
||||||
|
set {_packet} to {-scoreboard_objective_remove_packet}
|
||||||
|
set field 0 of {_packet} to {-hpbelowpacketid::%expression 1%}
|
||||||
|
send packet {_packet} to expression 1
|
||||||
|
|
||||||
|
delete {-hpbelowpacketid::%expression 1%} and {-hpbelowpacket::%expression 1%}
|
||||||
|
|
||||||
|
on quit:
|
||||||
|
remove belowname for player
|
||||||
|
on player world change:
|
||||||
|
{-hpbelowpacketid::%player%} is set:
|
||||||
|
remove belowname for player
|
Loading…
Reference in New Issue
Block a user