Fix inventory bug when respawning

This commit is contained in:
AJ Ferguson 2021-01-20 11:09:28 -09:00
parent ca620d6dd8
commit 5d4b368e51

View file

@ -35,6 +35,7 @@ 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.network.translators.Translator;
import org.geysermc.connector.network.translators.inventory.InventoryTranslator;
import org.geysermc.connector.utils.DimensionUtils;
@Translator(packet = ServerRespawnPacket.class)
@ -48,7 +49,10 @@ public class JavaRespawnTranslator extends PacketTranslator<ServerRespawnPacket>
// Max health must be divisible by two in bedrock
entity.getAttributes().put(AttributeType.HEALTH, AttributeType.HEALTH.getAttribute(maxHealth, (maxHealth % 2 == 1 ? maxHealth + 1 : maxHealth)));
session.setOpenInventory(null);
session.addInventoryTask(() -> {
session.setInventoryTranslator(InventoryTranslator.PLAYER_INVENTORY_TRANSLATOR);
session.setOpenInventory(null);
});
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
playerGameTypePacket.setGamemode(packet.getGamemode().ordinal());