Fixed CPE protocol not working

This commit is contained in:
FlorianMichael 2023-10-01 19:56:19 +02:00
parent ada906bd9f
commit b92aa99fd3
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126

View File

@ -21,7 +21,8 @@ import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.Protocol1_19_4To1_19_3;
import de.florianmichael.viafabricplus.definition.classic.CustomClassicProtocolExtensions;
import de.florianmichael.viafabricplus.definition.classic.model.WeatherTypes;
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.ClientboundPacketsc0_28;
@ -46,16 +47,16 @@ public class MixinProtocolc0_30toc0_30cpe extends AbstractProtocol<ClientboundPa
wrapper.cancel();
final byte weatherType = wrapper.read(Type.BYTE);
final PacketWrapper changeRainState = PacketWrapper.create(ClientboundPackets1_19_3.GAME_EVENT, wrapper.user());
final PacketWrapper changeRainState = PacketWrapper.create(ClientboundPackets1_19_4.GAME_EVENT, wrapper.user());
changeRainState.write(Type.BYTE, weatherType == WeatherTypes.SUNNY ? (byte) 2 : (byte) 1); // start raining
changeRainState.write(Type.FLOAT, 0F); // unused
changeRainState.sendRaw();
changeRainState.send(Protocol1_19_4To1_19_3.class);
if (weatherType == WeatherTypes.RAINING || weatherType == WeatherTypes.SNOWING) {
final PacketWrapper changeRainType = PacketWrapper.create(ClientboundPackets1_19_3.GAME_EVENT, wrapper.user());
final PacketWrapper changeRainType = PacketWrapper.create(ClientboundPackets1_19_4.GAME_EVENT, wrapper.user());
changeRainType.write(Type.BYTE, (byte) 7);
changeRainType.write(Type.FLOAT, weatherType == WeatherTypes.RAINING ? 0F : 1F);
changeRainType.sendRaw();
changeRainType.send(Protocol1_19_4To1_19_3.class);
}
});
}