Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Pikachu920/19bb3cb6f6c7fccb5962d2cce68473a2 to your computer and use it in GitHub Desktop.
Save Pikachu920/19bb3cb6f6c7fccb5962d2cce68473a2 to your computer and use it in GitHub Desktop.
function cursorItem(p: players, i: item):
set {_p} to new play_server_set_slot packet
set int pnum 1 of {_p} to 0
set "ItemModifier" pinfo 0 of {_p} to {_i}
set int pnum 0 of {_p} to -1
loop {_p::*}:
send loop-value packet {_p}
function resetSlot(p: player, t: packet):
set {_n} to new play_server_set_slot packet
set int pnum 1 of {_n} to int pnum 1 of {_t}
set {_s} to int pnum 1 of {_t}
set {_u} to {_p}'s uuid
set {_m} to metadata value "cinv" of {_p}
set "ItemModifier" pinfo 0 of {_n} to {currentslot::%{_u}%::%{_m}%::%{_s}%}
set int pnum 0 of {_n} to int pnum 0 of {_t}
send {_p} packet {_n}
on packet event play_client_window_click:
if {currentslot::%player's uuid%::%int pnum 0 of event-packet%::%int pnum 1 of event-packet%} is set:
cancel the event
resetSlot(player, event-packet)
cursorItem(player, cursor slot of player)
call custom event "gui click" to details player, "%int pnum 1 of event-packet%" parsed as an integer, event-packet and {currentslot::%player's uuid%::%int pnum 0 of event-packet%::%int pnum 1 of event-packet%}
on packet event play_server_open_window:
set metadata value "cinv" of player to int pnum 0 of event-packet
function getSlot(s: int, p: player) :: item:
set {_m} to metadata value "cinv" of {_p}
set {_u} to uuid of {_p}
return {currentslot::%{_u}%::%{_m}%::%{_s}%}
function formatSlot(s: integer, p: player, i: item):
set {_n} to new play_server_set_slot packet
set {_m} to "%metadata value ""cinv"" of {_p}%" parsed as a integer
set int pnum 0 of {_n} to {_m}
set int pnum 1 of {_n} to {_s}
set "ItemModifier" pinfo 0 of {_n} to {_i}
set {_u} to {_p}'s uuid
set {currentslot::%{_u}%::%{_m}%::%{_s}%} to {_i}
send {_p} packet {_n}
on packet event play_client_close_window:
delete {currentslot::%player's uuid%::*}
evt "gui click":
broadcast "%event-player%|%event-integer%|%event-item%|%event-packet%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment