mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix respawning and death not being registered on the client
This commit is contained in:
parent
4c2a8789af
commit
c804a6edfb
3 changed files with 28 additions and 3 deletions
|
@ -25,9 +25,11 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerRespawnPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
||||
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.entity.attribute.AttributeType;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
@ -35,9 +37,6 @@ import org.geysermc.connector.network.translators.PacketTranslator;
|
|||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.utils.DimensionUtils;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerRespawnPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
@Translator(packet = ServerRespawnPacket.class)
|
||||
|
|
|
@ -28,11 +28,14 @@ package org.geysermc.connector.network.translators.java.entity;
|
|||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityStatusPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
|
||||
import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Translator(packet = ServerEntityStatusPacket.class)
|
||||
public class JavaEntityStatusTranslator extends PacketTranslator<ServerEntityStatusPacket> {
|
||||
|
||||
|
@ -99,5 +102,16 @@ public class JavaEntityStatusTranslator extends PacketTranslator<ServerEntitySta
|
|||
}
|
||||
|
||||
session.sendUpstreamPacket(entityEventPacket);
|
||||
|
||||
// This fixes some death events not getting registered on the client such as drowning
|
||||
if (entityEventPacket.getType() == EntityEventType.DEATH) {
|
||||
GeyserConnector.getInstance().getGeneralThreadPool().schedule(() -> {
|
||||
EntityEventPacket eventPacket2 = new EntityEventPacket();
|
||||
eventPacket2.setRuntimeEntityId(entityEventPacket.getRuntimeEntityId());
|
||||
eventPacket2.setType(entityEventPacket.getType());
|
||||
eventPacket2.setData(entityEventPacket.getData());
|
||||
session.sendUpstreamPacket(eventPacket2);
|
||||
}, 1, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
|
|||
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.RespawnPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.SetEntityDataPacket;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.entity.PlayerEntity;
|
||||
import org.geysermc.connector.entity.type.EntityType;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
@ -42,6 +43,8 @@ import org.geysermc.connector.network.translators.PacketTranslator;
|
|||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.utils.ChunkUtils;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Translator(packet = ServerPlayerPositionRotationPacket.class)
|
||||
public class JavaPlayerPositionRotationTranslator extends PacketTranslator<ServerPlayerPositionRotationPacket> {
|
||||
|
||||
|
@ -71,6 +74,15 @@ public class JavaPlayerPositionRotationTranslator extends PacketTranslator<Serve
|
|||
eventPacket.setData(0);
|
||||
session.sendUpstreamPacket(eventPacket);
|
||||
|
||||
// This will prevent the client getting stuck at the respawn screen
|
||||
GeyserConnector.getInstance().getGeneralThreadPool().schedule(() -> {
|
||||
EntityEventPacket eventPacket2 = new EntityEventPacket();
|
||||
eventPacket2.setRuntimeEntityId(entity.getGeyserId());
|
||||
eventPacket2.setType(EntityEventType.RESPAWN);
|
||||
eventPacket2.setData(0);
|
||||
session.sendUpstreamPacket(eventPacket2);
|
||||
}, 1, TimeUnit.MILLISECONDS);
|
||||
|
||||
SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
|
||||
entityDataPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
entityDataPacket.getMetadata().putAll(entity.getMetadata());
|
||||
|
|
Loading…
Reference in a new issue