Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-09-08 20:43:04 +02:00
Ursprung
14882534c0
Commit
d0fa2d2b05
@ -27,10 +27,7 @@ package org.geysermc.geyser.translator.protocol.bedrock;
|
|||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.ClientCommand;
|
import com.github.steveice10.mc.protocol.data.game.ClientCommand;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientCommandPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientCommandPacket;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
|
||||||
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
|
|
||||||
import com.nukkitx.protocol.bedrock.packet.RespawnPacket;
|
import com.nukkitx.protocol.bedrock.packet.RespawnPacket;
|
||||||
import org.geysermc.geyser.entity.type.player.PlayerEntity;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||||
import org.geysermc.geyser.translator.protocol.Translator;
|
import org.geysermc.geyser.translator.protocol.Translator;
|
||||||
@ -41,28 +38,6 @@ public class BedrockRespawnTranslator extends PacketTranslator<RespawnPacket> {
|
|||||||
@Override
|
@Override
|
||||||
public void translate(GeyserSession session, RespawnPacket packet) {
|
public void translate(GeyserSession session, RespawnPacket packet) {
|
||||||
if (packet.getState() == RespawnPacket.State.CLIENT_READY) {
|
if (packet.getState() == RespawnPacket.State.CLIENT_READY) {
|
||||||
// Previously we only sent the respawn packet before the server finished loading
|
|
||||||
// The message included was 'Otherwise when immediate respawn is on the client never loads'
|
|
||||||
// But I assume the new if statement below fixes that problem
|
|
||||||
RespawnPacket respawnPacket = new RespawnPacket();
|
|
||||||
respawnPacket.setRuntimeEntityId(0);
|
|
||||||
respawnPacket.setPosition(Vector3f.ZERO);
|
|
||||||
respawnPacket.setState(RespawnPacket.State.SERVER_READY);
|
|
||||||
session.sendUpstreamPacket(respawnPacket);
|
|
||||||
|
|
||||||
if (session.isSpawned()) {
|
|
||||||
// Client might be stuck; resend spawn information
|
|
||||||
PlayerEntity entity = session.getPlayerEntity();
|
|
||||||
entity.updateBedrockMetadata(); // TODO test?
|
|
||||||
|
|
||||||
MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
|
|
||||||
movePlayerPacket.setRuntimeEntityId(entity.getGeyserId());
|
|
||||||
movePlayerPacket.setPosition(entity.getPosition());
|
|
||||||
movePlayerPacket.setRotation(entity.getBedrockRotation());
|
|
||||||
movePlayerPacket.setMode(MovePlayerPacket.Mode.RESPAWN);
|
|
||||||
session.sendUpstreamPacket(movePlayerPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
ServerboundClientCommandPacket javaRespawnPacket = new ServerboundClientCommandPacket(ClientCommand.RESPAWN);
|
ServerboundClientCommandPacket javaRespawnPacket = new ServerboundClientCommandPacket(ClientCommand.RESPAWN);
|
||||||
session.sendDownstreamPacket(javaRespawnPacket);
|
session.sendDownstreamPacket(javaRespawnPacket);
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,8 @@ public class JavaRespawnTranslator extends PacketTranslator<ClientboundRespawnPa
|
|||||||
public void translate(GeyserSession session, ClientboundRespawnPacket packet) {
|
public void translate(GeyserSession session, ClientboundRespawnPacket packet) {
|
||||||
SessionPlayerEntity entity = session.getPlayerEntity();
|
SessionPlayerEntity entity = session.getPlayerEntity();
|
||||||
|
|
||||||
|
session.setSpawned(false);
|
||||||
|
|
||||||
entity.setHealth(entity.getMaxHealth());
|
entity.setHealth(entity.getMaxHealth());
|
||||||
entity.getAttributes().put(GeyserAttributeType.HEALTH, entity.createHealthAttribute());
|
entity.getAttributes().put(GeyserAttributeType.HEALTH, entity.createHealthAttribute());
|
||||||
|
|
||||||
|
@ -86,13 +86,14 @@ public class JavaPlayerPositionTranslator extends PacketTranslator<ClientboundPl
|
|||||||
|
|
||||||
ChunkUtils.updateChunkPosition(session, pos.toInt());
|
ChunkUtils.updateChunkPosition(session, pos.toInt());
|
||||||
|
|
||||||
|
if (session.getGeyser().getConfig().isDebugMode()) {
|
||||||
session.getGeyser().getLogger().debug(GeyserLocale.getLocaleStringLog("geyser.entity.player.spawn", packet.getX(), packet.getY(), packet.getZ()));
|
session.getGeyser().getLogger().debug(GeyserLocale.getLocaleStringLog("geyser.entity.player.spawn", packet.getX(), packet.getY(), packet.getZ()));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity vehicle = session.getPlayerEntity().getVehicle();
|
Entity vehicle;
|
||||||
if (packet.isDismountVehicle() && vehicle != null) {
|
if (packet.isDismountVehicle() && (vehicle = session.getPlayerEntity().getVehicle()) != null) {
|
||||||
|
|
||||||
SetEntityLinkPacket linkPacket = new SetEntityLinkPacket();
|
SetEntityLinkPacket linkPacket = new SetEntityLinkPacket();
|
||||||
linkPacket.setEntityLink(new EntityLinkData(vehicle.getGeyserId(), entity.getGeyserId(), EntityLinkData.Type.REMOVE, false, false));
|
linkPacket.setEntityLink(new EntityLinkData(vehicle.getGeyserId(), entity.getGeyserId(), EntityLinkData.Type.REMOVE, false, false));
|
||||||
session.sendUpstreamPacket(linkPacket);
|
session.sendUpstreamPacket(linkPacket);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren