mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-11-27 01:06:39 +01:00
Fix rare slow dimension switching
This commit is contained in:
parent
782feed641
commit
6635241526
3 changed files with 10 additions and 5 deletions
|
@ -34,6 +34,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlaye
|
|||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPlaceBlockPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerStatePacket;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.protocol.bedrock.packet.PlayStatusPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.PlayerActionPacket;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
@ -107,6 +108,11 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
|||
break;
|
||||
case DIMENSION_CHANGE_SUCCESS:
|
||||
session.setSwitchingDimension(false);
|
||||
//sometimes the client doesn't feel like loading
|
||||
PlayStatusPacket spawnPacket = new PlayStatusPacket();
|
||||
spawnPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
|
||||
session.getUpstream().sendPacket(spawnPacket);
|
||||
entity.updateBedrockAttributes(session);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.ServerRespawnPacke
|
|||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.packet.*;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.entity.attribute.AttributeType;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.utils.ChunkUtils;
|
||||
|
@ -42,6 +43,9 @@ public class JavaRespawnTranslator extends PacketTranslator<ServerRespawnPacket>
|
|||
if (entity == null)
|
||||
return;
|
||||
|
||||
float maxHealth = entity.getAttributes().containsKey(AttributeType.MAX_HEALTH) ? entity.getAttributes().get(AttributeType.MAX_HEALTH).getValue() : 20f;
|
||||
entity.getAttributes().put(AttributeType.HEALTH, AttributeType.HEALTH.getAttribute(maxHealth));
|
||||
|
||||
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
|
||||
playerGameTypePacket.setGamemode(packet.getGamemode().ordinal());
|
||||
session.getUpstream().sendPacket(playerGameTypePacket);
|
||||
|
|
|
@ -54,10 +54,5 @@ public class JavaPlayerHealthTranslator extends PacketTranslator<ServerPlayerHea
|
|||
entity.getAttributes().put(AttributeType.HUNGER, AttributeType.HUNGER.getAttribute(packet.getFood()));
|
||||
entity.getAttributes().put(AttributeType.SATURATION, AttributeType.SATURATION.getAttribute(packet.getSaturation()));
|
||||
entity.updateBedrockAttributes(session);
|
||||
|
||||
if (packet.getHealth() <= 0) {
|
||||
entity.getAttributes().remove(AttributeType.HEALTH);
|
||||
entity.updateBedrockAttributes(session);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue