Solved Change weather instantly

Discussion in 'Spigot Plugin Development' started by GabrielVitza, Sep 11, 2019.

  1. When I change the weather it takes a few seconds until it changes.
    Is there a way to change instant weather without ProtocolLib and without API?
    I want an example code.
    #1 GabrielVitza, Sep 11, 2019
    Last edited: Sep 11, 2019
  2. Equals I want to be spoonfed?

    To make weather changes appear instantly, you can send the client a Change Game State packet with the fade value set to 1. At least this works in 1.12(.2). You can do this via ProtocolLib for example, there are enough examples.
    • Like Like x 1
  3. Do you know any other way without ProtocolLib or without an API
  4. You can create an instance of the NMS packet of type PacketPlayOutGameStateChange(int, float). When constructing the object, you would want to put 7 as the first value and 1.0f as the second value for reasons described in my first post and

    To send the packet to the Player, follow these steps:

    First, get yourself you have to cast your player to CraftPlayer (from CraftBukkit).
    You then have to invoke getHandle() on that object and save the returned object, which is of type EntityPlayer (NMS).
    This object of type EntityPlayer has a public field called playerConnection of type PlayerConnection (NMS).
    The playerConnection object has a public method called sendPacket(Packet), which takes the packet you want to send as a parameter.
    • Winner Winner x 1
  5. Thank you!
    • Like Like x 1