Fix gamemode changing
@@ -30,6 +30,8 @@ import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerNotifyClientPacket;
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket;
+import com.nukkitx.protocol.bedrock.packet.ShowCreditsPacket;
+import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
@@ -45,7 +47,6 @@ public class JavaNotifyClientTranslator extends PacketTranslator<ServerNotifyCli
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:
@@ -53,19 +54,23 @@ public class JavaNotifyClientTranslator extends PacketTranslator<ServerNotifyCli
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 CHANGE_GAMEMODE:
int gamemode = ((GameMode) packet.getValue()).ordinal();
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
playerGameTypePacket.setGamemode(gamemode);
+ session.getUpstream().sendPacket(playerGameTypePacket);
break;
case ENTER_CREDITS:
- // ShowCreditsPacket showCreditsPacket = new ShowCreditsPacket();
- // showCreditsPacket.setStatus(ShowCreditsPacket.Status.START_CREDITS);
- // showCreditsPacket.setRuntimeEntityId(runtimeEntityId);
- // session.getUpstream().sendPacket(showCreditsPacket);
+ Entity entity = session.getPlayerEntity();
+ if (entity == null)
+ return;
+
+ ShowCreditsPacket showCreditsPacket = new ShowCreditsPacket();
+ showCreditsPacket.setStatus(ShowCreditsPacket.Status.START_CREDITS);
+ showCreditsPacket.setRuntimeEntityId(entity.getGeyserId());
+ session.getUpstream().sendPacket(showCreditsPacket);
break;
default:
break;
