From caebb8e4f4b7f2f6c8fbe290766c5c7a12592c89 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Tue, 23 Jul 2019 11:47:20 -0500 Subject: [PATCH] Add weather packets --- .../network/translators/TranslatorsInit.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java b/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java index 61e2b135..da8a344e 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java @@ -36,6 +36,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntit import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityPositionRotationPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityTeleportPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityVelocityPacket; +import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerNotifyClientPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateTimePacket; import com.nukkitx.nbt.CompoundTagBuilder; import com.nukkitx.nbt.NbtUtils; @@ -49,6 +50,7 @@ import org.geysermc.connector.utils.Toolbox; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.concurrent.ThreadLocalRandom; public class TranslatorsInit { @@ -75,6 +77,7 @@ public class TranslatorsInit { addTitlePackets(); addTimePackets(); addEntityPackets(); + addNotifyPackets(); } private static void addLoginPackets() { @@ -271,4 +274,35 @@ public class TranslatorsInit { session.getUpstream().sendPacket(entityMotionPacket); }); } + + public static void addNotifyPackets() { + Registry.add(ServerNotifyClientPacket.class, (packet, session) -> { + switch (packet.getNotification()) { + case START_RAIN: + LevelEventPacket startRainPacket = new LevelEventPacket(); + startRainPacket.setEvent(LevelEventPacket.Event.START_RAIN); + startRainPacket.setData(ThreadLocalRandom.current().nextInt(50000) + 10000); + startRainPacket.setPosition(new Vector3f(0, 0, 0)); + + session.getUpstream().sendPacket(startRainPacket); + break; + case STOP_RAIN: + LevelEventPacket stopRainPacket = new LevelEventPacket(); + stopRainPacket.setEvent(LevelEventPacket.Event.STOP_RAIN); + stopRainPacket.setData(ThreadLocalRandom.current().nextInt(50000) + 10000); + stopRainPacket.setPosition(new Vector3f(0, 0, 0)); + + session.getUpstream().sendPacket(stopRainPacket); + break; + case ENTER_CREDITS: + // ShowCreditsPacket showCreditsPacket = new ShowCreditsPacket(); + // showCreditsPacket.setStatus(ShowCreditsPacket.Status.START_CREDITS); + // showCreditsPacket.setRuntimeEntityId(runtimeEntityId); + // session.getUpstream().sendPacket(showCreditsPacket); + break; + default: + break; + } + }); + } }