Hiya everyone,
This is the first time I have ever asked for help on these forums as I often figure things out myself but I cannot do this myself and I really need some help with it.
I am using Skript 2.5.3, Skript-Packet v2.0.1 and Skript-Reflect v2.2.3 along with many other addons that should not be important in this.
Now, I have a pretty decent knowledge of Skript but really none when it comes to JavaScript. I am trying to send a packet to the player to change their pitch and yaw. I understand how to send packets and all that, I have been able to send other packets successfully using Skript-Packet, it's just this one.
Below is the function I am using. I am using the PacketPlayOutPosition packet to control the pitch and yaw. Ignore all of the fields except field 5. All of the other fields are correct and working properly. It is field 5 that I really need help with.
function FirearmRecoil(p: player, v: number, h: number):
To get the packet to work as I intend it to, I need to set field 5 to a HashSet with the values "X, X_ROT, Y, Y_ROT, Z". The problem is I have no idea how to do that. I don't even know if it is possible with Sk-Reflect (Sk-Mirror fork).
Using what DeeCaaD said on the Spigot Forums (https://www.spigotmc.org/threads/change-players-yaw-pitch-for-recoil-effect.338132/), with actual Java he just does:
private Set<EnumPlayerTeleportFlags> teleportFlags = new HashSet<>(Arrays.asList(EnumPlayerTeleportFlags.X, EnumPlayerTeleportFlags.Y, EnumPlayerTeleportFlags.Z));
And then sends the packet with that Set as the fifth field.
Is it possible to do that with Skript using Sk-Reflect? If not, are there any other workarounds to get it to work?
Cheers,
- Orbinfog
(quick edit: It has to be a HashSet, because otherwise objects/lists etc are not accepted)
This is the first time I have ever asked for help on these forums as I often figure things out myself but I cannot do this myself and I really need some help with it.
I am using Skript 2.5.3, Skript-Packet v2.0.1 and Skript-Reflect v2.2.3 along with many other addons that should not be important in this.
Now, I have a pretty decent knowledge of Skript but really none when it comes to JavaScript. I am trying to send a packet to the player to change their pitch and yaw. I understand how to send packets and all that, I have been able to send other packets successfully using Skript-Packet, it's just this one.
Below is the function I am using. I am using the PacketPlayOutPosition packet to control the pitch and yaw. Ignore all of the fields except field 5. All of the other fields are correct and working properly. It is field 5 that I really need help with.
function FirearmRecoil(p: player, v: number, h: number):
#V = vertical recoil (pitch), H = horizontal (yaw)
set {_packet} to new play_server_position packet
set field 0 of {_packet} to 0.doubleValue()
set field 1 of {_packet} to 0.doubleValue()
set field 2 of {_packet} to 0.doubleValue()
set field 3 of {_packet} to {_h}.floatValue()
set field 4 of {_packet} to {_v}.floatValue()
set field 5 of {_packet} to ############Need help here
set field 6 of {_packet} to 0
send {_p} packet {_packet}
https://minidigger.github.io/MiniMappingViewer/#/spigot/server/1.15.2/PacketPlayOutPositionset {_packet} to new play_server_position packet
set field 0 of {_packet} to 0.doubleValue()
set field 1 of {_packet} to 0.doubleValue()
set field 2 of {_packet} to 0.doubleValue()
set field 3 of {_packet} to {_h}.floatValue()
set field 4 of {_packet} to {_v}.floatValue()
set field 5 of {_packet} to ############Need help here
set field 6 of {_packet} to 0
send {_p} packet {_packet}
To get the packet to work as I intend it to, I need to set field 5 to a HashSet with the values "X, X_ROT, Y, Y_ROT, Z". The problem is I have no idea how to do that. I don't even know if it is possible with Sk-Reflect (Sk-Mirror fork).
Using what DeeCaaD said on the Spigot Forums (https://www.spigotmc.org/threads/change-players-yaw-pitch-for-recoil-effect.338132/), with actual Java he just does:
private Set<EnumPlayerTeleportFlags> teleportFlags = new HashSet<>(Arrays.asList(EnumPlayerTeleportFlags.X, EnumPlayerTeleportFlags.Y, EnumPlayerTeleportFlags.Z));
And then sends the packet with that Set as the fifth field.
Is it possible to do that with Skript using Sk-Reflect? If not, are there any other workarounds to get it to work?
Cheers,
- Orbinfog
(quick edit: It has to be a HashSet, because otherwise objects/lists etc are not accepted)
Last edited: