Search in sources :

Example 1 with WorldTimeUpdateS2CPacket

use of net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket in project BleachHack by BleachDrinker420.

the class Ambience method readPacket.

@BleachSubscribe
public void readPacket(EventPacket.Read event) {
    if (event.getPacket() instanceof GameStateChangeS2CPacket && getSetting(0).asToggle().getState()) {
        GameStateChangeS2CPacket packet = (GameStateChangeS2CPacket) event.getPacket();
        if (packet.getReason() == GameStateChangeS2CPacket.RAIN_STARTED) {
            weatherManager.setRain(1f);
        } else if (packet.getReason() == GameStateChangeS2CPacket.RAIN_STOPPED) {
            weatherManager.setRain(0f);
        } else if (packet.getReason() == GameStateChangeS2CPacket.RAIN_GRADIENT_CHANGED) {
            weatherManager.setRain(packet.getValue());
        } else if (packet.getReason() == GameStateChangeS2CPacket.THUNDER_GRADIENT_CHANGED) {
            weatherManager.setThunder(packet.getValue());
        } else {
            return;
        }
        event.setCancelled(true);
    } else if (event.getPacket() instanceof DisconnectS2CPacket && getSetting(0).asToggle().getState()) {
        weatherManager.reset();
    } else if (event.getPacket() instanceof WorldTimeUpdateS2CPacket && getSetting(1).asToggle().getState()) {
        event.setCancelled(true);
    }
}
Also used : WorldTimeUpdateS2CPacket(net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket) GameStateChangeS2CPacket(net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket) DisconnectS2CPacket(net.minecraft.network.packet.s2c.play.DisconnectS2CPacket) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Aggregations

DisconnectS2CPacket (net.minecraft.network.packet.s2c.play.DisconnectS2CPacket)1 GameStateChangeS2CPacket (net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket)1 WorldTimeUpdateS2CPacket (net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket)1 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)1