Skip to content

Commit

Permalink
Fix inventory bug when respawning
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ-Ferguson committed Jan 20, 2021
1 parent ca620d6 commit 5d4b368
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
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)
Expand All @@ -48,7 +49,10 @@ public void translate(ServerRespawnPacket packet, GeyserSession session) {
// 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());
Expand Down

0 comments on commit 5d4b368

Please sign in to comment.