Fix gamemode changing

This commit is contained in:
Redned 2019-09-15 20:34:57 -05:00 committed by RednedEpic
parent fac7093bff
commit 4b3dfc09f9

View file

@ -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.github.steveice10.mc.protocol.packet.ingame.server.world.ServerNotifyClientPacket;
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket; import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket; 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.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.PacketTranslator;
@ -45,7 +47,6 @@ public class JavaNotifyClientTranslator extends PacketTranslator<ServerNotifyCli
startRainPacket.setEvent(LevelEventPacket.Event.START_RAIN); startRainPacket.setEvent(LevelEventPacket.Event.START_RAIN);
startRainPacket.setData(ThreadLocalRandom.current().nextInt(50000) + 10000); startRainPacket.setData(ThreadLocalRandom.current().nextInt(50000) + 10000);
startRainPacket.setPosition(new Vector3f(0, 0, 0)); startRainPacket.setPosition(new Vector3f(0, 0, 0));
session.getUpstream().sendPacket(startRainPacket); session.getUpstream().sendPacket(startRainPacket);
break; break;
case STOP_RAIN: case STOP_RAIN:
@ -53,19 +54,23 @@ public class JavaNotifyClientTranslator extends PacketTranslator<ServerNotifyCli
stopRainPacket.setEvent(LevelEventPacket.Event.STOP_RAIN); stopRainPacket.setEvent(LevelEventPacket.Event.STOP_RAIN);
stopRainPacket.setData(ThreadLocalRandom.current().nextInt(50000) + 10000); stopRainPacket.setData(ThreadLocalRandom.current().nextInt(50000) + 10000);
stopRainPacket.setPosition(new Vector3f(0, 0, 0)); stopRainPacket.setPosition(new Vector3f(0, 0, 0));
session.getUpstream().sendPacket(stopRainPacket); session.getUpstream().sendPacket(stopRainPacket);
break; break;
case CHANGE_GAMEMODE: case CHANGE_GAMEMODE:
int gamemode = ((GameMode) packet.getValue()).ordinal(); int gamemode = ((GameMode) packet.getValue()).ordinal();
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket(); SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
playerGameTypePacket.setGamemode(gamemode); playerGameTypePacket.setGamemode(gamemode);
session.getUpstream().sendPacket(playerGameTypePacket);
break; break;
case ENTER_CREDITS: case ENTER_CREDITS:
// ShowCreditsPacket showCreditsPacket = new ShowCreditsPacket(); Entity entity = session.getPlayerEntity();
// showCreditsPacket.setStatus(ShowCreditsPacket.Status.START_CREDITS); if (entity == null)
// showCreditsPacket.setRuntimeEntityId(runtimeEntityId); return;
// session.getUpstream().sendPacket(showCreditsPacket);
ShowCreditsPacket showCreditsPacket = new ShowCreditsPacket();
showCreditsPacket.setStatus(ShowCreditsPacket.Status.START_CREDITS);
showCreditsPacket.setRuntimeEntityId(entity.getGeyserId());
session.getUpstream().sendPacket(showCreditsPacket);
break; break;
default: default:
break; break;