Fix rare slow dimension switching

This commit is contained in:
AJ Ferguson 2019-12-28 21:15:12 -09:00
parent 782feed641
commit 6635241526
3 changed files with 10 additions and 5 deletions

View file

@ -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;
}
}

View file

@ -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);

View file

@ -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);
}
}
}