#client side gamemode 1.20.6 help

1 messages · Page 1 of 1 (latest)

hollow moss
#

Anyone can help client side gamemode?

brisk terrace
#

tf is client side gamemode

chrome bane
#

is the image even related

brisk terrace
#

well maybe i dunno what client side gamemode is xd

#

even tho that looks like speech bubbles to me

frank notch
#

dont think that image is supposed to have been attached....
but anyways you can do client side gamemodes by sending a GAME_STATE_CHANGE packet i believe, i was experimenting with something like this earlier:

        set {_newPacket} to {_packet}.getIntegers().write(3, -1)
        ProtocolLibrary.getProtocolManager().sendServerPacket(player, {_newPacket})```
it probably doesn't work perfectly (but u get the idea) but that sets field 3 of the GAME_STATE_CHANGE packet (the gamemode state) to -1 which is a fake spectator mode
#

the code that i attached uses protcollib + skript-reflect

hollow moss
#
import:
    net.minecraft.server.v1_16_R3.PacketPlayOutGameStateChange$a

effect change client side gamemode of %players% to %gamemode%:
    trigger:
        set {_packet} to new play_server_game_state_change packet
        set field 1 of {_packet} to 0 if "%expression-2%" is "survival"
        set field 1 of {_packet} to 1 if "%expression-2%" is "creative"
        set field 1 of {_packet} to 2 if "%expression-2%" is "adventure"
        set field 1 of {_packet} to 3 if "%expression-2%" is "spectator" 
        set field 0 of {_packet} to new a(3) # reason
        send packet {_packet} to expression-1 without calling event````
Found this but import doenst work
frank notch
#

thats because its using nms

#

afaik you cant import nms like that without having mojang mapping (which requires buildtools to get, i dont even understand it fully bc its very complicated) where did you get that code?

chrome bane
#

well that code would work for 1.16.3 only

#

and with skript packet i think

frank notch
#

nms mappings are different for each version (they are highly version-dependent) as they are obfuscated by mojang
looks like that code uses skript-packet combined with nms and skript-reflect

chrome bane
#

yes like i said it'd work for 1.16.3

#

no build tools stuff necessary

frank notch
#

well you can't just import net.minecraft.server stuff in skript unless you have the proper setup (from my understanding)

chrome bane
#

you can

#

it's even easier post-1.17

frank notch
#

well that would have been helpful for me to know 6 days ago to know so i didn't have to waste my entire weekend with setting up the paperweight test plugin to try messing with nms in java and it still didnt work 💀
didnt seem to work when i imported them from before, i'll have to give it a second go

frank notch
chrome bane
#

that's pre-1.17 nms

#

after 1.17 spigot changed how it's accessed

hollow moss
#

Aynone can help me?

visual zephyr
#

we don't do that here

toxic kiln
frank notch
#

looks like a bunch of text displays with a 3d skin resource pack for the npc but it doesnt look related to the question

hollow moss
#

And not mod

hollow moss
#

Im not asking that guys

#

Anyone know Client side gamemode changin?

frank notch
#

you have to use packets (like the code you put above) to change the client's gamemode

hollow moss
#

im using 1.20.6

#

the import is wrong

frank notch
#

try what Sovde mentioned and remove .v1_16_R3 because 1.17+ versions don't use that part anymore

hollow moss
#

net.minecraft.server.PacketPlayOutGameStateChange$a

#

like that?

chrome bane
#

it'd look like this

hollow moss
#

need protocollib right?

chrome bane
#

no

hollow moss
#

oh okay

#

nice

#

Ill try

#

net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity

chrome bane
#

don't forget the $a

#

if it's still a

#

probably is

#

and make sure to use the gamestatechange and not the spawn entity packet

hollow moss
#
    trigger:
        set {_packet} to new play_server_game_state_change packet
        set field 1 of {_packet} to 0 if "%expression-2%" is "survival"
        set field 1 of {_packet} to 1 if "%expression-2%" is "creative"
        set field 1 of {_packet} to 2 if "%expression-2%" is "adventure"
        set field 1 of {_packet} to 3 if "%expression-2%" is "spectator" 
        set field 0 of {_packet} to new a(3) # reason
        send packet {_packet} to expression-1 without calling event```
#

is it wrong?